Hi Aaron,
I can tell why it does not work (and a possible work-around.)
Float_t is a typedef (for float), not an object. So, "charge->" is
illegal because it is simply "(float)->"
The only work around I know (it is ugly!) is like this:
class Test : public TObject {public:double charge;};
Test t;
t.charge = 1.3;
t.Write();
Maybe, you can consider to include everything (TH1F, Float_t...)
related to a "quantity" into an object, and write that single object
into TFile.
Taylan
-- ---=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--- Taylan Akdogan Massachusetts Institute of Technology akdogan@mit.edu Department of Physics Phn:+1-617-258-0801 Laboratory for Nuclear Science Fax:+1-617-258-5440 Room 26-402b ---=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--- On Sep 21, 2004, at 5:28 PM, Aaron Joseph Maschinot wrote:> > in addition to storing a histogram in a root file, i would like to also > store the charge for the histogram also in the root file. the charge > would simply be a Float_t or Double_t. however, since neither or these > are explicitly root classes, they do not have a Write() function and > thus > can't be written to file per norm: > > { > TH1F *hist; > Float_t charge; > > f=new TFile("crap.root","recreate"); > > hist->Write(); //good! > charge->Write(); //hogwash! (that's the kentucky in me coming out > :^) ) > > f->Close(); > } > > does anyone know how to write Float_t's, Int_t's, etc. to root files? > i'm > sure it's a simple answer that i'm just not thinking about... > > aaron
This archive was generated by hypermail 2.1.2 : Mon Feb 24 2014 - 14:07:31 EST