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
void disableErrorHandler ()
 
void enableErrorHandler ()
 
void enableErrorHandlerWithoutWarnings ()
 
 RootHandlers ()
 
virtual ~RootHandlers ()
 

Static Public Member Functions

static void fillDescriptions (ConfigurationDescriptions &descriptions)
 

Private Member Functions

virtual void disableErrorHandler_ ()
 
virtual void enableErrorHandler_ ()
 
virtual void enableErrorHandlerWithoutWarnings_ ()
 

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

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

188  : RootHandlers(),
189  unloadSigHandler_(pset.getUntrackedParameter<bool> ("UnloadRootSigHandler")),
190  resetErrHandler_(pset.getUntrackedParameter<bool> ("ResetRootErrHandler")),
191  autoLibraryLoader_(pset.getUntrackedParameter<bool> ("AutoLibraryLoader")) {
192 
193  if(unloadSigHandler_) {
194  // Deactivate all the Root signal handlers and restore the system defaults
195  gSystem->ResetSignal(kSigChild);
196  gSystem->ResetSignal(kSigBus);
197  gSystem->ResetSignal(kSigSegmentationViolation);
198  gSystem->ResetSignal(kSigIllegalInstruction);
199  gSystem->ResetSignal(kSigSystem);
200  gSystem->ResetSignal(kSigPipe);
201  gSystem->ResetSignal(kSigAlarm);
202  gSystem->ResetSignal(kSigUrgent);
203  gSystem->ResetSignal(kSigFloatingException);
204  gSystem->ResetSignal(kSigWindowChanged);
205  } else if(pset.getUntrackedParameter<bool>("AbortOnSignal")){
206  //NOTE: ROOT can also be told to abort on these kinds of problems BUT
207  // it requires an TApplication to be instantiated which causes problems
208  gSystem->ResetSignal(kSigBus);
209  gSystem->ResetSignal(kSigSegmentationViolation);
210  gSystem->ResetSignal(kSigIllegalInstruction);
211  installCustomHandler(SIGBUS,sig_dostack_then_abort);
212  installCustomHandler(SIGSEGV,sig_dostack_then_abort);
213  installCustomHandler(SIGILL,sig_dostack_then_abort);
214  }
215 
216  if(resetErrHandler_) {
217 
218  // Replace the Root error handler with one that uses the MessageLogger
219  SetErrorHandler(RootErrorHandler);
220  }
221 
222  // Enable automatic Root library loading.
223  if(autoLibraryLoader_) {
225  }
226 
227  // Enable Cintex.
228  ROOT::Cintex::Cintex::Enable();
229 
230  // Set ROOT parameters.
231  TTree::SetMaxTreeSize(kMaxLong64);
232  TH1::AddDirectory(kFALSE);
233  G__SetCatchException(0);
234 
235  // Set custom streamers
238 
239  // Load the library containing dictionaries for std:: classes (e.g. std::vector<int>)
240  if (ROOT::Reflex::Type()== Reflex::Type::ByName("std::vector<std::vector<unsigned int> >")) {
241  edmplugin::PluginCapabilities::get()->load("LCGReflex/std::vector<std::vector<unsigned int> >");
242  }
243  }
void setRefCoreStreamer(bool resetAll=false)
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 245 of file InitRootHandlers.cc.

References f.

245  {
246  // close all open ROOT files
247  // We get a new iterator each time,
248  // because closing a file can invalidate the iterator
249  while(gROOT->GetListOfFiles()->GetSize()) {
250  TIter iter(gROOT->GetListOfFiles());
251  TFile* f = dynamic_cast<TFile*>(iter.Next());
252  if(f) f->Close();
253  }
254  }
double f[11][100]

Member Function Documentation

void edm::service::InitRootHandlers::disableErrorHandler_ ( )
privatevirtual

Implements edm::RootHandlers.

Definition at line 271 of file InitRootHandlers.cc.

271  {
272  SetErrorHandler(DefaultErrorHandler);
273  }
void edm::service::InitRootHandlers::enableErrorHandler_ ( )
privatevirtual

Implements edm::RootHandlers.

Definition at line 276 of file InitRootHandlers.cc.

276  {
277  SetErrorHandler(RootErrorHandler);
278  }
void edm::service::InitRootHandlers::enableErrorHandlerWithoutWarnings_ ( )
privatevirtual

Implements edm::RootHandlers.

Definition at line 281 of file InitRootHandlers.cc.

281  {
282  SetErrorHandler(RootErrorHandlerWithoutWarnings);
283  }
void edm::service::InitRootHandlers::fillDescriptions ( ConfigurationDescriptions descriptions)
static

Definition at line 256 of file InitRootHandlers.cc.

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

256  {
258  desc.setComment("Centralized interface to ROOT.");
259  desc.addUntracked<bool>("UnloadRootSigHandler", false)
260  ->setComment("If True, signals are handled by this service, rather than by ROOT.");
261  desc.addUntracked<bool>("ResetRootErrHandler", true)
262  ->setComment("If True, ROOT messages (e.g. errors, warnings) are handled by this service, rather than by ROOT.");
263  desc.addUntracked<bool>("AutoLibraryLoader", true)
264  ->setComment("If True, enables automatic loading of data dictionaries.");
265  desc.addUntracked<bool>("AbortOnSignal",true)
266  ->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.");
267  descriptions.add("InitRootHandlers", desc);
268  }

Member Data Documentation

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

Definition at line 25 of file InitRootHandlers.h.

Referenced by InitRootHandlers().

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

Definition at line 24 of file InitRootHandlers.h.

Referenced by InitRootHandlers().

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

Definition at line 23 of file InitRootHandlers.h.

Referenced by InitRootHandlers().