Noor1
November 22, 2018, 5:21pm
1
Dear rooters
I am reading time entries from 2-trees, and trying to calculate the difference between them
time in each tree is defined as Ulong64_t t0 & t1
so I impose this lone

ULong64_t delta_t= abs (int(t0)-int(t1));

at some point where this difference is below 10, the file should save this event and
reset the value of t0 -set zero-

if( delta_t <=10)
{
hist_1-> Fill(int (t0)-int(t1));
t0=0;
t1=0;
}

this work well for some limits then start to give strange numbers

example of out put

t0=91523352 t1=91523346 delta=6
fill hist

t0=0 t1=93638310 delta= -93638310
t0=98758154 t1=93638310 5119844 98758154
.
.
.
.
.
t0=6076377484 t1=6076377479 delta= 5
fill hist

t0=0 t1=6077175566 delta=-1782208270

is this related to the int and the ULong64_t ??

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided

See (for example): cppreference.com -> C++ -> C++ language -> Basic Concepts -> Fundamental types

Try with:

```
ULong64_t delta_t = ((t1 >= t0) ? t1 - t0 : t0 - t1); // abs(t1 - t0)
// ...
hist_1->Fill(delta_t); // if you want abs(t1 - t0)
hist_1->Fill(((t1 >= t0) ? 1. : -1.) * delta_t); // if you want (t1 - t0)
hist_1->Fill(((t0 >= t1) ? 1. : -1.) * delta_t); // if you want (t0 - t1)
```

Noor1
November 22, 2018, 6:44pm
3
dear
thank for fast reply,
this works correctly,
my main issue was when I reset the value of t0 or t1, I need it to be zero, but the output gives arbitrary values

P.S th initial definition of t0 and t1 are
ULong64_t t0=0.;
ULong64_t t1=0.;
cheers

Well, “0.” is a double-precision floating-point constant and you want “0llu” which is an unsigned long long (ULong64_t) constant (but you can safely use simply “0” there, too).

Noor1
November 22, 2018, 7:43pm
5
So as you suggest it is possible to use 0.
t0=0
and calculate delta_t , and int(t0)-int(t1)

ULong64_t delta_t = ((t1 >= t0) ? t1 - t0 : t0 - t1); // abs(t1 - t0)
cout<<“"<<t<<endl;
cout<<“t0=”<<t0<<" "<<“t1=”<<t1<< " “<< “int(t0)-int(t1)=”<< int(t0)-int(t1)<<endl;
cout<<“t0=”<<t0<<” "<<“t1=”<<t1<< " "<< “delta_t=”<<delta_t<<endl;
cout<<" ”<<t<<endl;

and this is the output

**********************3472675439
t0=0 t1=3472675439 int(t0)-int(t1)=822291857
t0=0 t1=3472675439 delta_t=3472675439
**********************3472675439
**********************3483499090
t0=0 t1=3483499090 int(t0)-int(t1)=811468206
t0=0 t1=3483499090 delta_t=3483499090
**********************3488774199
t0=3483764371 t1=3488774199 int(t0)-int(t1)=-5009828
t0=3483764371 t1=3488774199 delta_t=5009828

when there are long values it works (+, -), but if I have t0 or t1 equal to zero(due to the reset), delta_t calculate correctly, but regular way (int(t0)-int(t1)) not

I appreciate your responce

Where do you see “int(t0)-int(t1)” in my example code?
I guess you could try to use: `Long64_t(t0 - t1)`

In the web links which I gave in my previous posts, search for the values of “range” which particular integer related types are capable of.

system
Closed
December 6, 2018, 7:55pm
7
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.