20 #include "Cintex/Cintex.h"
27 #include "TUnixSystem.h"
39 static thread_local
bool s_ignoreWarnings =
false;
41 void RootErrorHandlerImpl(
int level,
char const* location,
char const*
message) {
49 if (level >= kFatal) {
50 el_severity = SeverityLevel::kFatal;
51 }
else if (level >= kSysError) {
52 el_severity = SeverityLevel::kSysError;
53 }
else if (level >=
kError) {
66 if (message != 0) el_message =
message;
77 size_t index1 = el_message.find(precursor);
78 if (index1 != std::string::npos) {
79 size_t index2 = index1 + precursor.length();
80 size_t index3 = el_message.find_first_of(
" :", index2);
81 if (index3 != std::string::npos) {
82 size_t substrlen = index3-index2;
84 el_identifier += el_message.substr(index2,substrlen);
87 index1 = el_location.find(
"::");
88 if (index1 != std::string::npos) {
90 el_identifier += el_location.substr(0, index1);
96 if ((el_location.find(
"TBranchElement::Fill") != std::string::npos)
97 && (el_message.find(
"fill branch") != std::string::npos)
98 && (el_message.find(
"address") != std::string::npos)
99 && (el_message.find(
"not set") != std::string::npos)) {
100 el_severity = SeverityLevel::kFatal;
103 if ((el_message.find(
"Tree branches") != std::string::npos)
104 && (el_message.find(
"different numbers of entries") != std::string::npos)) {
105 el_severity = SeverityLevel::kFatal;
111 if ((el_message.find(
"no dictionary for class") != std::string::npos) ||
112 (el_message.find(
"already in TClassTable") != std::string::npos) ||
113 (el_message.find(
"matrix not positive definite") != std::string::npos) ||
114 (el_message.find(
"not a TStreamerInfo object") != std::string::npos) ||
115 (el_location.find(
"Fit") != std::string::npos) ||
116 (el_location.find(
"TDecompChol::Solve") != std::string::npos) ||
117 (el_location.find(
"THistPainter::PaintInit") != std::string::npos) ||
118 (el_location.find(
"TUnixSystem::SetDisplay") != std::string::npos) ||
119 (el_location.find(
"TGClient::GetFontByName") != std::string::npos)) {
135 if (die && (el_location !=
std::string(
"@SUB=TUnixSystem::DispatchSignals"))) {
136 std::ostringstream sstr;
137 sstr <<
"Fatal Root Error: " << el_location <<
"\n" << el_message <<
'\n';
140 except.clearMessage();
148 if (el_severity == SeverityLevel::kFatal) {
150 }
else if (el_severity == SeverityLevel::kSysError) {
157 edm::LogInfo(
"Root_Information") << el_location << el_message ;
161 void RootErrorHandler(
int level,
bool,
char const* location,
char const* message) {
162 RootErrorHandlerImpl(level, location, message);
166 void sig_dostack_then_abort(
int sig,siginfo_t*,
void*) {
168 const char* signalname =
"unknown";
171 signalname =
"bus error";
174 signalname =
"segmentation violation";
177 signalname =
"illegal instruction";
181 edm::LogError(
"FatalSystemSignal")<<
"A fatal system signal has occurred: "<<signalname;
182 std::cerr<<
"\n\nA fatal system signal has occurred: "<<signalname<<
"\n"
183 <<
"The following is the call stack containing the origin of the signal.\n"
184 <<
"NOTE:The first few functions on the stack are artifacts of processing the signal and can be ignored\n\n";
186 gSystem->StackTrace();
187 std::cerr<<
"\nA fatal system signal has occurred: "<<signalname<<
"\n";
198 unloadSigHandler_(pset.getUntrackedParameter<bool> (
"UnloadRootSigHandler")),
199 resetErrHandler_(pset.getUntrackedParameter<bool> (
"ResetRootErrHandler")),
200 autoLibraryLoader_(pset.getUntrackedParameter<bool> (
"AutoLibraryLoader")) {
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);
217 gSystem->ResetSignal(kSigBus);
218 gSystem->ResetSignal(kSigSegmentationViolation);
219 gSystem->ResetSignal(kSigIllegalInstruction);
228 SetErrorHandler(RootErrorHandler);
237 ROOT::Cintex::Cintex::Enable();
240 TTree::SetMaxTreeSize(kMaxLong64);
241 TH1::AddDirectory(kFALSE);
242 G__SetCatchException(0);
249 if (!
TypeWithDict(
typeid(std::vector<std::vector<unsigned int> >)).hasDictionary()) {
263 while(gROOT->GetListOfFiles()->GetSize()) {
264 TIter iter(gROOT->GetListOfFiles());
265 TFile*
f =
dynamic_cast<TFile*
>(iter.Next());
272 desc.
setComment(
"Centralized interface to ROOT.");
274 ->setComment(
"If True, signals are handled by this service, rather than by ROOT.");
276 ->setComment(
"If True, ROOT messages (e.g. errors, warnings) are handled by this service, rather than by ROOT.");
278 ->setComment(
"If True, enables automatic loading of data dictionaries.");
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.");
282 ->setComment(
"Sets ROOT's gDebug value.");
283 descriptions.
add(
"InitRootHandlers", desc);
288 s_ignoreWarnings =
false;
293 s_ignoreWarnings =
true;
T getUntrackedParameter(std::string const &, T const &) const
virtual void enableWarnings_() override
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
void setRefCoreStreamer(bool resetAll=false)
std::string const & dictionaryPlugInPrefix()
void installCustomHandler(int signum, CFUNC func)
void setComment(std::string const &value)
virtual void ignoreWarnings_() override
void addAdditionalInfo(std::string const &info)
static PluginCapabilities * get()
InitRootHandlers(ParameterSet const &pset)
virtual ~InitRootHandlers()
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void setStreamedProductStreamer()
static void fillDescriptions(ConfigurationDescriptions &descriptions)
void load(const std::string &iName)
static void enable()
interface for TClass generators