Fill an histogram from a Ttree using Project()

hi forum

The problem i’m encountering is most probably a trivial one, but
please give me a
suggestion.
My data are stored in branches of a Ttree, which is:


*Tree :h1 : THERMO *
*Entries : 19764055 : Total = 118763334 bytes File Size = 43840030 *

  • : : Tree compression factor = 2.71 *

*Br 0 :numtel : numtel/s *
*Entries : 19764055 : Total Size= 39587264 bytes File Size = 10008816 *
*Baskets : 618 : Basket Size= 64000 bytes Compression= 3.95 *

*Br 1 :desilpg : desilpg/s *
*Entries : 19764055 : Total Size= 39587888 bytes File Size = 14798620 *
*Baskets : 618 : Basket Size= 64000 bytes Compression= 2.67 *

*Br 2 :desilgg : desilgg/s *
*Entries : 19764055 : Total Size= 39587888 bytes File Size = 18986602 *
*Baskets : 618 : Basket Size= 64000 bytes Compression= 2.08 *

In my C program I also read some data from a file and I store them in two
vectors (rapp_gain[] and offset[]).
I would like to fill an histogram with modified “desilgg” values, more
exactly I would like to fill the histogram with the following expression
desilgg/rapp_gain[numtel]+offset[numtel].
For this aim I have written the following code:

TH1F *hg[400];
char nriv[10],nteles[20];
for(int
j=1;j<100>Project(“istoHG”,“desilgg/rapp_gain[numtel]+offset[numtel]”,nteles);
}

but it doesn’t work, and I get the message:

*ERROR 30 :
Bad numerical expression : “rapp_gain[numtel]”

What is it wrong? What can I do? Isn’t it the right way to reach my goal?
Thank you!

Paola

Hi,

TTree::Draw (and TTree::Project) can only access the tree branches (like numtel or desilpg), their inner content (if the branch contains objects), member functions or global function (TMath::Abs).

I assume that in your example, rapp_gain is actually a C++ variable which is not accessible from TTree::Draw (and TTree::Project).

So unless you store this information in another TTree and make it a friend of Thermo, you will need to use a different technique (for example TTree::MakeSelector or TTree::MakeProxy).

Cheers,
Philippe

thank you very much, Philippe!

I’m going to try as you suggested me! I will let you know the result!

cheers

paola