20 #include "Cintex/Cintex.h"
27 #include "TUnixSystem.h"
32 void RootErrorHandlerImpl(
int level,
char const* location,
char const*
message,
bool ignoreWarnings) {
40 if (level >= kFatal) {
42 }
else if (level >= kSysError) {
44 }
else if (level >=
kError) {
57 if (message != 0) el_message =
message;
68 size_t index1 = el_message.find(precursor);
69 if (index1 != std::string::npos) {
70 size_t index2 = index1 + precursor.length();
71 size_t index3 = el_message.find_first_of(
" :", index2);
72 if (index3 != std::string::npos) {
73 size_t substrlen = index3-index2;
75 el_identifier += el_message.substr(index2,substrlen);
78 index1 = el_location.find(
"::");
79 if (index1 != std::string::npos) {
81 el_identifier += el_location.substr(0, index1);
87 if ((el_location.find(
"TBranchElement::Fill") != std::string::npos)
88 && (el_message.find(
"fill branch") != std::string::npos)
89 && (el_message.find(
"address") != std::string::npos)
90 && (el_message.find(
"not set") != std::string::npos)) {
94 if ((el_message.find(
"Tree branches") != std::string::npos)
95 && (el_message.find(
"different numbers of entries") != std::string::npos)) {
102 if ((el_message.find(
"no dictionary for class") != std::string::npos) ||
103 (el_message.find(
"already in TClassTable") != std::string::npos) ||
104 (el_message.find(
"matrix not positive definite") != std::string::npos) ||
105 (el_message.find(
"not a TStreamerInfo object") != std::string::npos) ||
106 (el_location.find(
"Fit") != std::string::npos) ||
107 (el_location.find(
"TDecompChol::Solve") != std::string::npos) ||
108 (el_location.find(
"THistPainter::PaintInit") != std::string::npos) ||
109 (el_location.find(
"TUnixSystem::SetDisplay") != std::string::npos) ||
110 (el_location.find(
"TGClient::GetFontByName") != std::string::npos)) {
126 if (die && (el_location !=
std::string(
"@SUB=TUnixSystem::DispatchSignals"))) {
127 std::ostringstream sstr;
128 sstr <<
"Fatal Root Error: " << el_location <<
"\n" << el_message <<
'\n';
131 except.clearMessage();
148 edm::LogInfo(
"Root_Information") << el_location << el_message ;
152 void RootErrorHandler(
int level,
bool,
char const* location,
char const* message) {
153 RootErrorHandlerImpl(level, location, message,
false);
156 void RootErrorHandlerWithoutWarnings(
int level,
bool,
char const* location,
char const* message) {
157 RootErrorHandlerImpl(level, location, message,
true);
161 void sig_dostack_then_abort(
int sig,siginfo_t*,
void*) {
163 const char* signalname =
"unknown";
166 signalname =
"bus error";
169 signalname =
"segmentation violation";
172 signalname =
"illegal instruction";
176 edm::LogError(
"FatalSystemSignal")<<
"A fatal system signal has occurred: "<<signalname;
177 std::cerr<<
"\n\nA fatal system signal has occurred: "<<signalname<<
"\n"
178 <<
"The following is the call stack containing the origin of the signal.\n"
179 <<
"NOTE:The first few functions on the stack are artifacts of processing the signal and can be ignored\n\n";
181 gSystem->StackTrace();
182 std::cerr<<
"\nA fatal system signal has occurred: "<<signalname<<
"\n";
193 unloadSigHandler_(pset.getUntrackedParameter<bool> (
"UnloadRootSigHandler")),
194 resetErrHandler_(pset.getUntrackedParameter<bool> (
"ResetRootErrHandler")),
195 autoLibraryLoader_(pset.getUntrackedParameter<bool> (
"AutoLibraryLoader")) {
199 gSystem->ResetSignal(kSigChild);
200 gSystem->ResetSignal(kSigBus);
201 gSystem->ResetSignal(kSigSegmentationViolation);
202 gSystem->ResetSignal(kSigIllegalInstruction);
203 gSystem->ResetSignal(kSigSystem);
204 gSystem->ResetSignal(kSigPipe);
205 gSystem->ResetSignal(kSigAlarm);
206 gSystem->ResetSignal(kSigUrgent);
207 gSystem->ResetSignal(kSigFloatingException);
208 gSystem->ResetSignal(kSigWindowChanged);
212 gSystem->ResetSignal(kSigBus);
213 gSystem->ResetSignal(kSigSegmentationViolation);
214 gSystem->ResetSignal(kSigIllegalInstruction);
223 SetErrorHandler(RootErrorHandler);
232 ROOT::Cintex::Cintex::Enable();
235 TTree::SetMaxTreeSize(kMaxLong64);
236 TH1::AddDirectory(kFALSE);
237 G__SetCatchException(0);
244 if (!
TypeWithDict(
typeid(std::vector<std::vector<unsigned int> >)).hasDictionary()) {
253 while(gROOT->GetListOfFiles()->GetSize()) {
254 TIter iter(gROOT->GetListOfFiles());
255 TFile*
f =
dynamic_cast<TFile*
>(iter.Next());
262 desc.
setComment(
"Centralized interface to ROOT.");
264 ->setComment(
"If True, signals are handled by this service, rather than by ROOT.");
266 ->setComment(
"If True, ROOT messages (e.g. errors, warnings) are handled by this service, rather than by ROOT.");
268 ->setComment(
"If True, enables automatic loading of data dictionaries.");
270 ->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.");
271 descriptions.
add(
"InitRootHandlers", desc);
276 SetErrorHandler(DefaultErrorHandler);
281 SetErrorHandler(RootErrorHandler);
286 SetErrorHandler(RootErrorHandlerWithoutWarnings);
T getUntrackedParameter(std::string const &, T const &) const
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
virtual void enableErrorHandlerWithoutWarnings_()
void setRefCoreStreamer(bool resetAll=false)
std::string const & dictionaryPlugInPrefix()
void installCustomHandler(int signum, CFUNC func)
void setComment(std::string const &value)
void addAdditionalInfo(std::string const &info)
static PluginCapabilities * get()
virtual void disableErrorHandler_()
InitRootHandlers(ParameterSet const &pset)
virtual ~InitRootHandlers()
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void setStreamedProductStreamer()
virtual void enableErrorHandler_()
static void fillDescriptions(ConfigurationDescriptions &descriptions)
void load(const std::string &iName)
static void enable()
interface for TClass generators