[ROOT] TTree::Scan(TClonesArray::GetSize())

From: Maxim Nikulin (nikulin@gorodok.net)
Date: Tue Oct 12 2004 - 09:43:26 MEST


Hi,

If a TTree has a branch contained an object, TTree::Scan() and 
TTree::Draw() methods can invoke methods of the object. I see it with my 
custom class. If I try to pass TClonesArray::GetSize() as an argument of 
TTree::Scan(), I get an error. I attached a script to reproduce the 
problem. Its output:

$ root TClonesArray-GetSize.C
   *******************************************
   *                                         *
   *        W E L C O M E  to  R O O T       *
   *                                         *
   *   Version   4.00/08  3 September 2004   *
   *                                         *
   *  You are welcome to visit our Web site  *
   *          http://root.cern.ch            *
   *                                         *
   *******************************************

FreeType Engine v2.1.3 used to render TrueType fonts.
Compiled for linux with thread support.

CINT/ROOT C/C++ Interpreter version 5.15.138, May 23 2004
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
root [0]
Processing TClonesArray-GetSize.C...
Error in <TTreeFormula::DefinedVariable>: Unknown method:GetSize()

*ERROR 30 :
  Bad numerical expression : "tca.GetSize()"
************************
*    Row   * tca.GetSi *
************************
*        0 *           *
*        1 *           *
*        2 *           *
************************
root [1]

I'm expecting 3, 1, 2 values in the table. I can't find detailed 
explanation of the invocation mechanism and its limitations.

-- 
Maxim Nikulin


{
   // TTree::Scan(TClonesArray::GetSize())

   tree = new TTree("tree", "Draw(TCLonesArray::GetSize()) trouble");
   tca = new TClonesArray("TObjString", 10);
   tree->Branch("tca", "TClonesArray", &tca);
   
   new((*tca)[0]) TObjString("e0s0");
   new((*tca)[1]) TObjString("e0s1");
   new((*tca)[2]) TObjString("e0s2");
   tree->Fill();
   tca->Clear();

   new((*tca)[0]) TObjString("e1s0");
   tree->Fill();
   tca->Clear();

   new((*tca)[0]) TObjString("e2s0");
   new((*tca)[1]) TObjString("e2s1");
   tree->Fill();
   tca->Clear();

   tree->Scan("tca.GetSize()");
}



This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:09 MET