CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Functions | Variables
compare Namespace Reference

Functions

def ensureDir
 
def hoverlay
 
def LegendSettings
 
def makeCompareVars
 
def makeEffPlotsVars
 
def overlay
 
def save
 

Variables

tuple argc = len(argvs)
 
 argvs = sys.argv
 
string den_sel = '1'
 
tuple hist = TH1F('h_' + hname + '_' + rel, 'h_' + hname + '_' + rel, hdict['nbin'], hdict['min'], hdict['max'])
 
list hists = []
 
dictionary hvardict
 
string loose_id = 'tau_decayModeFindingOldDMs > 0.5 && tau_byLooseCombinedIsolationDeltaBetaCorr3Hits > 0.5'
 
 num_sel = reco_cut
 
string reco_cut = 'tau_pt > 20 && abs(tau_eta) < 2.3'
 
list runtype = argvs[1]
 
dictionary sampledict
 
tuple tfile = TFile(rdict['file'])
 
string tlabel = 'Z #rightarrow #tau#tau'
 
tuple tree = tfile.Get('per_tau')
 
dictionary vardict
 
string xlabel = 'gen. tau p_{T}^{vis} (GeV)'
 

Function Documentation

def compare.ensureDir (   directory)

Definition at line 43 of file compare.py.

Referenced by save().

43 
44 def ensureDir(directory):
45  if not os.path.exists(directory):
46  os.makedirs(directory)
def ensureDir
Definition: compare.py:43
def compare.hoverlay (   hists,
  xtitle,
  ytitle,
  name 
)

Definition at line 195 of file compare.py.

References LegendSettings(), and save().

196 def hoverlay(hists, xtitle, ytitle, name):
197 
198  c = TCanvas()
199 
200  ymax = 0
201  for hist in hists:
202  if ymax < hist.GetMaximum():
203  ymax = hist.GetMaximum()
204 
205 
206  leg = TLegend(0.6,0.65,0.91,0.9)
207  LegendSettings(leg,1)
208 
209  for ii, ihist in enumerate(hists):
210  ihist.SetMaximum(ymax*1.2)
211  ihist.SetMinimum(0.)
212  ihist.SetMarkerSize(0.)
213  ihist.GetXaxis().SetTitle(xtitle)
214  ihist.GetYaxis().SetTitle(ytitle)
215 
216  if ii ==0:
217  ihist.Draw('h')
218  else:
219  ihist.Draw('hsame')
220 
221  leg.AddEntry(ihist, ihist.GetName(), "l")
222 
223 
224  leg.Draw()
225 
226 
227  save(c, 'compare_' + runtype + '/hist_' + name)
228 
229 
230 
def hoverlay
Definition: compare.py:195
def save
Definition: compare.py:47
def LegendSettings
Definition: compare.py:53
def compare.LegendSettings (   leg,
  ncolumn 
)

Definition at line 53 of file compare.py.

Referenced by hoverlay(), makeCompareVars(), and overlay().

53 
54 def LegendSettings(leg, ncolumn):
55  leg.SetNColumns(ncolumn)
56  leg.SetBorderSize(0)
57  leg.SetFillColor(10)
58  leg.SetLineColor(0)
59  leg.SetFillStyle(0)
60  leg.SetTextSize(0.03)
61  leg.SetTextFont(42)
62 
63 
def LegendSettings
Definition: compare.py:53
def compare.makeCompareVars (   tree,
  var,
  sel,
  leglist,
  nbin,
  xmin,
  xmax,
  xtitle,
  ytitle,
  scale,
  name 
)

Definition at line 64 of file compare.py.

References LegendSettings(), and str.

64 
65 def makeCompareVars(tree, var, sel, leglist, nbin, xmin, xmax, xtitle, ytitle, scale, name):
66 
67 # print leglist
68 
69  c = TCanvas()
70 
71  hists = []
72  col = [1,2,4,8,6]
73  ymax = 0
74 
75  for ii, isel in enumerate(sel):
76  hist = TH1F('h_' + str(ii), 'h_' + str(ii), nbin, xmin, xmax)
77  hist.GetXaxis().SetTitle(xtitle)
78  hist.GetYaxis().SetTitle(ytitle)
79  hist.GetYaxis().SetNdivisions(507)
80  hist.SetLineColor(col[ii])
81  hist.SetLineWidth(len(sel)+1-ii)
82  hist.SetLineStyle(1)
83  hist.SetMarkerSize(0)
84  hist.SetMinimum(0)
85  hist.Sumw2()
86 
87 # print hist.GetName(), var, isel
88  tree.Project(hist.GetName(), var, isel)
89  hist.Scale(1./hist.GetEntries())
90 
91  if ymax < hist.GetMaximum():
92  ymax = hist.GetMaximum()
93 
94  hists.append(hist)
95 
96 
97  leg = TLegend(0.6,0.65,0.91,0.9)
98  LegendSettings(leg,1)
99 
100  for ii, ihist in enumerate(hists):
101  ihist.SetMaximum(ymax*1.2)
102  ihist.SetMinimum(0.)
103 
104  if ii ==0:
105  ihist.Draw('h')
106  else:
107  ihist.Draw('hsame')
108 
109  if leglist[ii] != 'None':
110  leg.AddEntry(ihist, leglist[ii], "l")
111 
112 
113  if leglist[0]!='None':
114  leg.Draw()
115 
116 
117 # save(c, 'compare_' + runtype + '/compare_' + name)
118 
119 
120 
121 
def makeCompareVars
Definition: compare.py:64
def LegendSettings
Definition: compare.py:53
#define str(s)
def compare.makeEffPlotsVars (   tree,
  varx,
  vary,
  sel,
  nbinx,
  xmin,
  xmax,
  nbiny,
  ymin,
  ymax,
  xtitle,
  ytitle,
  leglabel = None,
  header = '',
  addon = '',
  option = 'pt',
  marker = 20 
)

Definition at line 231 of file compare.py.

References mps_check.array.

232 def makeEffPlotsVars(tree, varx, vary, sel, nbinx, xmin, xmax, nbiny, ymin, ymax, xtitle, ytitle, leglabel = None, header='', addon='', option='pt', marker=20):
233 
234  binning = [20,30,40,50,60,70,80,100,150,200]
235 
236  c = TCanvas()
237 
238  if option=='pt':
239  _hist_ = TH1F('h_effp_' + addon, 'h_effp' + addon, len(binning)-1, array('d',binning))
240  _ahist_ = TH1F('ah_effp_' + addon, 'ah_effp' + addon, len(binning)-1, array('d',binning))
241  elif option=='eta':
242  _hist_ = TH1F('h_effp_' + addon, 'h_effp' + addon, nbinx, xmin, xmax)
243  _ahist_ = TH1F('ah_effp_' + addon, 'ah_effp' + addon, nbinx, xmin, xmax)
244  elif option=='nvtx':
245  _hist_ = TH1F('h_effp_' + addon, 'h_effp' + addon, len(vbinning)-1, array('d',vbinning))
246  _ahist_ = TH1F('ah_effp_' + addon, 'ah_effp' + addon, len(vbinning)-1, array('d',vbinning))
247 
248 
249  tree.Draw(varx + ' >> ' + _hist_.GetName(), sel)
250  tree.Draw(varx + ' >> ' + _ahist_.GetName(), sel + ' && ' + vary)
251 
252  g_efficiency = TGraphAsymmErrors()
253  g_efficiency.BayesDivide(_ahist_, _hist_)
254  g_efficiency.GetXaxis().SetTitle(xtitle)
255  g_efficiency.GetYaxis().SetTitle('efficiency')
256  g_efficiency.GetYaxis().SetNdivisions(507)
257  g_efficiency.SetLineWidth(3)
258  g_efficiency.SetName(header)
259  g_efficiency.SetMinimum(0.)
260  g_efficiency.GetYaxis().SetTitleOffset(1.3)
261  g_efficiency.SetMarkerStyle(marker)
262  g_efficiency.SetMarkerSize(1)
263  g_efficiency.Draw('ap')
264 
265 # save(c, 'plots/' + addon)
266 
267  return copy.deepcopy(g_efficiency)
268 
269 
270 
271 
tuple array
Definition: mps_check.py:216
def makeEffPlotsVars
Definition: compare.py:231
def compare.overlay (   hists,
  ytitle,
  header,
  addon 
)

Definition at line 122 of file compare.py.

References LegendSettings(), print(), sistrip::SpyUtilities.range(), and save().

Referenced by FWCaloTowerDetailView.build(), FWMuonDetailView.build(), FWPhotonDetailView.build(), FWElectronDetailView.build(), and SiStripHitEffFromCalibTree.makeSummary().

123 def overlay(hists, ytitle, header, addon):
124 
125  print('number of histograms = ', len(hists))
126 
127  canvas = TCanvas()
128  leg = TLegend(0.2,0.7,0.5,0.9)
129  LegendSettings(leg, 1)
130 
131  col = [1,2,4,6,8,9,12]
132 
133  ymax = -1
134  ymin = 100
135 
136  for ii, hist in enumerate(hists):
137  hist.GetYaxis().SetTitle('efficiency')
138  hist.SetLineColor(col[ii])
139  hist.SetMarkerColor(col[ii])
140  hist.SetLineWidth(2)
141  hist.SetMarkerSize(1)
142 
143 
144  for ip in range(hist.GetN()):
145  x = Double(-1)
146  y = Double(-1)
147  hist.GetPoint(ip, x, y)
148 
149  if ymin > y:
150  ymin = y
151  if ymax < y:
152  ymax = y
153 
154 #
155 # if ymax < hist.GetMaximum():
156 # ymax = hist.GetMaximum()
157 # if ymin > hist.GetMinimum():
158 # ymin = hist.GetMinimum()
159 
160  if ii==0:
161  hist.Draw("Azp")
162  else:
163 
164  hist.Draw("pzsame")
165 
166 # print hist.GetName(), hist.GetTitle()
167  legname = hist.GetName()
168 
169  leg.AddEntry(hist, legname, 'lep')
170 
171 
172  for hist in hists:
173  hist.SetMaximum(ymax*2)
174 # hist.SetMinimum(ymin*0.5)
175 
176  leg.Draw()
177 
178  tex = TLatex( hists[-1].GetXaxis().GetXmin() + 0.01*(hists[-1].GetXaxis().GetXmax() - hists[-1].GetXaxis().GetXmin()), ymax*2.1, addon.replace('tau_',''))
179 
180  tex.SetTextFont(42)
181  tex.SetTextSize(0.03)
182  tex.Draw()
183 
184  tex2 = TLatex( hists[-1].GetXaxis().GetXmin() + 0.87*(hists[-1].GetXaxis().GetXmax() - hists[-1].GetXaxis().GetXmin()), ymax*2.1, tlabel)
185 
186  tex2.SetTextFont(42)
187  tex2.SetTextSize(0.03)
188  tex2.Draw()
189 
190 
191 
192  save(canvas, 'compare_' + runtype + '/' + header)
193 
194 
def overlay
Definition: compare.py:122
const uint16_t range(const Frame &aFrame)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def save
Definition: compare.py:47
def LegendSettings
Definition: compare.py:53
def compare.save (   canvas,
  name 
)

Definition at line 47 of file compare.py.

References ensureDir(), and python.rootplot.root2matplotlib.replace().

Referenced by hoverlay(), and overlay().

47 
48 def save(canvas, name):
49  ensureDir('compare_' + runtype)
50  canvas.SaveAs(name.replace(' ','').replace('&&','')+'.pdf')
51  canvas.SaveAs(name.replace(' ','').replace('&&','')+'.gif')
52 
def ensureDir
Definition: compare.py:43
def save
Definition: compare.py:47

Variable Documentation

tuple compare.argc = len(argvs)

Definition at line 17 of file compare.py.

compare.argvs = sys.argv

Definition at line 16 of file compare.py.

string compare.den_sel = '1'

Definition at line 328 of file compare.py.

tuple compare.hist = TH1F('h_' + hname + '_' + rel, 'h_' + hname + '_' + rel, hdict['nbin'], hdict['min'], hdict['max'])

Definition at line 375 of file compare.py.

list compare.hists = []

Definition at line 318 of file compare.py.

Referenced by trklet::TrackletCalculatorBase.barrelSeeding(), AlignmentMonitorGeneric.book(), TrigObjTnPHistColl::HistDefs.bookHists(), PPSTimingCalibrationPCLHarvester.dqmEndJob(), EcalSelectiveReadoutValidation.EcalSelectiveReadoutValidation(), trklet::MatchCalculator.execute(), MillePedeMonitor.fillResidualHitHists(), PedsFullNoiseHistograms.histoAnalysis(), main(), and trklet::MatchProcessor.matchCalculator().

dictionary compare.hvardict
Initial value:
1 = {
2  'tau_dm':{'var':'tau_dm', 'nbin':12, 'min':0., 'max':12, 'title':'decay Mode', 'sel':'1'},
3  'tau_mass_1prong':{'var':'tau_mass', 'nbin':30, 'min':0., 'max':2.5, 'title':'Tau mass, 1prong', 'sel':'tau_dm==0'},
4  'tau_mass_1prongp0':{'var':'tau_mass', 'nbin':30, 'min':0., 'max':2.5, 'title':'Tau mass, 1prong+#pi^{0}', 'sel':'tau_dm==1'},
5  'tau_mass_2prong':{'var':'tau_mass', 'nbin':30, 'min':0., 'max':2.5, 'title':'Tau mass, 2prong', 'sel':'(tau_dm==5 || tau_dm==6)'},
6  'tau_mass_3prong':{'var':'tau_mass', 'nbin':30, 'min':0., 'max':2.5, 'title':'Tau mass, 3prong (+#pi^{0})', 'sel':'(tau_dm==10 || tau_dm==11)'},
7  'pt_resolution_1prong':{'var':'(tau_genpt-tau_pt)/(tau_genpt)', 'nbin':30, 'min':-1., 'max':1., 'title':'pT resolution, 1prong', 'sel':'tau_dm==0'},
8  'pt_resolution_1prongp0':{'var':'(tau_genpt-tau_pt)/(tau_genpt)', 'nbin':30, 'min':-1., 'max':1., 'title':'pT resolution, 1prong+#pi^{0}', 'sel':'tau_dm==1'},
9  'pt_resolution_2prong':{'var':'(tau_genpt-tau_pt)/(tau_genpt)', 'nbin':30, 'min':-1., 'max':1., 'title':'pT resolution, 2prong', 'sel':'(tau_dm==5 || tau_dm==6)'},
10  'pt_resolution_3prong':{'var':'(tau_genpt-tau_pt)/(tau_genpt)', 'nbin':30, 'min':-1., 'max':1., 'title':'pT resolution, 3prong (+#pi^{0})', 'sel':'(tau_dm==10 || tau_dm==11)'},
11  }

Definition at line 350 of file compare.py.

string compare.loose_id = 'tau_decayModeFindingOldDMs > 0.5 && tau_byLooseCombinedIsolationDeltaBetaCorr3Hits > 0.5'

Definition at line 307 of file compare.py.

string compare.num_sel = reco_cut

Definition at line 327 of file compare.py.

string compare.reco_cut = 'tau_pt > 20 && abs(tau_eta) < 2.3'

Definition at line 306 of file compare.py.

list compare.runtype = argvs[1]

Definition at line 23 of file compare.py.

dictionary compare.sampledict
Initial value:
1 = {
2 # '7_6_0_pre7':{'file':'Myroot_7_6_0_pre7_' + runtype + '.root', 'col':2, 'marker':20, 'width':3},
3 # '7_6_0':{'file':'Myroot_7_6_0_' + runtype + '.root', 'col':1, 'marker':21, 'width':4},
4 # '7_6_1':{'file':'Myroot_7_6_1_' + runtype + '.root', 'col':4, 'marker':22, 'width':2},
5  '7_6_1_v3':{'file':'Myroot_7_6_1_v3_' + runtype + '.root', 'col':3, 'marker':23, 'width':1},
6  }

Definition at line 309 of file compare.py.

tuple compare.tfile = TFile(rdict['file'])

Definition at line 324 of file compare.py.

Referenced by SiStripGainFromCalibTree.algoAnalyzeTheTree(), MaterialBudgetHcalAnalysis.beginJob(), HitParentTest.beginJob(), HcalSimHitAnalysis.beginJob(), HOSimHitStudy.beginJob(), EcalSimHitStudy.beginJob(), MaterialBudgetCastorHistos.book(), MaterialBudgetHcalHistos.book(), MaterialBudgetForward.book(), MaterialBudget.book(), CaloSimHitAnalysis.CaloSimHitAnalysis(), CaloSimHitStudy.CaloSimHitStudy(), CherenkovAnalysis.CherenkovAnalysis(), ECalSD.ECalSD(), ElectronStudy.ElectronStudy(), HCalSD.HCalSD(), HcalTB02Histo.HcalTB02Histo(), HcalTB04Histo.HcalTB04Histo(), HcalTB06Histo.HcalTB06Histo(), HFGflash.HFGflash(), HFShowerParam.HFShowerParam(), HGCalTBMB.HGCalTBMB(), HGCalTBMBAnalyzer.HGCalTBMBAnalyzer(), HLTCSCOverlapFilter.HLTCSCOverlapFilter(), HGCSD.initRun(), MuonAlignmentFromReference.MuonAlignmentFromReference(), and XtalDedxAnalysis.XtalDedxAnalysis().

string compare.tlabel = 'Z #rightarrow #tau#tau'

Definition at line 27 of file compare.py.

Referenced by cscdqm::EventProcessor.getCSCFromMap().

tuple compare.tree = tfile.Get('per_tau')

Definition at line 325 of file compare.py.

dictionary compare.vardict
Initial value:
1 = {
2  'againstMuonLoose3':{'var':'tau_againstMuonLoose3 > 0.5', 'nbin':2, 'min':-0.5, 'max':1.5, 'title':'againstMuonLoose3'},
3  'againstMuonTight3':{'var':'tau_againstMuonTight3 > 0.5', 'nbin':2, 'min':-0.5, 'max':1.5, 'title':'againstMuonTight3'},
4 
5  'againstElectronVLooseMVA5':{'var':'tau_againstElectronVLooseMVA5 > 0.5', 'nbin':2, 'min':-0.5, 'max':1.5, 'title':'againstElectronVLooseMVA5'},
6  'againstElectronLooseMVA5':{'var':'tau_againstElectronLooseMVA5 > 0.5', 'nbin':2, 'min':-0.5, 'max':1.5, 'title':'againstElectronLooseMVA5'},
7  'againstElectronMediumMVA5':{'var':'tau_againstElectronMediumMVA5 > 0.5', 'nbin':2, 'min':-0.5, 'max':1.5, 'title':'againstElectronMediumMVA5'},
8 
9  'againstElectronVLooseMVA6':{'var':'tau_againstElectronVLooseMVA6 > 0.5', 'nbin':2, 'min':-0.5, 'max':1.5, 'title':'againstElectronVLooseMVA6'},
10  'againstElectronLooseMVA6':{'var':'tau_againstElectronLooseMVA6 > 0.5', 'nbin':2, 'min':-0.5, 'max':1.5, 'title':'againstElectronLooseMVA6'},
11  'againstElectronMediumMVA6':{'var':'tau_againstElectronMediumMVA6 > 0.5', 'nbin':2, 'min':-0.5, 'max':1.5, 'title':'againstElectronMediumMVA6'},
12 
13  'byLoosePileupWeightedIsolation3Hits':{'var':'tau_byLoosePileupWeightedIsolation3Hits > 0.5 && tau_decayModeFindingOldDMs > 0.5', 'nbin':2, 'min':-0.5, 'max':1.5, 'title':'byLoosePileupWeightedIsolation3Hits'},
14  'byMediumPileupWeightedIsolation3Hits':{'var':'tau_byMediumPileupWeightedIsolation3Hits > 0.5 && tau_decayModeFindingOldDMs > 0.5', 'nbin':2, 'min':-0.5, 'max':1.5, 'title':'byMediumPileupWeightedIsolation3Hits'},
15  'byTightPileupWeightedIsolation3Hits':{'var':'tau_byTightPileupWeightedIsolation3Hits > 0.5 && tau_decayModeFindingOldDMs > 0.5', 'nbin':2, 'min':-0.5, 'max':1.5, 'title':'byTightPileupWeightedIsolation3Hits'},
16 
17  'byLooseCombinedIsolationDeltaBetaCorr3Hits':{'var':'tau_byLooseCombinedIsolationDeltaBetaCorr3Hits > 0.5 && tau_decayModeFindingOldDMs > 0.5', 'nbin':2, 'min':-0.5, 'max':1.5, 'title':'byLooseCombinedIsolationDeltaBetaCorr3Hits'},
18  'byMediumCombinedIsolationDeltaBetaCorr3Hits':{'var':'tau_byMediumCombinedIsolationDeltaBetaCorr3Hits > 0.5 && tau_decayModeFindingOldDMs > 0.5', 'nbin':2, 'min':-0.5, 'max':1.5, 'title':'byMediumCombinedIsolationDeltaBetaCorr3Hits'},
19  'byTightCombinedIsolationDeltaBetaCorr3Hits':{'var':'tau_byTightCombinedIsolationDeltaBetaCorr3Hits > 0.5 && tau_decayModeFindingOldDMs > 0.5', 'nbin':2, 'min':-0.5, 'max':1.5, 'title':'byTightCombinedIsolationDeltaBetaCorr3Hits'},
20 
21  'byLooseIsolationMVA3oldDMwLT':{'var':'tau_byLooseIsolationMVA3oldDMwLT > 0.5 && tau_decayModeFindingOldDMs > 0.5', 'nbin':2, 'min':-0.5, 'max':1.5, 'title':'byLooseIsolationMVA3oldDMwLT'},
22  'byMediumIsolationMVA3oldDMwLT':{'var':'tau_byMediumIsolationMVA3oldDMwLT > 0.5 && tau_decayModeFindingOldDMs > 0.5', 'nbin':2, 'min':-0.5, 'max':1.5, 'title':'byMediumIsolationMVA3oldDMwLT'},
23  'byTightIsolationMVA3oldDMwLT':{'var':'tau_byTightIsolationMVA3oldDMwLT > 0.5 && tau_decayModeFindingOldDMs > 0.5', 'nbin':2, 'min':-0.5, 'max':1.5, 'title':'byTightIsolationMVA3oldDMwLT'},
24 
25  'byLooseIsolationMVArun2v1DBoldDMwLT':{'var':'tau_byLooseIsolationMVArun2v1DBoldDMwLT > 0.5 && tau_decayModeFindingOldDMs > 0.5', 'nbin':2, 'min':-0.5, 'max':1.5, 'title':'byLooseIsolationMVArun2v1DBoldDMwLT'},
26  'byMediumIsolationMVArun2v1DBoldDMwLT':{'var':'tau_byMediumIsolationMVArun2v1DBoldDMwLT > 0.5 && tau_decayModeFindingOldDMs > 0.5', 'nbin':2, 'min':-0.5, 'max':1.5, 'title':'byMediumIsolationMVArun2v1DBoldDMwLT'},
27  'byTightIsolationMVArun2v1DBoldDMwLT':{'var':'tau_byTightIsolationMVArun2v1DBoldDMwLT > 0.5 && tau_decayModeFindingOldDMs > 0.5', 'nbin':2, 'min':-0.5, 'max':1.5, 'title':'byTightIsolationMVArun2v1DBoldDMwLT'},
28 
29  }

Definition at line 275 of file compare.py.

string compare.xlabel = 'gen. tau p_{T}^{vis} (GeV)'

Definition at line 28 of file compare.py.