Home | News | Documentation | Download

Fitting Histograms :: null pointer error

Hello,

I have a fitting routine written to fit peaks in a histogram.
But unfortunately it breaks down with the following error -

root [1] [/Users/mansisaxena/build_6.18/lib/libCling.so] cling_runtime_internal_throwIfInvalidPointer (no debug info)

[] (no debug info)

[] (no debug info)

[/Users/mansisaxena/build_6.18/lib/libCling.so] cling::IncrementalExecutor::executeWrapper(llvm::StringRef, cling::Value*) const (no debug info)

[/Users/mansisaxena/build_6.18/lib/libCling.so] cling::Interpreter::RunFunction(clang::FunctionDecl const*, cling::Value*) (no debug info)

[/Users/mansisaxena/build_6.18/lib/libCling.so] cling::Interpreter::EvaluateInternal(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, cling::CompilationOptions, cling::Value*, cling::Transaction**, unsigned long) (no debug info)

[/Users/mansisaxena/build_6.18/lib/libCling.so] cling::Interpreter::process(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, cling::Value*, cling::Transaction**, bool) (no debug info)

[/Users/mansisaxena/build_6.18/lib/libCling.so] cling::MetaProcessor::process(llvm::StringRef, cling::Interpreter::CompilationResult&, cling::Value*, bool) (no debug info)

[/Users/mansisaxena/build_6.18/lib/libCling.so] HandleInterpreterException(cling::MetaProcessor*, char const*, cling::Interpreter::CompilationResult&, cling::Value*) /Users/mansisaxena/Downloads/root-6.18.04/core/metacling/src/TCling.cxx:2161

[/Users/mansisaxena/build_6.18/lib/libCling.so] TCling::ProcessLine(char const*, TInterpreter::EErrorCode*) /Users/mansisaxena/Downloads/root-6.18.04/core/metacling/src/TCling.cxx:2310

[/Users/mansisaxena/build_6.18/lib/libCore.so] TROOT::ProcessLine(char const*, int*) /Users/mansisaxena/Downloads/root-6.18.04/core/base/src/TROOT.cxx:2371

[/Users/mansisaxena/build_6.18/lib/libGpad.so] TPad::AutoExec() /Users/mansisaxena/Downloads/root-6.18.04/graf2d/gpad/src/TPad.cxx:455

[/Users/mansisaxena/build_6.18/lib/libGpad.so] TCanvas::HandleInput(EEventType, int, int) /Users/mansisaxena/Downloads/root-6.18.04/graf2d/gpad/src/TCanvas.cxx:1284

[/Users/mansisaxena/build_6.18/lib/libGui.so] TRootCanvas::HandleContainerButton(Event_t*) /Users/mansisaxena/Downloads/root-6.18.04/gui/gui/src/TRootCanvas.cxx:0

[/Users/mansisaxena/build_6.18/lib/libGui.so] TRootContainer::HandleButton(Event_t*) /Users/mansisaxena/Downloads/root-6.18.04/gui/gui/src/TRootCanvas.cxx:296

[/Users/mansisaxena/build_6.18/lib/libGui.so] TGFrame::HandleEvent(Event_t*) /Users/mansisaxena/Downloads/root-6.18.04/gui/gui/src/TGFrame.cxx:518

[/Users/mansisaxena/build_6.18/lib/libGui.so] TGClient::HandleEvent(Event_t*) /Users/mansisaxena/Downloads/root-6.18.04/gui/gui/src/TGClient.cxx:0

[/Users/mansisaxena/build_6.18/lib/libGui.so] TGClient::ProcessOneEvent() /Users/mansisaxena/Downloads/root-6.18.04/gui/gui/src/TGClient.cxx:653

[/Users/mansisaxena/build_6.18/lib/libGui.so] TGInputHandler::Notify() /Users/mansisaxena/Downloads/root-6.18.04/gui/gui/src/TGClient.cxx:700

[/Users/mansisaxena/build_6.18/lib/libCore.so] TMacOSXSystem::DispatchOneEvent(bool) /Users/mansisaxena/Downloads/root-6.18.04/core/macosx/src/TMacOSXSystem.mm:421

[/Users/mansisaxena/build_6.18/lib/libCore.so] TSystem::InnerLoop() /Users/mansisaxena/Downloads/root-6.18.04/core/base/src/TSystem.cxx:413

[/Users/mansisaxena/build_6.18/lib/libCore.so] TSystem::Run() /Users/mansisaxena/Downloads/root-6.18.04/core/base/src/TSystem.cxx:363

[/Users/mansisaxena/build_6.18/lib/libCore.so] TApplication::Run(bool) /Users/mansisaxena/Downloads/root-6.18.04/core/base/src/TApplication.cxx:1179

[/Users/mansisaxena/build_6.18/lib/libRint.so] TRint::Run(bool) /Users/mansisaxena/Downloads/root-6.18.04/core/rint/src/TRint.cxx:463

[/Users/mansisaxena/build_6.18/bin/root.exe] main /Users/mansisaxena/Downloads/root-6.18.04/main/src/rmain.cxx:32

[/usr/lib/system/libdyld.dylib] start (no debug info)

Error in : Trying to dereference null pointer or trying to call routine taking non-null arguments.

Execution of your code was aborted.

In file included from input_line_8:1:

/Users/mansisaxena/57ZnBetaP/e18018/e18018_home/Efficiency/Clover_Analyzer.C:134:10: warning: null passed to a callee that requires a non-null argument [-Wnonnull]

if(h1->GetBinContent(k) > py) {

^~

Any ideas please ???

Thanks
Mansi

Hi,
It’s hard to say without code, but for me seems that h1 is null or deleted.

Clover_Analyzer.C (20.5 KB)

Hey,
I attached my script.

It might have few iterations, as I was trying with different things.

Mansi

Hi,
it seems that the source of problem is that you use global h1 (line 32) in Position_Selector, whereas you load only local h1 (declared at line 546)

Yeah,
I noticed that now.
Now, I can have the histogram plotted

But, still the fitting routine completely fails.

I attached the root file, just for checking.

MansiTest-for-Chain-003.root (602.7 KB)

The Fit fails at
h1->GetBinContent(bin)

I can’t seem to understand why ?

Any ideas will be very helpful.

Thanks

At least, remove “TH1D *h1;” from “void Clover_Analyzer()”.

Thank you,

As suggested I removed the TH1D *h1 from the main program.

But now it fails at
h1->GetBinContent(bin);

please help.

Well, try to add “gPad->Modifed(); gPad->Update();” right before “gPad->AddExec(...);”.

If you are using Mac OS X with Cocoa, maybe you need to add one or two calls “gSystem->ProcessEvents();” after each “some_pad_or_canvas->Update();”.

If it doesn’t help, maybe @couet has some idea.

Hi,

Thanks.
I tried that.
But it cannot evaluate h1->GetBinContent(bin) correctly.

Any ideas please ??

Mansi