#!/usr/bin/python
# -*- coding: utf-8 -*-

import ROOT
import numpy
from tools import *
from Styles import tdrStyle
from kalibration import *
tdrStyle()

def normedHist( name, color, func = 0):
	if func == 0:
		hist = tkaToHist( name, 2000, 16000 )
		hist.Rebin(50)
	else:
		# let's hope func is a TF1
		hist = tkaToTimeHist(name, func , -2, 8 )
	hist.Scale(1./hist.Integral())
	hist.GetYaxis().SetTitle("Normierte Eintr#ddot{a}ge")
	hist.SetLineColor( color )
	hist.SetMarkerStyle( 23 + color )
	hist.SetMarkerSize( 1.5 )
	hist.SetMarkerColor( color )
	return hist


func = kalibration()
alutime = normedHist( 'data/aluminium.TKA', 3, func )
polytime = normedHist( 'data/poly.TKA', 4, func )
cotime = normedHist( 'data/co60.TKA', 1, func )
#!/usr/bin/python
# -*- coding: utf-8 -*-
from Styles import tdrStyle
style = tdrStyle()
from tools import *
import ROOT

def plotSpectrum():
	'''
	plots the spectrum for data selection in the slow circuit
	'''
	hist = tkaToHist( 'data/auswahl.TKA', 0, 10500 )

	can = ROOT.TCanvas()
	can.cd()
	can.SetLogy()
	can.SetBatch()
	can.SetCanvasSize( 1400, 800 )
	hist.SetMinimum(9)
	hist.Draw()

	grenzkanaele = [ 260, 3630] # richtige kanalnummer rausfinden
	lines = []
	hist.SetYTitle('Eintr#ddot{a}ge')
	hist.Draw()
	for grenzkanal in grenzkanaele:
		line = ROOT.TLine( grenzkanal, hist.GetMinimum(), grenzkanal, hist.GetMaximum() + 7500 )
		line.SetLineStyle(2)
		line.SetLineWidth(2)
		line.Draw()
		lines.append(line)