00001 // -*- C++ -*- 00002 // 00003 // Package: LibraryLoader 00004 // Class : AutoLibraryLoader 00005 // 00006 // Implementation: 00007 // <Notes on implementation> 00008 // 00009 // Original Author: 00010 // Created: Wed Nov 30 14:55:01 EST 2005 00011 // $Id: AutoLibraryLoader.cc,v 1.23 2008/10/03 18:14:15 wmtan Exp $ 00012 // 00013 00014 // system include files 00015 #include <iostream> 00016 #include "TROOT.h" 00017 #include "TInterpreter.h" 00018 #include "TApplication.h" 00019 00020 // user include files 00021 #include "FWCore/FWLite/interface/AutoLibraryLoader.h" 00022 #include "FWCore/RootAutoLibraryLoader/interface/RootAutoLibraryLoader.h" 00023 #include "FWCore/FWLite/src/BareRootProductGetter.h" 00024 #include "FWCore/PluginManager/interface/PluginManager.h" 00025 #include "FWCore/PluginManager/interface/standard.h" 00026 #include "DataFormats/Common/interface/CacheStreamers.h" 00027 00028 #include "FWCore/FWLite/interface/setRefStreamer.h" 00029 // 00030 // constants, enums and typedefs 00031 // 00032 00033 // 00034 // static data member definitions 00035 // 00036 00037 bool AutoLibraryLoader::enabled_(false); 00038 00039 // 00040 // constructors and destructor 00041 // 00042 AutoLibraryLoader::AutoLibraryLoader() 00043 { 00044 } 00045 00046 00047 // 00048 // member functions 00049 // 00050 00051 void 00052 AutoLibraryLoader::enable() 00053 { 00054 if (enabled_) { return; } 00055 enabled_ = true; 00056 00057 edmplugin::PluginManager::configure(edmplugin::standard::config()); 00058 static BareRootProductGetter s_getter; 00059 static edm::EDProductGetter::Operate s_op(&s_getter); 00060 edm::RootAutoLibraryLoader::enable(); 00061 edm::setCacheStreamers(); 00062 //this function must be called after enabling the autoloader 00063 // so that the Reflex dictionaries will be converted to ROOT 00064 // dictionaries and the TClass we need will be available 00065 fwlite::setRefStreamer(&s_getter); 00066 00067 //Make it easy to load our headers 00068 TInterpreter* intrp= gROOT->GetInterpreter(); 00069 const char* env = getenv("CMSSW_FWLITE_INCLUDE_PATH"); 00070 if( 0 != env) { 00071 //this is a comma separated list 00072 const char* start = env; 00073 const char* end = env; 00074 do{ 00075 //find end 00076 for(end=start; *end!=0 and *end != ':';++end); 00077 std::string dir(start, end); 00078 intrp->AddIncludePath(dir.c_str()); 00079 start = end+1; 00080 }while(*end != 0); 00081 } 00082 00083 bool foundCMSIncludes = false; 00084 env = getenv("CMSSW_BASE"); 00085 if( 0 != env) { 00086 foundCMSIncludes = true; 00087 std::string dir(env); 00088 dir += "/src"; 00089 intrp->AddIncludePath(dir.c_str()); 00090 } 00091 00092 env = getenv("CMSSW_RELEASE_BASE"); 00093 if( 0 != env) { 00094 foundCMSIncludes = true; 00095 std::string dir(env); 00096 dir += "/src"; 00097 intrp->AddIncludePath(dir.c_str()); 00098 } 00099 if( not foundCMSIncludes) { 00100 std::cerr <<"Could not find the environment variables \n" 00101 <<" CMSSW_BASE or\n" 00102 <<" CMSSW_RELEASE_BASE\n" 00103 <<" therefore attempting to '#include' any CMS headers will not work"<<std::endl; 00104 } 00105 if (0 != gApplication) { 00106 gApplication->InitializeGraphics(); 00107 } 00108 } 00109 00110 void 00111 AutoLibraryLoader::loadAll() 00112 { 00113 // std::cout <<"LoadAllDictionaries"<<std::endl; 00114 enable(); 00115 edm::RootAutoLibraryLoader::loadAll(); 00116 } 00117 00118 00119 ClassImp(AutoLibraryLoader)