Hello Rooters,
I am trying to use the attached unnamed macro to extract information from a *.root file and add it to an ascii file (for subsequent import into a database). The first time I run the macro all is well, the second time it fails:
root [1] .x parms.C
Data filename: file1
Diode reading: 1.0
root [2] .x parms.C
Note: File "Riostream.h" already loaded
Data filename: file2
Diode reading: 1.0
Error: Symbol parms[i] is not defined in current scope parms.C:65: Error: << Illegal operator for pointer 3 parms.C:65: Error: << Illegal operator for real number parms.C:65:!!!Dictionary position not recovered because G__unloadfile() is used in a macro!!! *** Interpreter error recovered ***
Here is the macro:
{
gROOT->Reset();
//#include <fstream>
#include <Riostream.h>
#include <TString.h>
/*
Input section
*/
Char_t fname[100]; // Input data file
cout << "Data filename: ";
cin >> fname;
Double_t diode;
cout << "Diode reading: ";
cin >> diode;
Char_t run[] = {"92020(c)"}; Char_t date[] = {"050912"}; Char_t temp[] = {"to_calculate"}; Char_t records[] = {"2007-02-25-110403.howm"}; // Processing notes
TFile *f = new TFile(strcat(fname,".root"));
TF1 *all;
f->GetObject("all",All);
Int_t npar = All->GetNpar();
Double_t parms[40];
All->GetParameters(parms);
Double_t* err = All->GetParErrors();
// Cleanup
f->Close();
delete f;
delete all;
f = 0;
all = 0;
/*
Output section
*/
// Make sure lorentzian starts at parms[30], even when there was no second G.
// Zero the unused parameters and errors.
if (npar == 30){
int j = 30;
for (int i = 20; i < 30; i++){ parms[j] = parms[i]; parms[i] = 0; err[j] = err[i]; err[i] = 0;
ofstream out;
ofstream out("Fits.050912.dat", ios::app);
out << run << "\t" << date << "\t" << fname << "\t" << diode << "\t" << temp << "\t" << records;
for (int i = 0; i < 40; i++) {
out << "\t" << parms[i] << "\t" << err[i];
}
out << endl;// End record
// Cleanup
// out closed by destructor
out.close();
}
I'm using 5.14/00 on Linux 2.6.18-gentoo-r6.
Thanks for any help,
Roger Received on Mon Feb 26 2007 - 16:38:59 CET
This archive was generated by hypermail 2.2.0 : Mon Feb 26 2007 - 23:50:01 CET