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 217 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(), edm::setStreamedProductStreamer(), sigBusHandler_, sigIllHandler_, sigSegvHandler_, and unloadSigHandler_.

218  : RootHandlers(),
219  unloadSigHandler_(pset.getUntrackedParameter<bool> ("UnloadRootSigHandler")),
220  resetErrHandler_(pset.getUntrackedParameter<bool> ("ResetRootErrHandler")),
221  loadAllDictionaries_(pset.getUntrackedParameter<bool>("LoadAllDictionaries")),
222  autoLibraryLoader_(loadAllDictionaries_ or pset.getUntrackedParameter<bool> ("AutoLibraryLoader"))
223  {
224 
225  if(unloadSigHandler_) {
226  // Deactivate all the Root signal handlers and restore the system defaults
227  gSystem->ResetSignal(kSigChild);
228  gSystem->ResetSignal(kSigBus);
229  gSystem->ResetSignal(kSigSegmentationViolation);
230  gSystem->ResetSignal(kSigIllegalInstruction);
231  gSystem->ResetSignal(kSigSystem);
232  gSystem->ResetSignal(kSigPipe);
233  gSystem->ResetSignal(kSigAlarm);
234  gSystem->ResetSignal(kSigUrgent);
235  gSystem->ResetSignal(kSigFloatingException);
236  gSystem->ResetSignal(kSigWindowChanged);
237  } else if(pset.getUntrackedParameter<bool>("AbortOnSignal")){
238  //NOTE: ROOT can also be told to abort on these kinds of problems BUT
239  // it requires an TApplication to be instantiated which causes problems
240  gSystem->ResetSignal(kSigBus);
241  gSystem->ResetSignal(kSigSegmentationViolation);
242  gSystem->ResetSignal(kSigIllegalInstruction);
243  installCustomHandler(SIGBUS,sig_dostack_then_abort);
244  sigBusHandler_ = std::shared_ptr<const void>(nullptr,[](void*) {
245  installCustomHandler(SIGBUS,sig_abort);
246  });
247  installCustomHandler(SIGSEGV,sig_dostack_then_abort);
248  sigSegvHandler_ = std::shared_ptr<const void>(nullptr,[](void*) {
249  installCustomHandler(SIGSEGV,sig_abort);
250  });
251  installCustomHandler(SIGILL,sig_dostack_then_abort);
252  sigIllHandler_ = std::shared_ptr<const void>(nullptr,[](void*) {
253  installCustomHandler(SIGILL,sig_abort);
254  });
255  }
256 
257  if(resetErrHandler_) {
258 
259  // Replace the Root error handler with one that uses the MessageLogger
260  SetErrorHandler(RootErrorHandler);
261  }
262 
263  // Enable automatic Root library loading.
264  if(autoLibraryLoader_) {
268  }
269  }
270 
271  // Enable Cintex.
272  ROOT::Cintex::Cintex::Enable();
273 
274  // Set ROOT parameters.
275  TTree::SetMaxTreeSize(kMaxLong64);
276  TH1::AddDirectory(kFALSE);
277  G__SetCatchException(0);
278 
279  // Set custom streamers
282 
283  // Load the library containing dictionaries for std:: classes, if not already loaded.
284  if (!TypeWithDict(typeid(std::vector<std::vector<unsigned int> >)).hasDictionary()) {
285  edmplugin::PluginCapabilities::get()->load(dictionaryPlugInPrefix() + "std::vector<std::vector<unsigned int> >");
286  }
287 
288  int debugLevel = pset.getUntrackedParameter<int>("DebugLevel");
289  if(debugLevel >0) {
290  gDebug = debugLevel;
291  }
292  }
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 setStreamedProductStreamer()
void load(const std::string &iName)
static void enable()
interface for TClass generators
edm::service::InitRootHandlers::~InitRootHandlers ( )
virtual

Definition at line 294 of file InitRootHandlers.cc.

References f, and getDQMSummary::iter.

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

Member Function Documentation

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

Implements edm::RootHandlers.

Definition at line 338 of file InitRootHandlers.cc.

338  {
339  s_ignoreWarnings =false;
340  }
void edm::service::InitRootHandlers::fillDescriptions ( ConfigurationDescriptions descriptions)
static

Definition at line 319 of file InitRootHandlers.cc.

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

319  {
321  desc.setComment("Centralized interface to ROOT.");
322  desc.addUntracked<bool>("UnloadRootSigHandler", false)
323  ->setComment("If True, signals are handled by this service, rather than by ROOT.");
324  desc.addUntracked<bool>("ResetRootErrHandler", true)
325  ->setComment("If True, ROOT messages (e.g. errors, warnings) are handled by this service, rather than by ROOT.");
326  desc.addUntracked<bool>("AutoLibraryLoader", true)
327  ->setComment("If True, enables automatic loading of data dictionaries.");
328  desc.addUntracked<bool>("LoadAllDictionaries",false)
329  ->setComment("If True, loads all ROOT dictionaries.");
330  desc.addUntracked<bool>("AbortOnSignal",true)
331  ->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.");
332  desc.addUntracked<int>("DebugLevel",0)
333  ->setComment("Sets ROOT's gDebug value.");
334  descriptions.add("InitRootHandlers", desc);
335  }
void edm::service::InitRootHandlers::ignoreWarnings_ ( )
overrideprivatevirtual

Implements edm::RootHandlers.

Definition at line 343 of file InitRootHandlers.cc.

343  {
344  s_ignoreWarnings = true;
345  }
void edm::service::InitRootHandlers::initializeThisThreadForUse ( )
overrideprivatevirtual

Implements edm::RootHandlers.

Definition at line 315 of file InitRootHandlers.cc.

315  {
316  static thread_local TThread guard;
317  }
void edm::service::InitRootHandlers::willBeUsingThreads ( )
overrideprivatevirtual

Implements edm::RootHandlers.

Definition at line 305 of file InitRootHandlers.cc.

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

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().