ATLAS Offline Software
get_cutMap.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 # Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
4 import os, sys, re
5 from ROOT import *
6 # from rootUtil import useAtlasStyle, waitRootCmd, savehistory, get_default_fig_dir
7 
8 funlist=[]
9 
10 def waitNext(savename='temp', pad=gPad):
11  while True:
12  c = raw_input('Next:')
13  if c=='q': sys.exit(0)
14  elif c=='s':
15  pad.SaveAs(savename+'.pdf')
16  pad.SaveAs(savename+'.eps')
17  pad.SaveAs(savename+'.png')
18  elif c=='n':
19  return
20  else:
21  print "'q' to quit\n's' to save\n'n' for next"
22 
23 
24 def showCutMap(var, effFun, sTag='test'):
25  dir0 = '/cvmfs/atlas.cern.ch/repo/sw/database/GroupData/'
26  print dir0
27  f1 = TFile(dir0+'IsolationSelection/v2/MC15_Z_Jpsi_cutMap.root','read')
28  h1 = f1.Get('Muons/DFCommonGoodMuon/mu_cutValues_'+var)
29  h1.GetZaxis().SetRangeUser(99,99)
30  h1_xy = h1.Project3D('xy')
31  h1_xy.GetXaxis().SetTitle(h1_xy.GetXaxis().GetTitle().replace('eta','#eta'))
32 
33 # h1_xy.Draw('colz')
34 
35  h1_xy.Reset()
36  h1_eff = h1_xy.Clone(h1_xy.GetName()+'_eff')
37  fun1 = TF1('fun1', effFun, 0.0, 1000.0)
38  for ix in range(h1_xy.GetNbinsX()+2):
39  for iy in range(h1_xy.GetNbinsY()+2):
40  pt = h1_xy.GetYaxis().GetBinCenter(iy)
41  print pt,min(int(fun1.Eval(pt)),99),0.1*pt+90
42  h1_xy.SetBinContent(ix,iy,h1.GetBinContent(iy,ix, min(int(fun1.Eval(pt)), 99)))
43  h1_eff.SetBinContent(ix,iy, min(int(fun1.Eval(pt)),99))
44 
45  h1_eff.Draw('colz')
46  gPad.Update()
47  waitNext(sTag+'_eff')
48 # waitRootCmd(sTag+'_eff')
49  h1_xy.Draw('colztext')
50  lt = TLatex()
51  lt.DrawLatexNDC(0.25,0.95,var+', #epsilon='+effFun.replace('x','p_{T}')+' [%]')
52 
53  gPad.Update()
54  waitNext(sTag+'_cuts')
55 # waitRootCmd(sTag+'_cuts')
56 
57 def test():
58  dir1 = './'
59 # dir1 = get_default_fig_dir()
60 
61 # showCutMap('ptvarcone30', '99', dir1+'LooseTrackOnlyIso_ptvarcone30')
62 #
63 # showCutMap('topoetcone20', '99', dir1+'LooseIso_topoetcone20')
64  showCutMap('topoetcone20', '96', dir1+'TightIso_topoetcone20')
65 #
66 # showCutMap('ptvarcone30', '96', dir1+'TightIso_ptvarcone30')
67 #
68 # showCutMap('topoetcone20', '0.1143*x+92.14', dir1+'GradientIso_topoetcone20')
69 # showCutMap('ptvarcone30', '0.1143*x+92.14', dir1+'GradientIso_ptvarcone30')
70 
71 # showCutMap('topoetcone20', '0.057*x+95.57', dir1+'GradientLooseIso_topoetcone20')
72 # showCutMap('ptvarcone30', '0.057*x+95.57', dir1+'GradientLooseIso_ptvarcone30')
73 
74 funlist.append(test)
75 
76 if __name__ == '__main__':
77 # savehistory('.')
78 # useAtlasStyle()
79  gStyle.SetPadRightMargin(0.14)
80  gStyle.SetPadTopMargin(0.06)
81  gStyle.SetPaintTextFormat('.2f');
82  gStyle.SetOptTitle(0)
83  gStyle.SetOptStat(0)
84  for fun in funlist: print fun()
replace
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition: hcg.cxx:307
generateReferenceFile.fun
fun
Definition: generateReferenceFile.py:18
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
get_cutMap.waitNext
def waitNext(savename='temp', pad=gPad)
Definition: get_cutMap.py:10
python.LArMinBiasAlgConfig.int
int
Definition: LArMinBiasAlgConfig.py:59
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
get_cutMap.test
def test()
Definition: get_cutMap.py:57
get_cutMap.showCutMap
def showCutMap(var, effFun, sTag='test')
Definition: get_cutMap.py:24