26 void SetBasicMacros(TString what_file, TString what_sub_directory);
40 namespace __LoadWatchers__ {
56 using namespace __LoadWatchers__ ;
90 if(!gSystem->IsFileInIncludePath(cpp_path))
92 cout<<cpp_path<<
" not found, class not loaded."<<
endl;
97 TString CompileLine =
".L " + cpp_path + Form(
"+%s",
CompOpt.Data());
98 gROOT->ProcessLine(CompileLine.Data());
105 if(!what_directory.BeginsWith(
"/"))
107 TString CurrentDir = gSystem->pwd();
109 what_directory.Prepend(CurrentDir);
111 tmp = what_directory;
printf(
"{Conf} Add %s to the include path \n",
tmp.Data());
112 tmp.Prepend(
" .include ");
113 gROOT->ProcessLine(
tmp.Data());
119 if ( gSystem->AccessPathName( what_file.Data() ) ) {
120 cout <<
"{Conf} A standard " << what_file <<
" is installed from " << what_sub_directory <<
"/" <<
CAMPAIGN <<
endl;
121 gSystem->CopyFile(Form(
"%s/%s/%s",what_sub_directory.Data(),
CAMPAIGN.Data(),what_file.Data()),what_file.Data());
124 if(what_file.EndsWith(
".sh"))
125 gSystem->Exec(Form(
"chmod u+x %s",what_file.Data()));
131 sprintf(
DefaultW,
" \033[1;34m [*] "); sprintf(
MyW,
" \033[1;32m [+] "); sprintf(
WarningW,
" \033[1;31m [!] "); sprintf(
AncW,
" \033[1;35m [+] "); sprintf(
EndColor,
"\033[0m");
135 gROOT->ProcessLine(
"WatchersUtilities()");
147 LoadClass(
"Macros/Visu/WatchersTools.cpp");
155 LoadClass(
"Macros/SpectraViewer/GWRecal/FitSpek.cpp");
156 LoadClass(
"Macros/SpectraViewer/GWRecal/ReadSpek.cpp");
157 LoadClass(
"Macros/SpectraViewer/GWRecal/RecalEnergy.cpp");
159 LoadClass(
"Macros/SpectraViewer/FitSpectra.cpp");
160 LoadClass(
"Macros/SpectraViewer/FitFunctions.cpp");
161 LoadClass(
"Macros/SpectraViewer/SpectraViewerWatcher.cpp");
162 LoadClass(
"Macros/SpectraViewer/BaselineWatcher.cpp");
163 LoadClass(
"Macros/SpectraViewer/RawAmpWatcher.cpp");
164 LoadClass(
"Macros/SpectraViewer/SignalWatcher.cpp");
166 LoadClass(
"Macros/SpectraViewer/SpecViewer.C");
173 printf(
"******************************************************************** \n") ;
174 printf(
" Configure/Compile/Load Watcher for the GANIL phase \n") ;
175 printf(
"******************************************************************** \n") ;
181 if ( macroPATH.Contains(tmp.Data()) ==
false ) {
182 printf(
"{Conf} Add %s to the macros path \n",tmp.Data());
184 macroPATH.Prepend(tmp.Data()); gROOT->SetMacroPath(macroPATH.Data());
191 gSystem->Load(
"libGWCORE.so");
192 gSystem->Load(
"libGWADF.so");
193 gSystem->Load(
"libGWADFE.so");
194 gSystem->Load(
"libGWTOOLS.so");
195 gSystem->Load(
"libGWPHYSICS.so");
197 if (
AGAPRO.Contains(
"/") ) {
199 AGAPRO.Append(
"/include");
printf(
"{Conf} Add path to AGAPRO includes [%s] to the include path \n",
AGAPRO.Data());
200 AGAPRO.Prepend(
" .include ");
201 gROOT->ProcessLine(
AGAPRO.Data());
203 gSystem->Load(
"libAgaProCommon.so");
204 gSystem->Load(
"libCrystalProducer.so");
205 gSystem->Load(
"libPreprocessingFilter.so");
206 gSystem->Load(
"libTrackingFilter.so");
210 gSystem->MakeDirectory(
"./MyWatchers");
211 gSystem->MakeDirectory(
"./Out");
218 MFMDIR = gSystem->Getenv(
"MFMLIB");
VAMOSDIR = gSystem->Getenv(
"VAMOSLIB");
GRUDIR = gSystem->Getenv(
"GRULIB");
220 std::ofstream fdefs(
"WatchersConfigNew.h",ios::out | ios::trunc);
221 if ( fdefs.is_open() ) {
224 if (
AGAPRO.Contains(
"/") ) {
225 fdefs <<
"#define HAS_AGAPROCONFIG " <<
std::endl;
229 fdefs <<
"// enable / disable GANIL " <<
std::endl;
230 if (
MFMDIR !=
"" && !gSystem->AccessPathName(Form(
"%s/lib/libMFM.so",
MFMDIR.Data())) ) {
233 tmp =
MFMDIR; tmp+=
"/include";
printf(
"{Conf} Add %s to the include path \n",tmp.Data());
234 tmp.Prepend(
" .include ");
235 gROOT->ProcessLine(tmp.Data());
239 && !gSystem->AccessPathName(Form(
"%s/lib/libVamos.so",
VAMOSDIR.Data()))
240 && !gSystem->AccessPathName(Form(
"%s/lib/libGWVamos.so",
VAMOSDIR.Data()))
243 fdefs <<
"#define HAS_VAMOS " <<
std::endl;
245 tmp =
VAMOSDIR; tmp+=
"/include";
printf(
"{Conf} Add %s to the include path \n",tmp.Data());
246 tmp.Prepend(
" .include ");
252 fdefs <<
"#define HAS_GRU " <<
std::endl;
260 std::ifstream fich2(
"WatchersConfig.h");
261 if(!fich2) system(
"mv WatchersConfigNew.h WatchersConfig.h");
262 else if(system(
"diff WatchersConfigNew.h WatchersConfig.h")) system(
"mv WatchersConfigNew.h WatchersConfig.h");
263 else system(
"rm WatchersConfigNew.h");
284 std::cout <<
"|INFO| Place to add personnal Watchers" <<
std::endl;
285 std::cout <<
"|INFO| 1 - Put your files (Ex: MyW.h and MyW.C) in the MyWatchers Directory " <<
std::endl;
286 std::cout <<
"|INFO| 2 - Add LoadClass(\"MyWatchers/MyW.C\") just under this line is this GANILLoadWatchers.C Macro and re-start" <<
std::endl;
318 std::cout <<
AncW <<
" NO Watchers for ancillaries, install first MFM [MANDATORY] VAMOS / GRU ... to get some " <<
EndColor <<
std::endl;
322 cout <<
"[Load] libMFM from " <<
MFMDIR <<
endl;
323 gSystem->Load(
"libMFM.so" );
330 cout <<
"[Load] libVamos.so and libGWVamos.so from " <<
VAMOSDIR <<
endl;
331 gSystem->Load(
"libVamos.so" );
332 gSystem->Load(
"libGWVamos.so" );
338 tmp = gSystem->Getenv(
"ANALYSIS_AGATA");
339 if ( !(
tmp ==
"") ) {
340 printf(
"{Conf} ANALYSIS_AGATA found to be %s \n",
tmp.Data());
343 printf(
"{Conf} Set ANALYSIS_AGATA to ./ConfVAMOS \n"); gSystem->Setenv(
"ANALYSIS_AGATA",
"./ConfVAMOS");
347 cout <<
"- Load libGRU.so from " <<
GRUDIR.Data() <<
endl;
348 gSystem->Load( Form(
"%s/lib/libGRU.so",
GRUDIR.Data()) );
350 tmp.Prepend(
" .include ");
351 gROOT->ProcessLine(
tmp.Data());
361 if ( what_conf ==
"ADF.conf" ) {
363 TString adf_path = gSystem->Getenv(
"ADF_CONF_PATH");
365 if ( adf_path ==
"" ) {
368 if ( !gSystem->AccessPathName(
"./ADF.conf") ) {
373 TString tmp_dir = gSystem->TempDirectory();
374 std::cout <<
WarningW <<
"Cannot find ADF.conf ... try and install a default one from internet, make sure it fullfils your needs " <<
EndColor <<
std::endl;
375 gSystem->Exec(Form(
"svn --quiet checkout svn+ssh://anonsvn@anonsvn.in2p3.fr/agata/conf/watchers/ %s",tmp_dir.Data()));
376 if ( gSystem->CopyFile(Form(
"%s/ADF.conf",tmp_dir.Data()),
"./ADF.conf") == 0 )
380 adf_path = gSystem->Getenv(
"PWD");
384 if ( adf_path ==
"" ) {
388 gSystem->Setenv(
"ADF_CONF_PATH",adf_path.Data());
389 printf(
"\n\t{Conf}\tADF_CONF_PATH has been set to %s \n\n",adf_path.Data());
392 if ( what_conf ==
"CrystalPositionLookUpTable.dat" ) {
395 if ( !gSystem->AccessPathName(
"./CrystalPositionLookUpTable.dat") ) {
400 TString tmp_dir = gSystem->TempDirectory();
401 gSystem->Exec(Form(
"svn --quiet checkout svn+ssh://anonsvn@anonsvn.in2p3.fr/agata/conf/watchers/ %s",tmp_dir.Data()));
402 if ( gSystem->CopyFile(Form(
"%s/CrystalPositionsLookUpTableGANIL.dat",tmp_dir.Data()),
"./CrystalPositionLookUpTable.dat") == 0 ) {
403 std::cout <<
WarningW <<
"CrystalPositionLookUpTable.dat was not there ... a default one from internet has been installed, make sure it fullfils your needs! " <<
EndColor <<
std::endl;;
408 std::cout <<
WarningW <<
"Mapping of AGATA Ge Crystal, CrystalPositionLookUpTable.dat, not found !" <<
EndColor <<
std::endl;
412 if ( (what_conf ==
"TimeChecks.conf") && gSystem->AccessPathName( what_conf.Data() ) ) {
413 cout <<
"{Conf} A standard " << what_conf <<
" is installed from Conf folder" <<
endl;
414 gSystem->CopyFile(
"Conf/TimeChecks.conf",what_conf.Data());
422 cout <<
endl <<
"|INFO| ... informations ... messages ... help ... for Online/Quasi Online Analysis |" <<
endl;
423 cout <<
"|INFO|" <<
endl;
424 cout <<
"|INFO|\tTo start online (Local Level) Watchers : " <<
endl;
425 cout <<
"|INFO|\t.L OnlineWatchersLLP.C+ " <<
endl;
426 cout <<
"|INFO|\tOnlineWatchersLLP(0x0,0x0) or OnlineWatchersLLP(new TFile(\"MySpectra.root\",\"UPDATE\"),new TFile(\"MyTagSpectra.root\",\"UPDATE\"))" <<
endl;
427 cout <<
"|INFO|\tTo start online (Global Level) Watchers : " <<
endl;
428 cout <<
"|INFO|\t.L OnlineWatchersGLP.C+ " <<
endl;
429 cout <<
"|INFO|\tOnlineWatchersGLP() or OnlineWatchersGLP(new TFile(\"MySpectra.root\",\"UPDATE\"),new TFile(\"MyTagSpectra.root\",\"UPDATE\"))" <<
endl;
430 cout <<
"|INFO|\tThen start the watching from the ROOT Browser " <<
endl;
431 cout <<
"|INFO|" <<
endl;
432 cout <<
"|INFO|\tTo start offline Watchers : " <<
endl;
433 cout <<
"|INFO|\t\t1 - Configure OfflineWatcher.C (it could be a copy of of the one in DefaultWatchers)" <<
endl;
434 cout <<
"|INFO|\t\t2 - Compile/Run the Watchers with : " <<
endl;
435 cout <<
"|INFO|\t\t.L OfflineWatchers.C+" <<
endl;
436 cout <<
"|INFO|\t\tOfflineWatchers() or OfflineWatchers(new TFile(\"MySpectra.root\",\"UPDATE\"))" <<
endl;
437 cout <<
"|INFO|" <<
endl;
438 cout <<
"|INFO|\tTo start Actor Spectra Watchers : " <<
endl;
439 cout <<
"|INFO|\t\t1 - For different files from a run:"<<
endl;
440 cout <<
"|INFO|\t\t Import(TString Incl=\"*\", TString Excl=\"*.samp\", TString DefaultPath=\"\");" <<
endl;
441 cout <<
"|INFO|\t\t ex: Import(\"*\",\"*.samp\",\"\")" <<
endl;
442 cout <<
"|INFO|\t\t2 - For a single spectrum file:"<<
endl;
443 cout <<
"|INFO|\t\t ImportFile(TString DefaultPath="", Double_t DefGain=1);" <<
endl;
444 cout <<
"|INFO|\t\t ex: ImportFile(\"Path/Containing/Spectrum/File\",\"Gain if necessary\")" <<
endl;
445 cout <<
"|INFO|" <<
endl;
446 cout <<
"|INFO| ... informations ... messages ... help ... for Online/Quasi Online Analysis |" <<
endl;
450 CheckConf(
"CrystalPositionLookUpTable.dat");
460 gROOT->ProcessLine(
"TFolder *TaskFolder = (TFolder*)gROOT->GetRootFolder()->FindObject(\"Tasks\");");
461 gROOT->ProcessLine(
"TBrowser *browser = new TBrowser(\"Browser\",TaskFolder,\"Welcome in the wonderful world of Gammaware watchers, have fun !!!\");");
463 gROOT->ProcessLine(
"TFolder *SpectraViewerFolder = (TFolder*)gROOT->GetRootFolder()->FindObject(\"SpectraViewer\");");
464 gROOT->ProcessLine(
"if (SpectraViewerFolder) browser->BrowseObject(SpectraViewerFolder);");
466 gROOT->ProcessLine(
"TFolder *GwWatchersFolder = (TFolder*)gROOT->GetRootFolder()->FindObject(\"GwWatchers\");");
467 gROOT->ProcessLine(
"if(GwWatchersFolder) browser->BrowseObject(GwWatchersFolder);");
469 gROOT->ProcessLine(
"gROOT->GetRootFolder()->AddFolder(\"Tools\",\"Tools\");");
470 gROOT->ProcessLine(
"TFolder *f = (TFolder*)gROOT->GetRootFolder()->FindObject(\"Tools\");");
472 gROOT->ProcessLine(
"ManipConfig *WManipConfig= new ManipConfig(\"GlobalView\",\"GlobalView\");");
473 gROOT->ProcessLine(
"f->Add(WManipConfig)");
475 gROOT->ProcessLine(
"Gw::GSPlayerTUI *SpectrumPlayer = new Gw::GSPlayerTUI(\"SpectrumPlayer\",\"SpectrumPlayer\");");
476 gROOT->ProcessLine(
"f->Add(SpectrumPlayer);");
478 gROOT->ProcessLine(
"Collector *theCollector = new Collector(\"SpectraCollector\",\"SpectraCollector\");");
479 gROOT->ProcessLine(
"f->Add(theCollector);");
481 gROOT->ProcessLine(
"WatchersRefresh *WRefresh = new WatchersRefresh(\"AutoRefresh\",\"AutoRefresh\");");
482 gROOT->ProcessLine(
"f->Add(WRefresh);");
484 gROOT->ProcessLine(
"browser->Add(f);");
486 gROOT->ProcessLine(
"if ( browser ) browser->Draw();");
498 CleanDir(
"Macros/SpectraViewer/GWRecal");
504 gSystem->Exec(Form(
"rm -rf %s/*_C.so %s/*_C.d %s/*.o %s/*_cpp.so %s/*_cpp.d %s/*.pcm",
505 Dir.Data(),Dir.Data(),Dir.Data(),Dir.Data(),Dir.Data(),Dir.Data() ));
511 gSystem->Rename(
"SetupWatchers.C",
"MyWatchers/SetupWatchers.backup");
512 gSystem->Rename(
"OnlineWatchersLLP.C",
"MyWatchers/OnlineWatchersLLP.backup");
513 gSystem->Rename(
"OnlineWatchersGLP.C",
"MyWatchers/OnlineWatchersGLP.backup");
514 gSystem->Rename(
"OfflineWatchers.C",
"MyWatchers/OfflineWatchers.backup");
515 gSystem->Rename(
"ADF_To_Tree.C",
"MyWatchers/ADF_To_Tree.backup");
517 gSystem->Rename(
"ADF_to_Tree.C",
"MyWatchers/ADF_to_Tree.backup");
518 gSystem->Rename(
"SpyLLP.C",
"MyWatchers/SpyLLP.backup");
519 gSystem->Rename(
"SpyGLP.C",
"MyWatchers/SpyGLP.backup");
520 gSystem->Rename(
"RunOffline.C",
"MyWatchers/RunOffline.backup");
521 gSystem->Rename(
"RunADFToTree.C",
"MyWatchers/RunADFToTree.backup");
522 gSystem->Rename(
"StartBatch.sh",
"MyWatchers/StartBatch.sh.backup");
printf("******************************************************************** \n")
void CheckConf(TString what_conf)
void LoadClass(TString cpp_path)
functions defined in this macro
void LoadWatchers_AGATA()
void SetBasicMacros(TString what_file, TString what_sub_directory)
this check if a given file is there or not and install some default if there are not ...
void CleanSetup()
clean up setup by moving the corresoponding files
ADF::LogMessage & endl(ADF::LogMessage &log)
void BeginLoadWatchers()
Set Env and Load Gw libraries.
void AddInclude(TString what_directory)
void GANILLoadWatchers(const Char_t *comp_opt="g", const Char_t *path_to_agapro="")
void CleanWatchers()
clean up all created watchers
void LoadWatchers_ANCILLARIES()
void LoadWatchers_MyWatchers()
here is a place to add my personnal watchers
static const char * GetPath(const char *)
to get a particular GW environment variable
void CleanDir(TString Dir)
clean up all created watchers