Double_t Trouble?

From: Christopher A. Stevens (stevensca@navair.navy.mil)
Date: Wed Aug 25 1999 - 21:47:09 MEST


Redhat 6.0 Linux with SMP kernel with ROOT 2.22/10.
I've been having problems moving from simple TNtuples to TTrees.
I took the "simple example" from the TTree Class Description,
made it into an macro, and simplified it to:
{
   TFile hfile("htree.root","RECREATE","Demo ROOT file with histograms &
trees")

   typedef struct {
      Int_t ntrack,nseg,nvertex;
      UInt_t flag;
      Float_t temperature; 
//      Double_t temperature; 
   } EVENTN;
   static EVENTN eventn;

   TTree *tree = new TTree("T","An example of ROOT tree with a few
branches");
  
tree->Branch("eventn",&eventn,"ntrack/I:nseg:nvertex:flag/i:temperature/F");
//  
tree->Branch("eventn",&eventn,"ntrack/I:nseg:nvertex:flag/i:temperature/D")

   for ( Int_t i=0; i<1000; i++) {
      Float_t random = gRandom->Rndm(1);

      eventn.ntrack  = Int_t(100*random);
      eventn.nseg    = Int_t(2*eventn.ntrack);
      eventn.nvertex = 1;
      eventn.flag    = Int_t(random+0.5);
      eventn.temperature = Float_t(20+random);
//      eventn.temperature = Double_t (20+random);

      tree->Fill();
   }

   hfile.Write();

   hfile.Close();

}
I get what looks like a good histogram with the Float_t lines,
but when I use the Double_t lines I get a histogram with a
single spike at zero.
What am I doing wrong?

Chris Stevens



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:38 MET