#include "Riostream.h" #include "TFile.h" #include "TH1.h" #include "TNtuple.h" void hist() { ifstream in; in.open(Form("eu_gu_1.dat")); Float_t x,y; Int_t nlines= 0; TFile*f= new TFile("basic.root","RECREATE"); //TH1F *h1 = new TH1F("h1","x distribution",8063,128.5,8191.5); TH1F *h1 = new TH1F("h1","x distribution",3872.,128.5,5000.5); //TH1F *h1 = (TH1F*)f->Get("h1"); TNtuple*ntuple= new TNtuple("ntuple","data from asciifile","x:y"); while (1) { in >> x>> y; if (!in.good()) break; if (nlines< 5) printf("x=%8f, y=%8f",x,y); h1->Fill(x,y); ntuple->Fill(x,y); nlines++; } TF1 *g1= new TF1("g1", "gaus",350.,450.); TF1 *g2 = new TF1 ("g2", "gaus",800.,900.); TF1 *g3 = new TF1 ("g3", "gaus",1142.5,1210.5); TF1 *g4 = new TF1 ("g4", "gaus",1480.,1580.); TF1 *g5 = new TF1 ("g5", "gaus",2600.,2700.); TF1 *g6 = new TF1 ("g6", "gaus",2900.,3000.); TF1 *g7 = new TF1 ("g7", "gaus",3250.,3350.); TF1 *g8 = new TF1 ("g8", "gaus",3750.,3850.); TF1 *g9 = new TF1 ("g9", "gaus",4750.,4850.); //TF1 *total = new TF1("mstotal","gaus(0)+gaus(3)+gaus(6)",128.5,1000.5); g1->SetParameters(5850.,418.,1.75); g2->SetParameters(2000.,840.,1.7); g3->SetParameters(5395.,1178.5,1.7); g4->SetParameters(500.,1525.,1.7); g5->SetParameters(1020.,2660.,1.7); g6->SetParameters(500.,2980.,1.7); g7->SetParameters(1020.,3300.,1.7); g8->SetParameters(820.,3810.,1.7); g9->SetParameters(1020.,4810.,1.7); //total->SetParameters(par[6]); h1->Draw("HIST"); g1->Draw("same"); g2->Draw("same"); g3->Draw("same"); g4->Draw("same"); g5->Draw("same"); g6->Draw("same"); g7->Draw("same"); g8->Draw("same"); g9->Draw("same"); //h1->Fit("func","R"); //func->Draw(); printf("found %dpoints\n",nlines); in.close(); f->Write(); }