Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:12:32

0001 // -*- C++ -*-
0002 //
0003 // Package:     LibraryLoader
0004 // Class  :     FWLiteEnabler
0005 //
0006 // Implementation:
0007 //     <Notes on implementation>
0008 //
0009 //
0010 
0011 // system include files
0012 #include <iostream>
0013 #include "TROOT.h"
0014 #include "TInterpreter.h"
0015 #include "TApplication.h"
0016 
0017 // user include files
0018 #include "FWCore/FWLite/interface/FWLiteEnabler.h"
0019 #include "FWCore/FWLite/src/BareRootProductGetter.h"
0020 #include "FWCore/PluginManager/interface/PluginManager.h"
0021 #include "FWCore/PluginManager/interface/standard.h"
0022 
0023 #include "FWCore/FWLite/interface/setRefStreamer.h"
0024 
0025 //
0026 // constants, enums and typedefs
0027 //
0028 
0029 //
0030 // static data member definitions
0031 //
0032 
0033 bool FWLiteEnabler::enabled_(false);
0034 
0035 //
0036 // constructors and destructor
0037 //
0038 // Note: this ctor will never be invoked.
0039 // All data and functions are static
0040 FWLiteEnabler::FWLiteEnabler() {}
0041 
0042 //
0043 // member functions
0044 //
0045 
0046 void FWLiteEnabler::enable() {
0047   if (enabled_) {
0048     return;
0049   }
0050   enabled_ = true;
0051 
0052   edmplugin::PluginManager::configure(edmplugin::standard::config());
0053   static BareRootProductGetter s_getter;
0054   //this function must be called
0055   // so that the TClass we need will be available
0056   fwlite::setRefStreamer(&s_getter);
0057 
0058   //Make it easy to load our headers
0059   TInterpreter* intrp = gROOT->GetInterpreter();
0060   char const* env = std::getenv("CMSSW_FWLITE_INCLUDE_PATH");
0061   if (nullptr != env) {
0062     //this is a comma separated list
0063     char const* start = env;
0064     char const* end;
0065     do {
0066       //find end
0067       for (end = start; *end != 0 and *end != ':'; ++end)
0068         ;
0069       std::string dir(start, end);
0070       intrp->AddIncludePath(dir.c_str());
0071       start = end + 1;
0072     } while (*end != 0);
0073   }
0074 
0075   bool foundCMSIncludes = false;
0076   env = std::getenv("CMSSW_BASE");
0077   if (nullptr != env) {
0078     foundCMSIncludes = true;
0079     std::string dir(env);
0080     dir += "/src";
0081     intrp->AddIncludePath(dir.c_str());
0082   }
0083 
0084   env = std::getenv("CMSSW_RELEASE_BASE");
0085   if (nullptr != env) {
0086     foundCMSIncludes = true;
0087     std::string dir(env);
0088     dir += "/src";
0089     intrp->AddIncludePath(dir.c_str());
0090   }
0091   if (not foundCMSIncludes) {
0092     std::cerr << "Could not find the environment variables \n"
0093               << "  CMSSW_BASE or\n"
0094               << "  CMSSW_RELEASE_BASE\n"
0095               << " therefore attempting to '#include' any CMS headers will not work" << std::endl;
0096   }
0097   if (nullptr != gApplication) {
0098     gApplication->InitializeGraphics();
0099   }
0100 }