File indexing completed on 2025-01-30 09:17:19
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #include "TInterpreter.h"
0016 #include "TSystem.h"
0017 #include "RVersion.h"
0018
0019
0020 #include <iostream>
0021 #include <string>
0022
0023 std::string make_str(const char* data) {
0024 if ( !data ) {
0025 std::cout << "make_str: '" << (data ? data : "Bad-Pointer") << "'" << std::endl;
0026 return std::string("");
0027 }
0028 return std::string(data);
0029 }
0030
0031
0032 int processCommand(const char* command, bool end_process) {
0033 int status;
0034
0035 gInterpreter->SetClassAutoparsing(false);
0036 status = gInterpreter->ProcessLine(command);
0037 gInterpreter->SetClassAutoparsing(true);
0038 ::printf("+++ Status(%s) = %d\n",command,status);
0039 if ( end_process ) {
0040 gInterpreter->ProcessLine("gSystem->Exit(0)");
0041 }
0042 return status;
0043 }
0044
0045
0046 int processMacro(const char* macro, bool end_process) {
0047 std::string cmd = ".X ";
0048 cmd += macro;
0049 cmd += ".C+()";
0050 return processCommand(cmd.c_str(), end_process);
0051 }
0052
0053
0054 int initAClick(const char* command=0) {
0055 std::string rootsys = make_str(gSystem->Getenv("ROOTSYS"));
0056 std::string geant4 = make_str(gSystem->Getenv("G4INSTALL"));
0057 std::string dd4hep = make_str(gSystem->Getenv("DD4hepINSTALL"));
0058 std::string clhep = make_str(gSystem->Getenv("CLHEP_ROOT_DIR"));
0059 std::string defs = "";
0060
0061 std::string libs = " -L"+rootsys+"/lib" + " -L"+rootsys+"/lib/root";
0062 std::string inc = " -I"+dd4hep+"/examples/DDG4/examples -I"+dd4hep + " -I"+dd4hep+"/include ";
0063 std::string ext = "so";
0064 if ( !geant4.empty() ) {
0065 inc += " -I"+geant4+"/include/Geant4";
0066 #ifdef __APPLE__
0067 libs += (" -L"+geant4+"/lib");
0068 ext = "dylib";
0069 #else
0070 libs += (" -L"+geant4+"/lib -L"+geant4+"/lib64");
0071 #endif
0072 }
0073 if ( !clhep.empty() ) {
0074
0075
0076 inc += " -I"+clhep+"/include";
0077 std::string clhep_lib = make_str(gSystem->Getenv("CLHEP_LIBRARY_PATH"));
0078 if ( !clhep_lib.empty() ) libs += " -L"+clhep_lib+"/lib";
0079 }
0080 inc += " -Wno-shadow -g -O0" + defs;
0081 #ifndef __APPLE__
0082 libs += " -lCore -lMathCore -pthread -lm -ldl -rdynamic";
0083 #endif
0084
0085
0086
0087 libs += " -L" +dd4hep+"/lib ";
0088 #ifdef __APPLE__
0089 int ret = gSystem->Load("libDD4hepGaudiPluginMgr");
0090 #else
0091
0092 int ret = gSystem->Load("libDD4hepGaudiPluginMgr");
0093 #endif
0094 gSystem->AddIncludePath(inc.c_str());
0095 gSystem->AddLinkedLibs(libs.c_str());
0096 std::cout << "+++ Includes: " << gSystem->GetIncludePath() << std::endl;
0097 std::cout << "+++ Linked libs:" << gSystem->GetLinkedLibs() << std::endl;
0098 if ( command ) {
0099 processCommand(command, true);
0100 }
0101 return ret;
0102 }