def init(self): self.a4 = OutputStream(open(self.file_name, "w"), "AOD2A4", Event, EventStreamInfo) import PyCintex PyCintex.loadDict("egammaAnalysisTools") self.tool_ciwt = PyAthena.py_tool("CaloIsolationWrapperTool", iface="ICaloIsolationWrapperTool") assert bool(self.tool_ciwt) PyCintex.loadDictionary("TrigMuonEvent") PyCintex.loadDictionary("TrigObjectMatching") self.tmefih = PyCintex.makeClass("TrigMatch::TrigMuonEFInfoHelper") from ROOT import vector PyCintex.loadDictionary("JetUtils") from ROOT import JetCaloHelper, JetCaloQualityUtils, Long, CaloSampling self.jet_emf = lambda jet : JetCaloHelper.jetEMFraction(jet) self.jet_hecF = lambda jet : JetCaloQualityUtils.hecF(jet) ### smax needed for jet cealning #### FIX THIS: don't know either getNumberOfSamplings() or Unknown #### UPDATE: getNumberOfSamplings just returns Unknown! self.jet_smax = Long(CaloSampling.getNumberOfSamplings()) self.jet_fmax = lambda jet : JetCaloQualityUtils.fracSamplingMax(jet, Long(CaloSampling.Unknown)) self.jet_time = lambda jet : JetCaloQualityUtils.jetTimeCells(jet) self.jet_quality_lar = lambda jet : JetCaloQualityUtils.jetQualityLAr(jet) self.jet_quality_hec = lambda jet : JetCaloQualityUtils.jetQualityHEC(jet) self.jet_bad = lambda jet : JetCaloQualityUtils.isBad(jet, False) self.jet_ugly = lambda jet : JetCaloQualityUtils.isUgly(jet, False) PyCintex.loadDictionary("egammaEnumsDict") PyCintex.loadDictionary("muonEventDict") PyCintex.loadDictionary("egammaAnalysisUtils") PyCintex.loadDictionary("MissingETEvent") from ROOT import MuonParameters, egammaParameters, egammaPID from ROOT import ElectronMCChargeCorrector self.MuonParameters = MuonParameters self.egammaParameters = egammaParameters self.egammaPID = egammaPID self.empp_helper = PyCintex.makeClass("isEMPlusPlusHelper")() if self.year == 2010: gROOT.ProcessLine(".L checkOQ.C++") from ROOT import egammaOQ self.egOQ = egammaOQ() self.egOQ.initialize() self.tool_ttv = PyAthena.py_tool("Reco::TrackToVertex", iface="Reco::ITrackToVertex") self.tool_tdt = PyAthena.py_tool('Trig::TrigDecisionTool/TrigDecisionTool') self.tool_tmt = PyAthena.py_tool("TrigMatchTool/TrigMatchTool") self.tool_hfor= PyAthena.py_tool("HforTool",iface="IHforTool") self.tool_timing = PyAthena.py_tool("Rec::MuonCombinedTimingTool/MuonCombinedTimingTool", iface="Rec::IMuonCombinedTimingTool") PyCintex.loadDictionary("TrkSpaceTimePoint")
def initialize(self): self.msg.info( "Initializing %s", self.name() ) ## storegate self.sg = PyAthena.StoreGate.pointer("StoreGateSvc") # or: PyAthena.py_svc("StoreGateSvc",createIf=True) ## Datavector stuff import PyCintex PyCintex.loadDict("libAthExThinningEventDict") from RootUtils import PyROOTFixes return StatusCode.Success
def gen_typeregistry_dso(oname=_dflt_typereg_fname): '''inspect all the accessible reflex types and get their rootmap-naming. also associate the clid if available. ''' import CLIDComps.clidGenerator as _c cliddb = _c.clidGenerator(db=None) del _c import PyUtils.path as _p oname = _p.path(oname) del _p import PyUtils.Logging as _L msg = _L.logging.getLogger('typereg-dso') #msg.setLevel(_L.logging.INFO) msg.setLevel(_L.logging.VERBOSE) del _L msg.info("installing registry in [%s]...", oname) # FIXME: should use the Cxx one... #reg = DsoDb() reg = PyDsoDb() cls_names = reg.db.keys() msg.debug("::: loading reflex") import PyCintex PyCintex.Cintex.Enable() PyCintex.loadDict('libReflexRflx.so') rflx = PyCintex.makeNamespace('Reflex') if not rflx: rflx = PyCintex.makeNamespace('ROOT::Reflex') rflx = rflx.Type assert (rflx) import PyCintex _load_lib = PyCintex.loadDict def _load_dict(libname, retry=10): msg.debug("::: loading [%s]...", libname) try: return _load_lib(libname) except ( Exception, SystemError, ), err: msg.warning("**error** %s", err) return
def initialize(self): self.msg.info( "Initializing %s", self.name() ) ## storegate self.sg = PyAthena.StoreGate.pointer("StoreGateSvc") # or: PyAthena.py_svc("StoreGateSvc",createIf=True) ## Datavector stuff import PyCintex PyCintex.loadDict("libAthExThinningEventDict") from RootUtils import PyROOTFixes ## thinningsvc self.thinSvc = PyAthena.py_svc("ThinningSvc", createIf=True, iface='IThinningSvc') self.msg.info( "==> thinning svc...: %s", self.thinSvc.name() ) self.filter = self.Filter return StatusCode.Success
def gen_typeregistry_dso(oname=_dflt_typereg_fname): '''inspect all the accessible reflex types and get their rootmap-naming. also associate the clid if available. ''' import CLIDComps.clidGenerator as _c cliddb = _c.clidGenerator(db=None) del _c import PyUtils.path as _p oname = _p.path(oname) del _p import PyUtils.Logging as _L msg = _L.logging.getLogger('typereg-dso') #msg.setLevel(_L.logging.INFO) msg.setLevel(_L.logging.VERBOSE) del _L msg.info("installing registry in [%s]...", oname) # FIXME: should use the Cxx one... #reg = DsoDb() reg = PyDsoDb() cls_names = reg.db.keys() msg.debug("::: loading reflex") import PyCintex PyCintex.Cintex.Enable() PyCintex.loadDict('libReflexRflx.so') rflx = PyCintex.makeNamespace('Reflex') if not rflx: rflx = PyCintex.makeNamespace('ROOT::Reflex') rflx = rflx.Type assert(rflx) import PyCintex _load_lib = PyCintex.loadDict def _load_dict(libname,retry=10): msg.debug("::: loading [%s]...", libname) try: return _load_lib(libname) except (Exception,SystemError,), err: msg.warning("**error** %s", err) return
#usage is: #from PathResolver import PathResolver #PathResolver.FindCalibFile("blah") import PyCintex PyCintex.loadDict('libPathResolverDict') FindCalibFile = PyCintex.gbl.PathResolverFindCalibFile FindCalibDirectory = PyCintex.gbl.PathResolverFindCalibDirectory
def _pythonize_tfile(): import PyCintex; PyCintex.Cintex.Enable() root = import_root() import PyUtils.Helpers as H with H.ShutUp(filters=[ re.compile( 'TClass::TClass:0: RuntimeWarning: no dictionary for.*'), re.compile( 'Warning in <TEnvRec::ChangeValue>: duplicate entry.*' ), ]): PyCintex.loadDict("RootUtilsPyROOTDict") rootutils = getattr(root, "RootUtils") pybytes = getattr(rootutils, "PyBytes") read_root_file = getattr(rootutils, "_pythonize_read_root_file") tell_root_file = getattr(rootutils, "_pythonize_tell_root_file") pass def read(self, size=-1): """read([size]) -> read at most size bytes, returned as a string. If the size argument is negative or omitted, read until EOF is reached. Notice that when in non-blocking mode, less data than what was requested may be returned, even if no size parameter was given. FIXME: probably doesn't follow python file-like conventions... """ SZ = 4096 if size>=0: #size = _adjust_sz(size) #print "-->0",self.tell(),size c_buf = read_root_file(self, size) if c_buf and c_buf.sz: #print "-->1",self.tell(),c_buf.sz #self.seek(c_buf.sz+self.tell()) #print "-->2",self.tell() buf = c_buf.buffer() buf.SetSize(c_buf.sz) return str(buf[:]) return '' else: size = SZ out = [] while True: #size = _adjust_sz(size) c_buf = read_root_file(self, size) if c_buf and c_buf.sz: buf = c_buf.buffer() buf.SetSize(c_buf.sz) out.append(str(buf[:])) else: break return ''.join(out) root.TFile.read = read del read root.TFile.seek = root.TFile.Seek root.TFile.tell = lambda self: tell_root_file(self) ## import os ## def tell(self): ## fd = os.dup(self.GetFd()) ## return os.fdopen(fd).tell() ## root.TFile.tell = tell ## del tell return
def _pythonize_tfile(): import PyCintex PyCintex.Cintex.Enable() root = import_root() import PyUtils.Helpers as H with H.ShutUp(filters=[ re.compile( 'TClass::TClass:0: RuntimeWarning: no dictionary for.*'), re.compile('Warning in <TEnvRec::ChangeValue>: duplicate entry.*'), ]): PyCintex.loadDict("RootUtilsPyROOTDict") rootutils = getattr(root, "RootUtils") pybytes = getattr(rootutils, "PyBytes") read_root_file = getattr(rootutils, "_pythonize_read_root_file") tell_root_file = getattr(rootutils, "_pythonize_tell_root_file") pass def read(self, size=-1): """read([size]) -> read at most size bytes, returned as a string. If the size argument is negative or omitted, read until EOF is reached. Notice that when in non-blocking mode, less data than what was requested may be returned, even if no size parameter was given. FIXME: probably doesn't follow python file-like conventions... """ SZ = 4096 if size >= 0: #size = _adjust_sz(size) #print "-->0",self.tell(),size c_buf = read_root_file(self, size) if c_buf and c_buf.sz: #print "-->1",self.tell(),c_buf.sz #self.seek(c_buf.sz+self.tell()) #print "-->2",self.tell() buf = c_buf.buffer() buf.SetSize(c_buf.sz) return str(buf[:]) return '' else: size = SZ out = [] while True: #size = _adjust_sz(size) c_buf = read_root_file(self, size) if c_buf and c_buf.sz: buf = c_buf.buffer() buf.SetSize(c_buf.sz) out.append(str(buf[:])) else: break return ''.join(out) root.TFile.read = read del read root.TFile.seek = root.TFile.Seek root.TFile.tell = lambda self: tell_root_file(self) ## import os ## def tell(self): ## fd = os.dup(self.GetFd()) ## return os.fdopen(fd).tell() ## root.TFile.tell = tell ## del tell return
e_coll = jobproperties.HSG2.llqqElectronCollection() staco_coll = jobproperties.HSG2.llqqStacoMuonCollection() muons_coll = jobproperties.HSG2.llqqMuonsCollection() calo_coll = jobproperties.HSG2.llqqCaloMuonCollection() jet_coll = jobproperties.HSG2.llqqJetCollection() diLeptonMassCut = jobproperties.HSG2.llqqDiLeptonMassCut() electronJetDRCut = jobproperties.HSG2.llqqElectronJetDRCut() from AthenaCommon.Logging import logging msg = logging.getLogger( "NTUP_2L2QHSG2_Filter" ) # AthElectronLikelihoodTool with PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/data/ElectronLikelihoodPdfs.root # and LikeEnum::Loose by following https://twiki.cern.ch/twiki/bin/viewauth/AtlasProtected/HiggsZZllllSummer2013#More_information import ROOT import PyCintex PyCintex.loadDict('libElectronPhotonSelectorToolsDict') from AthenaCommon.AppMgr import ToolSvc if not hasattr(ToolSvc, "AthElectronLikelihoodTool_VeryLoose"): from ElectronPhotonSelectorTools.ElectronPhotonSelectorToolsConf import AthElectronLikelihoodTool ToolSvc += AthElectronLikelihoodTool( "AthElectronLikelihoodTool_VeryLoose", inputPDFFileName = "ElectronPhotonSelectorTools/ElectronLikelihoodPdfs.root", cutLikelihoodEnum = ROOT.LikeEnum.VeryLoose, useUserData = False , forceRecalculateImpactParameter = True) msg.info("AthElectronLikelihoodTool/AthElectronLikelihoodTool_VeryLoose is added") if not hasattr(ToolSvc, "AthElectronLikelihoodTool_Loose"): from ElectronPhotonSelectorTools.ElectronPhotonSelectorToolsConf import AthElectronLikelihoodTool ToolSvc += AthElectronLikelihoodTool( "AthElectronLikelihoodTool_Loose", inputPDFFileName = "ElectronPhotonSelectorTools/ElectronLikelihoodPdfs.root", cutLikelihoodEnum = ROOT.LikeEnum.Loose, useUserData = False ,
import AthenaPython.PyAthena as PyAthena import AthenaCommon.SystemOfUnits as Units from AthenaPython.PyAthena import StatusCode import PyCintex import ROOT import math PyCintex.loadDictionary('egammaEnumsDict') # Needed for egammaParameters from ROOT import egammaParameters from ROOT import egammaPID PyCintex.loadDict("libTrkTrackSummaryDict") PyCintex.loadDict('libegammaAnalysisUtilsDict') from ROOT import TLorentzVector class HSG2_2L2QDPDFilter(PyAthena.AthFilterAlgorithm): def __init__(self, name="HSG2_2L2QDPDFilter",**kw): kw['name'] = name super(HSG2_2L2QDPDFilter, self).__init__(**kw) self.cutDict=dict() # types are e or mu or jet self.cutDict["types"] = kw.get("types", []) # pT cuts for muons and jets, ET cut for electrons self.cutDict["pTCuts"] = kw.get("pTCuts", []) # quality cuts are LoosePP or ORLH for electrons, combined+lowpt for muons, barrel for jets self.cutDict["qualityCuts"] = kw.get("qualityCuts", []) # Container names in AOD self.cutDict["collections"] = kw.get("collections", []) # Di-lepton mass cut self.cutDict["diLeptonMassCut"] = kw.get("diLeptonMassCut", 5.*Units.GeV) # Electron-jet dR cut self.cutDict["electronJetDRCut"] = kw.get("electronJetDRCut", 0.05) # Negative value means no overlap removal
rflx = rflx.Type assert(rflx) import PyCintex _load_lib = PyCintex.loadDict def _load_dict(libname,retry=10): msg.debug("::: loading [%s]...", libname) try: return _load_lib(libname) except (Exception,SystemError,), err: msg.warning("**error** %s", err) return # we need to pre-load these guys as HepPDT is missing a linkopts # against HepPID. see bug #46551 hep_pid = PyCintex.loadDict('libHepPID.so') hep_pdt = PyCintex.loadDict('libHepPDT.so') from PyUtils.Decorators import forking import os dict_libs = reduce(set.union, [set(v) for v in reg.db.values()]) dict_libs = [os.path.basename(l) for l in dict_libs] _veto_libs = [ 'libG4EventGraphicsDict.so', # freaking statics ! ] dict_libs = [l for l in dict_libs if l not in _veto_libs] msg.debug("::: loading dict-libraries...") @forking
""" python -c "import urllib;print urllib.urlopen('http://www.cern.ch/~frankm').read()" """ import sys, time, platform import PyCintex as Dictionary lib_prefix = '' if platform.system()=='Linux': lib_prefix = 'lib' gbl = Dictionary.makeNamespace('') std = gbl.std Dictionary.loadDict(lib_prefix+'LHCbStatusDict') LHCbStatus=gbl.LHCbStatus srv=LHCbStatus.Server() s = srv.info() s.hlt.subfarm(0)='OT' print s.hlt.subfarm(0)
import os, sys, string, platform import Online.Utils as Utils import PyCintex as PyLCGDict lib_prefix = '' if platform.system() == 'Linux': lib_prefix = 'lib' PyLCGDict.loadDict(lib_prefix + 'DIMDict') DIM = PyLCGDict.makeNamespace('DIM') gbl = PyLCGDict.makeNamespace('') #----enable tab completion--------------------------------------------------------------- try: import rlcompleter, readline readline.parse_and_bind("tab: complete") except: pass log = Utils.log error = Utils.error def void_call(self): return 1 #CmdInfo = gbl.CmndInfo Info = gbl.DimInfo Info = DIM.Info Timer = gbl.DimTimer Client = gbl.DimClient
_load_lib = PyCintex.loadDict def _load_dict(libname, retry=10): msg.debug("::: loading [%s]...", libname) try: return _load_lib(libname) except ( Exception, SystemError, ), err: msg.warning("**error** %s", err) return # we need to pre-load these guys as HepPDT is missing a linkopts # against HepPID. see bug #46551 hep_pid = PyCintex.loadDict('libHepPID.so') hep_pdt = PyCintex.loadDict('libHepPDT.so') from PyUtils.Decorators import forking import os dict_libs = reduce(set.union, [set(v) for v in reg.db.values()]) dict_libs = [os.path.basename(l) for l in dict_libs] _veto_libs = [ 'libG4EventGraphicsDict.so', # freaking statics ! ] dict_libs = [l for l in dict_libs if l not in _veto_libs] msg.debug("::: loading dict-libraries...")