Behaviour of TTree draw formula for array of array

Bonjour,

I have lost some hours looking for a inexistant bug while filling TTree with TClonesArray containing an array. At the end it turned out to be a “feature” of the TTreeFormula.

My TTree is made of Event containing a TClonesArray fHits (of length fNhits), which in turn contains a fixed size array fThr[3]. All the hits must at least have the lowest threshold set to 1 (useless information apparently).

But the Draw or Scan command with “fThr[0]” (or “fHits.fThr[0]”) reports some 0 :

[code] Event->Scan(“fHeader.fEvtNum:fNhits:fThr[0]:fThr[1]”,"","", 274, 0);


  • Row * Instance * fHeader.f * fNhits * fThr[0] * fThr[1] *

  •    0 *        0 *         0 *         1 *         1 *           *
    
  •    0 *        1 *         0 *         1 *         1 *           *
    
  •    0 *        2 *         0 *         1 *         0 *           *
    
  •    1 *        0 *         1 *         2 *         1 *         1 *
    
  •    1 *        1 *         1 *         2 *         1 *         1 *
    
  •    1 *        2 *         1 *         2 *         0 *         0 *
    
  •    2 *        0 *         2 *         1 *         1 *           *
    
  •    2 *        1 *         2 *         1 *         1 *           *
    
  •    2 *        2 *         2 *         1 *         0 *           *
    

[/code]
while the "fHits[].fThr[0] is OK.

The 1,1,0 sequence actually reflexes the content if the full fThr[] array.

In principle knowing that the fHits is an array of variable length, the TTreeFormula could add fHits[] rather than fHits, and produce a correct output.

Best regards,
Vincent.

Hi,

The array indices position in the string are materials (to TTreeFormula):
‘fHits[0].fThr’, ‘fHits.fThr[0]’ and ‘fHits.fThr[0][]’ are exactly the same thing (to TTreeFormula) but fHits.fThr[][0] is different (but the same as fHits[].fThr[0]). The [] indicates a index for which you want TTreeFormula to loop over all values.

To get the plot you are looking for use:
Event->Scan("fHeader.fEvtNum:fNhits:fThr[][0]:fThr[][1]","","", 274, 0);

Cheers,
Philippe.