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