Cling Runtime Error

I am wondering if this is due to a coding error or internal error.

I am just trying to get the bin content of a histogram which I loaded from a root file. It works just fine in the interactive window. However, not while I am trying to compile a macro.

==========================================
=============== STACKTRACE ===============
==========================================


================ Thread 0 ================
  0x13fd5ae ??
  0x13fd041 ??
  libCling!cling::runtime::internal::EvaluateDynamicExpression()
  libCling!cling::runtime::internal::EvaluateDynamicExpression()
  libCling!cling::runtime::internal::EvaluateDynamicExpression()
  libCling!cling::runtime::internal::setValueWithAlloc()
  libCling!TCling::GetTopLevelMacroName()
  libCling!TCling::ProcessLine()
  libCore!TApplication::ProcessLine()
  libRint!TRint::ProcessLineNr()
  libRint!TRint::HandleTermInput()
  libCore!TWinNTSystem::DispatchOneEvent()
  libCore!TSystem::InnerLoop()
  libCore!TApplication::Run()
  libRint!TRint::Run()
  root!??
  root!??
  KERNEL32!BaseThreadInitThunk()
  ntdll!RtlGetAppContainerNamedObjectPath()
  ntdll!RtlGetAppContainerNamedObjectPath()

================ Thread 1 ================
  ntdll!ZwWaitForWorkViaWorkerFactory()
  KERNEL32!BaseThreadInitThunk()
  ntdll!RtlGetAppContainerNamedObjectPath()
  ntdll!RtlGetAppContainerNamedObjectPath()

================ Thread 2 ================
  ntdll!ZwWaitForWorkViaWorkerFactory()
  KERNEL32!BaseThreadInitThunk()
  ntdll!RtlGetAppContainerNamedObjectPath()
  ntdll!RtlGetAppContainerNamedObjectPath()

================ Thread 3 ================
  ntdll!ZwWaitForWorkViaWorkerFactory()
  KERNEL32!BaseThreadInitThunk()
  ntdll!RtlGetAppContainerNamedObjectPath()
  ntdll!RtlGetAppContainerNamedObjectPath()

================ Thread 4 ================
  ntdll!ZwDelayExecution()
  KERNELBASE!Sleep()
  libCore!TWinNTSystem::TimerThread()
  KERNEL32!BaseThreadInitThunk()
  ntdll!RtlGetAppContainerNamedObjectPath()
  ntdll!RtlGetAppContainerNamedObjectPath()

================ Thread 5 ================
  win32u!NtUserGetMessage()
  libCore!TWinNTSystem::FreeDirectory()
  KERNEL32!BaseThreadInitThunk()
  ntdll!RtlGetAppContainerNamedObjectPath()
  ntdll!RtlGetAppContainerNamedObjectPath()

==========================================
============= END STACKTRACE =============
==========================================

The macro I was trying to run is:

void PlotUglovFits(void)
{
	printf("Check one\n");
	TFile *fin = new TFile("../data/data/exp/plots.root");
	if (fin == NULL)
	{
		printf("Failed to open file. . .\n");
		exit(-1);
	}
	
	printf("Check two\n");
	TH1D *h_DLDL;  ///< Spin 2 contribution
	TH1D *h_DTDL;  ///< Spin 0 contribution
	TH1D *h_total; ///< sum of previous two
	
	printf("Check three\n");
	h_DLDL = (TH1D*)fin->Get("D^{*+}LD^{*-}L");
	h_DTDL = (TH1D*)fin->Get("D^{*+}TD^{*_}L");
	
	printf("Check four\n");
	int entries = h_DLDL->GetEntries();
	double const xmin = h_DLDL->GetXaxis()->GetXmin();
	double const xmax = h_DLDL->GetXaxis()->GetXmax();
	
	printf("Check five\n");
	h_total = new TH1D("h_total","blank",entries,xmin,xmax);
	printf("Check six\n");
	for (int i = 1; i < entries + 1; i++)
	{
		double dldl = h_DLDL->GetBinContent(i);
		double dtdl = h_DTDL->GetBinContent(i);
		printf("i = %d; \t dldl  = %lf; \t dtdl = %lf\n",i,dldl,dtdl);
		h_total->SetBinContent(i,dldl+dtdl);
	}
	
	printf("Check seven\n");
	TCanvas *c = new TCanvas("c","Spin contributions",X0,Y0,Width*1.30,Height);
	h_DLDL->Draw();
	h_DTDL->Draw("same");
	h_total->Draw("same");
	
	printf("Check eight\n");
	
}

The error message I get is
This text will be hidden


_ROOT Version:6.16
_Platform:Windows
_Compiler:Cling?


Hi,

what is the exact line that crashes (you can know this with some bisection)?
Can you check that the histograms you take out of the files are not nullptrs?

Cheers,
D

Hi,

I was able to find the error.
It ended up just being a typo in the name of the histogram I was trying to get.
The line reads

h_DTDL = (TH1D*)fin->Get("D^{*+}TD^{*_}L");

but should have read:

h_DTDL = (TH1D*)fin->Get("D^{*+}TD^{*-}L");

Thank you,
Kevin

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