histName = calo_init.args.histogramName print("Draw linearity: ", not calo_init.args.noLinearity) from ROOT import gSystem, gROOT, TCanvas, TGraphErrors, TF1, gStyle, kRed, kBlue, kGray, TFile, TTree, TPad from draw_functions import prepare_graph, prepare_second_graph, prepare_single_canvas, prepare_double_canvas, draw_text import numpy from math import sqrt gRes = TGraphErrors() gLin = TGraphErrors() # first get all the resolutions and prepare graphs for ifile, filename in enumerate(calo_init.filenamesIn): energy = calo_init.energy(ifile) f = TFile(filename, "READ") htotal = f.Get(histName) myfunPre = TF1("firstGaus","gaus", htotal.GetMean() - 2. * htotal.GetRMS(), htotal.GetMean() + 2. * htotal.GetRMS()) resultPre = htotal.Fit(myfunPre, "SRQN") myfun = TF1("finalGaus", "gaus", resultPre.Get().Parameter(1) - 2. * resultPre.Get().Parameter(2), resultPre.Get().Parameter(1) + 2. * resultPre.Get().Parameter(2) ) result = htotal.Fit(myfun, "SRQN") resolution = result.Get().Parameter(2) / result.Get().Parameter(1) resolutionErrorSigma = result.Get().Error(2) / result.Get().Parameter(1) resolutionErrorMean = result.Get().Error(1) * result.Get().Parameter(2) / ( result.Get().Parameter(1) ** 2) resolutionError = sqrt( resolutionErrorSigma ** 2 + resolutionErrorMean ** 2 ) linearity = ( result.Get().Parameter(1) - energy ) / energy linearityError = result.Get().Error(1) / energy gRes.SetPoint(ifile, energy, resolution)
#if calo_init.args.bitfieldEcal: # ecalBitfield = calo_init.args.bitfieldEcal #if calo_init.args.bitfieldHcal: # hcalBitfield = calo_init.args.bitfieldHcal from ROOT import gSystem gSystem.Load("libCaloAnalysis") import ROOT as r import numpy as n from draw_functions import draw_1histogram, draw_2histograms, draw_hist2d from export_to_csv import * r.gROOT.SetBatch(True) Energy = float(calo_init.energy(calo_init.filenamesIn)) Et = float(Energy / r.TMath.CosH(0.)) sigma = r.TMath.Sqrt( r.TMath.Power(0.8 * r.TMath.Sqrt(Energy) + 0.02 * (Energy), 2)) etaBinsECal = 40 etaBinsHCal = 20 phiBinsECal = 40 phiBinsHCal = 20 etaMinECal = .2 phiMinECal = .2 etaMin = .25 phiMin = .25 h_etaphiEnergy1 = r.TH2D("h_etaphiEnergy1", "", etaBinsECal, -etaMinECal, etaMinECal, phiBinsECal, -phiMinECal, phiMinECal)
print (legend) from ROOT import gSystem, gROOT, TCanvas, TGraphErrors, TF1, gStyle, kRed, kBlue, kGray, TFile, TTree, TPad, TGaxis, gPad, TLine, kOrange, kGreen, SetOwnership from draw_functions import prepare_histogram, prepare_divided_canvas, prepare_single_canvas, draw_text, draw_1histogram import numpy gStyle.SetOptFit(0) gStyle.SetOptStat(0) colours = [ kRed + 2, 8, kGray + 3 , kOrange + 1 , 8, 9] coloursFit = [kRed, kGreen+2, kGray+3, kOrange + 2 , kGreen + 2, kBlue + 2] if len(calo_init.energies) > 1: print("Plotting of the enrgy distribution can be performed only for one energy value") exit() energy = calo_init.energy(0) canv = prepare_single_canvas( 'energyDistribution_'+str(energy)+'GeV', 'Energy distribution for '+str(energy)+'GeV' ) canv.cd() energy = calo_init.energy(0) resolution_list = [] mean_list = [] # files represent different types for the same particle energy: for ifile, filename in enumerate(calo_init.filenamesIn): f = TFile(filename, "READ") hEn = f.Get(histogramNames[ifile]) hEn.Sumw2() if hEn.GetEntries() > 0: hEn.Scale(1./hEn.GetEntries()) hEn.Rebin(4) hEn.SetTitle('') if calo_init.args.axisMax:
from draw_functions import prepare_histogram, prepare_divided_canvas, prepare_single_canvas, draw_text, draw_1histogram import numpy gStyle.SetOptFit(0) gStyle.SetOptStat(0) colours = [kRed + 2, 8, kGray + 3, kOrange + 1, 8, 9] coloursFit = [kRed, kGreen + 2, kGray + 3, kOrange + 2, kGreen + 2, kBlue + 2] if len(calo_init.energies) > 1: print( "Plotting of the enrgy distribution can be performed only for one energy value" ) exit() energy = calo_init.energy(0) canv = prepare_single_canvas('energyDistribution_' + str(energy) + 'GeV', 'Energy distribution for ' + str(energy) + 'GeV') canv.cd() energy = calo_init.energy(0) resolution_list = [] mean_list = [] # files represent different types for the same particle energy: for ifile, filename in enumerate(calo_init.filenamesIn): f = TFile(filename, "READ") hEn = f.Get(histogramNames[ifile]) hEn.Sumw2() if hEn.GetEntries() > 0: hEn.Scale(1. / hEn.GetEntries()) hEn.Rebin(4) hEn.SetTitle('')