20 #include "Cintex/Cintex.h"
27 #include "TUnixSystem.h"
29 #include "TVirtualStreamerInfo.h"
32 #include "TClassTable.h"
33 #include "Reflex/Type.h"
45 static thread_local
bool s_ignoreWarnings =
false;
47 static bool s_ignoreEverything =
false;
49 void RootErrorHandlerImpl(
int level,
char const* location,
char const*
message) {
57 if (level >= kFatal) {
58 el_severity = SeverityLevel::kFatal;
59 }
else if (level >= kSysError) {
60 el_severity = SeverityLevel::kSysError;
61 }
else if (level >=
kError) {
67 if(s_ignoreEverything) {
78 if (message != 0) el_message =
message;
89 size_t index1 = el_message.find(precursor);
90 if (index1 != std::string::npos) {
91 size_t index2 = index1 + precursor.length();
92 size_t index3 = el_message.find_first_of(
" :", index2);
93 if (index3 != std::string::npos) {
94 size_t substrlen = index3-index2;
96 el_identifier += el_message.substr(index2,substrlen);
99 index1 = el_location.find(
"::");
100 if (index1 != std::string::npos) {
101 el_identifier +=
"/";
102 el_identifier += el_location.substr(0, index1);
108 if ((el_location.find(
"TBranchElement::Fill") != std::string::npos)
109 && (el_message.find(
"fill branch") != std::string::npos)
110 && (el_message.find(
"address") != std::string::npos)
111 && (el_message.find(
"not set") != std::string::npos)) {
112 el_severity = SeverityLevel::kFatal;
115 if ((el_message.find(
"Tree branches") != std::string::npos)
116 && (el_message.find(
"different numbers of entries") != std::string::npos)) {
117 el_severity = SeverityLevel::kFatal;
123 if ((el_message.find(
"no dictionary for class") != std::string::npos) ||
124 (el_message.find(
"already in TClassTable") != std::string::npos) ||
125 (el_message.find(
"matrix not positive definite") != std::string::npos) ||
126 (el_message.find(
"not a TStreamerInfo object") != std::string::npos) ||
127 (el_location.find(
"Fit") != std::string::npos) ||
128 (el_location.find(
"TDecompChol::Solve") != std::string::npos) ||
129 (el_location.find(
"THistPainter::PaintInit") != std::string::npos) ||
130 (el_location.find(
"TUnixSystem::SetDisplay") != std::string::npos) ||
131 (el_location.find(
"TGClient::GetFontByName") != std::string::npos) ||
132 (el_message.find(
"nbins is <=0 - set to nbins = 1") != std::string::npos) ||
133 (el_message.find(
"nbinsy is <=0 - set to nbinsy = 1") != std::string::npos) ||
135 (el_location.find(
"CINTTypedefBuilder::Setup")!= std::string::npos) and
136 (el_message.find(
"possible entries are in use!") != std::string::npos))) {
152 if (die && (el_location !=
std::string(
"@SUB=TUnixSystem::DispatchSignals"))) {
153 std::ostringstream sstr;
154 sstr <<
"Fatal Root Error: " << el_location <<
"\n" << el_message <<
'\n';
157 except.clearMessage();
165 if (el_severity == SeverityLevel::kFatal) {
167 }
else if (el_severity == SeverityLevel::kSysError) {
174 edm::LogInfo(
"Root_Information") << el_location << el_message ;
178 void RootErrorHandler(
int level,
bool,
char const* location,
char const* message) {
179 RootErrorHandlerImpl(level, location, message);
183 void sig_dostack_then_abort(
int sig,siginfo_t*,
void*) {
185 const char* signalname =
"unknown";
188 signalname =
"bus error";
191 signalname =
"segmentation violation";
194 signalname =
"illegal instruction";
198 edm::LogError(
"FatalSystemSignal")<<
"A fatal system signal has occurred: "<<signalname;
199 std::cerr<<
"\n\nA fatal system signal has occurred: "<<signalname<<
"\n"
200 <<
"The following is the call stack containing the origin of the signal.\n"
201 <<
"NOTE:The first few functions on the stack are artifacts of processing the signal and can be ignored\n\n";
203 gSystem->StackTrace();
204 std::cerr<<
"\nA fatal system signal has occurred: "<<signalname<<
"\n";
209 void sig_abort(
int sig, siginfo_t*,
void*) {
219 unloadSigHandler_(pset.getUntrackedParameter<bool> (
"UnloadRootSigHandler")),
220 resetErrHandler_(pset.getUntrackedParameter<bool> (
"ResetRootErrHandler")),
221 loadAllDictionaries_(pset.getUntrackedParameter<bool>(
"LoadAllDictionaries")),
222 autoLibraryLoader_(loadAllDictionaries_
or pset.getUntrackedParameter<bool> (
"AutoLibraryLoader"))
227 gSystem->ResetSignal(kSigChild);
228 gSystem->ResetSignal(kSigBus);
229 gSystem->ResetSignal(kSigSegmentationViolation);
230 gSystem->ResetSignal(kSigIllegalInstruction);
231 gSystem->ResetSignal(kSigSystem);
232 gSystem->ResetSignal(kSigPipe);
233 gSystem->ResetSignal(kSigAlarm);
234 gSystem->ResetSignal(kSigUrgent);
235 gSystem->ResetSignal(kSigFloatingException);
236 gSystem->ResetSignal(kSigWindowChanged);
240 gSystem->ResetSignal(kSigBus);
241 gSystem->ResetSignal(kSigSegmentationViolation);
242 gSystem->ResetSignal(kSigIllegalInstruction);
260 SetErrorHandler(RootErrorHandler);
272 ROOT::Cintex::Cintex::Enable();
275 TTree::SetMaxTreeSize(kMaxLong64);
276 TH1::AddDirectory(kFALSE);
277 G__SetCatchException(0);
284 if (!
TypeWithDict(
typeid(std::vector<std::vector<unsigned int> >)).hasDictionary()) {
298 while(gROOT->GetListOfFiles()->GetSize()) {
299 TIter
iter(gROOT->GetListOfFiles());
300 TFile*
f =
dynamic_cast<TFile*
>(
iter.Next());
307 TThread::Initialize();
309 TObject::SetObjectStat(
false);
312 TVirtualStreamerInfo::Optimize(
false);
316 static thread_local TThread guard;
321 desc.
setComment(
"Centralized interface to ROOT.");
323 ->setComment(
"If True, signals are handled by this service, rather than by ROOT.");
325 ->setComment(
"If True, ROOT messages (e.g. errors, warnings) are handled by this service, rather than by ROOT.");
327 ->setComment(
"If True, enables automatic loading of data dictionaries.");
329 ->setComment(
"If True, loads all ROOT dictionaries.");
331 ->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.");
333 ->setComment(
"Sets ROOT's gDebug value.");
334 descriptions.
add(
"InitRootHandlers", desc);
339 s_ignoreWarnings =
false;
344 s_ignoreWarnings =
true;
T getUntrackedParameter(std::string const &, T const &) const
bool loadAllDictionaries_
virtual void enableWarnings_() override
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
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
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_
void setComment(std::string const &value)
std::shared_ptr< const void > sigIllHandler_
virtual void initializeThisThreadForUse() override
virtual void ignoreWarnings_() override
void addAdditionalInfo(std::string const &info)
static PluginCapabilities * get()
InitRootHandlers(ParameterSet const &pset)
virtual ~InitRootHandlers()
static void loadAll()
load all known libraries holding dictionaries
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void setStreamedProductStreamer()
virtual void willBeUsingThreads() override
static void fillDescriptions(ConfigurationDescriptions &descriptions)
void load(const std::string &iName)
static void enable()
interface for TClass generators