#define invm_cxx #include "invm.h" #include "TH2.h" #include "TStyle.h" #include "TCanvas.h" #include #include "TCanvas.h" //<=========================== using namespace std; #include "TMatrixD.h" void invm::Loop() {// invm loop starts Double_t PI = 3.1428571428571 ; cout << " PI " << PI << endl; Double_t twoPI = 2*PI ; cout << " twoPI " << twoPI << endl; ///// Defining Histogram Array..... /////////////// TH1F *Dca[8]; Dca[0] = new TH1F("Dca_0","dca distribution: no correction:-40GetEntries()); Int_t nbytes = 0; Int_t nb = 0; ////////////// Event loop start here for(Int_t ev=0 ; ev < nentries ; ev++ ) {//first event loop start with ev = 0 if(LoadTree(ev) < 0) break; nb = fChain->GetEntry(ev); nbytes += nb; if(ev%100==0)cout<zbin[i] && zvalFill(dca);// here filling histogram } } } //////// ******* PROBLEM PART ***************** ///////////////////////////////// /////// defining variables for fitting Double_t chisq=0.0, ndf=0.0 ; Double_t sigma=0.0, errsigma=0.0; for(Int_t i=0; i<8; i++) { // here i am doing fitting gausfit(Dca[i],sigma,errsigma,chisq,ndf); Sigdca [i] = sigma ; Errsigdca[i] = errsigma ; Chisq_1a[i] = chisq; Ndf_1a[i] = ndf ; } // it works of first histogram, then it fails //after first fitting it gives following error message //--------------------------------------------------------- //: created default TCanvas with name c1 // *** Break *** segmentation violation // Root > Function gausfit() busy flag cleared // Function Loop() busy flag cleared //--------------------------------------------------------- /////// *************************************************** //////////////////// /////////////// writing histogram in file TFile *out = new TFile("example_avd.root","RECREATE"); out->Clear(); //////////// set line color of histo Dca_0->SetLineColor(3); Dca_1->SetLineColor(3); Dca_2->SetLineColor(3); Dca_3->SetLineColor(3); Dca_4->SetLineColor(3); Dca_5->SetLineColor(3); Dca_6->SetLineColor(3); Dca_7->SetLineColor(3); ////////////////// write histo on root file Dca_0->Write(); Dca_1->Write(); Dca_2->Write(); Dca_3->Write(); Dca_4->Write(); Dca_5->Write(); Dca_6->Write(); Dca_7->Write(); out->Close(); }