Hi All,
I am having a segmantation violation error when I run my code on Solaris
as:
----------------------------8<------------------------------
root [0] .x tree_fit.C
Enter the file name:id827.root
FCN=0 FROM MIGRAD STATUS=CONVERGED 299 CALLS 300 TOTAL
EDM=0 STRATEGY= 1 ERROR MATRIX UNCERTAINTY 100.0
per cent
EXT PARAMETER APPROXIMATE STEP FIRST
NO. NAME VALUE ERROR SIZE DERIVATIVE
1 Const 1.00000e+02 1.41421e+00 0.00000e+00 0.00000e+00
2 Slope 0.00000e+00 1.41421e+00 0.00000e+00 0.00000e+00
3 Curvature 0.00000e+00 1.41421e+00 0.00000e+00 0.00000e+00
4 Ampl 1.50000e+02 1.41421e+00 0.00000e+00 0.00000e+00
5 Mean_value 2.28000e+00 1.41421e+00 0.00000e+00 0.00000e+00
6 Sigma 5.00000e-02 1.41421e+00 0.00000e+00 0.00000e+00
<TCanvas::MakeDefCanvas>: created default TCanvas with name c1
Integral of function = 1761.54
PostScript file: ID400.eps has been created
*** Break *** bus error
*** Break *** segmentation violation
-----------------------8<--------------------------------
whereas the SAME code runs on SGI runs without any problem and do what
it is supposed to do. the root version is 2.25 on Solaris and 2.23 on
SGI. Can anyone have any comment/idea/suggestion to this problem?
ps: at the attachment you can find the code , which basically opens an
ntuple and is supposed to do some fits etc...
regards
sedat
***************
Ahmet Sedat Ayan
Physics & Astronomy Dept.
Van Allen Hall
University of Iowa
Iowa City, IA, 52242
Voice : (++ 1 319) 335-2832 (W) (GMT-6)
Occupation : Ph.D Candidate (But still dreamer!)
e-mail : ayan@cms.physics.uiowa.edu
web : http://home.cern.ch/ayan
//
// The script to read an ntuple type tree and extract parameters of the ntuple
// creating and fitting a histogram. Use it as an example to solve your own needs
// To run it use the command
// root> .x tree_fit.C
//
#include "TROOT.h"
#include "TFile.h"
#include "TNtuple.h"
#include "TRandom.h"
#include "TH1.h"
#include "TF1.h"
#include <iostream.h>
#include <stdio.h>
#include "TTree.h"
#include "TBranch.h"
#include "TCanvas.h"
typedef struct {
Float_t run; // run number
Float_t event; // event number
Float_t ID; // recon ID
// beam track
Float_t X0b; // x0 in vertex spectrometer
Float_t Y0b; // y0 in vertex spectrometer.
Float_t Pxb; // Beam track momenta
Float_t Pyb;
Float_t Pzb;
Float_t Pidb; // Pid of the beam
//
// Primary vertex
Float_t Xp; // Primary vertex coordinates
Float_t Yp;
Float_t Zp;
Float_t SXp; // and errors
Float_t SYp;
Float_t SZp;
Float_t Pchi; // chi2 of the vertex
Float_t Pnf; // number of tracks in fit
Float_t Pnt; // number of tracks
//
// secondary vertex (1st secondary)
Float_t Pxs;
Float_t Pys;
Float_t Pzs;
Float_t Es; // coordinates
Float_t Xs;
Float_t Ys;
Float_t Zs;
Float_t Sxs; // errors
Float_t Sys;
Float_t Szs;
Float_t Schi; // Chi2 of the vertex
Float_t Isol; // vertex isolation dist.
//
// reconstruction information
Float_t tgt; // target number of the primary interaction
Float_t nt; // number of tracks in the reconstruction
Float_t ns; // number of secondary vertexes
Float_t Xf; // Xf of the recon. if possible
Float_t Pt; // Pt of the recon. if possible
Float_t L; // L - dist. from primary inter. to the secondary vert.
Float_t S; // error in L
Float_t LoS; // L:S their ratio
Float_t pvtx; // point back reduced chi-squared
Float_t smin; // second to max. misdistance
Float_t scut;
Float_t mass; // mass of the recon. particle
//
// secondary vertex track information
//
Float_t X0t1; // first track parameters
Float_t Y0t1; // x0,y0 in vertex spectrometer
Float_t Pxt1; // momenta components
Float_t Pyt1;
Float_t Pzt1;
Float_t chit1; // chi2 of the track
Float_t masst1; // mass of the suggested particle
Float_t pidt1; // pid of the suggested particle
//
Float_t X0t2; // second track parameters
Float_t Y0t2; // x0,y0 in vertex spectrometer
Float_t Pxt2; // momenta components
Float_t Pyt2;
Float_t Pzt2;
Float_t chit2; // chi2 of the track
Float_t masst2; // mass of the suggested particle
Float_t pidt2; // pid of the suggested particle
//
Float_t X0t3; // third track parameters
Float_t Y0t3; // x0,y0 in vertex spectrometer
Float_t Pxt3; // momenta components
Float_t Pyt3;
Float_t Pzt3;
Float_t chit3; // chi2 of the track
Float_t masst3; // mass of the suggested particle
Float_t pidt3; // pid of the suggested particle
//
Float_t X0t4; // fourth track parameters
Float_t Y0t4; // x0,y0 in vertex spectrometer
Float_t Pxt4; // momenta components
Float_t Pyt4;
Float_t Pzt4;
Float_t chit4; // chi2 of the track
Float_t masst4; // mass of the suggested particle
Float_t pidt4; // pid of the suggested particle
} RNtup;
Double_t par[6];
Double_t x[1];
// Define background function
Double_t backg(Double_t *x, Double_t *par)
{
return par[0] + par[1]*x[0] + par[2]*x[0]*x[0];
}
// Define gaussian peak function
Double_t g1(Double_t *x, Double_t *par)
{
Double_t arg = 0.;
if (par[2]) arg = (x[0]-par[1])/par[2];
return par[0]*TMath::Exp(-0.5*arg*arg);
}
Double_t FitFunc(Double_t *x, Double_t *par)
{
return backg(x,par) + g1(x,&par[3]);
}
void tree_fit()
{
char hfile[128];
cout<<" Enter the file name:";
cin>>hfile;
cout<<endl;
TFile *f = new TFile(hfile,"READ");
TTree *ntuple = (TTree* )f->Get("tuple"); // tuple is the name of the tree
RNtup NT;
TH1F *hM = new TH1F("hM", "Mass of Lc",60,2.0,2.6);
hM->SetFillColor(2);
hM->SetMarkerStyle(21);
ntuple->SetBranchAddress("RN",&NT.run); // RN is a name of the branch as
// it was created
//
// Data processing loop. Here you can put any calculations you want
// and fill any histograms you want
//
Int_t nentries = (Int_t)ntuple->GetEntries();
for (Int_t i=0;i<nentries;i++) {
ntuple->GetEntry(i);
if (NT.scut>5.){
hM->Fill(NT.mass);
}
}
//
// Now lets fit the histogram
//
Double_t chan = 0.6/60.; // The channel width for evaluation of the signal
// Create fitting function in the range 2.2 2.4
TF1 *fitF = new TF1("FitF",FitFunc,2.1,2.4,6);
// Set initial parameters
fitF->SetParameters(100.,0.,0.,150.,2.28,0.05);
fitF->SetParNames("Const","Slope","Curvature","Ampl","Mean_value","Sigma");
hM->Fit("FitF","r");
//
// Now make an output of the results
//
TCanvas *c1 = new TCanvas("c1","Lc mass",600,800);
c1->Divide(1,2);
c1->cd(1);
hM->Draw();
c1->cd(2);
hM->SetFillColor(0);
hM->Draw();
// improve the picture:
TF1 *backFcn = new TF1("backFcn",backg,2.2,2.4,3);
backFcn->SetLineColor(3);
TF1 *signalFcn = new TF1("signalFcn",g1,2.2,2.4,3);
signalFcn->SetLineColor(4);
Double_t par[6];
// writes the fit results into the par array
fitF->GetParameters(par);
backFcn->SetParameters(par);
backFcn->Draw("same");
signalFcn->SetParameters(&par[3]);
signalFcn->Draw("same");
printf("Integral of function = %g\n",(signalFcn->Integral(2.2,2.4))/chan);
//
hM->SetLineColor(2);
c1->Print("ID400.eps");
}
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:43 MET