[ROOT] Bug in root/cint on Win NT 2.21 & 2.24

From: Stephan Heising (stephan.heising@cern.ch)
Date: Tue Apr 25 2000 - 16:08:24 MEST


Hello

I have a problem with a macro which gives under Win NT 4.0 (sp4) with
Root 2.23/09 an error which is not understandable to me:

The variable definition/declaration is

volatile Int_t iEnd = 0;   or
Int_t iEnd = 0;

During program execution I get the error:

Warning: Re-initialization ignored const iEnd
FILE:H:\LorentzFebruar00\root\lore
ntz\mess00apr\phfit.c LINE:222
*** Interpreter error recovered ***

sometimes I can overcome this by using .L befor .x

the listing of the complete code is attached

Thanks in advance

Stephan Heising



#include <fstream.h>

typedef struct _event
{
  char date[20], time[20];
  char cfib[20];
  Int_t lno;
  Float_t indu;
  Float_t bias;
  Float_t irev;
  Float_t delt;
  Int_t   fiber;
  Float_t pt1, pt2, pt3, pt4, pt5, pt6, pt7;
  Float_t sip, np, bxPHp, bsPHp, bxSNp, bsSNp;
  Float_t sin, nn, bxPHn, bsPHn, bxSNn, bsSNn;
  Float_t *aph, *asn, *anoi, *ax;
  Int_t   nph, nsn, nnoi, nx;
} event;


Double_t fitf (Double_t *x, Double_t *par)
// size of x: 1
// size of par: 4
{
   Double_t fitval;

   if (x[0] < par[1])
      fitval = par[0] * exp (x[0] - par[1]) + par[2];
   else
      fitval = par[2] + par[0] * exp (-.5*((x[0] - par[1])/par[3])**2.);
        
   return fitval;
}


Double_t fitf1 (Double_t *x, Double_t *par)
// size of x: 1
// size of par: 3
{
   Double_t fitval;

   if (x[0] < par[1])
      fitval = par[0] * exp (x[0] - par[1]) + par[2];
   else
      fitval = par[2];

   return fitval;
}

int readev (ifstream& in, event& ev)
{
    in >> ev.date;
    in >> ev.time;
//    cout << ev.date << " " << ev.time << "\n";

    in >> ev.lno;
    in >> ev.indu;
    in >> ev.bias;
    in >> ev.irev;
    in >> ev.delt;
    in >> ev.fiber;

    switch (ev.fiber)
    {
        case 0:
          strcpy (ev.cfib, "SLD ");
          break;
        case 1:
          strcpy (ev.cfib, "p660");
          break;
        case 2:
          strcpy (ev.cfib, "n660");
          break;
        case 3:
          strcpy (ev.cfib, "1060");
          break;
    }

    in >> ev.pt1 >> ev.pt2 >> ev.pt3;
    in >> ev.pt4 >> ev.pt5 >> ev.pt6;
    in >> ev.pt7;

    in >> ev.sip >> ev.np >> ev.bxPHp >> ev.bsPHp >> ev.bxSNp >> ev.bsSNp;  

    in >> ev.sin >> ev.nn >> ev.bxPHn >> ev.bsPHn >> ev.bxSNn >> ev.bsSNn;  

    in >> ev.nph;
    ev.aph = new Float_t[ev.nph];
    for (Int_t i=0;i< ev.nph; i++)
    {
       in >> ev.aph[i];    
    } 

    in >> ev.nsn;
    ev.asn = new Float_t[ev.nsn];
    for (Int_t i=0;i< ev.nsn; i++)
    {
       in >> ev.asn[i];    
    } 

    in >> ev.nnoi;
    ev.anoi = new Float_t[ev.nnoi];
    for (Int_t i=0;i< ev.nnoi; i++)
    {
       in >> ev.anoi[i];    
    } 

    in >> ev.nx;
    ev.ax = new Float_t[ev.nx];
    for (Int_t i=0;i< ev.nx; i++)
    {
       in >> ev.ax[i];    
    } 

    return in.good();
}

int phfit (char *fName, Int_t logi, Int_t logf)
{
  // modified log_rep128a4.c to use C++ streams to read from file.
  // or string
  // PH information is stored in the txt file and analysed.
 
 ifstream in;
 ofstream out;

 in.open(fName, ios::in);
 out.open("out.txt", ios::out);

 Int_t iEnd = 0; 

 char    sDetektor[100], StrTmp[100];
 Float_t aPitchP, pPitchP; // real pitch and barycenter used pitch 
 Float_t aPitchN, pPitchN; // real pitch and barycenter used pitch 
 Float_t pitchConvP;      // factor to convert used to real pitch
 Float_t pitchConvN;      // for P and N side
 Float_t TAdd;           // value to add to temperature for 
                         // displaying both graphs
 Float_t yAdd;           // value to add to x-value (y-axis) 
                         // for displaying

 event ev1;
 
// Set global options for postscript graphics (bw)
//
 gStyle->SetOptFit (0);
 gStyle->SetOptStat (0);
 gStyle->SetCanvasBorderMode(0);
 gStyle->SetPadBorderMode(0);
 gStyle->SetFrameBorderMode(0);
 gStyle->SetPadColor(0);
 gStyle->SetCanvasColor(0);
 gStyle->SetTitleColor(0);
 gStyle->SetTitleW (.9);
 gStyle->SetTitleH (.06);
 gStyle->SetTitleX (.15);
 gStyle->SetTitleY (.97);
 gStyle->SetPaperSize (20, 29);
 gStyle->SetPadLeftMargin (.15);
 gStyle->SetPadRightMargin (.05);
 Int_t  iFound = 0;

 TPad *pTPad;
 TCanvas *cPH = (TCanvas*) gROOT->FindObject ("PH");
 if (cPH == NULL)
 {
    TCanvas *cPH = new TCanvas("PH", "canvas1", 0, 0, 640, 480); 
    TPad *padPH  = new TPad ("padPH", "T vs B Pad", 0, 0, 1, 1);
 }
 else
 { 
    TPad *padPH = (TPad*) gROOT->FindObject ("padPH");
    iFound = 1;
 }

 cPH->Draw ();
 cPH->cd ();
// create histogram to present x vs B data
//

 padPH->Draw ();

 if (iFound == 0)
 {
    TH2F *hrPH = new TH2F ("histPH", "", 2, 8000, 256*50, 2, -50, 50);
    hrPH->SetLabelSize (.04, "X");
    hrPH->SetLabelOffset (.02, "X");
    hrPH->SetLabelSize (.04, "Y");
    hrPH->SetLabelOffset (.025, "Y");
 }
 else
 {
    TH2F *hrPH = (TH2F*) gROOT->FindObject ("histPH");
    hrPH->SetBins (2, 8000, 256*50, 2, -50, 50);
    hrPH->Clear ();
    hrPH->SetLabelSize (.04, "X");
    hrPH->SetLabelOffset (.02, "X");
    hrPH->SetLabelSize (.04, "Y");
    hrPH->SetLabelOffset (.025, "Y");
 }
 padPH->cd ();
 hrPH->Draw ();
 

 Int_t iStart = 0;
 while (iEnd == 0)
 {
    readev(in, ev1);

    out << "\n" << ev1.lno;

    if (ev1.lno == logi)
    {
//       cout << "\n" << ev1.lno;
//       cout << "B=" << ev1.indu << "T|U="<< ev1.bias;
//       cout << " V|f=" << ev1.cfib << "\n"; 
       iStart = 1;
    }

    if (ev1.lno == logf)
    {
       iEnd = 1;        // log found
    }
    if (in.eof ())
       iEnd = 1;
    

    if (iStart != 0)
    {
       Float_t *ErrPh = new Float_t[ev1.nph];
       Float_t *ErrX = new Float_t[ev1.nph];
       Int_t i;
       for (i=0; i<ev1.nph; i++)
       {
          ErrPh[i] = 1000. / (fabs(ev1.aph[i] * ev1.aph[i])+.001);
	  //          ErrPh[i] = 100.;
          ErrX[i] = 30.;
       }
       
       TGraphErrors *gPH = new TGraphErrors (ev1.nph, ev1.ax, ev1.aph);
       gPH->SetMarkerStyle (21);
       gPH->SetMarkerSize (.8);
       gPH->Draw ("L");

       g1    = new TF1("g1","[3]*sin(x*[4]+[5])+[0]*exp(-0.5*((x-[1])/[2])^2)", 1000, 5000);
       g1->SetParameters (10, 2500, 100, 0, 1);
       gPH->Fit ("g1", "RQMI");
       Double_t f1p0 = g1->GetParameter (0);
       Double_t f1p1 = g1->GetParameter (1);
       Double_t f1p2 = g1->GetParameter (2);
       Double_t f1p3 = g1->GetParameter (3);
       Double_t f1p4 = g1->GetParameter (4);
       Double_t f1p5 = g1->GetParameter (5);
       Double_t cp   = g1->GetChisquare ();
       out << " g:" << f1p0 << " " << f1p1 << " " << f1p2;
       out << " | s:" << f1p3 << " " << f1p4 << " " << f1p5;
       out << " | c2 = " << cp;// << "\n";
      

       g2    = new TF1("g2",fitf1, 8000, 12000, 3);
       g2->SetParameters (-300, 10000, -1); //, 100, 1, 1);
       gPH->Fit ("g2", "RMI");
       Double_t f2p0 = g2->GetParameter (0);
       Double_t f2p1 = g2->GetParameter (1);
       Double_t f2p2 = g2->GetParameter (2);
       // Double_t f2p3 = g2->GetParameter (3);
       // Double_t f2p4 = g1->GetParameter (4);
       // Double_t f2p5 = g1->GetParameter (5);
       // Double_t f2p6 = g1->GetParameter (6);
       Double_t cn   = g2->GetChisquare ();

       Double_t x1[1000], y1[1000];
       for (i=0; i<1000; i++)
       {
          x1[i] = 8000 + 4000. / (i+1);
          if (x1[i] < f2p1)
             y1[i] = f2p0 * exp (x1[i] - f2p1) + f1p2;
          else
             y1[i] = f1p2;
       }
       TGraph *gFit = new TGraph (1000, x1, y1);
       gFit->SetMarkerStyle (21);
       gFit->SetMarkerSize (.8);
       gFit->SetLineColor (kRed);
       gFit->SetLineWidth (2);
       gFit->Draw ("LP");

       cout << "e: "  << f2p0 << " " << f2p1 << " | k: " << f2p2;
       cout << " | c2 = " << cn << "\n"; */
    }

 }

 in.close();
 out.close ();

 return (0);
}



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:24 MET