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
 

Private Attributes

bool autoLibraryLoader_
 
bool resetErrHandler_
 
bool unloadSigHandler_
 

Detailed Description

Definition at line 11 of file InitRootHandlers.h.

Constructor & Destructor Documentation

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

Definition at line 196 of file InitRootHandlers.cc.

References autoLibraryLoader_, edm::dictionaryPlugInPrefix(), edm::RootAutoLibraryLoader::enable(), edmplugin::PluginCapabilities::get(), edm::ParameterSet::getUntrackedParameter(), edm::installCustomHandler(), edmplugin::PluginCapabilities::load(), resetErrHandler_, edm::setRefCoreStreamer(), edm::setStreamedProductStreamer(), and unloadSigHandler_.

197  : RootHandlers(),
198  unloadSigHandler_(pset.getUntrackedParameter<bool> ("UnloadRootSigHandler")),
199  resetErrHandler_(pset.getUntrackedParameter<bool> ("ResetRootErrHandler")),
200  autoLibraryLoader_(pset.getUntrackedParameter<bool> ("AutoLibraryLoader")) {
201 
202  if(unloadSigHandler_) {
203  // Deactivate all the Root signal handlers and restore the system defaults
204  gSystem->ResetSignal(kSigChild);
205  gSystem->ResetSignal(kSigBus);
206  gSystem->ResetSignal(kSigSegmentationViolation);
207  gSystem->ResetSignal(kSigIllegalInstruction);
208  gSystem->ResetSignal(kSigSystem);
209  gSystem->ResetSignal(kSigPipe);
210  gSystem->ResetSignal(kSigAlarm);
211  gSystem->ResetSignal(kSigUrgent);
212  gSystem->ResetSignal(kSigFloatingException);
213  gSystem->ResetSignal(kSigWindowChanged);
214  } else if(pset.getUntrackedParameter<bool>("AbortOnSignal")){
215  //NOTE: ROOT can also be told to abort on these kinds of problems BUT
216  // it requires an TApplication to be instantiated which causes problems
217  gSystem->ResetSignal(kSigBus);
218  gSystem->ResetSignal(kSigSegmentationViolation);
219  gSystem->ResetSignal(kSigIllegalInstruction);
220  installCustomHandler(SIGBUS,sig_dostack_then_abort);
221  installCustomHandler(SIGSEGV,sig_dostack_then_abort);
222  installCustomHandler(SIGILL,sig_dostack_then_abort);
223  }
224 
225  if(resetErrHandler_) {
226 
227  // Replace the Root error handler with one that uses the MessageLogger
228  SetErrorHandler(RootErrorHandler);
229  }
230 
231  // Enable automatic Root library loading.
232  if(autoLibraryLoader_) {
234  }
235 
236  // Enable Cintex.
237  ROOT::Cintex::Cintex::Enable();
238 
239  // Set ROOT parameters.
240  TTree::SetMaxTreeSize(kMaxLong64);
241  TH1::AddDirectory(kFALSE);
242  G__SetCatchException(0);
243 
244  // Set custom streamers
247 
248  // Load the library containing dictionaries for std:: classes, if not already loaded.
249  if (!TypeWithDict(typeid(std::vector<std::vector<unsigned int> >)).hasDictionary()) {
250  edmplugin::PluginCapabilities::get()->load(dictionaryPlugInPrefix() + "std::vector<std::vector<unsigned int> >");
251  }
252 
253  int debugLevel = pset.getUntrackedParameter<int>("DebugLevel");
254  if(debugLevel >0) {
255  gDebug = debugLevel;
256  }
257  }
void setRefCoreStreamer(bool resetAll=false)
std::string const & dictionaryPlugInPrefix()
void installCustomHandler(int signum, CFUNC func)
static PluginCapabilities * get()
void setStreamedProductStreamer()
void load(const std::string &iName)
static void enable()
interface for TClass generators
edm::service::InitRootHandlers::~InitRootHandlers ( )
virtual

Definition at line 259 of file InitRootHandlers.cc.

References f.

259  {
260  // close all open ROOT files
261  // We get a new iterator each time,
262  // because closing a file can invalidate the iterator
263  while(gROOT->GetListOfFiles()->GetSize()) {
264  TIter iter(gROOT->GetListOfFiles());
265  TFile* f = dynamic_cast<TFile*>(iter.Next());
266  if(f) f->Close();
267  }
268  }
double f[11][100]

Member Function Documentation

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

Implements edm::RootHandlers.

Definition at line 287 of file InitRootHandlers.cc.

287  {
288  s_ignoreWarnings =false;
289  }
void edm::service::InitRootHandlers::fillDescriptions ( ConfigurationDescriptions descriptions)
static

Definition at line 270 of file InitRootHandlers.cc.

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

270  {
272  desc.setComment("Centralized interface to ROOT.");
273  desc.addUntracked<bool>("UnloadRootSigHandler", false)
274  ->setComment("If True, signals are handled by this service, rather than by ROOT.");
275  desc.addUntracked<bool>("ResetRootErrHandler", true)
276  ->setComment("If True, ROOT messages (e.g. errors, warnings) are handled by this service, rather than by ROOT.");
277  desc.addUntracked<bool>("AutoLibraryLoader", true)
278  ->setComment("If True, enables automatic loading of data dictionaries.");
279  desc.addUntracked<bool>("AbortOnSignal",true)
280  ->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.");
281  desc.addUntracked<int>("DebugLevel",0)
282  ->setComment("Sets ROOT's gDebug value.");
283  descriptions.add("InitRootHandlers", desc);
284  }
void edm::service::InitRootHandlers::ignoreWarnings_ ( )
overrideprivatevirtual

Implements edm::RootHandlers.

Definition at line 292 of file InitRootHandlers.cc.

292  {
293  s_ignoreWarnings = true;
294  }

Member Data Documentation

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

Definition at line 24 of file InitRootHandlers.h.

Referenced by InitRootHandlers().

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

Definition at line 23 of file InitRootHandlers.h.

Referenced by InitRootHandlers().

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

Definition at line 22 of file InitRootHandlers.h.

Referenced by InitRootHandlers().