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

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

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

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

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

Member Function Documentation

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

Implements edm::RootHandlers.

Definition at line 332 of file InitRootHandlers.cc.

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

Definition at line 313 of file InitRootHandlers.cc.

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

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

Implements edm::RootHandlers.

Definition at line 337 of file InitRootHandlers.cc.

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

Implements edm::RootHandlers.

Definition at line 309 of file InitRootHandlers.cc.

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

Implements edm::RootHandlers.

Definition at line 299 of file InitRootHandlers.cc.

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

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