# Cut with arrays in a tree

Hi everebody,

I have a tree t defined with this:

t->Branch(“Ah”, &event.Ah,“Ah/I”);
t->Branch(“Emch”,&event.Emch,“Emch[multiplicityh]/F”);

In a Canvas, I draw both Ah and Emch as 1-D histograms separately.
Imagine we have a tree t defined with only 1 event.

For example:
Ah=140;
Emch=[1,3,5];

When I draw Ah with any cut, it displays a graph with a pick at 140 and a height of 1.
But now, if a draw the same histogram but with a cut defined with “Emch>2”, it displays , for Ah, a pick at 140 but with a height of 2. It’s because the number of particles which have their Emch above 2 are twice, one with 3 and an other with 5. We obtain the number of values which obey the condition, so , 2 , and not the number of event, this last equals to 1.
I would like to obtain the number of events when the condition is respected. So, I expect the value 1.

What I have to do or add to have it?

Thank you.

Hi,

Cheers,
Philippe.

Hi,

I replace Emch>2 by Sum\$(Emch>2)>=1 in the cut string, it is better but it seems to miss few evenments, not to much but when I cut with parameters larger than values in the root files, the 2 graphs are not exactely the same. There is something like 16% of evenements lost.

Thanks

Hi,

Without seeing your data file, it is bit hard to tell

Anyway my guess would be that you missing the events where multiplicityh is zero.

Cheers,
Philippe.

OK, you’re right , I replace Sum\$(Emch>2)>=1 by Sum\$(Emch>2)>=0
and it is perfect

thank you very much

No there is still a problem.
When I have Sum\$(Emch>2)>=0 , I can have all evenements but it cuts nothing>
And I have Sum\$(Emch>2)>=1 , I lose evenements but it cuts.
I must add a condition I thing but I don’t see which one.
I think you’re write, I forgot the case when the array is void.
The condition " Sum\$(Emch>)>=1" is only valable if the size of Emch > 0;
What for size of Emch =0 ?

Thanks

[quote]What for size of Emch =0 ?[/quote]The Sum\$ is invalid and the condition is false. However this sounds like the correct result anyway. If there is no Emch then the is none greater than >2. What am I missing?

Philippe.

OK , that was I discover in fact. I had some other conditions to take in account the case multiplicityh ==0 and now it is ok.