What you wanted to do was: root [0] TClonesArray* tps = new TClonesArray("TH1F",5); root [1] dummy = new((*tps)[0]) TH1F("bname0","btitle0",40,-20.,200); root [6] ((*tps)[0])->Draw(); Warning in <MakeDefCanvas>: creating a default canvas with name c1 .... Regards, Pasha -------------------------------------------------------------------------------- Dirk Meier writes: > > Hi, > > I want to create a TClonesArray with pointers to histograms. > Later I need to fill these histograms in a loop from a tree > with the >> . > First I excersided this > > root [0] TH1F* b = new TH1F("bname","btitle",40,-20.,200); > root [1] b->Draw(); > Warning in <MakeDefCanvas>: creating a default canvas with name c1 > > o.k. this worked, but now > > root [2] TClonesArray* tps = new TClonesArray("TH1F",5); > root [3] dummy = new(tps[0]) TH1F("bname0","btitle0",40,-20.,200); > root [4] tps[0]->Draw(); > Warning in <MakeDefCanvas>: creating a default canvas with name c1 > > *** Break *** segmentation violation > > ( 0) 0xc14f5d40 StackTrace__11TUnixSystemFv + 0x28 > [/afs/cern.ch/na49/library/local/ROOT/hpux10aCC/root/lib/libUnix.sl] > > this did not work. > Also bname0->Draw() does not work. > (I do not know exactly why the new operator with placement requires > a syntax like `dummy new() ..', I use it in other programs > without `dummy', but CINT would complain..). > Later I want to iterate over the histogram objects in the > TClonesArray like > > Float_t tEntries[5]; > Char_t tWhat[30]; > for(Int_t s = 0; s < 5; s++) { > sprintf(tWhat,"fTPS%d>>bname%d",s); // fTPS is leave in my TTree T > T->Draw(tWhat,""); > tEntries[s] = tps[s]->GetIntegral(); // also access other properties > here > } > > > .. which did not work so far. > Is there an example how to iterate through a TClonesArray > with histograms and fill them from e.g. a TTree or TNtuple? > I also need to access the histograms like in tps[s]->GetIntegral() > > thanks for any help > Dirk > > > >
This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:31 MET