def PaveText(x1,y1,x2,y2): txt = TPaveText(x1,y1,x2,y2) txt.SetFillStyle(0) txt.SetLineWidth(0) txt.SetLineStyle(0) txt.SetTextFont(52) txt.SetTextSize(0.033) return txt
def makeStats(mean,rms): label = TPaveText( 0.25, 0.7, 0.3, 0.8, 'NB NDC' ) label.SetTextSize( 0.035 ) label.SetTextFont( 42 ) label.SetFillStyle( 0 ) label.SetLineWidth( 0 ) label.AddText( 'Mean = ' + str(mean) ) label.AddText( 'RMS = ' + str(rms) ) return label
def addText(): label = TPaveText( 0.7, 0.7, 0.75, 0.8, 'NB NDC' ) label.SetTextSize( 0.04 ) label.SetTextFont( 42 ) label.SetFillStyle( 0 ) label.SetLineWidth( 0 ) label.AddText( "Elastic #gamma#gamma#rightarrow#gamma#gamma" ) label.AddText( "FPMC, BSM pred." ) return label
def prelimLabel(): label = TPaveText( 0.2, 0.9, 0.27, 0.92, 'NB NDC' ) label.SetFillStyle(0) label.SetBorderSize(0) label.SetLineWidth(0) label.SetLineStyle(0) label.SetTextAlign(31) label.AddText( "#font[62]{CMS} #font[52]{Preliminary}" ) label.SetTextSize(0.03) label.SetTextColor( 1 ) return label
def condLabel(): label = TPaveText( 0.67, 0.9, 0.81, 0.93, 'NB NDC' ) label.SetFillStyle(0) label.SetBorderSize(0) label.SetLineWidth(0) label.SetLineStyle(0) label.AddText( "%s cond. (13 TeV)" % era ) label.SetTextSize( 0.034 ) label.SetTextAlign(11) label.SetTextFont( 42 ) label.SetTextColor( 1 ) return label
def selectionLabel(text): label = TPaveText( 0.15, 0.9, 0.23, 0.92, 'NB NDC' ) label.SetFillStyle(0) label.SetBorderSize(0) label.SetLineWidth(0) label.SetLineStyle(0) label.AddText( text ) label.SetTextSize( 0.048 ) label.SetTextAlign(11) label.SetTextFont( 52 ) label.SetTextColor( 1 ) return label
def condLabel(): label = TPaveText(0.63, 0.9, 0.8, 0.92, 'NB NDC') label.SetFillStyle(0) label.SetBorderSize(0) label.SetLineWidth(0) label.SetLineStyle(0) label.AddText("2017 PU cond. (13 TeV)") label.SetTextSize(0.034) label.SetTextAlign(11) label.SetTextFont(42) label.SetTextColor(1) return label
def lumiLabel(): label = TPaveText( 0.72, 0.9, 0.8, 0.92, 'NB NDC' ) label.SetFillStyle(0) label.SetBorderSize(0) label.SetLineWidth(0) label.SetLineStyle(0) label.AddText( "37.19 fb^{-1} (13 TeV)" ) label.SetTextSize( 0.03 ) label.SetTextAlign(11) label.SetTextFont( 42 ) label.SetTextColor( 1 ) return label
def simLabel(): label = TPaveText( 0.12, 0.9, 0.18, 0.92, 'NB NDC' ) label.SetFillStyle(0) label.SetBorderSize(0) label.SetLineWidth(0) label.SetLineStyle(0) label.SetTextAlign(11) label.AddText( "#font[62]{CMS} #font[52]{Simulation}" ) label.SetTextSize(0.035) label.SetTextFont( 52 ) label.SetTextColor( 1 ) return label
def selectionLabel(text,ratio,log,maximum): label = TPaveText( 0.1, 0.9, 0.18, 0.92, 'NB NDC' ) label.SetFillStyle(0) label.SetBorderSize(0) label.SetLineWidth(0) label.SetLineStyle(0) label.AddText( text ) if ratio: label.SetTextSize( 0.048 ) else: label.SetTextSize( 0.034 ) label.SetTextAlign(11) label.SetTextFont( 52 ) label.SetTextColor( 1 ) return label
def descriptionLabel(): label = TPaveText( 0.73, 0.65, 0.81, 0.8, 'NB NDC' ) label.SetFillStyle(0) label.SetBorderSize(0) label.SetLineWidth(0) label.SetLineStyle(0) label.AddText( "Elastic #gamma#gamma#rightarrow#gamma#gamma" ) label.AddText( "FPMC BSM pred." ) label.AddText( "#sigma_{bd} = 30 #murads" ) label.SetTextSize( 0.032 ) label.SetTextAlign(11) label.SetTextFont( 42 ) label.SetTextColor( 1 ) return label
def prelimLabel(): label = TPaveText( 0.14, 0.8, 0.2, 0.87, 'NB NDC' ) label.SetFillStyle(0) label.SetBorderSize(0) label.SetLineWidth(0) label.SetLineStyle(0) label.SetTextAlign(11) label.AddText( "#font[62]{CMS}" ) #label.AddText( "#scale[0.75]{#font[52]{Preliminary}}" ) label.AddText( "#scale[0.75]{#font[52]{Inteneral}}" ) label.SetTextSize(0.043) label.SetTextFont( 52 ) label.SetTextColor( 1 ) return label
def simLabel(): #label = TPaveText( 0.11, 0.9, 0.2, 0.92, 'NB NDC' ) label = TPaveText(0.8, 0.79, 0.87, 0.86, 'NB NDC') label.SetFillStyle(0) label.SetBorderSize(0) label.SetLineWidth(0) label.SetLineStyle(0) #label.SetTextAlign(11) label.SetTextAlign(31) #label.AddText( "#font[62]{CMS} #font[52]{Simulation}" ) label.AddText("#font[62]{CMS}") label.AddText("#scale[0.75]{#font[52]{Simulation}}") label.SetTextSize(0.045) #label.SetTextFont( 52 ) label.SetTextColor(1) return label
def lumiLabel(): label = TPaveText( 0.7, 0.89, 0.8, 0.93, 'NB NDC' ) label.SetFillStyle(0) label.SetBorderSize(0) label.SetLineWidth(0) label.SetLineStyle(0) if len(years) == 1 and years[0] == '2016': luminosity = '9.78' elif len(years) == 1 and years[0] == '2017': luminosity = '37.19' elif len(years) == 1 and years[0] == '2018': luminosity = '55.72' elif len(years) == 2: luminosity = '92.91' elif len(years) == 3: luminosity = '102.7' label.AddText( luminosity+" fb^{-1} (13 TeV)" ) label.SetTextSize( 0.033 ) label.SetTextAlign(11) label.SetTextFont( 42 ) label.SetTextColor( 1 ) return label
def prelimLabel(location, log): if location == 'left': label = TPaveText(0.135, 0.76, 0.2, 0.84, 'NB NDC') label.AddText("#font[62]{CMS}") label.AddText("#scale[0.75]{#font[52]{Preliminary}}") elif location == 'top': label = TPaveText(0.15, 0.9, 0.25, 0.92, 'NB NDC') label.AddText("#font[62]{CMS} #font[52]{Preliminary}") label.SetFillStyle(0) label.SetBorderSize(0) label.SetLineWidth(0) label.SetLineStyle(0) label.SetTextAlign(11) # Align bottom left if location == 'top': label.SetTextSize(0.04) else: label.SetTextSize(0.05) label.SetTextFont(52) label.SetTextColor(1) return label
def __draw_text(self): """Draw potential text into pad """ if not self._texts: return if not self.pave_boxes: self.pave_boxes = [] for text in self._texts: pave_box = TPaveText(self.__adjust_coordinate_x(text.x_low), self.__adjust_coordinate_y(text.y_low), self.__adjust_coordinate_x(1), self.__adjust_coordinate_y(text.y_low + text.size), "brNDC") pave_box.SetLineWidth(0) pave_box.AddText(text.text) pave_box.SetBorderSize(0) pave_box.SetFillStyle(0) pave_box.SetTextAlign(10) pave_box.SetTextFont(63) pave_box.SetTextSizePixels(self.__adjust_text_size(text.size)) self.pave_boxes.append(pave_box) pave_box.Draw()
def make_histos(signal, com, cutflows, stage): N2s = [] N1s = [] N2mN1s = [] nTots = [] nTotErrs = [] nEnds = [] nEndErrs = [] paveTitle = '?' paveTitle2 = '' for cutflow in glob(cutflows): N2 = cutflow.split('_')[7] N1 = cutflow.split('_')[8] with open(cutflow, 'r') as f: for line in f: if line.split()[0] == 'entry' and line.split()[1] == 'point': nTot = line.split()[2] nTotErr = line.split()[3] elif line.split()[0] == 'dR-Lep1-Lep2-smaller-2': nEnd = line.split()[1] nEndErr = line.split()[2] N2s.append(float(N2)) N1s.append(float(N1)) N2mN1s.append(float(N2) - float(N1)) nTots.append(float(nTot)) nTotErrs.append(float(nTotErr)) nEnds.append(float(nEnd)) nEndErrs.append(float(nEndErr)) if signal == 'N2N1' and com == '13': N2bins = [90., 110., 130., 150., 170., 190., 210., 230., 250.] N2mN1bins = [6.5, 8.5, 12.5, 17.5, 25., 35., 45.] elif signal == 'N2C1' and com == '13': N2bins = [ 87.5, 112.5, 137.5, 162.5, 187.5, 212.5, 237.5, 262.5, 287.5, 312.5 ] N2mN1bins = [6.5, 8.5, 12.5, 17.5, 25., 35., 45.] elif signal == 'N2C1' and com == '14': N2bins = [75., 125., 175., 225., 275., 325., 375., 425.] N2mN1bins = [2.5, 7.5, 12.5, 17.5, 22.5, 27.5, 32.5, 37.5, 42.5] N2bina = array('d', sorted(set(N2bins))) N2mN1bina = array('d', sorted(set(N2mN1bins))) # Histogram h = TH2D('', '', len(N2bina) - 1, N2bina, len(N2mN1bina) - 1, N2mN1bina) for idx in range(0, len(N2s)): N2 = N2s[idx] N1 = N1s[idx] N2mN1 = N2mN1s[idx] nTot = nTots[idx] nTotErr = nTotErrs[idx] nEnd = nEnds[idx] nEndErr = nEndErrs[idx] #print 'Foo01', N2, N2mN1, nEnd if stage == 'nTot': paveTitle = 'Total events' h.Fill(N2, N2mN1, nTot) elif stage == 'nEnd': paveTitle = 'Events in SR' h.Fill(N2, N2mN1, nEnd) elif stage == 'Acc': paveTitle = 'Acceptance' paveTitle2 = '(*1000)' try: h.Fill(N2, N2mN1, 1000. * nEnd / nTot) except ZeroDivisionError: pass # Style gStyle.SetOptStat(0) gStyle.SetPaintTextFormat('.2f') h.GetXaxis().SetTitle('N2') h.GetYaxis().SetTitle('dM') set_palette() # Pave Text t1 = TPaveText(.1, .906, .2, 1., 'NDC') t1.SetTextSize(.039) t1.SetFillColor(0) t1.SetFillStyle(0) t1.SetLineWidth(0) t1.SetTextAlign(12) t1.AddText('CMS') t2 = TPaveText(.13, .9, .9, 1., 'NDC') t2.SetTextSize(.033) t2.SetFillColor(0) t2.SetFillStyle(0) t2.SetLineWidth(0) t2.SetTextAlign(12) t2.SetTextFont(42) t2.AddText('Phase-2 Simulation Preliminary {} {} at {}TeV {}'.format( signal, paveTitle, com, paveTitle2)) # Plot c = TCanvas() #c.SetLogy() h.Draw('colz|text') t1.Draw('same') t2.Draw('same') c.Print('{}_{}_{}TeV.pdf'.format(stage, signal, com)) c.Print('{}_{}_{}TeV.png'.format(stage, signal, com))
h.Fill(200., 30., 1.71) h.Fill(200., 40., 1.82) # Style gStyle.SetOptStat(0) gStyle.SetPaintTextFormat('.2f') h.GetXaxis().SetTitle('N2') h.GetYaxis().SetTitle('dM') set_palette() # Pave Text t1 = TPaveText(.1, .906, .2, 1., 'NDC') t1.SetTextSize(.039) t1.SetFillColor(0) t1.SetFillStyle(0) t1.SetLineWidth(0) t1.SetTextAlign(12) t1.AddText('CMS') t2 = TPaveText(.13, .9, .9, 1., 'NDC') t2.SetTextSize(.033) t2.SetFillColor(0) t2.SetFillStyle(0) t2.SetLineWidth(0) t2.SetTextAlign(12) t2.SetTextFont(42) t2.AddText('Phase-2 Simulation Preliminary (N2C1+N2N1)/N2C1 Events in SR') # Plot c = TCanvas() #c.SetLogy() h.Draw('colz|text')