ROOT crash introduces me this website. I sincerely appreciate your assistance for this crash

Hello, I am a newbie to this intelligent website, where I have been introduced here after so many times of CRASH of my python code.
I would be sincerely glad if you could help me with this question.

In my cluster,
smearSpectra.py exists under
$HOME/CI8TeV/work

In the python file, if I describe the only relevant part of the code

from ROOT import TColor, TCanvns, gSystem, gPad, TH1D, TFile, kFALSE, kTRUE
def makePlot(hname, spectrum, pt, COLOR=kBlue):
code involving root functions such as
h.GetXaxis, GetYaxis, SetBinError, SetBinContent
def main():
h = makePlot(hname, sspectrum, pT, kBlue)

For my .sh shell, I get ROOT environment with commands at $HOME

ls /cvmfs/cms.cern.ch/
source /cvmfs/cms.cern.ch/cmsset_default.sh
cd ~/cmssw/CMSSW/src
cmsenv

with ROOT source environment path as
/cvmfs/cms.cern.ch/slc6_amd64_gcc630

  1. List item

Now, I am ready to describe my error messsages,

When I execute

python smearSpectra py sys.argv[1]

I obtain error message

Traceback (most recent call last):
File “smearSpectra.py”, line 64, in
def makePlot(hname, spectrum, pt, COLOR = kBlue):
NameError: name ‘kBlue’ is not defined

After replacing the the 4th argument as COLOR from kBlue and exterminating the initial condition, I executed the same command

Then, I obtain a lengthy error message,

The lines below might hint at the cause of the crash.
You may get help by asking at the ROOT forum rootcernch/forum.
Only if you are really convinced it is a bug in ROOT then please submit a
report at rootcernchbugs. Please post the ENTIRE stack trace
from above as an attachment in addition to anything else
that might help us fixing this issue.

#6 0x00007ff672579c2c in TProtoClass::FillTClass(TClass*) () from /cvmfs/cms.cern.ch/slc6_amd64_gcc630/cms/cmssw/CMSSW_9_3_3/external/slc6_amd64_gcc630/lib/libCore.so
#7 0x00007ff6725587d8 in TClass::Init(char const*, short, std::type_info const*, TVirtualIsAProxy*, char const*, char const*, int, int, ClassInfo_t*, bool) () from /cvmfs/cms.cern.ch/slc6_amd64_gcc630/cms/cmssw/CMSSW_9_3_3/external/slc6_amd64_gcc630/lib/libCore.so
#8 0x00007ff672561a93 in TClass::TClass(char const*, short, std::type_info const&, TVirtualIsAProxy*, char const*, char const*, int, int, bool) () from /cvmfs/cms.cern.ch/slc6_amd64_gcc630/cms/cmssw/CMSSW_9_3_3/external/slc6_amd64_gcc630/lib/libCore.so
#9 0x00007ff67256204b in ROOT::CreateClass(char const*, short, std::type_info const&, TVirtualIsAProxy*, char const*, char const*, int, int) () from /cvmfs/cms.cern.ch/slc6_amd64_gcc630/cms/cmssw/CMSSW_9_3_3/external/slc6_amd64_gcc630/lib/libCore.so
#10 0x00007ff67256e7cd in ROOT::TGenericClassInfo::GetClass() () from /cvmfs/cms.cern.ch/slc6_amd64_gcc630/cms/cmssw/CMSSW_9_3_3/external/slc6_amd64_gcc630/lib/libCore.so
#11 0x00007ff672559c72 in TClass::GetClass(char const*, bool, bool) () from /cvmfs/cms.cern.ch/slc6_amd64_gcc630/cms/cmssw/CMSSW_9_3_3/external/slc6_amd64_gcc630/lib/libCore.so
#12 0x00007ff672e2ebe2 in Cppyy::GetScope(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&) () from /cvmfs/cms.cern.ch/slc6_amd64_gcc630/lcg/root/6.10.04-ghjeda/lib/libPyROOT.so
#13 0x00007ff672e4af29 in PyROOT::CreateScopeProxy(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, _object*) () from /cvmfs/cms.cern.ch/slc6_amd64_gcc630/lcg/root/6.10.04-ghjeda/lib/libPyROOT.so
#14 0x00007ff672e49d4f in (anonymous namespace)::LookupCppEntity(_object*, _object*) () from /cvmfs/cms.cern.ch/slc6_amd64_gcc630/lcg/root/6.10.04-ghjeda/lib/libPyROOT.so
#15 0x00007ff6732d5b96 in call_function (oparg=, pp_stack=0x7fff830f3c40) at Python/ceval.c:4350
#16 PyEval_EvalFrameEx (f=f
entry=0x3db3520, throwflag=throwflag
entry=0) at Python/ceval.c:2987
#17 0x00007ff6732d69bc in PyEval_EvalCodeEx (co=, globals=, locals=locals
entry=0x0, args=args
entry=0x7ff6675d7cc8, argcount=2, kws=kws
entry=0x0, kwcount=0, defs=0x0, defcount=0, closure=0x0) at Python/ceval.c:3582
#18 0x00007ff67324d2fc in function_call (func=0x7ff66748b410, arg=0x7ff6675d7cb0, kw=0x0) at Objects/funcobject.c:526
#19 0x00007ff67321c953 in PyObject_Call (func=func
entry=0x7ff66748b410, arg=arg
entry=0x7ff6675d7cb0, kw=kw
entry=0x0) at Objects/abstract.c:2546
#20 0x00007ff67322db8c in instancemethod_call (func=0x7ff66748b410, arg=0x7ff6675d7cb0, kw=0x0) at Objects/classobject.c:2602
#21 0x00007ff67321c953 in PyObject_Call (func=func
entry=0x7ff673164c80, arg=arg
entry=0x7ff666177690, kw=kw
entry=0x0) at Objects/abstract.c:2546
#22 0x00007ff67321d547 in PyObject_CallFunctionObjArgs (callable=callable
entry=0x7ff673164c80) at Objects/abstract.c:2773
#23 0x00007ff67328bc38 in call_attribute (name=0x7ff6730405f0, attr=0x7ff673164c80, self=0x7ff667491a90) at Objects/typeobject.c:5497
#24 slot_tp_getattr_hook (self=0x7ff667491a90, name=0x7ff6730405f0) at Objects/typeobject.c:5551
#25 0x00007ff6732cf3ef in import_from (name=, v=) at Python/ceval.c:4867
#26 PyEval_EvalFrameEx (f=f
entry=0x42a47f0, throwflag=throwflag
entry=0) at Python/ceval.c:2654
#27 0x00007ff6732d3c72 in fast_function (nk=0, na=, n=, pp_stack=0x7fff830f43f0, func=) at Python/ceval.c:4436
#28 call_function (oparg=, pp_stack=0x7fff830f43f0) at Python/ceval.c:4371
#29 PyEval_EvalFrameEx (f=f
entry=0x7ff67308eb00, throwflag=throwflag
entry=0) at Python/ceval.c:2987
#30 0x00007ff6732d69bc in PyEval_EvalCodeEx (co=co
entry=0x7ff67303e6b0, globals=globals
entry=0x7ff673140168, locals=locals
entry=0x7ff673140168, args=args
entry=0x0, argcount=argcount
entry=0, kws=kws
entry=0x0, kwcount=0, defs=0x0, defcount=0, closure=0x0) at Python/ceval.c:3582
#31 0x00007ff6732d6ab9 in PyEval_EvalCode (co=co
entry=0x7ff67303e6b0, globals=globals
entry=0x7ff673140168, locals=locals
entry=0x7ff673140168) at Python/ceval.c:669
#32 0x00007ff6732fb90a in run_mod (arena=0x20df7c0, flags=0x7fff830f4650, locals=0x7ff673140168, globals=0x7ff673140168, filename=0x20b73e0 “”, mod=) at Python/pythonrun.c:1370
#33 PyRun_FileExFlags (fp=fp
entry=0x20b73e0, filename=filename
entry=0x7fff830f614e “smearSpectra py”, start=start
entry=257, globals=globals
entry=0x7ff673140168, locals=locals
entry=0x7ff673140168, closeit=closeit
entry=1, flags=0x7fff830f4650) at Python/pythonrun.c:1356
#34 0x00007ff6732fcce5 in PyRun_SimpleFileExFlags (fp=fp
entry=0x20b73e0, filename=0x7fff830f614e “smearSpectra py”, closeit=closeit
entry=1, flags=flags
entry=0x7fff830f4650) at Python/pythonrun.c:948
#35 0x00007ff6732fd3a3 in PyRun_AnyFileExFlags (fp=fp
entry=0x20b73e0, filename=, closeit=closeit
entry=1, flags=flags
entry=0x7fff830f4650) at Python/pythonrun.c:752
#36 0x00007ff673313201 in Py_Main (argc=, argv=) at Modules/main.c:640
#37 0x000000363a01ed1d in __libc_start_main () from /lib64/libc.so.6
#38 0x0000000000400651 in _start ()

I tried to fathom through this lengthy one, but the attempt was futile for a newbie.

I would sincerely appreciate if you could help me with the problem and possibly come up with a solution.

Thank you so much.

p.s. Please note I had to notate smearSpectra python file as “smearSpectra py” (without dot) due to my newbie limit on number of links that could be used in topic.

Try COLOR = ROOT.kBlue and

def main():
   h = makePlot(hname, sspectrum, pT, ROOT.kBlue)

Regarding the backtrace (the lengthy error message): I’d expect an earlier error message / output in this case. Can you send the code / input that reproduces this crash?

Cheers, Axel.

Thank you for your response.

I tried your suggestion, and it gave me the similar lengthy error message.
This time, I posted the entire error message

<=== smearSpectra.py ===>

TClassTable::Add:0: RuntimeWarning: class JetCorrectorParameters already in TClassTable
TClassTable::Add:0: RuntimeWarning: class JetCorrectionUncertainty already in TClassTable
TClassTable::Add:0: RuntimeWarning: class SimpleJetCorrectionUncertainty already in TClassTable

*** Break *** segmentation violation

===========================================================
There was a crash.
This is the entire stack trace of all threads:

Thread 2 (Thread 0x7f8381c46700 (LWP 24955)):
#0 0x000000363a80da00 in sem_wait () from /lib64/libpthread.so.0
#1 0x00007f838dcee118 in PyThread_acquire_lock (lock=lock
entry=0x15e4710, waitflag=waitflag
entry=1) at Python/thread_pthread.h:324
#2 0x00007f838dcaaf26 in PyEval_RestoreThread (tstate=tstate
entry=0x3442950) at Python/ceval.c:359
#3 0x00007f8381f740d8 in floatsleep (secs=) at /build/cmsbld/auto-builds/CMSSW_9_1_0_pre3-slc6_amd64_gcc630/build/CMSSW_9_1_0_pre3-build/BUILD/slc6_amd64_gcc630/external/python/2.7.11-mlhled2/python-2.7.11/Modules/timemodule.c:959
#4 time_sleep (self=, args=) at /build/cmsbld/auto-builds/CMSSW_9_1_0_pre3-slc6_amd64_gcc630/build/CMSSW_9_1_0_pre3-build/BUILD/slc6_amd64_gcc630/external/python/2.7.11-mlhled2/python-2.7.11/Modules/timemodule.c:206
#5 0x00007f838dcb4b96 in call_function (oparg=, pp_stack=0x7f8381c454d0) at Python/ceval.c:4350
#6 PyEval_EvalFrameEx (f=f
entry=0x7f8381e955f0, throwflag=throwflag
entry=0) at Python/ceval.c:2987
#7 0x00007f838dcb59bc in PyEval_EvalCodeEx (co=, globals=, locals=locals
entry=0x0, args=args
entry=0x7f8381e8b7e8, argcount=1, kws=kws
entry=0x7f838db48068, kwcount=0, defs=0x0, defcount=0, closure=0x0) at Python/ceval.c:3582
#8 0x00007f838dc2c3cd in function_call (func=0x7f8381e6a140, arg=0x7f8381e8b7d0, kw=0x7f8381fbdc58) at Objects/funcobject.c:526
#9 0x00007f838dbfb953 in PyObject_Call (func=func
entry=0x7f8381e6a140, arg=arg
entry=0x7f8381e8b7d0, kw=kw
entry=0x7f8381fbdc58) at Objects/abstract.c:2546
#10 0x00007f838dcaff4c in ext_do_call (nk=, na=0, flags=, pp_stack=0x7f8381c45778, func=0x7f8381e6a140) at Python/ceval.c:4663
#11 PyEval_EvalFrameEx (f=f
entry=0x7f8381e6dcc8, throwflag=throwflag
entry=0) at Python/ceval.c:3026
#12 0x00007f838dcb2c72 in fast_function (nk=0, na=, n=, pp_stack=0x7f8381c458b0, func=) at Python/ceval.c:4436
#13 call_function (oparg=, pp_stack=0x7f8381c458b0) at Python/ceval.c:4371
#14 PyEval_EvalFrameEx (f=f
entry=0x7f837c000910, throwflag=throwflag
entry=0) at Python/ceval.c:2987
#15 0x00007f838dcb2c72 in fast_function (nk=0, na=, n=, pp_stack=0x7f8381c459f0, func=) at Python/ceval.c:4436
#16 call_function (oparg=, pp_stack=0x7f8381c459f0) at Python/ceval.c:4371
#17 PyEval_EvalFrameEx (f=f
entry=0x7f8381e97590, throwflag=throwflag
entry=0) at Python/ceval.c:2987
#18 0x00007f838dcb59bc in PyEval_EvalCodeEx (co=, globals=, locals=locals
entry=0x0, args=args
entry=0x7f8381e8b7a8, argcount=1, kws=kws
entry=0x0, kwcount=0, defs=0x0, defcount=0, closure=0x0) at Python/ceval.c:3582
#19 0x00007f838dc2c2fc in function_call (func=0x7f8381e8ec08, arg=0x7f8381e8b790, kw=0x0) at Objects/funcobject.c:526
#20 0x00007f838dbfb953 in PyObject_Call (func=func
entry=0x7f8381e8ec08, arg=arg
entry=0x7f8381e8b790, kw=kw
entry=0x0) at Objects/abstract.c:2546
#21 0x00007f838dc0cb8c in instancemethod_call (func=0x7f8381e8ec08, arg=0x7f8381e8b790, kw=0x0) at Objects/classobject.c:2602
#22 0x00007f838dbfb953 in PyObject_Call (func=func
entry=0x7f838da53d20, arg=arg
entry=0x7f838db48050, kw=) at Objects/abstract.c:2546
#23 0x00007f838dcab607 in PyEval_CallObjectWithKeywords (func=0x7f838da53d20, arg=0x7f838db48050, kw=) at Python/ceval.c:4219
#24 0x00007f838dcf4032 in t_bootstrap (boot_raw=0x346d2b0) at ./Modules/threadmodule.c:620
#25 0x000000363a807aa1 in start_thread () from /lib64/libpthread.so.0
#26 0x000000363a0e8bcd in clone () from /lib64/libc.so.6

Thread 1 (Thread 0x7f838db89700 (LWP 24931)):
#0 0x000000363a0ac86d in waitpid () from /lib64/libc.so.6
#1 0x000000363a03e479 in do_system () from /lib64/libc.so.6
#2 0x000000363a03e7b0 in system () from /lib64/libc.so.6
#3 0x00007f838cf81d68 in TUnixSystem::StackTrace() () from /cvmfs/cms.cern.ch/slc6_amd64_gcc630/cms/cmssw/CMSSW_9_3_3/external/slc6_amd64_gcc630/lib/libCore.so
#4 0x00007f838cf8421c in TUnixSystem::DispatchSignals(ESignals) () from /cvmfs/cms.cern.ch/slc6_amd64_gcc630/cms/cmssw/CMSSW_9_3_3/external/slc6_amd64_gcc630/lib/libCore.so
#5
#6 0x00007f838cf58c2c in TProtoClass::FillTClass(TClass*) () from /cvmfs/cms.cern.ch/slc6_amd64_gcc630/cms/cmssw/CMSSW_9_3_3/external/slc6_amd64_gcc630/lib/libCore.so
#7 0x00007f838cf377d8 in TClass::Init(char const*, short, std::type_info const*, TVirtualIsAProxy*, char const*, char const*, int, int, ClassInfo_t*, bool) () from /cvmfs/cms.cern.ch/slc6_amd64_gcc630/cms/cmssw/CMSSW_9_3_3/external/slc6_amd64_gcc630/lib/libCore.so
#8 0x00007f838cf40a93 in TClass::TClass(char const*, short, std::type_info const&, TVirtualIsAProxy*, char const*, char const*, int, int, bool) () from /cvmfs/cms.cern.ch/slc6_amd64_gcc630/cms/cmssw/CMSSW_9_3_3/external/slc6_amd64_gcc630/lib/libCore.so
#9 0x00007f838cf4104b in ROOT::CreateClass(char const*, short, std::type_info const&, TVirtualIsAProxy*, char const*, char const*, int, int) () from /cvmfs/cms.cern.ch/slc6_amd64_gcc630/cms/cmssw/CMSSW_9_3_3/external/slc6_amd64_gcc630/lib/libCore.so
#10 0x00007f838cf4d7cd in ROOT::TGenericClassInfo::GetClass() () from /cvmfs/cms.cern.ch/slc6_amd64_gcc630/cms/cmssw/CMSSW_9_3_3/external/slc6_amd64_gcc630/lib/libCore.so
#11 0x00007f838cf38c72 in TClass::GetClass(char const*, bool, bool) () from /cvmfs/cms.cern.ch/slc6_amd64_gcc630/cms/cmssw/CMSSW_9_3_3/external/slc6_amd64_gcc630/lib/libCore.so
#12 0x00007f838d80dbe2 in Cppyy::GetScope(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&) () from /cvmfs/cms.cern.ch/slc6_amd64_gcc630/lcg/root/6.10.04-ghjeda/lib/libPyROOT.so
#13 0x00007f838d829f29 in PyROOT::CreateScopeProxy(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, _object*) () from /cvmfs/cms.cern.ch/slc6_amd64_gcc630/lcg/root/6.10.04-ghjeda/lib/libPyROOT.so
#14 0x00007f838d828d4f in (anonymous namespace)::LookupCppEntity(_object*, _object*) () from /cvmfs/cms.cern.ch/slc6_amd64_gcc630/lcg/root/6.10.04-ghjeda/lib/libPyROOT.so
#15 0x00007f838dcb4b96 in call_function (oparg=, pp_stack=0x7ffcc2a7f550) at Python/ceval.c:4350
#16 PyEval_EvalFrameEx (f=f
entry=0x31b6e00, throwflag=throwflag
entry=0) at Python/ceval.c:2987
#17 0x00007f838dcb59bc in PyEval_EvalCodeEx (co=, globals=, locals=locals
entry=0x0, args=args
entry=0x7f8381fb6068, argcount=2, kws=kws
entry=0x0, kwcount=0, defs=0x0, defcount=0, closure=0x0) at Python/ceval.c:3582
#18 0x00007f838dc2c2fc in function_call (func=0x7f8381e6a410, arg=0x7f8381fb6050, kw=0x0) at Objects/funcobject.c:526
#19 0x00007f838dbfb953 in PyObject_Call (func=func
entry=0x7f8381e6a410, arg=arg
entry=0x7f8381fb6050, kw=kw
entry=0x0) at Objects/abstract.c:2546
#20 0x00007f838dc0cb8c in instancemethod_call (func=0x7f8381e6a410, arg=0x7f8381fb6050, kw=0x0) at Objects/classobject.c:2602
#21 0x00007f838dbfb953 in PyObject_Call (func=func
entry=0x7f838db43c80, arg=arg
entry=0x7f8380b566d0, kw=kw
entry=0x0) at Objects/abstract.c:2546
#22 0x00007f838dbfc547 in PyObject_CallFunctionObjArgs (callable=callable
entry=0x7f838db43c80) at Objects/abstract.c:2773
#23 0x00007f838dc6ac38 in call_attribute (name=0x7f838da1f5f0, attr=0x7f838db43c80, self=0x7f8381e70a90) at Objects/typeobject.c:5497
#24 slot_tp_getattr_hook (self=0x7f8381e70a90, name=0x7f838da1f5f0) at Objects/typeobject.c:5551
#25 0x00007f838dcae3ef in import_from (name=, v=) at Python/ceval.c:4867
#26 PyEval_EvalFrameEx (f=f
entry=0x3699840, throwflag=throwflag
entry=0) at Python/ceval.c:2654
#27 0x00007f838dcb2c72 in fast_function (nk=0, na=, n=, pp_stack=0x7ffcc2a7fd00, func=) at Python/ceval.c:4436
#28 call_function (oparg=, pp_stack=0x7ffcc2a7fd00) at Python/ceval.c:4371
#29 PyEval_EvalFrameEx (f=f
entry=0x7f838da6db00, throwflag=throwflag
entry=0) at Python/ceval.c:2987
#30 0x00007f838dcb59bc in PyEval_EvalCodeEx (co=co
entry=0x7f838da1d6b0, globals=globals
entry=0x7f838db1f168, locals=locals
entry=0x7f838db1f168, args=args
entry=0x0, argcount=argcount
entry=0, kws=kws
entry=0x0, kwcount=0, defs=0x0, defcount=0, closure=0x0) at Python/ceval.c:3582
#31 0x00007f838dcb5ab9 in PyEval_EvalCode (co=co
entry=0x7f838da1d6b0, globals=globals
entry=0x7f838db1f168, locals=locals
entry=0x7f838db1f168) at Python/ceval.c:669
#32 0x00007f838dcda90a in run_mod (arena=0x14d47c0, flags=0x7ffcc2a7ff60, locals=0x7f838db1f168, globals=0x7f838db1f168, filename=0x14ac3e0 “”, mod=) at Python/pythonrun.c:1370
#33 PyRun_FileExFlags (fp=fp
entry=0x14ac3e0, filename=filename
entry=0x7ffcc2a8214e “smearSpectra. py”, start=start
entry=257, globals=globals
entry=0x7f838db1f168, locals=locals
entry=0x7f838db1f168, closeit=closeit
entry=1, flags=0x7ffcc2a7ff60) at Python/pythonrun.c:1356
#34 0x00007f838dcdbce5 in PyRun_SimpleFileExFlags (fp=fp
entry=0x14ac3e0, filename=0x7ffcc2a8214e “smearSpectra. py”, closeit=closeit
entry=1, flags=flags
entry=0x7ffcc2a7ff60) at Python/pythonrun.c:948
#35 0x00007f838dcdc3a3 in PyRun_AnyFileExFlags (fp=fp
entry=0x14ac3e0, filename=, closeit=closeit
entry=1, flags=flags
entry=0x7ffcc2a7ff60) at Python/pythonrun.c:752
#36 0x00007f838dcf2201 in Py_Main (argc=, argv=) at Modules/main.c:640
#37 0x000000363a01ed1d in __libc_start_main () from /lib64/libc.so.6
#38 0x0000000000400651 in _start ()

The lines below might hint at the cause of the crash.
You may get help by asking at the ROOT forum http://root.cern.ch/forum.
Only if you are really convinced it is a bug in ROOT then please submit a
report at http://root.cern.ch/bugs. Please post the ENTIRE stack trace
from above as an attachment in addition to anything else
that might help us fixing this issue.

#6 0x00007f838cf58c2c in TProtoClass::FillTClass(TClass*) () from /cvmfs/cms.cern.ch/slc6_amd64_gcc630/cms/cmssw/CMSSW_9_3_3/external/slc6_amd64_gcc630/lib/libCore.so
#7 0x00007f838cf377d8 in TClass::Init(char const*, short, std::type_info const*, TVirtualIsAProxy*, char const*, char const*, int, int, ClassInfo_t*, bool) () from /cvmfs/cms.cern.ch/slc6_amd64_gcc630/cms/cmssw/CMSSW_9_3_3/external/slc6_amd64_gcc630/lib/libCore.so
#8 0x00007f838cf40a93 in TClass::TClass(char const*, short, std::type_info const&, TVirtualIsAProxy*, char const*, char const*, int, int, bool) () from /cvmfs/cms.cern.ch/slc6_amd64_gcc630/cms/cmssw/CMSSW_9_3_3/external/slc6_amd64_gcc630/lib/libCore.so
#9 0x00007f838cf4104b in ROOT::CreateClass(char const*, short, std::type_info const&, TVirtualIsAProxy*, char const*, char const*, int, int) () from /cvmfs/cms.cern.ch/slc6_amd64_gcc630/cms/cmssw/CMSSW_9_3_3/external/slc6_amd64_gcc630/lib/libCore.so
#10 0x00007f838cf4d7cd in ROOT::TGenericClassInfo::GetClass() () from /cvmfs/cms.cern.ch/slc6_amd64_gcc630/cms/cmssw/CMSSW_9_3_3/external/slc6_amd64_gcc630/lib/libCore.so
#11 0x00007f838cf38c72 in TClass::GetClass(char const*, bool, bool) () from /cvmfs/cms.cern.ch/slc6_amd64_gcc630/cms/cmssw/CMSSW_9_3_3/external/slc6_amd64_gcc630/lib/libCore.so
#12 0x00007f838d80dbe2 in Cppyy::GetScope(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&) () from /cvmfs/cms.cern.ch/slc6_amd64_gcc630/lcg/root/6.10.04-ghjeda/lib/libPyROOT.so
#13 0x00007f838d829f29 in PyROOT::CreateScopeProxy(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, _object*) () from /cvmfs/cms.cern.ch/slc6_amd64_gcc630/lcg/root/6.10.04-ghjeda/lib/libPyROOT.so
#14 0x00007f838d828d4f in (anonymous namespace)::LookupCppEntity(_object*, _object*) () from /cvmfs/cms.cern.ch/slc6_amd64_gcc630/lcg/root/6.10.04-ghjeda/lib/libPyROOT.so
#15 0x00007f838dcb4b96 in call_function (oparg=, pp_stack=0x7ffcc2a7f550) at Python/ceval.c:4350
#16 PyEval_EvalFrameEx (f=f
entry=0x31b6e00, throwflag=throwflag
entry=0) at Python/ceval.c:2987
#17 0x00007f838dcb59bc in PyEval_EvalCodeEx (co=, globals=, locals=locals
entry=0x0, args=args
entry=0x7f8381fb6068, argcount=2, kws=kws
entry=0x0, kwcount=0, defs=0x0, defcount=0, closure=0x0) at Python/ceval.c:3582
#18 0x00007f838dc2c2fc in function_call (func=0x7f8381e6a410, arg=0x7f8381fb6050, kw=0x0) at Objects/funcobject.c:526
#19 0x00007f838dbfb953 in PyObject_Call (func=func
entry=0x7f8381e6a410, arg=arg
entry=0x7f8381fb6050, kw=kw
entry=0x0) at Objects/abstract.c:2546
#20 0x00007f838dc0cb8c in instancemethod_call (func=0x7f8381e6a410, arg=0x7f8381fb6050, kw=0x0) at Objects/classobject.c:2602
#21 0x00007f838dbfb953 in PyObject_Call (func=func
entry=0x7f838db43c80, arg=arg
entry=0x7f8380b566d0, kw=kw
entry=0x0) at Objects/abstract.c:2546
#22 0x00007f838dbfc547 in PyObject_CallFunctionObjArgs (callable=callable
entry=0x7f838db43c80) at Objects/abstract.c:2773
#23 0x00007f838dc6ac38 in call_attribute (name=0x7f838da1f5f0, attr=0x7f838db43c80, self=0x7f8381e70a90) at Objects/typeobject.c:5497
#24 slot_tp_getattr_hook (self=0x7f8381e70a90, name=0x7f838da1f5f0) at Objects/typeobject.c:5551
#25 0x00007f838dcae3ef in import_from (name=, v=) at Python/ceval.c:4867
#26 PyEval_EvalFrameEx (f=f
entry=0x3699840, throwflag=throwflag
entry=0) at Python/ceval.c:2654
#27 0x00007f838dcb2c72 in fast_function (nk=0, na=, n=, pp_stack=0x7ffcc2a7fd00, func=) at Python/ceval.c:4436
#28 call_function (oparg=, pp_stack=0x7ffcc2a7fd00) at Python/ceval.c:4371
#29 PyEval_EvalFrameEx (f=f
entry=0x7f838da6db00, throwflag=throwflag
entry=0) at Python/ceval.c:2987
#30 0x00007f838dcb59bc in PyEval_EvalCodeEx (co=co
entry=0x7f838da1d6b0, globals=globals
entry=0x7f838db1f168, locals=locals
entry=0x7f838db1f168, args=args
entry=0x0, argcount=argcount
entry=0, kws=kws
entry=0x0, kwcount=0, defs=0x0, defcount=0, closure=0x0) at Python/ceval.c:3582
#31 0x00007f838dcb5ab9 in PyEval_EvalCode (co=co
entry=0x7f838da1d6b0, globals=globals
entry=0x7f838db1f168, locals=locals
entry=0x7f838db1f168) at Python/ceval.c:669
#32 0x00007f838dcda90a in run_mod (arena=0x14d47c0, flags=0x7ffcc2a7ff60, locals=0x7f838db1f168, globals=0x7f838db1f168, filename=0x14ac3e0 “”, mod=) at Python/pythonrun.c:1370
#33 PyRun_FileExFlags (fp=fp
entry=0x14ac3e0, filename=filename
entry=0x7ffcc2a8214e “smearSpectra. py”, start=start
entry=257, globals=globals
entry=0x7f838db1f168, locals=locals
entry=0x7f838db1f168, closeit=closeit
entry=1, flags=0x7ffcc2a7ff60) at Python/pythonrun.c:1356
#34 0x00007f838dcdbce5 in PyRun_SimpleFileExFlags (fp=fp
entry=0x14ac3e0, filename=0x7ffcc2a8214e “smearSpectra. py”, closeit=closeit
entry=1, flags=flags
entry=0x7ffcc2a7ff60) at Python/pythonrun.c:948
#35 0x00007f838dcdc3a3 in PyRun_AnyFileExFlags (fp=fp
entry=0x14ac3e0, filename=, closeit=closeit
entry=1, flags=flags
entry=0x7ffcc2a7ff60) at Python/pythonrun.c:752
#36 0x00007f838dcf2201 in Py_Main (argc=, argv=) at Modules/main.c:640
#37 0x000000363a01ed1d in __libc_start_main () from /lib64/libc.so.6
#38 0x0000000000400651 in _start ()

Segmentation fault

I sincerely appreciate your help! If you possibly would need more information about what I’am currently doing, please let me know.

Thank you

Hi,

I installed CMSSW 9_3_3 as you did:

source /cvmfs/cms.cern.ch/cmsset_default.sh
cmsrel CMSSW_9_3_3
cd CMSSW_9_3_3
cmsenv

I then tried some PyROOT code to produce plots and everything works fine. Can you, in this order:

  • Try my recipe above and run your code from a clean CMSSW area?
  • If the above fails, post the exact code that crashes?

Cheers,
D

1 Like

Thank you for your response.

I would like to reprise my commands to prevent my mis-communication.

I am in cms07 T3 cluster where

$HOME = /storage/5/home/trentacoollime 

In order to source and setup ROOT env, I execute at $HOME

ls /cvmfs/cms.cern.ch/
source /cvmfs/cms.cern.ch/cmsset_default.sh
cd ~/cmssw/CMSSW/src
cmsenv

It makes my $PATH to be

/cvmfs/cms.cern.ch/share/overrides/bin:/storage/5/home/trentacoollime/cmssw/CMSSW_9_3_3/bin/slc6_amd64_gcc630:/storage/5/home/trentacoollime/cmssw/CMSSW_9_3_3/external/slc6_amd64_gcc630/bin:/cvmfs/cms.cern.ch/slc6_amd64_gcc630/cms/cmssw/CMSSW_9_3_3/bin/slc6_amd64_gcc630:/cvmfs/cms.cern.ch/slc6_amd64_gcc630/cms/cmssw/CMSSW_9_3_3/external/slc6_amd64_gcc630/bin:/cvmfs/cms.cern.ch/slc6_amd64_gcc630/external/llvm/4.0.0-njopjo/bin:/cvmfs/cms.cern.ch/slc6_amd64_gcc630/external/gcc/6.3.0/bin:/cvmfs/cms.cern.ch/common:/cvmfs/cms.cern.ch/bin:/storage/5/home/trentacoollime/external/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin: No such file or directory

and $LD_LIBRARY_PATH as

/storage/5/home/trentacoollime/cmssw/CMSSW_9_3_3/biglib/slc6_amd64_gcc630:/storage/5/home/trentacoolime/cmssw/CMSSW_9_3_3/lib/slc6_amd64_gcc630:/storage/5/home/trentacoolime/cmssw/CMSSW_9_3_3/external/slc6_amd64_gcc630/lib:/cvmfs/cms.cern.ch/slc6_amd64_gcc630/cms/cmssw/CMSSW_9_3_3/biglib/slc6_amd64_gcc630:/cvmfs/cms.cern.ch/slc6_amd64_gcc630/cms/cmssw/CMSSW_9_3_3/lib/slc6_amd64_gcc630:/cvmfs/cms.cern.ch/slc6_amd64_gcc630/cms/cmssw/CMSSW_9_3_3/external/slc6_amd64_gcc630/lib:/cvmfs/cms.cern.ch/slc6_amd64_gcc630/external/llvm/4.0.0-njopjo/lib64:/cvmfs/cms.cern.ch/slc6_amd64_gcc630/external/gcc/6.3.0/lib64:/cvmfs/cms.cern.ch/slc6_amd64_gcc630/external/gcc/6.3.0/lib:/storage/5/home/suhokim/external/bin:/storage/5/home/trentacoolime/external/lib:/storage/5/home/trentacoolime/CI8TeV/CI/lib:: No such file or directory

In my $HOME/CI8TeV/work directory, I execute

python smearSpectra.py target_dir

smearSpectra code is

#!/usr/bin/env python
#-----------------------------------------------------------------------------

#-----------------------------------------------------------------------------
import os, sys, re, optparse
from math import *
from histutil import *
from string import *
from glob import glob
from array import array
from time import sleep
from ROOT import gSystem, gPad, TH1D, TFile, TCanvas, kFALSE, kTRUE
#-----------------------------------------------------------------------------
LHAPATH = os.environ['LHAPDF_DATA_PATH']
YMIN    = 1.0e-10
YMAX    = 1.0e+8
#-----------------------------------------------------------------------------
# default list of histograms to be smeared
HISTNAMES = '''
nlo_0.500_0.500
nlo_0.500_1.000
nlo_1.000_0.500
nlo_1.000_1.000
nlo_1.000_2.000
nlo_2.000_1.000
nlo_2.000_2.000
'''
HISTNAMES = split(strip(HISTNAMES))
DATAFILENAME  = '../data/data_8TeV_L19.71_V8.root'
JECUNFILENAME = '../corrections/Winter14_V5_DATA_UncertaintySources_AK7PF.txt'
EWKFILENAME   = '../corrections/ElectroWeakCorrection.root'
JECUNTOTAL    = 'TotalNoTime'
#-----------------------------------------------------------------------------
LUMI = 19710.0 # 1/pb
#-----------------------------------------------------------------------------
def decodeCommandLine():
    VERSION = '22-Nov-2014'
    USAGE = '''
    python smearSpectra.py [options] <pathname to unsmeared spectra>

    options
       -s<smearing>   jes+jer+pdf, jes+jer, or pdf [default=jes+jer+pdf]
    '''
    parser = optparse.OptionParser(usage=USAGE,
                                   version=VERSION)
    parser.add_option('-s', '--smearing',
                      action='store',
                      dest='smearing',
                      type='string',
                      default='jes+jer+pdf',
                      help='level of smearing to apply')
    options, args = parser.parse_args()
    if len(args) == 0:
        print USAGE
        sys.exit(0)
    PDFdir = args[0]
    if PDFdir[-1] == '/': PDFdir=PDFdir[:-1]
    return (upper(options.smearing), PDFdir)
#-----------------------------------------------------------------------------
def makePlot(hname, spectrum, pt, COLOR=kBlue):
    x = array('d')
    nbins = pt.size()-1
    for ii in xrange(nbins+1): x.append(pt[ii])
    h = TH1D(hname, '', nbins, x)
    h.GetXaxis().SetTitle('Jet p_{T} (GeV)')
    h.GetYaxis().SetTitle('')
    h.SetLineColor(COLOR)
    h.SetLineWidth(1)
    for ii in xrange(nbins):
        # save cross section/bin
        h.SetBinContent(ii+1, spectrum(pt[ii], pt[ii+1]))
        h.SetBinError(ii+1, 0)
    return h
#-----------------------------------------------------------------------------
def main():
    print "\n\t<=== smearSpectra.py ===>"
    
    smearingLevel, PDFdir = decodeCommandLine()
    doJESJER = find(smearingLevel, 'J') > -1
    doPDF    = find(smearingLevel, 'P') > -1

    cmd = '(?<=%s/)[0-9]+' % PDFdir
    getPDFmember = re.compile(cmd)

    gSystem.Load("libCI.so")
    from ROOT import JetCorrectorParameters
    from ROOT import JetCorrectionUncertainty
    from ROOT import JetSpectrum, JetSpectrumSmeared
    from ROOT import hutil
          
    setStyle()
    
  -
    doSmearing = True
    if   doJESJER and not doPDF:
        member   = '000'
        histnames= ['nlo_1.000_1.000']
        nsmears  = 500
        prefix   = 'JESJER'


    elif not doJESJER and doPDF:
        member   = '*'
        histnames= HISTNAMES
        nsmears  = 1
        prefix   = 'PDF'
  
    elif doJESJER and doPDF:
        member   = '*'
        histnames= HISTNAMES
        nsmears  = 1
        prefix   = 'JESJERPDF'
    else:
        member   = '*'
        histnames= HISTNAMES
        nsmears  = 1
        prefix   = 'NONE'
        doSmearing = False
        
    # ------------------------------------------------------------------------
    # get input rootfiles and construct output file names
    # ------------------------------------------------------------------------
    fdirs = glob('%s/%s' % (PDFdir, member))
    fdirs.sort()
    rootfiles= []
    for fdir in fdirs:
        rootfiles += glob('%s/*.root' % fdir)
        
    outfiles = []
    dirnames = {}
    for rootfile in rootfiles:
        t = split(rootfile, '/')
        filename = t[-1]
        dirname  = '%s/%s' % (joinfields(t[:-1], '/'), prefix)
        outfile  = '%s/%s' % (dirname, filename)
        if not os.path.exists(dirname):
            os.system('mkdir -p %s' % dirname)
        outfiles.append(outfile)
        
    # which is it, fastCI or fastNLO?
    fastNLO = find(rootfiles[0], 'fastNLO') > 0
    
    print "="*80
    print "\tfirst input root file:   %s" % rootfiles[0]
    print "\tlast  input root file:   %s" % rootfiles[-1]
    print "\tnumber of output files:  %d" % len(outfiles)
    print "\tnumber of smearings:     %d" % nsmears
    print "\thistograms to smear:     %s" % histnames
    
    if doJESJER:
        print "\tinclude JES+JER uncertainties"
    if doPDF:
        print "\tinclude PDF uncertainties"
    if not doJESJER and not doPDF:
        print "\tno smearing"
        
    if fastNLO:
        print "\tfastNLO"
    else:
        print "\tfastCI"
    print "="*80

    # --------------------------------------------------------
    # get correction functions
    # --------------------------------------------------------
    if not os.path.exists(JECUNFILENAME):
        print "** can't open file %s" % JECUNFILENAME
        sys.exit(0)
  
    jetcor = JetCorrectorParameters(JECUNFILENAME, JECUNTOTAL)
    JESunc = JetCorrectionUncertainty(jetcor)
    JERunc = 0.1 # assume a flat 10% uncertainty in JER

    if not os.path.exists(EWKFILENAME):
        print "** can't open file %s" % EWKFILENAME
        sys.exit(0)            
    fEWK = TFile(EWKFILENAME)
    hEWK = fEWK.Get("IncJet_Ewk_Y0")
    
    doNPcor  = True  # non-perturbative corrections
    
  
    nxy = map(lambda x: map(atof, x),
              map(split, open("normalvariates.txt").readlines()))

    # --------------------------------------------------------      
    # read data
    # --------------------------------------------------------    
    hdfile = TFile(DATAFILENAME)
    if not hdfile.IsOpen():
        print "** can't open file %s" % DATAFILENAME
        sys.exit(0)
    hdata  = hdfile.Get('hdata')
    hdata.GetYaxis().SetTitle('#sigma / bin (pb)')
    hdata.Scale(1.0/LUMI)
    ptmin = 500.0
    ptmax =2500.0    
    pT = hutil.binlowedges(hdata)
    pT.push_back(ptmax)

    # --------------------------------------------------------
    # loop over files and smear selected histograms within
    # each file
    # --------------------------------------------------------              
    cspect = TCanvas('cspec', 'spectra', 10, 10, 500, 500)
    jxy = 0
    variates = {} # map between (PDF member, mur, muf) and (x, y)
    for index, rootfile in enumerate(rootfiles):
        if not os.path.exists(rootfile):
            print "\t*** can't find rootfile %s" % rootfile
            sys.exit(0)

        member = getPDFmember.findall(rootfile)
        if len(member) == 0:
            hutil.error('smearSpectra.py', "can't get PDF member from %s" % \
                        rootfile)
        member = member[0]

        if index % 100 == 0:
            print "%5d\t%s" % (index, rootfile)
         
        # open an output file for smeared histograms
        hfile = TFile(outfiles[index], 'recreate')
        hist = []
        for histname in histnames:
            spectrum = JetSpectrum(rootfile, histname, fastNLO, doNPcor, hEWK)
            
            for ii in xrange(nsmears):

                if doSmearing:
                    # get the correct mapping between
                    # (PDFmember, mur, muf) and (x, y)
                    key = '%s/%s/%3.3d' % (member, histname, ii)
                    if variates.has_key(key):
                        x, y = variates[key]
                    else:
                        if doJESJER:
                            x, y = nxy[jxy]
                            jxy += 1
                        else:
                            x, y = 0.0, 0.0
                        variates[key] = (x, y)

                    sspectrum = JetSpectrumSmeared(spectrum,
                                                   JESunc, JERunc,
                                                   x, y)
                else:
                    sspectrum = JetSpectrumSmeared(spectrum)

                hname = '%s_%3.3d' % (histname, ii)
               
                hfile.cd()
                h = makePlot(hname, sspectrum, pT, kBlue)
                hist.append(h)

                cspect.cd()
                if fastNLO:
                    gPad.SetLogy()
                    hdata.Draw('ep')
                    h.Draw('c same')
                else:
                    gPad.SetLogy(kFALSE)
                    h.Draw('c')
                cspect.Update()
            del spectrum
            del sspectrum
        hfile.Write()
        hfile.Close()
    sleep(5)
#-----------------------------------------------------------------------------
try:
    main()
except KeyboardInterrupt:
    print 'ciao!'

I obtain error message with

Traceback (most recent call last):
File “smearSpectra. py”, line 64, in
def makePlot(hname, spectrum, pt, COLOR = kBlue):
NameError: name ‘kBlue’ is not definedBlockquote

After replacing the the 4th argument as COLOR from kBlue and exterminating the initial condition or executing the command recommanded by Axel, which is

Trying COLOR = kBlue

def main():
   h = makePlot(hname, sspectrum, pT, ROOT.kBlue)

both resulted in the extremely long error message that I posted for the 2nd reply to Axel.

I also tried dpiparo’s code by executing at $HOME

ls /cvmfs/cms.cern.ch
source /cvmfs/cms.cern.ch/cmsset_default.sh
cmsrel CMSSW_9_3_3
cd CMSSW_9_3_3
cmsenv
python ../CI8TeV/work/smearSpectra.py target_dir

However, it resulted in the same error message.

Please note that when I executed

cmsrel CMSSW_9_3_3

WARNING: Release CMSSW_9_3_3 is not available for architecture slc6_amd64_gcc472.
Developer’s area is created for available architecture slc6_amd64_gcc630.
Blockquote

This message showed up.

In addition, I was unsure with dpapiro’s suggestion for

a clean CMSSW area

As a newbie to this website, I would love to be lectured about the statement above.

I really hope I can get an advice now for what to do with my account in the cluster so I can solve the issue!

Thank you so much to you for consistent feedback!

Hi,

thanks for the complete feedback.
With a “clean CMSSW area” I meant something which does not carry information about your work environment, e.g. the content of “$HOME/CI8TeV/work”.
What would be needed is a reproducer which would allow us to see the problem you are experiencing in our computers. Your code relies on files on your own.
Could you reduce the code to a stand-alone script which we could copy/paste and run to see the exact same problem?

Cheers,
D

Hi, I reduced the smearSpectra.py to smearSpectra.spec using PyInstaller.

However, it seems I can not attach that on the web due to .spec extension.

Should I email you?

Am I misunderstanding your direction for stand-alone script (probably I am)…

I appreciate your suggestion to send the stand-alone script version of smearSpectra, whether it’s .spec file or something else that I am missing…

Hi,

could you please provide a python script?

Danilo

smearSpectra.py (10.3 KB)

Hi,

thanks. I think one still needs input files to reproduce the issue, right? If yes, can you provide those?

Cheers,
D

Yes, I should.

I committed the files needed to run the smearSpectra. py script in

Please note

histutil needed for module

libCI. so needed for library (This was not attachable in this website so I moved to gitHub).

Three input files
(data_8Tev, ElectroWeakCorrection, UncertaintySources)

Target PartonDIstributionFunction directory - CT10practice
(I only included 4 different PDFsets within the CT10practice directory instead of 500, since I thought 500 would be unnecessary and overwhelming for its massive file size).

Please ignore 000,001,002,003 and remove those directories.

I believe these are the files needed to run the script.

If something else is needed, I will of course revisit the site and try to supply those.

I sincerely appreciate your patience to keep up with this neophyte!

Thank you.

Hi,

how do I run this? Can you copy a recipe I can paste in my shell?

D

Hi,

I tried the recipe you sent to me privately:

# export the path to libCI.so as LD_LIBRARY_PATH on your bash
git clone https://github.com/trentacoollime/CI8TeV

source CI8TeV/histutil/setup.sh

cd CI8TeV

mkdir work/ data/ corrections/

mv path/to/smearSpectra/smearSpectra.py work/
mv data_8TeV_L19.71_V8.root data/
mv Winter14_V5_DATA_UncertaintySources_AK7PF.txt corrections/
mv ElectroWeakCorrection.root corrections/

cd work

python smearSpectra.py ../CT10practice/

There is no smearSpectra.py in the repo. I took the one you attached above.
The script itself contains a mistake, kBlue should be imported as well at the top of it.
Even after this, the setup does not work. pcm files are missing.
Can you reduce it to a stand alone script, one single file, not needeing cmssw, libraries but just pyROOT? It’s hard to find out where the issue is, if there is one in root, with all this overhead.

Cheers,
D

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.