19 #include "Cintex/Cintex.h"
26 #include "TUnixSystem.h"
28 #include "TVirtualStreamerInfo.h"
31 #include "TClassTable.h"
32 #include "Reflex/Type.h"
44 static thread_local
bool s_ignoreWarnings =
false;
46 static bool s_ignoreEverything =
false;
48 void RootErrorHandlerImpl(
int level,
char const* location,
char const*
message) {
56 if (level >= kFatal) {
57 el_severity = SeverityLevel::kFatal;
58 }
else if (level >= kSysError) {
59 el_severity = SeverityLevel::kSysError;
60 }
else if (level >=
kError) {
66 if(s_ignoreEverything) {
77 if (message != 0) el_message =
message;
88 size_t index1 = el_message.find(precursor);
89 if (index1 != std::string::npos) {
90 size_t index2 = index1 + precursor.length();
91 size_t index3 = el_message.find_first_of(
" :", index2);
92 if (index3 != std::string::npos) {
93 size_t substrlen = index3-index2;
95 el_identifier += el_message.substr(index2,substrlen);
98 index1 = el_location.find(
"::");
99 if (index1 != std::string::npos) {
100 el_identifier +=
"/";
101 el_identifier += el_location.substr(0, index1);
107 if ((el_location.find(
"TBranchElement::Fill") != std::string::npos)
108 && (el_message.find(
"fill branch") != std::string::npos)
109 && (el_message.find(
"address") != std::string::npos)
110 && (el_message.find(
"not set") != std::string::npos)) {
111 el_severity = SeverityLevel::kFatal;
114 if ((el_message.find(
"Tree branches") != std::string::npos)
115 && (el_message.find(
"different numbers of entries") != std::string::npos)) {
116 el_severity = SeverityLevel::kFatal;
122 if ((el_message.find(
"no dictionary for class") != std::string::npos) ||
123 (el_message.find(
"already in TClassTable") != std::string::npos) ||
124 (el_message.find(
"matrix not positive definite") != std::string::npos) ||
125 (el_message.find(
"not a TStreamerInfo object") != std::string::npos) ||
127 ( (el_message.find(
"Collection proxy for") !=std::string::npos &&
128 el_message.find(
"was not properly initialized!") != std::string::npos)) ||
129 (el_location.find(
"Fit") != std::string::npos) ||
130 (el_location.find(
"TDecompChol::Solve") != std::string::npos) ||
131 (el_location.find(
"THistPainter::PaintInit") != std::string::npos) ||
132 (el_location.find(
"TUnixSystem::SetDisplay") != std::string::npos) ||
133 (el_location.find(
"TGClient::GetFontByName") != std::string::npos) ||
134 (el_message.find(
"nbins is <=0 - set to nbins = 1") != std::string::npos) ||
135 (el_message.find(
"nbinsy is <=0 - set to nbinsy = 1") != std::string::npos) ||
137 (el_location.find(
"CINTTypedefBuilder::Setup")!= std::string::npos) and
138 (el_message.find(
"possible entries are in use!") != std::string::npos))) {
154 if (die && (el_location !=
std::string(
"@SUB=TUnixSystem::DispatchSignals"))) {
155 std::ostringstream sstr;
156 sstr <<
"Fatal Root Error: " << el_location <<
"\n" << el_message <<
'\n';
159 except.clearMessage();
167 if (el_severity == SeverityLevel::kFatal) {
169 }
else if (el_severity == SeverityLevel::kSysError) {
176 edm::LogInfo(
"Root_Information") << el_location << el_message ;
180 void RootErrorHandler(
int level,
bool,
char const* location,
char const* message) {
181 RootErrorHandlerImpl(level, location, message);
185 void sig_dostack_then_abort(
int sig,siginfo_t*,
void*) {
187 const char* signalname =
"unknown";
190 signalname =
"bus error";
193 signalname =
"segmentation violation";
196 signalname =
"illegal instruction";
200 edm::LogError(
"FatalSystemSignal")<<
"A fatal system signal has occurred: "<<signalname;
201 std::cerr<<
"\n\nA fatal system signal has occurred: "<<signalname<<
"\n"
202 <<
"The following is the call stack containing the origin of the signal.\n"
203 <<
"NOTE:The first few functions on the stack are artifacts of processing the signal and can be ignored\n\n";
205 gSystem->StackTrace();
206 std::cerr<<
"\nA fatal system signal has occurred: "<<signalname<<
"\n";
211 void sig_abort(
int sig, siginfo_t*,
void*) {
221 unloadSigHandler_(pset.getUntrackedParameter<bool> (
"UnloadRootSigHandler")),
222 resetErrHandler_(pset.getUntrackedParameter<bool> (
"ResetRootErrHandler")),
223 loadAllDictionaries_(pset.getUntrackedParameter<bool>(
"LoadAllDictionaries")),
224 autoLibraryLoader_(loadAllDictionaries_
or pset.getUntrackedParameter<bool> (
"AutoLibraryLoader"))
229 gSystem->ResetSignal(kSigChild);
230 gSystem->ResetSignal(kSigBus);
231 gSystem->ResetSignal(kSigSegmentationViolation);
232 gSystem->ResetSignal(kSigIllegalInstruction);
233 gSystem->ResetSignal(kSigSystem);
234 gSystem->ResetSignal(kSigPipe);
235 gSystem->ResetSignal(kSigAlarm);
236 gSystem->ResetSignal(kSigUrgent);
237 gSystem->ResetSignal(kSigFloatingException);
238 gSystem->ResetSignal(kSigWindowChanged);
242 gSystem->ResetSignal(kSigBus);
243 gSystem->ResetSignal(kSigSegmentationViolation);
244 gSystem->ResetSignal(kSigIllegalInstruction);
262 SetErrorHandler(RootErrorHandler);
274 ROOT::Cintex::Cintex::Enable();
277 TTree::SetMaxTreeSize(kMaxLong64);
278 TH1::AddDirectory(kFALSE);
279 G__SetCatchException(0);
285 if (!
TypeWithDict(
typeid(std::vector<std::vector<unsigned int> >)).hasDictionary()) {
297 TIter
iter(gROOT->GetListOfFiles());
298 TObject *
obj =
nullptr;
299 while(
nullptr != (obj =
iter.Next())) {
300 TFile*
f =
dynamic_cast<TFile*
>(
obj);
305 iter = TIter(gROOT->GetListOfFiles());
312 TThread::Initialize();
314 TObject::SetObjectStat(
false);
317 TVirtualStreamerInfo::Optimize(
false);
321 static thread_local TThread guard;
326 desc.
setComment(
"Centralized interface to ROOT.");
328 ->setComment(
"If True, signals are handled by this service, rather than by ROOT.");
330 ->setComment(
"If True, ROOT messages (e.g. errors, warnings) are handled by this service, rather than by ROOT.");
332 ->setComment(
"If True, enables automatic loading of data dictionaries.");
334 ->setComment(
"If True, loads all ROOT dictionaries.");
336 ->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.");
338 ->setComment(
"Sets ROOT's gDebug value.");
339 descriptions.
add(
"InitRootHandlers", desc);
344 s_ignoreWarnings =
false;
349 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)
virtual void willBeUsingThreads() override
static void fillDescriptions(ConfigurationDescriptions &descriptions)
void load(const std::string &iName)
static void enable()
interface for TClass generators