#!/usr/bin/env python2 import collections from xPhoton.xPhoton.Managers.LogMgr import GetLogger logger = GetLogger(__name__) class TextIOMgr(object): def __init__(self): self._info = None self._importable = None self._exportable = None self._contentprovider = None def __del__(self): pass def Export(self, filename): if self._exportable: with open(filename, 'w') as F: logger.debug('exporting') print 'aksdflj' self._contentprovider.WriteTo(F) #def Load(self, filename): # pass def SetContent(self, content): self._contentprovider = content self.SetIOStatus(False, True) def SetIOStatus(self, importable, exportable):
}, "QCD_HT300to500_TuneCP5_13TeV-madgraphMLM-pythia8": { "v15-v1": "../test/QCD18/QCD_HT300to500_TuneCP5_13TeV-madgraphMLM-pythia8/QCD_HT300to500_TuneCP5_13TeV-madgraphMLM-pythia8.root", }, } testDict = { "QCD_HT300to500_TuneCP5_13TeV-madgraphMLM-pythia8": { "v15-v1": "../test/QCD18/QCD_HT300to500_TuneCP5_13TeV-madgraphMLM-pythia8/QCD_HT300to500_TuneCP5_13TeV-madgraphMLM-pythia8.root", }, } import os from xPhoton.xPhoton.AppendEventInfo import FindXSInfo, nodir, ShowPD, ShowDetail from xPhoton.xPhoton.Managers.LogMgr import InitLogger, GetLogger mylog = GetLogger(__name__) #from xPhoton.xPhoton.AppendEventInfo_IntegratedGenWeights import IntegratedGenWeights import ROOT def IntegratedGenWeights(filename): print 'input file %s' % filename f = ROOT.TFile.Open(filename) nt = f.Get('genweightsummary') Sum = 0 for a in nt: Sum += a.sumupgenweight return Sum
#!/usr/bin/env python2 import ROOT from types import MethodType import os from xPhoton.xPhoton.Managers.LogMgr import GetLogger, LoadLoggerConfig LoadLoggerConfig('/home/ltsai/local/mylib/data/logger_debug.config') logger = GetLogger(__name__) FIGTEMPLATE = 'storefig/parfit_{0}.png' from xPhoton.xPhoton.Managers.AdditionalFunctionMgr import ImportAddFunc from xPhoton.analysis.myfit.RooFitSpaceMgr import RooFitSpaceMgr from xPhoton.analysis.myfit.RooFitFittingMgr import RooFitFittingMgr from xPhoton.analysis.myfit.WorkspaceContents import * factory_extendpdf = 'ExtendPdf::{name}({pdf},{num})' factory_histpdf = 'HistPdf::{name}({var},{datahist})' factory_var = '{name}({xmin},{xval})' factory_num = '{name}({xdef},{xmin},{xmax})' factory_addpdf = 'SUM::{name}({num1}*{pdf1},{num2}*{pdf2})' ''' def BuildHistPdf(self, spaceMGR, hist, label): return CreatePDF_Hist(spaceMGR,hist,label,'mva') ''' # input objname_desc_opts is a list contains objname and its description def CreateLegend_findObject(rooplot, objname_desc_opts, title=None, p0=(0.60, 0.70), p1=(0.89, 0.89),
#!/usr/bin/env python2 import ROOT from types import MethodType import os from xPhoton.xPhoton.Managers.LogMgr import GetLogger from xPhoton.xPhoton.Managers.AdditionalFunctionMgr import ImportAddFunc from xPhoton.analysis.RootObjFormatMgr import RootObjFormatMgr logging=GetLogger(__name__) LEN=96.38 DEFAULT_WindowW=2400 DEFAULT_WindowH=2000 SMALL_WindowW=600 SMALL_WindowH=500 def ClearWorkspace(NeedToClean, directory='storefig'): if NeedToClean: if os.listdir(directory): print 'cleaning temporary files' os.system('/bin/rm %s/*'%(directory)) else: print 'You have a clean workspace' class MyCanvas(ROOT.TCanvas): def __init__(self, name, title, width, height): super(MyCanvas,self).__init__(name,title,width,height) ROOT.gROOT.SetBatch(True) ''' super(MyCanvas,self).SetFrameFillColor(4000) super(MyCanvas,self).SetFrameFillStyle(4000)
#!/usr/bin/env python2 # usage : ./this.py # format of ouptut json file # { pd: { version : { 'xs':[val,err,unit], 'fracofevt':[val,err], 'lumiper1Mevt':[val,err,unit] } } } template_summaryoutput = '../mcInformation/summary_%s.json' from xPhoton.xPhoton.Managers.LogMgr import GetLogger, LoadLoggerConfig LoadLoggerConfig(confPath='/home/ltsai/local/mylib/data/logger_debug.config', fromCurrentDir=False) mylog = GetLogger(__name__) from mcinfo_extractMCInfo import ExtractMCInfo from mcinfo_primarydatasetMatching import PrimaryDataseatMatching, GetFileNameFromPD, _version, _primarydataset, _secondarydataset import os import json class keyinfo(object): def __init__(self, pd, ver): self.pd = pd self.ver = ver def primarydataset(self): return self.pd def version(self): return self.ver def Key(self): return self.pd