A question about files

From: Chris Jillings (chris@loon.phy.queensu.ca)
Date: Thu Feb 05 1998 - 17:37:48 MET


Hi,
    This question is simple, but has caused me hours of problems.
I want to read an ntuple and fill a histogram with data from the ntuple 
and then write the histgram to another file.

  TH1F* h4 = new TH1F("h4","4 MeV Electrons",80,-1,1);
  TFile* fout = new TFile("arHistos.root","NEW","AR hists",1);
  TFile* ntp = new TFile("cjj_e4.root","READ");
  if(ntp->IsOpen()) 
    h509->Draw("(Ue*Uft+Ve*Vft+We*Wft)>>+h4","Rfitt<600",);
Everything to here is fine.  


The first problem is that if I 
  ntp->Close();
  h4->Draw();
the histogram is empty. The upper/lower bounds and title are correct
but there is no data in the histogram: I get a flat line at zero counts.

I checked the browser and it turns out that the histogram is "part of"
the file cjj_e4.root (even though I opend it read only.)

I thought I would work around the problem by opening a second file and 
writing the histogram to it. That gives an error that the file cjj_e4 is 
read-only.

I realize that for just one file, I can keep it open for the duration of 
my work, but I will need to take one histogram from each of 6 or 12 
files, and it seems inelagant to be forced to keep open that many files.

Also, the histogram is created before any files are opened. When I fill
the histogram with the draw command, why doesn't the data get written to 
something with global scope? (ie something that will exist in memory after 
the file is closed) I don't understand why that wouldn't be automatically
so. 

Thanks for your time and consideration.

Chris.



=================================================================
=                                                               =
= Chris Jillings                                                =
= Department of Physics   phone/voice mail: (613) 545-6000x4805 =   
= Queen's University      fax: (613) 545-6813                   =
= Kingston, Ontario       email: chris@mips2.phy.queensu.ca     =             
= Canada, K7L 3N6         web: http://snodaq.phy.queensu.ca     =
=                                                               =
=================================================================



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