All of the histo are booked using the following code:

```
for (Int_t i0=0; i0<dimNalgo ; i0++)
for (Int_t i1=0; i1<nBinEta ; i1++)
for (Int_t i2=0; i2<nBinEt ; i2++) {
hDist_B[i0][i1][i2]= new TH1F(Form("hDist_B_%d_%d_%d",i0,i1,i2),"",100,0,2 );
hDist_C[i0][i1][i2]= new TH1F(Form("hDist_C_%d_%d_%d",i0,i1,i2),"",100,0,2 );
hDist_Q[i0][i1][i2]= new TH1F(Form("hDist_Q_%d_%d_%d",i0,i1,i2),"",100,0,2 );
hDist_G[i0][i1][i2]= new TH1F(Form("hDist_G_%d_%d_%d",i0,i1,i2),"",100,0,2 );
}
```

I analyze let’s say 5M events. For each event I have 2 jets. For each jet I get one entry which fills one (and only one) of the 320.000 histo depending on the algo used for the jet, et, eta and flavour of the jet.

It’s not clear to me how to implement the same functionality in a tree. Also because I need to fit all of these histos with a guassian function. I guess I can try to write a tree which save the same infos… Just to be sure I understood correctly:

- I save a tree with a sort of structure like this:

myTree1[nAlgo][nEta][nEt][nFlav][nBin] where:

nAlgo=0 --> 7

nEta=0 --> 50

nEt=0 --> 200

nFlav=0 --> 3 (8*50*200*4=320.000 the famous number of histos)

nBin=0 --> 100 (100 bin each histo)

and I increase of 1 unit each time I get an entries for that particular bin

This structure mimic exactly the histos.

I have exactly 32M entries in the tree and the merging produce only an increase in the values saved in the tree but there is no change in the total number of entries
- This structure in a tree allow to save space (I really don’t care)
- This structure allows for a much faster merging of many files (this is really important)
- After the merging I can create the famous 320.000 histos from the tree and fit each histo with my gaussian
- Plot the result and I’m happy !

Is this the best way to prooceed? if you confirm it I can start right now to build the tree and test this solution…

But there is another possibility:

I build the same tree but the last variable:

myTree2[nAlgo][nEta][nEt][nFlav] = theVariableIuseToFillHisto

This option give me 2 entriy for each event (for 5M events -> 10M entries considering I have 2 entries, i.e. 2 jets, from each analyzed event). This number increase when I merge all the events and it depends on the number of events I’m analyzing… It mean also that the final file can be really big (depends on the number of entries)

Then I scan the full tree, I build the histos, fit and that’s all.

I’m a little bit confused…

Thanks

Attilio