CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
edm::service::InitRootHandlers Class Reference

#include <InitRootHandlers.h>

Inheritance diagram for edm::service::InitRootHandlers:
edm::RootHandlers

Public Member Functions

 InitRootHandlers (ParameterSet const &pset)
 
virtual ~InitRootHandlers ()
 
- Public Member Functions inherited from edm::RootHandlers
template<typename F >
void ignoreWarningsWhileDoing (F iFunc)
 
 RootHandlers ()
 
virtual ~RootHandlers ()
 

Static Public Member Functions

static void fillDescriptions (ConfigurationDescriptions &descriptions)
 

Private Member Functions

virtual void enableWarnings_ () override
 
virtual void ignoreWarnings_ () override
 
virtual void initializeThisThreadForUse () override
 
virtual void willBeUsingThreads () override
 

Private Attributes

bool autoLibraryLoader_
 
bool loadAllDictionaries_
 
bool resetErrHandler_
 
std::shared_ptr< const void > sigBusHandler_
 
std::shared_ptr< const void > sigIllHandler_
 
std::shared_ptr< const void > sigSegvHandler_
 
bool unloadSigHandler_
 

Detailed Description

Definition at line 12 of file InitRootHandlers.h.

Constructor & Destructor Documentation

edm::service::InitRootHandlers::InitRootHandlers ( ParameterSet const &  pset)
explicit

Definition at line 219 of file InitRootHandlers.cc.

References autoLibraryLoader_, edm::dictionaryPlugInPrefix(), edm::RootAutoLibraryLoader::enable(), edmplugin::PluginCapabilities::get(), edm::ParameterSet::getUntrackedParameter(), edm::installCustomHandler(), edmplugin::PluginCapabilities::load(), edm::RootAutoLibraryLoader::loadAll(), loadAllDictionaries_, resetErrHandler_, edm::setRefCoreStreamer(), sigBusHandler_, sigIllHandler_, sigSegvHandler_, and unloadSigHandler_.

220  : RootHandlers(),
221  unloadSigHandler_(pset.getUntrackedParameter<bool> ("UnloadRootSigHandler")),
222  resetErrHandler_(pset.getUntrackedParameter<bool> ("ResetRootErrHandler")),
223  loadAllDictionaries_(pset.getUntrackedParameter<bool>("LoadAllDictionaries")),
224  autoLibraryLoader_(loadAllDictionaries_ or pset.getUntrackedParameter<bool> ("AutoLibraryLoader"))
225  {
226 
227  if(unloadSigHandler_) {
228  // Deactivate all the Root signal handlers and restore the system defaults
229  gSystem->ResetSignal(kSigChild);
230  gSystem->ResetSignal(kSigBus);
231  gSystem->ResetSignal(kSigSegmentationViolation);
232  gSystem->ResetSignal(kSigIllegalInstruction);
233  gSystem->ResetSignal(kSigSystem);
234  gSystem->ResetSignal(kSigPipe);
235  gSystem->ResetSignal(kSigAlarm);
236  gSystem->ResetSignal(kSigUrgent);
237  gSystem->ResetSignal(kSigFloatingException);
238  gSystem->ResetSignal(kSigWindowChanged);
239  } else if(pset.getUntrackedParameter<bool>("AbortOnSignal")){
240  //NOTE: ROOT can also be told to abort on these kinds of problems BUT
241  // it requires an TApplication to be instantiated which causes problems
242  gSystem->ResetSignal(kSigBus);
243  gSystem->ResetSignal(kSigSegmentationViolation);
244  gSystem->ResetSignal(kSigIllegalInstruction);
245  installCustomHandler(SIGBUS,sig_dostack_then_abort);
246  sigBusHandler_ = std::shared_ptr<const void>(nullptr,[](void*) {
247  installCustomHandler(SIGBUS,sig_abort);
248  });
249  installCustomHandler(SIGSEGV,sig_dostack_then_abort);
250  sigSegvHandler_ = std::shared_ptr<const void>(nullptr,[](void*) {
251  installCustomHandler(SIGSEGV,sig_abort);
252  });
253  installCustomHandler(SIGILL,sig_dostack_then_abort);
254  sigIllHandler_ = std::shared_ptr<const void>(nullptr,[](void*) {
255  installCustomHandler(SIGILL,sig_abort);
256  });
257  }
258 
259  if(resetErrHandler_) {
260 
261  // Replace the Root error handler with one that uses the MessageLogger
262  SetErrorHandler(RootErrorHandler);
263  }
264 
265  // Enable automatic Root library loading.
266  if(autoLibraryLoader_) {
270  }
271  }
272 
273  // Enable Cintex.
274  ROOT::Cintex::Cintex::Enable();
275 
276  // Set ROOT parameters.
277  TTree::SetMaxTreeSize(kMaxLong64);
278  TH1::AddDirectory(kFALSE);
279  G__SetCatchException(0);
280 
281  // Set custom streamers
283 
284  // Load the library containing dictionaries for std:: classes, if not already loaded.
285  if (!TypeWithDict(typeid(std::vector<std::vector<unsigned int> >)).hasDictionary()) {
286  edmplugin::PluginCapabilities::get()->load(dictionaryPlugInPrefix() + "std::vector<std::vector<unsigned int> >");
287  }
288 
289  int debugLevel = pset.getUntrackedParameter<int>("DebugLevel");
290  if(debugLevel >0) {
291  gDebug = debugLevel;
292  }
293  }
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
void setRefCoreStreamer(bool resetAll=false)
std::string const & dictionaryPlugInPrefix()
void installCustomHandler(int signum, CFUNC func)
std::shared_ptr< const void > sigSegvHandler_
std::shared_ptr< const void > sigBusHandler_
std::shared_ptr< const void > sigIllHandler_
static PluginCapabilities * get()
static void loadAll()
load all known libraries holding dictionaries
void load(const std::string &iName)
static void enable()
interface for TClass generators
edm::service::InitRootHandlers::~InitRootHandlers ( )
virtual

Definition at line 295 of file InitRootHandlers.cc.

References f, getDQMSummary::iter, and getGTfromDQMFile::obj.

295  {
296  // close all open ROOT files
297  TIter iter(gROOT->GetListOfFiles());
298  TObject *obj = nullptr;
299  while(nullptr != (obj = iter.Next())) {
300  TFile* f = dynamic_cast<TFile*>(obj);
301  if(f) {
302  // We get a new iterator each time,
303  // because closing a file can invalidate the iterator
304  f->Close();
305  iter = TIter(gROOT->GetListOfFiles());
306  }
307  }
308  }
double f[11][100]

Member Function Documentation

void edm::service::InitRootHandlers::enableWarnings_ ( )
overrideprivatevirtual

Implements edm::RootHandlers.

Definition at line 343 of file InitRootHandlers.cc.

343  {
344  s_ignoreWarnings =false;
345  }
void edm::service::InitRootHandlers::fillDescriptions ( ConfigurationDescriptions descriptions)
static

Definition at line 324 of file InitRootHandlers.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::addUntracked(), and edm::ParameterSetDescription::setComment().

324  {
326  desc.setComment("Centralized interface to ROOT.");
327  desc.addUntracked<bool>("UnloadRootSigHandler", false)
328  ->setComment("If True, signals are handled by this service, rather than by ROOT.");
329  desc.addUntracked<bool>("ResetRootErrHandler", true)
330  ->setComment("If True, ROOT messages (e.g. errors, warnings) are handled by this service, rather than by ROOT.");
331  desc.addUntracked<bool>("AutoLibraryLoader", true)
332  ->setComment("If True, enables automatic loading of data dictionaries.");
333  desc.addUntracked<bool>("LoadAllDictionaries",false)
334  ->setComment("If True, loads all ROOT dictionaries.");
335  desc.addUntracked<bool>("AbortOnSignal",true)
336  ->setComment("If True, do an abort when a signal occurs that causes a crash. If False, ROOT will do an exit which attempts to do a clean shutdown.");
337  desc.addUntracked<int>("DebugLevel",0)
338  ->setComment("Sets ROOT's gDebug value.");
339  descriptions.add("InitRootHandlers", desc);
340  }
void edm::service::InitRootHandlers::ignoreWarnings_ ( )
overrideprivatevirtual

Implements edm::RootHandlers.

Definition at line 348 of file InitRootHandlers.cc.

348  {
349  s_ignoreWarnings = true;
350  }
void edm::service::InitRootHandlers::initializeThisThreadForUse ( )
overrideprivatevirtual

Implements edm::RootHandlers.

Definition at line 320 of file InitRootHandlers.cc.

320  {
321  static thread_local TThread guard;
322  }
void edm::service::InitRootHandlers::willBeUsingThreads ( )
overrideprivatevirtual

Implements edm::RootHandlers.

Definition at line 310 of file InitRootHandlers.cc.

310  {
311  //Tell Root we want to be multi-threaded
312  TThread::Initialize();
313  //When threading, also have to keep ROOT from logging all TObjects into a list
314  TObject::SetObjectStat(false);
315 
316  //Have to avoid having Streamers modify themselves after they have been used
317  TVirtualStreamerInfo::Optimize(false);
318  }

Member Data Documentation

bool edm::service::InitRootHandlers::autoLibraryLoader_
private

Definition at line 29 of file InitRootHandlers.h.

Referenced by InitRootHandlers().

bool edm::service::InitRootHandlers::loadAllDictionaries_
private

Definition at line 28 of file InitRootHandlers.h.

Referenced by InitRootHandlers().

bool edm::service::InitRootHandlers::resetErrHandler_
private

Definition at line 27 of file InitRootHandlers.h.

Referenced by InitRootHandlers().

std::shared_ptr<const void> edm::service::InitRootHandlers::sigBusHandler_
private

Definition at line 30 of file InitRootHandlers.h.

Referenced by InitRootHandlers().

std::shared_ptr<const void> edm::service::InitRootHandlers::sigIllHandler_
private

Definition at line 32 of file InitRootHandlers.h.

Referenced by InitRootHandlers().

std::shared_ptr<const void> edm::service::InitRootHandlers::sigSegvHandler_
private

Definition at line 31 of file InitRootHandlers.h.

Referenced by InitRootHandlers().

bool edm::service::InitRootHandlers::unloadSigHandler_
private

Definition at line 26 of file InitRootHandlers.h.

Referenced by InitRootHandlers().