from os.path import dirname, realpath, sep, pardir
import sys
sys.path.append(dirname(dirname(realpath(__file__))))
import os
os.chdir('../')
print os.getcwd()
from distribsForHNLandBG_byEvent import *

tc = cutsWithDraw()
print tc.nu
print tc.noB
tmu = studies['mumunu']['data']
te = studies['tiny']['data']
geomu = studies['mumunu']['geo']
geoe = studies['tiny']['geo']
zminmu = geomu['Veto_5']['z']['pos']+geomu['Veto_5']['z']['dim']
zmaxmu = geomu['Tr1_1']['z']['pos']-geomu['Tr1_1']['z']['dim']
zmine = geoe['Veto_5']['z']['pos']+geoe['Veto_5']['z']['dim']
zmaxe = geoe['Tr1_1']['z']['pos']-geoe['Tr1_1']['z']['dim']
mucuts = [ tc.recoed()[0], tc.notVetoed(1000.)[0], tc.redChi2(5.)[0], tc.ndf(25)[0], tc.fiducial(zminmu, zmaxmu, 250., 500.)[0], tc.goodtracks()[0], tc.muon1(2)[0], tc.muon2(2)[0], tc.doca(30.)[0] ]
ecuts = [ tc.recoed()[0], tc.notVetoed(1000.)[0], tc.redChi2(5.)[0], tc.ndf(25)[0], tc.fiducial(zmine, zmaxe, 250., 500.)[0], tc.goodtracks()[0], tc.ecal()[0], tc.doca(30.)[0] ]
ntotmu = studies['mumunu']['ntot']
ntote = studies['tiny']['ntot']
r.gStyle.SetOptStat(r.kFALSE)
te.Draw('NoB_IP0>>he', "(weight/%s)*("%(ntote)+str("&&".join([c for c in ecuts]))+ ")", "norm")
r.gStyle.SetOptStat(r.kFALSE)
tmu.Draw('NoB_IP0>>hmu', "(weight/%s)*("%(ntotmu)+str("&&".join([c for c in mucuts]))+ ")", "norm same")
hmu = r.gDirectory.Get('hmu')
hmu.SetLineColor(r.kRed)
hmu.SetMarkerColor(r.kRed)
