diff --git a/.rootrc b/.rootrc index 4e21523d3dbd19181361755bb47ee6109a3be330..20cca0953f13cadb1b7ff9dd007b312e00c085c0 100644 --- a/.rootrc +++ b/.rootrc @@ -1,5 +1,5 @@ -Canvas.ShowEventStatus: true -Canvas.ShowToolTips: true -Canvas.ShowToolBar: true -Canvas.ShowEditor: true +#Canvas.ShowEventStatus: true +#Canvas.ShowToolTips: true +#Canvas.ShowToolBar: true +#Canvas.ShowEditor: true \ No newline at end of file diff --git a/FittingDemo.cxx b/FittingDemo.cxx deleted file mode 100644 index 915a6da0c832a868ccbcf7e5c6ea508d835a182c..0000000000000000000000000000000000000000 --- a/FittingDemo.cxx +++ /dev/null @@ -1,102 +0,0 @@ -//Example for fitting signal/background. -// This example can be executed with: -// root > .x FittingDemo.C (using the CINT interpreter) -// root > .x FittingDemo.C+ (using the native complier via ACLIC) -//Author: Rene Brun - -#include "TH1.h" -#include "TMath.h" -#include "TF1.h" -#include "TLegend.h" -#include "TCanvas.h" - -// Quadratic background function -Double_t background(Double_t *x, Double_t *par) { - return par[0] + par[1]*x[0] + par[2]*x[0]*x[0]; -} - - -// Lorenzian Peak function -Double_t lorentzianPeak(Double_t *x, Double_t *par) { - return (0.5*par[0]*par[1]/TMath::Pi()) / - TMath::Max( 1.e-10,(x[0]-par[2])*(x[0]-par[2]) - + .25*par[1]*par[1]); -} - -// Sum of background and peak function -Double_t fitFunction(Double_t *x, Double_t *par) { - return background(x,par) + lorentzianPeak(x,&par[3]); -} - -void FittingDemo() { - //Bevington Exercise by Peter Malzacher, modified by Rene Brun - - const int nBins = 60; - - Double_t data[nBins] = { 6, 1,10,12, 6,13,23,22,15,21, - 23,26,36,25,27,35,40,44,66,81, - 75,57,48,45,46,41,35,36,53,32, - 40,37,38,31,36,44,42,37,32,32, - 43,44,35,33,33,39,29,41,32,44, - 26,39,29,35,32,21,21,15,25,15}; - TCanvas *c1 = new TCanvas("c1","Fitting Demo",10,10,700,500); - c1->SetFillColor(33); - c1->SetFrameFillColor(41); - c1->SetGrid(); - - TH1F *histo = new TH1F("histo", - "Lorentzian Peak on Quadratic Background",60,0,3); - histo->SetMarkerStyle(21); - histo->SetMarkerSize(0.8); - histo->SetStats(0); - - for(int i=0; i < nBins; i++) histo->SetBinContent(i+1,data[i]); - - // create a TF1 with the range from 0 to 3 and 6 parameters - TF1 *fitFcn = new TF1("fitFcn",fitFunction,0,3,6); - fitFcn->SetNpx(500); - fitFcn->SetLineWidth(4); - fitFcn->SetLineColor(kMagenta); - - // first try without starting values for the parameters - // This defaults to 1 for each param. - // this results in an ok fit for the polynomial function - // however the non-linear part (lorenzian) does not - // respond well. - fitFcn->SetParameters(1,1,1,1,1,1); - histo->Fit("fitFcn","0"); - - // second try: set start values for some parameters - fitFcn->SetParameter(4,0.2); // width - fitFcn->SetParameter(5,1); // peak - - histo->Fit("fitFcn","V+","ep"); - - // improve the picture: - TF1 *backFcn = new TF1("backFcn",background,0,3,3); - backFcn->SetLineColor(kRed); - TF1 *signalFcn = new TF1("signalFcn",lorentzianPeak,0,3,3); - signalFcn->SetLineColor(kBlue); - signalFcn->SetNpx(500); - Double_t par[6]; - - // writes the fit results into the par array - fitFcn->GetParameters(par); - - backFcn->SetParameters(par); - backFcn->Draw("same"); - - signalFcn->SetParameters(&par[3]); - signalFcn->Draw("same"); - - // draw the legend - TLegend *legend=new TLegend(0.6,0.65,0.88,0.85); - legend->SetTextFont(72); - legend->SetTextSize(0.04); - legend->AddEntry(histo,"Data","lpe"); - legend->AddEntry(backFcn,"Background fit","l"); - legend->AddEntry(signalFcn,"Signal fit","l"); - legend->AddEntry(fitFcn,"Global Fit","l"); - legend->Draw(); - -} diff --git a/Li9_007all_1.root b/Li9_007all_1.root new file mode 100644 index 0000000000000000000000000000000000000000..46cd06889f939c2b44a2f26a88af6ab52f76d021 Binary files /dev/null and b/Li9_007all_1.root differ diff --git a/fitting.cxx b/fitting.cxx index ec7e004175c670ffd778a1155e1475bcacb094bb..d01dec4f930e6beac51b81d8e81559b55e443831 100644 --- a/fitting.cxx +++ b/fitting.cxx @@ -12,12 +12,12 @@ void fitting() const Int_t bins = 200; -// TFile *fr = new TFile("simeventsNew.root"); - TFile *fr = new TFile("simeventsNew1.root"); + TFile *fr = new TFile("simeventsNew.root"); +// TFile *fr = new TFile("simeventsNew1.root"); TTree *tr = (TTree*)fr->Get("simevents"); - TCanvas *c1 = new TCanvas("name1", "title of canvas 1"); + TCanvas *c1 = new TCanvas("name1", "title of canvas 1", 0, 0, 950, 700); c1->Divide(2,2); c1->cd(1); @@ -58,7 +58,7 @@ void fitting() total->SetParameters(par); hEtot->Fit(total,"R+"); - TCanvas *c2 = new TCanvas("name2", "title of canvas 2"); + TCanvas *c2 = new TCanvas("name2", "title of canvas 2", 0, 0, 950, 700); c2->Divide(2,2); c2->cd(1); @@ -107,12 +107,12 @@ void fitting() // cout << maxSingle << endl; - TLine *l1 = new TLine(maxSingle, 100., maxSingle, 800.); + TLine *l1 = new TLine(maxSingle, 100., maxSingle, 4500.); l1->SetLineWidth(2); l1->SetLineColor(gHigh->GetLineColor()); l1->Draw(""); - TLine *l2 = new TLine(maxTotal, 100., maxTotal, 800.); + TLine *l2 = new TLine(maxTotal, 100., maxTotal, 4500.); l2->SetLineWidth(2); l2->SetLineColor(total->GetLineColor()); l2->Draw(""); diff --git a/openExpTree.cxx b/openExpTree.cxx new file mode 100644 index 0000000000000000000000000000000000000000..95d3c28be35e319015fe5e7bb073cb376b429386 --- /dev/null +++ b/openExpTree.cxx @@ -0,0 +1,7 @@ +//void openExpTree() +{ + + TFile *fr = new TFile("Li9_007all_1.root"); + TTree *tr = (TTree*)fr->Get("AnalysisxTree"); + +} diff --git a/opentrees.cxx b/opentrees.cxx index f4fac3716bbdad426390680ca133261a43b13a33..29ffdc9705b3a73786fcec35d32bf843a2d7573d 100644 --- a/opentrees.cxx +++ b/opentrees.cxx @@ -7,18 +7,29 @@ void opentrees() { - - -// TFile *fr1 = new TFile("simevents-1.root"); - TFile *fr1 = new TFile("simeventsNew.root"); - TFile *fr2 = new TFile("simevents-2.root"); - TFile *fr = new TFile("simevents.root"); - + TString fName = "simevents.root"; + TString fName1 = "simevents-1.root"; + TString fName2 = "simevents-2.root"; + + //open files + TFile *fr1 = new TFile(fName1.Data()); + if (fr1->IsZombie()) { + Error("opentrees", "File %s not found.", fName1.Data()); + return; + } + TFile *fr2 = new TFile(fName2.Data()); + TFile *fr = new TFile(fName.Data()); + + //get trees TTree *tr1 = (TTree*)fr1->Get("simevents"); TTree *tr2 = (TTree*)fr2->Get("simevents"); TTree *tr = (TTree*)fr->Get("simevents"); - TCanvas *c1 = new TCanvas("name1", "title of canvas"); + + //first Canvas + TCanvas *c1 = new TCanvas(); + // TCanvas *c1 = new TCanvas("name1", "title of canvas"); + // TCanvas *c1 = new TCanvas("name1", "title of canvas", 0, 0, 950, 700); c1->Divide(2,2); c1->cd(1); @@ -38,105 +49,4 @@ void opentrees() tr2->SetLineColor(kBlue); tr2->Draw("E", "E>0", "same"); - TCanvas *c2 = new TCanvas("name2", "title of canvas"); - c2->Divide(2,2); - - c2->cd(1); - tr->Draw("E", "E>0.95"); - TH1F *h = (TH1F*)gPad->GetPrimitive("htemp"); - - c2->cd(2); -// fr.cd(); - TH1F *hE = new TH1F("hE", "histogram title", 100, 0.95, 1.4); - hE->Draw(); - tr->Draw("E >> hE", "", ""); - - TF1 *g1 = new TF1("m1","gaus",1.,1.15); - TF1 *g2 = new TF1("m2","gaus",1.2,1.3); - // The total is the sum of the three, each has 3 parameters - TF1 *total = new TF1("mstotal","gaus(0)+gaus(3)",1.,1.3); - - - Double_t par[6]; - - // Fit each function and add it to the list of functions - hE->Fit(g1,"R"); - hE->Fit(g2,"R+"); - - - c2->cd(3); - TH1F *hEtot = new TH1F("hEtot", "histogram title", 100, 0.95, 1.4); - hEtot->Draw(); - tr->Draw("E >> hEtot", "", ""); - // Get the parameters from the fit - g1->GetParameters(&par[0]); - g2->GetParameters(&par[3]); - - // Use the parameters on the sum - total->SetParameters(par); - hEtot->Fit(total,"R+"); - - TCanvas *c3 = new TCanvas("name3", "title of canvas 3"); - c3->Divide(2,2); - - c3->cd(1); - tr1->Draw("E", "E>0.95"); -// TH1F *h = (TH1F*)gPad->GetPrimitive("htemp"); - - c3->cd(2); - // fr.cd(); - TH1F *hE1 = new TH1F("hE1", "histogram title", 100, 0.95, 1.4); - hE1->Draw(); - tr1->Draw("E >> hE1", "", ""); - - TF1 *g11 = new TF1("m11","gaus",1.,1.15); - TF1 *g21 = new TF1("m21","gaus",1.2,1.3); - // The total is the sum of the three, each has 3 parameters - TF1 *total1 = new TF1("mstotal1","gaus(0)+gaus(3)",1.,1.3); - - - Double_t par1[6]; - - // Fit each function and add it to the list of functions - hE1->Fit(g11,"R"); - hE1->Fit(g21,"R+"); - - - c3->cd(3); - TH1F *hEtot1 = new TH1F("hEtot1", "histogram title", 100, 0.95, 1.4); - hEtot1->Draw(); - tr1->Draw("E >> hEtot1", "", ""); - // Get the parameters from the fit - g11->GetParameters(&par1[0]); - g21->GetParameters(&par1[3]); - - // Use the parameters on the sum - total1->SetParameters(par1); - hEtot1->Fit(total1,"R+"); - - - c3->cd(4); - TH1F *hEtot11 = new TH1F("hEtot11", "histogram title", 100, 0.95, 1.4); - tr1->Draw("E >> hEtot11", "", ""); - - Double_t par12[6]; - total1->GetParameters(&par12[0]); - TF1 *gLow = new TF1("mLow","gaus",0.95,1.2); - TF1 *gHigh = new TF1("mHigh","gaus",1.0,1.4); - gHigh->SetLineColor(kGreen); - - gLow->SetParameter(0, par12[0]); - gLow->SetParameter(1, par12[1]); - gLow->SetParameter(2, par12[2]); - - gHigh->SetParameter(0, par12[3]); - gHigh->SetParameter(1, par12[4]); - gHigh->SetParameter(2, par12[5]); - - gLow->Draw("same"); - gHigh->Draw("same"); - - - - } diff --git a/rootlogon.C b/rootlogon.C index 7af786bd449607673159949f6e08e5000275e8c4..6df914f61f6658d01cd84b0f47f94aade9f82ced 100644 --- a/rootlogon.C +++ b/rootlogon.C @@ -1,5 +1,7 @@ void rootlogon() { + return; + Info("rootlogon.c", "This settings are used to make large canvases"); // return; @@ -98,11 +100,6 @@ void rootlogon() { gStyle->SetPadBottomMargin(0.13); gStyle->SetPadLeftMargin(0.14); gStyle->SetPadRightMargin(0.05); - gStyle->SetTitleOffset(1.3, "Y"); - gStyle->SetLabelSize(0.05, "X"); - gStyle->SetLabelSize(0.05, "Y"); - gStyle->SetTitleSize(0.06, "X"); - gStyle->SetTitleSize(0.06, "Y"); // gStyle->SetAxisColor(1); diff --git a/simevents-1.root b/simevents-1.root new file mode 100644 index 0000000000000000000000000000000000000000..eb98bc8c0046763d37266a26087a9af98da216c8 Binary files /dev/null and b/simevents-1.root differ diff --git a/simevents-2.root b/simevents-2.root new file mode 100644 index 0000000000000000000000000000000000000000..a435c56f5e4730638b989c35427ebad572f48d66 Binary files /dev/null and b/simevents-2.root differ diff --git a/simevents.root b/simevents.root new file mode 100644 index 0000000000000000000000000000000000000000..482b9b2bd93f8ffcf35bddb9be1c2df5775e2ccd Binary files /dev/null and b/simevents.root differ diff --git a/simeventsNew.root b/simeventsNew.root new file mode 100644 index 0000000000000000000000000000000000000000..c45895322c1bccfc4b1108ed557409b452fd97a8 Binary files /dev/null and b/simeventsNew.root differ diff --git a/simeventsNew1.root b/simeventsNew1.root new file mode 100644 index 0000000000000000000000000000000000000000..26aeb36f024616ab57812f7e3b60116f771f3b06 Binary files /dev/null and b/simeventsNew1.root differ