GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
LoadPFC.C
Go to the documentation of this file.
1 #include "TString.h"
2 #include <cstring>
3 
4 // some globals protected by a namespace
5 namespace _LoadPFC_ {
6 // used for subdirectories containing campaign related [in Default and Macros]
7 
8 // to force compilation / debugging @ the ACLIC level
9 TString CompOpt = "g";
10 // just a usefull String
11 TString tmp;
12 
13 Char_t DefaultW[100]; Char_t MyW[100]; Char_t AncW[100]; Char_t WarningW[100]; Char_t EndColor[100];
14 }
15 using namespace _LoadPFC_ ;
16 
17 void AddInclude(TString what_directory);
18 void LoadClass(TString cpp_path);
19 void CheckConf(TString what_conf);
20 void Clean();
21 void CleanDir(TString Dir);
22 
23 void LoadPFC()
24 {
25 
26  sprintf(DefaultW," \033[1;34m [*] "); sprintf(MyW," \033[1;32m [+] "); sprintf(WarningW," \033[1;31m [!] "); sprintf(EndColor,"\033[0m");
27 
28  printf("******************************************************************** \n") ;
29  printf(" Messages from LoadPFC.C \n") ;
30  printf("******************************************************************** \n") ;
31 
32  TString AGAPRO_ENV = gSystem->Getenv("AGAPRO_INC");
33  if(AGAPRO_ENV == "")
34  {
35  std::cout << WarningW <<" AGAPRO libraries not loaded ==> EXIT !!!" << EndColor << endl;
36  exit(0);
37  }
38 
39  AddInclude(AGAPRO_ENV);
40 
41  // load the different Gw libraries needed
42  gSystem->Load("libADF.so");
43  gSystem->Load("libTrackingFilter.so");
44 
45  LoadClass("../stogs/analysis/BashColor.cpp");
46  AddInclude("../stogs/analysis/");
47 
48  LoadClass("EmulatorControl.C");
49 
50  // check whether or not ADF_CONF_PATH has been set !
51  CheckConf("ADF.conf");
52  CheckConf("CrystalPositionLookUpTable.dat");
53 }
54 
56 void LoadClass(TString cpp_path)
57 {
58  if(!gSystem->IsFileInIncludePath(cpp_path))
59  {
60  cout<<cpp_path<<" not found, class not loaded."<<endl;
61  return;
62  }
63  else
64  {
65  TString CompileLine = ".L " + cpp_path + Form("+%s",CompOpt.Data());
66  gROOT->ProcessLine(CompileLine.Data());
67  }
68 }
69 
70 // add a directory containing includes
71 void AddInclude(TString what_directory)
72 {
73  tmp = what_directory; printf("{Conf} Add %s to the include path \n",tmp.Data());
74  tmp.Prepend(" .include ");
75  gROOT->ProcessLine(tmp.Data());
76 }
77 
78 void CheckConf(TString what_conf)
79 {
80  if ( what_conf == "ADF.conf" ) {
81  //
82  TString adf_path = gSystem->Getenv("ADF_CONF_PATH");
83  //
84  if ( adf_path == "" ) { // the ADF_CONF_PATH is not set, try the current directory. If no ADF.conf file, load a default from server
85  Bool_t ok = false;
86  //
87  if ( !gSystem->AccessPathName("./ADF.conf") ) { // current directory
88  ok = true;
89  }
90  else {
91  // try and downlaod into a temporary directory
92  TString tmp_dir = gSystem->TempDirectory();
93  std::cout << WarningW << "Cannot find ADF.conf ... try and install a default one from internet, make sure it fullfils your needs " << EndColor << std::endl;
94  gSystem->Exec(Form("svn --quiet checkout svn+ssh://anonsvn@anonsvn.in2p3.fr/agata/conf/watchers/ %s",tmp_dir.Data()));
95  if ( gSystem->CopyFile(Form("%s/ADF.conf",tmp_dir.Data()),"./ADF.conf") == 0 )
96  ok = true;
97  }
98  if ( ok ) { // does not exist in the current directory
99  adf_path = gSystem->Getenv("PWD");
100 
101  }
102  }
103  if ( adf_path == "" ) {
104  std::cout << WarningW << " ADF_CONF_PATH not set !" << EndColor << std::endl;
105  }
106  else {
107  gSystem->Setenv("ADF_CONF_PATH",adf_path.Data());
108  printf("\n\t{Conf}\tADF_CONF_PATH has been set to %s \n\n",adf_path.Data());
109  }
110  }
111  if ( what_conf == "CrystalPositionLookUpTable.dat" ) {
112  //
113  Bool_t ok = false;
114  if ( !gSystem->AccessPathName("./CrystalPositionLookUpTable.dat") ) { // current directory
115  }
116  else {
117  gSystem->Exec("ln -s Tools/CrystalLookUpTableIdentity.dat CrystalPositionLookUpTable.dat");
118  gSystem->Exec("ln -s Tools/CrystalLookUpTableIdentity.dat CrystalPositionLookUpTable");
119  std::cout << WarningW;
120  std::cout<<"CrystalPositionLookUpTable.dat not found, an Identity lookup table has been linked to avoid tracking problems"<<std::endl;
121  gSystem->Exec("ls -l CrystalPositionLookUpTable*");
122  std::cout<<EndColor << std::endl;
123  }
124  }
125 }
126 
128 void Clean()
129 {
130  CleanDir(".");
131 }
132 
134 void CleanDir(TString Dir)
135 {
136  gSystem->Exec(Form("rm -rf %s/*_C.so %s/*_C.d %s/*.o %s/*_cpp.so %s/*_cpp.d %s/*.pcm", Dir.Data(),Dir.Data(),Dir.Data(),Dir.Data(),Dir.Data(),Dir.Data() ));
137 }
printf("******************************************************************** \n")
void LoadClass(TString cpp_path)
a usefull facility to compile/load a given Watcher
Definition: LoadPFC.C:56
void LoadPFC()
Definition: LoadPFC.C:23
void Clean()
clean up all created watchers
Definition: LoadPFC.C:128
void CleanDir(TString Dir)
clean up all created watchers
Definition: LoadPFC.C:134
Char_t MyW[100]
Definition: LoadPFC.C:13
Char_t EndColor[100]
Definition: LoadPFC.C:13
Char_t AncW[100]
Definition: LoadPFC.C:13
void AddInclude(TString what_directory)
Definition: LoadPFC.C:71
TString CompOpt
Definition: LoadPFC.C:9
Char_t WarningW[100]
Definition: LoadPFC.C:13
Char_t DefaultW[100]
Definition: LoadPFC.C:13
TString tmp
Definition: LoadPFC.C:11
ADF::LogMessage & endl(ADF::LogMessage &log)
void CheckConf(TString what_conf)
Definition: LoadPFC.C:78