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 213 of file InitRootHandlers.cc.

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

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

Definition at line 283 of file InitRootHandlers.cc.

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

283  {
284  // close all open ROOT files
285  TIter iter(gROOT->GetListOfFiles());
286  TObject *obj = nullptr;
287  while(nullptr != (obj = iter.Next())) {
288  TFile* f = dynamic_cast<TFile*>(obj);
289  if(f) {
290  // We get a new iterator each time,
291  // because closing a file can invalidate the iterator
292  f->Close();
293  iter = TIter(gROOT->GetListOfFiles());
294  }
295  }
296  }
double f[11][100]

Member Function Documentation

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

Implements edm::RootHandlers.

Definition at line 331 of file InitRootHandlers.cc.

331  {
332  s_ignoreWarnings =false;
333  }
void edm::service::InitRootHandlers::fillDescriptions ( ConfigurationDescriptions descriptions)
static

Definition at line 312 of file InitRootHandlers.cc.

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

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

Implements edm::RootHandlers.

Definition at line 336 of file InitRootHandlers.cc.

336  {
337  s_ignoreWarnings = true;
338  }
void edm::service::InitRootHandlers::initializeThisThreadForUse ( )
overrideprivatevirtual

Implements edm::RootHandlers.

Definition at line 308 of file InitRootHandlers.cc.

308  {
309  static thread_local TThread guard;
310  }
void edm::service::InitRootHandlers::willBeUsingThreads ( )
overrideprivatevirtual

Implements edm::RootHandlers.

Definition at line 298 of file InitRootHandlers.cc.

298  {
299  //Tell Root we want to be multi-threaded
300  TThread::Initialize();
301  //When threading, also have to keep ROOT from logging all TObjects into a list
302  TObject::SetObjectStat(false);
303 
304  //Have to avoid having Streamers modify themselves after they have been used
305  TVirtualStreamerInfo::Optimize(false);
306  }

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.

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