Histogram and data integral with entries different


Please read tips for efficient and successful posting and posting code

ROOT Version: 6.18.00
Platform: UBUNTU 18.04.5
Compiler: Not Provided


Good Morning for all!

I’m computing a data from GAMOS in root tree. And so I used the makeclass to run the code for do an histogram (attached). But something strange happens. In the histogram the entries is 2.010533e7 but when I use the file sumpHistoToTxt.C the values of all entries gives me 1.77838e+07.

Could help me? I can’t understand where exacttly was the mistake.

TotalFotoes_0.025mm.pdf (37.4 KB)
dumpHistoToTxt.C (971 Bytes)
SPEC_TotalFotoesA.root (6.2 KB)

Thanks

God bless you all

If you have so many entries, do not use TH1F but TH1D to avoid truncation errors happening when bin counts are larger than ~ 1.E7 !

Note also that the number of entries could contain also underflow or overflow which are counted in the integral

Thanks @moneta, for the reply!

I will change this and report here what happens. There was some way to avoid this underor overflow?

best regards!

@moneta, I have done what you said but and I run again the file dumpHistoToTxt.C was an error:

#0  0x00007fe9a114c457 in __GI___waitpid (pid=7029, stat_loc=stat_loc
entry=0x7ffd71c0f568, options=options
entry=0) at ../sysdeps/unix/sysv/linux/waitpid.c:30
#1  0x00007fe9a10b7177 in do_system (line=<optimized out>) at ../sysdeps/posix/system.c:149
#2  0x00007fe9a1d597c3 in TUnixSystem::Exec (shellcmd=<optimized out>, this=0x55bfe07ecb80) at /home/gamos/gamos/external/root/6.18.00/root/core/unix/src/TUnixSystem.cxx:2106
#3  TUnixSystem::StackTrace (this=0x55bfe07ecb80) at /home/gamos/gamos/external/root/6.18.00/root/core/unix/src/TUnixSystem.cxx:2400
#4  0x00007fe99c32fe45 in cling::MultiplexInterpreterCallbacks::PrintStackTrace() () from /home/gamos/gamos/external/root/6.18.00/root/rootbuild/lib/libCling.so
#5  0x00007fe99c32f84b in cling_runtime_internal_throwIfInvalidPointer () from /home/gamos/gamos/external/root/6.18.00/root/rootbuild/lib/libCling.so
#6  0x00007fe9a24e616c in ?? ()
#7  0x000055bfe1358ae0 in ?? ()
#8  0x000055bfe0cf4370 in ?? ()
#9  0x000055bfe18899a0 in ?? ()
#10 0x000055bfe130a540 in ?? ()
#11 0x000055bfe1358ae0 in ?? ()
#12 0x000055bfe1358ae0 in ?? ()
#13 0x000055bfe175b0c0 in ?? ()
#14 0x000055bfe15c4d00 in ?? ()
#15 0x000055bfe11b8270 in ?? ()
#16 0x7b661cb315842600 in ?? ()
#17 0x0000000000000000 in ?? ()
Error in <HandleInterpreterException>: 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_12:1:
/home/gamos/brachy_VMBox/Etapas/teste/sample/gamma_test/dose_testeSB/exTest/GAM/GAM1/Volumes/VolNormal/espMin/spectro/dumpHistoToTxt.C:9:16: warning: null passed to a callee that requires a non-null argument [-Wnonnull]
double integ = tr->Integral();

How can I fix this?

Thanks

Hi David,

maybe instead of

TH1D *tr; f->GetObject("energy", tr);

you can try

TH1D* tr = static_cast<TH1D*>(f->Get("energy"));
if (!tr)
{
    printf("ERROR: no \"energy\" histogram found in the .root file\n");
    return;
}

Thanks, @yus!

It seems to work now! I will just run some test to certifed that is all right.

Best regards

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