Maybe you could use an stl vector instead? #include <vector> //declare std::vector<Float_t> array; //add next element array.push_back(aFloat); Int_t size=array.size(); stl vectors should at least work in compiled code. I'm not sure if they're implemented in intrepreter. A.E. Snyder, Group EC \!c*p?/ SLAC Mail Stop #95 ((. .)) Box 4349 | Stanford, Ca, USA, 94309 '\|/` e-mail:snyder@slac.stanford.edu o phone:650-926-2701 _ http://www.slac.stanford.edu/~snyder BaBar FAX:650-926-2657 Collaboration On Fri, 31 Jan 2003, Carlos Muņoz Camacho wrote: > > Hi, > > I have a class similar to Event.h with an array of Float_t as a member. > I want the dimension of the array to be a non-const parameter (as it will > be read from an input file). The parameter is a static member of an > inherited class, but this can change. The important thing is I don't want > to hardcode the value of the parameter, because it is read from a file. > > The solution I found in the documentation is to allocate it dynamically > via a pointer and tell the streamer the size of the array in the > commentary field : //[fSize] . However, fSize needs to be a data member of > the class. Obviously, I don't want to save this data member to file > because it is constant for all the events. If I use fSize //! to avoid > writing it, I get an Error in <TStreamerInfo::Build>. Below is a short > example which reproduces the problem. > > Is there a way around this? > > ROOT 3.03/08 on a RH 7.2 > > > File: class.C > ______________________________________________________ > > #include "TObject.h" > > class TEvent : public TObject { > > private : > > Int_t fSize; //! > Float_t* fBlocks; //[fSize] > > ClassDef(TEvent,1) > > }; > _______________________________________________ > > Result: > > CINT/ROOT C/C++ Interpreter version 5.15.53, Aug 15 2002 > Type ? for help. Commands must be C++ statements. > Enclose multiple statements between { }. > root [0] .L class.C+ > Info in <TUnixSystem::ACLiC>: creating shared library > /dsm/phnpcd232/local/home/cmunoz/./class_C.so > root [1] TEvent *ev=new TEvent(); > root [2] TTree t("t","My tree"); > root [3] t.Branch("event","TEvent",&ev,16000,99); > Error in <TStreamerInfo::Build>: TEvent, discarding: Float_t* fBlocks, > illegal [fSize] > > > > Carlos Munoz Camacho > SPhN/CEA-Saclay > >
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:09 MET