#!/usr/bin/python

from michel_spectrum import *
from ROOT import *

def makegstyle(cStyle):
    cStyle.SetPadBorderMode(0)
    cStyle.SetOptStat(0)	   ## Hide stats
    cStyle.SetOptTitle(1)	   ## Display histogram titles.
    cStyle.SetCanvasColor(10)	   ## Background color (white)
    cStyle.SetPadColor(10)	   ## Background color (white)
    cStyle.SetFillColor(10)	   ## Background color (white)
    cStyle.SetTitleFillColor(10)   ## Background color (white)
    cStyle.SetStatColor(10)	   ## Background color (white)
    cStyle.SetPalette(1)	   ## Nicer colour scale for 2D histograms.  
    cStyle.SetTitleBorderSize(0)   ##duh
    return cStyle

def call_ms(x,p):
    if p[1] == 0.:
        return michel_spectrum(x,p[0],{'rho':0.75,'eta':0.0,'xi':1.0,'delta':0.75},'base')
    elif p[1] == 1.:
        return michel_spectrum(x,p[0],{'rho':0.75,'eta':0.0,'xi':1.0,'delta':0.75},'all')
    elif p[1] == 2.:
        return michel_spectrum(x,p[0],{'rho':0.75,'eta':0.0,'xi':1.0,'delta':0.75},'oa')
    else:
        return None

if __name__ == '__main__':

    # make a list of TF1s
    specs = ['base','all','oa']
    TF1s = []
    for spec_type in [0,1,2]: ##base,all,oa
        for cos_theta in [ -1., 0., 1.]:
            TF1_name = specs[spec_type]+'_cos_theta_'+str(cos_theta)
#            new_TF1 = TF1(TF1_name,call_ms,0.,0.995,2)
            new_TF1 = TF1(TF1_name,call_ms,0.,1.01,2)
            new_TF1.SetParameter(0,cos_theta)
            new_TF1.SetParameter(1,float(spec_type))
            TF1s.append(new_TF1)
    
    # and draw them
    gStyle = makegstyle(gStyle)
    gStyle.SetOptTitle(0)
    c = TCanvas()
    TF1s[0].SetMaximum(2.)
    TF1s[0].SetLineStyle(2)
    TF1s[0].Draw()
    for t in TF1s[1:3]:
        t.SetLineStyle(2)
        t.Draw('same')
    for t in TF1s[3:6]:
        t.Draw('same')
    for t in TF1s[6:]:
        t.SetLineColor(4)
        t.Draw('same')

    l = TLegend(0.8,0.8,0.9,0.9)
    l.SetBorderSize(0)
    l.AddEntry(TF1s[0],'tf1s0','l')
    l.AddEntry(TF1s[3],'tf1s3','l')
    l.AddEntry(TF1s[3],'tf1s6','l')
    l.Draw()
    
    au = raw_input('>')