// MyPoissonSpekfit.cpp - 20041117 - neue Variante der Fitfunktionen fuer A-Messung // // user Interface zum Spektren fitten, ursprnglich Michael Kreuz // Anpassungen fuer Daniela Mund, A-Messung 2004 // Einfuegen der fuer neue Rootversion benoetigten TApplication // Fehler in Eichfitfunktionen behoben // 2004 10 20 Fitfunktion fuer Fierzterm hinzugefgt, dafuer Eichparameter slope genutzt // Fitfunktionen ausgelagert in fitfun.cpp // #define ROOT //to suppress double variable type definition #include "fitfun.h" // header files // standard include libraries for c++ #include #include #include #include #include #include #include // ROOT libraries #include #include #include #include #include #include #include #include #include #include using namespace std; // externe Variablen TF1 *tfun; // Triggerfunktion TF1 *sp; // Spence-Funktion int FitFlag; void waitForKey(void) { Bool_t done=kFALSE; TTimer *timer = new TTimer("gSystem->ProcessEvents();", 50, kFALSE); char *input; do { timer->TurnOn(); timer->Reset(); input = Getline("Type to continue: "); timer->TurnOff(); // Now usefull stuff with the input! if (input) done=kTRUE; } while (!done); timer->Delete(); return; } Int_t ReadInt(void){ Bool_t done=kFALSE; TTimer *timer = new TTimer("gSystem->ProcessEvents();", 50, kFALSE); Int_t value=-1; do { timer->TurnOn(); timer->Reset(); cin>>value; timer->TurnOff(); // Now usefull stuff with the input! if (value!=-1) done=kTRUE; } while (!done); return value; } int main(void) { TApplication theApp("theApp",NULL,NULL); // Fenster fuer Ergebnisse TCanvas *cfit = new TCanvas("cfit","cfit",1); cfit->cd(); gStyle->SetOptStat(0000000); gStyle->SetOptFit(1100); cfit->SetFillColor(0); cfit->SetGrid(1,1); // Spence-Funktion sp = new TF1("sp","log(1-x)/x",0.,1.); cout<<"Can you hear me?"<SetParNames("konst"); konst->SetParameter(0,0.); // Triggerfunktion tfun=new TF1("tfun",triggerfun,0.,SPEKLEN,2); tfun->SetParNames("p","PE_per_Channel"); // File oeffnen /*Char_t rname[35], rootname[40]; cout << "Name des Files mit dem Spektrum (ohne .root) ---> "; cin >> rname; sprintf(rootname,"%s.root",rname); TFile f(rootname); f.ls();*/ TFile f("TimeCut2.root"); //Histogramm oeffnen /*Char_t hname[40]; cout << "Name des Histogramms ---> "; cin >> hname; TH1F *hist = (TH1F*) f.Get(hname);*/ TH1F *hist = (TH1F*) f.Get("ko1minup0"); hist->Draw(); cfit->Update(); hist->SetXTitle("Channel"); hist->SetAxisRange(0.,500.); hist->SetTitle(""); cfit->Update(); waitForKey(); // Anlegen des Funktions- und der Differenz-Histos TH1F *hdif = (TH1F*)hist->Clone(); hdif->SetName("hdif"); hdif->SetTitle("Spektrum-Funktion"); hdif->SetMinimum(); hdif->SetMaximum(); TH1F *hpdif = (TH1F*) hist->Clone(); hpdif->SetName("hpdif"); hpdif->SetTitle("(Spektrum-Funktion)/Spektrum"); hpdif->SetMinimum(); hpdif->SetMaximum(); TH1F *hfun = (TH1F*) hist->Clone(); hfun->SetName("hfun"); TH1F *hquot = (TH1F*) hpdif->Clone(); hquot->SetName("hquot"); hquot->SetTitle("Spektrum/Funktion"); /*Double_t BinPerPhotoElectron=par[0]; Double_t PhotoElektronen_per_keV=par[1]; Double_t SigmaGaus=par[2]; Double_t sigmaPed=par[3]; Double_t ChannelOffset=par[4]; Double_t biscale=par[5]; Double_t norm=par[6];*/ FitFlag=1; Double_t par[PAR_NUM]={3.,.12,50.,1.,-7.,.4,10.}; TH1F *mySpec=fitspec(par); mySpec->SetLineColor(2); mySpec->Draw("same"); cfit->Update(); waitForKey(); MyFit *newFit=new MyFit(par,FitFlag); /*int lauf=1; while(lauf) { waitForKey(); cout<<"Weitermachen(1/0)?"; cin>>lauf; }*/ return 0; }