def setupOnline(directory, prefix, filename): """ Setup the online environment: Buffer managers, event serialisation, etc. @author M.Frank """ class __MonAdd: def __init__(self): pass def addMonitors(self): GaudiSequencer("EscherSequencer").Members += ["HistogramResetter"] from Configurables import LHCb__FILEEvtSelector as es Online = importOnline() app = Gaudi.ApplicationMgr() app.AppName = '' HistogramPersistencySvc().OutputFile = "" app.HistogramPersistency = '' app.SvcOptMapping.append('LHCb::FILEEvtSelector/EventSelector') app.SvcOptMapping.append('LHCb::FmcMessageSvc/MessageSvc') app.ExtSvc.insert(0, "MonitorSvc") sel = es("EventSelector") sel.Input = filename sel.Directory = directory sel.OutputLevel = MSG_INFO sel.DeleteFiles = False sel.FilePrefix = prefix sel.Decode = False sel.Pause = True sel.PauseSleep = 5000 sel.AllowedRuns = Online.DeferredRuns if hasattr(Online, "DeferredRuns") else [] app.EvtSel = sel app.EvtMax = -1 Online.rawPersistencySvc() evtloop = Configs.EventLoopMgr('EventLoopMgr') evtloop.Warnings = False evtloop.EvtSel = sel app.EventLoop = evtloop runable = Configs.LHCb__EventRunable("Runable") runable.MEPManager = "" app.Runable = runable app.AuditAlgorithms = False Configs.MonitorSvc().OutputLevel = MSG_ERROR Configs.MonitorSvc().UniqueServiceNames = 1 Configs.MonitorSvc().CounterUpdateInterval = -1 Configs.MonitorSvc().DimUpdateInterval = -1 Configs.RootHistCnv__PersSvc("RootHistSvc").OutputLevel = MSG_ERROR mon = __MonAdd() Gaudi.appendPostConfigAction(mon.addMonitors) app.OutputLevel = MSG_INFO cdb = CondDB() cdb.Online = True
def initialise(): if not globals()['initialised']: import os # Check results dir if not os.path.exists("results"): os.mkdir("results") from ROOT import gROOT # No info messages gROOT.ProcessLine("gErrorIgnoreLevel = kWarning;") # Batch mode (no TCanvas) gROOT.SetBatch(True) import GaudiPython # Initialise a few things from Configurables import DDDBConf, CondDB, LHCbApp, CondDBAccessSvc cDB = CondDB() #DDDBConf(DataType = "2009") #LHCbApp().DDDBtag = "head-20110303" #LHCbApp().CondDBtag = "head-20110524" #DDDBConf(DataType = "2010") #LHCbApp().DDDBtag = "head-20110303" #LHCbApp().CondDBtag = "head-20110524" #DDDBConf(DataType = "2011") #LHCbApp().DDDBtag = "head-20110722" #LHCbApp().CondDBtag = "head-20110722" #LHCbApp().CondDBtag = "HEAD" DDDBConf(DataType="2012") LHCbApp().DDDBtag = "head-20120413" LHCbApp().CondDBtag = "cond-20120730" CondDB().addLayer( CondDBAccessSvc( "2012Aerogel", ConnectionString="sqlite_file:2012Aerogel.db/LHCBCOND", DefaultTAG="HEAD")) # Set message level to info and above only msgSvc().setOutputLevel(3) # Finally, initialize GaudiPython GaudiPython.AppMgr().initialize() # Initialise various DeRich objects loadRichDet() # flag as done globals()['initialised'] = True
def add_data(job_name, job_id): IOHelper('ROOT').inputFiles(glob(join('output/scenarios', job_name, 'hists', str(job_id), 'Brunel.xdst'))) CondDB().Upgrade = True if job_name == 'Original_DB': lhcbApp.DDDBtag = "dddb-20160304" lhcbApp.CondDBtag = "sim-20150716-vc-md100" else: CondDB().addLayer(dbFile=join(os.getcwd(), 'output/DDDB.db'), dbName="DDDB") CondDB().addLayer(dbFile=join(os.getcwd(), 'output/SIMCOND.db'), dbName="SIMCOND") alignment_conditions = CondDBAccessSvc("AlignmentConditions") alignment_conditions.ConnectionString = "sqlite_file:{}/output/scenarios/{}/Alignment_SIMCOND.db/SIMCOND".format(os.getcwd(), job_name) CondDB().addLayer(alignment_conditions)
def _gen_postconfig_(): """ specific post-config action for (x)GEN-files """ logger.info('Start post-config action for (x)gen-files') from Configurables import DataOnDemandSvc dod = DataOnDemandSvc() from copy import deepcopy algs = deepcopy(dod.AlgMap) bad = set() for key in algs: if 0 <= key.find('Rec'): bad.add(key) elif 0 <= key.find('Raw'): bad.add(key) elif 0 <= key.find('DAQ'): bad.add(key) elif 0 <= key.find('Trigger'): bad.add(key) elif 0 <= key.find('Phys'): bad.add(key) elif 0 <= key.find('Prev/'): bad.add(key) elif 0 <= key.find('Next/'): bad.add(key) elif 0 <= key.find('/MC/') and 'GEN' == ext: bad.add(key) for b in bad: logger.debug('Remove key from DataOnDemand actions %s' % key) del algs[b] logger.info('Remove %d keys from DataOnDemand actions ' % len(bad)) dod.AlgMap = algs from Configurables import EventClockSvc, CondDB EventClockSvc(EventTimeDecoder="FakeEventTime") logger.info('Use fake event time decoder for (x)gen-files') CondDB(IgnoreHeartBeat=True) logger.info('Ignore Heart-beat for (x)gen-files')
def configure(use_case="simple"): # Common configuration import Gaudi.Configuration from Configurables import (ApplicationMgr, MessageSvc, DDDBConf, CondDB, CondDBAccessSvc, UpdateManagerSvc) DDDBConf() # detector description localDb = CondDBAccessSvc( "VeloAlignCondTestDB", ConnectionString="sqlite_file:../data/VeloAlignCondTest.db/DDDB", DefaultTAG="simple") CondDB().addLayer(localDb) # use local DB ApplicationMgr(TopAlg=[], EvtSel="NONE") #MessageSvc(OutputLevel = 1) if use_case == "simple": # nothing to do more return elif use_case == "override_motion_system": # Example of how to move the Velo UpdateManagerSvc().ConditionsOverride.append( "Conditions/Online/Velo/MotionSystem := double ResolPosY = 100") elif use_case == "override_alignment": UpdateManagerSvc().ConditionsOverride.append( "Conditions/Alignment/Velo/VeloLeft := double_v dPosXYZ = 0 100 0") elif use_case == "override_alignment2": UpdateManagerSvc().ConditionsOverride.append( "Conditions/Alignment/Velo/VeloLeft := double_v YOffsetCoeffs = 20 -5" ) UpdateManagerSvc().ConditionsOverride.append( "Conditions/Alignment/Velo/VeloRight := double_v YOffsetCoeffs = 0 1" )
def initialise(): # Initialise a few things from Configurables import DDDBConf, CondDB, LHCbApp, CondDBAccessSvc cDB = CondDB() #DDDBConf(DataType = "2009") #LHCbApp().DDDBtag = "head-20110303" #LHCbApp().CondDBtag = "head-20110524" #DDDBConf(DataType = "2010") #LHCbApp().DDDBtag = "head-20110721" #LHCbApp().CondDBtag = "cond-20140328" #DDDBConf(DataType = "2011") #LHCbApp().DDDBtag = "head-20110722" #LHCbApp().CondDBtag = "head-20110722" #DDDBConf(DataType = "2012") #LHCbApp().DDDBtag = "dddb-20120831" #LHCbApp().CondDBtag = "cond-20121025" DDDBConf(DataType = "2015") LHCbApp().DDDBtag = "dddb-20150526" LHCbApp().CondDBtag = "cond-20150625" # Set message level to info and above only msgSvc().setOutputLevel(3) # Finally, initialize GaudiPython GaudiPython.AppMgr().initialize()
def doIt(): """ specific post-config action for (x)GEN-files """ extension = "xgen" ext = extension.upper() from Configurables import DataOnDemandSvc dod = DataOnDemandSvc () from copy import deepcopy algs = deepcopy ( dod.AlgMap ) bad = set() for key in algs : if 0 <= key.find ( 'Rec' ) : bad.add ( key ) elif 0 <= key.find ( 'Raw' ) : bad.add ( key ) elif 0 <= key.find ( 'DAQ' ) : bad.add ( key ) elif 0 <= key.find ( 'Trigger' ) : bad.add ( key ) elif 0 <= key.find ( 'Phys' ) : bad.add ( key ) elif 0 <= key.find ( 'Prev/' ) : bad.add ( key ) elif 0 <= key.find ( 'Next/' ) : bad.add ( key ) elif 0 <= key.find ( '/MC/' ) and 'GEN' == ext : bad.add ( key ) for b in bad : del algs[b] dod.AlgMap = algs from Configurables import EventClockSvc, CondDB EventClockSvc ( EventTimeDecoder = "FakeEventTime" ) CondDB ( IgnoreHeartBeat = True )
def configure(inputdata, catalogs=[], castor=False): from Configurables import DaVinci DaVinci(DataType='2012', Lumi=False) from Configurables import CondDB CondDB(IgnoreHeartBeat=True) ## get/create application manager gaudi = appMgr() ## define the input data setData(inputdata, catalogs, castor) # modify/update the configuration: # (1) create the algorithm alg = KSDecayFinder('KsFinder') # (2) replace the list of top level algorithm by # new list, which contains only *THIS* algorithm gaudi.setAlgorithms([alg]) return SUCCESS
def _setup_rch(self): # Setup DB snapshot and RCH from Configurables import EventClockSvc EventClockSvc().EventTimeDecoder = 'OdinTimeDecoder' tag = { "DDDB": self._config['DDDBtag'], "LHCBCOND": self._config['CondDBtag'], "ONLINE": 'fake' } baseloc = '/group/online/hlt/conditions' from Configurables import CondDB conddb = CondDB() # hack to allow us to chance connectionstrings... conddb.Online = True # Set alternative connection strings and tags # (see Det/DetCond's configurable... ) dbPartitions = ["DDDB", "LHCBCOND", "ONLINE"] for part in dbPartitions: if tag[part] is 'default': raise KeyError('must specify an explicit %s tag' % part) conddb.PartitionConnectionString[ part] = "sqlite_file:%(dir)s/%(part)s_%(tag)s.db/%(part)s" % { "dir": baseloc, "part": part, "tag": tag[part] } conddb.Tags[part] = tag[part] # Set the location of the Online conditions from Configurables import MagneticFieldSvc MagneticFieldSvc().UseSetCurrent = True online_xml = '%s/LHCb/2015/%%d/online.xml' % baseloc from Configurables import RunChangeHandlerSvc rch = RunChangeHandlerSvc() rch.Conditions = { "Conditions/Online/LHCb/Magnet/Set": online_xml, "Conditions/Online/Velo/MotionSystem": online_xml, "Conditions/Online/LHCb/Lumi/LumiSettings": online_xml, "Conditions/Online/LHCb/RunParameters": online_xml, "Conditions/Online/Rich1/R1HltGasParameters": online_xml, "Conditions/Online/Rich2/R2HltGasParameters": online_xml } ApplicationMgr().ExtSvc.append(rch)
def _configureDQTags(self): from Configurables import CondDB tag = None toset = MooreExpert().getProp("DQFLAGStag") if not len(toset) or toset == "latest" or toset == "default": from CondDBUI.Admin.TagsFilter import last_gt_lts dqtags = last_gt_lts('DQFLAGS', self.getProp("DataType")) if dqtags: tag = dqtags[0] else: tag = toset if CondDB().isPropertySet("Tags") and 'DQFLAGS' in CondDB().getProp( "Tags") and len(CondDB().getProp("Tags")["DQFLAGS"]): #don't set anything if it has already been set elsewhere pass elif tag: CondDB().Tags = Funcs._zipdict(CondDB().Tags, {"DQFLAGS": tag})
def configure(): from Gaudi.Configuration import (ApplicationMgr, MessageSvc, ERROR) from Configurables import DDDBConf, CondDB, CondDBAccessSvc, EventClockSvc, FakeEventTime dddbConf = DDDBConf() cdb = CondDB() cdb.PartitionConnectionString[ "DQFLAGS"] = "sqlite_file:../data/DQFLAGS.db/DQFLAGS" cdb.Tags["DQFLAGS"] = "" ecs = EventClockSvc(InitialTime=toTimeStamp(datetime(2012, 1, 1, 12))) ecs.addTool(FakeEventTime, "EventTimeDecoder") ecs.EventTimeDecoder.StartTime = ecs.InitialTime ecs.EventTimeDecoder.TimeStep = toTimeStamp(timedelta(days=1)) ApplicationMgr(TopAlg=["LoadDDDB"], EvtSel="NONE") MessageSvc(OutputLevel=ERROR)
def _configureDBSnapshot(self): """ Configure the database to use the online snapshot """ tag = { "DDDB": self.getProp('DDDBtag') , "LHCBCOND": self.getProp('CondDBtag') , "SIMCOND" : self.getProp('CondDBtag') , "ONLINE" : 'fake' } # https://savannah.cern.ch/bugs/?94454#comment12 from Configurables import MagneticFieldSvc MagneticFieldSvc().UseSetCurrent = True cdb = CondDB() cdb.Tags = tag cdb.setProp('IgnoreHeartBeat', True) cdb.setProp('EnableRunChangeHandler', True) self.setOtherProps( cdb, [ 'UseDBSnapshot', 'DBSnapshotDirectory', 'PartitionName' ]) if [det for det in ['Rich1', "Rich2", "Rich1Pmt", "Rich2Pmt"] if det in self.getProp("Detectors")]: log.warning( "using hack https://savannah.cern.ch/task/index.php?27329#comment45" ) from Configurables import RichRecSysConf rConf = RichRecSysConf("RichOfflineRec") rConf.Context = "HLT" from Configurables import RichRecQCConf rMoni = RichRecQCConf("OfflineRichMoni") rMoni.Context = "HLT"
def configure_data_opts(self, datafile, explicitTags = False, datatype = None, diracversion = 'prod') : if not isinstance(datafile, dict) : settings = self.get_data_settings(datafile, explicitTags, datatype, diracversion) else : settings = datafile if settings['DataType'] == None : if not datatype : raise ValueError("Couldn't determine DataType from LFNs and DataType isn't set manually!") settings['DataType'] = datatype if not 'CondDBtag' in settings : conddb = CondDB() conddb.LatestGlobalTagByDataType = settings['DataType'] self.extraobjs.add(conddb) for attr, val in settings.iteritems() : if hasattr(self.__class__, attr) : setattr(self, attr, val)
def defineDB(self): # Delegate handling of properties to DDDBConf self.setOtherProps(DDDBConf(), ["Simulation", "DataType"]) # Set CondDB tags if given, otherwise use default defined in DDDBConf from Configurables import CondDB if hasattr(self, "DDDBtag"): CondDB().Tags["DDDB"] = self.getProp("DDDBtag") if hasattr(self, "CondDBtag"): CondDB().Tags["LHCBCOND"] = self.getProp("CondDBtag") CondDB().Tags["SIMCOND"] = self.getProp("CondDBtag") if hasattr(self, "DQFLAGStag"): CondDB().Tags["DQFLAGS"] = self.getProp("DQFLAGStag") # Set up a time decoder for real data (Simulation uses FakeEventTime) if not self.getProp("Simulation"): from Configurables import EventClockSvc ecs = EventClockSvc() # do not overwrite already set values if not ecs.isPropertySet("EventTimeDecoder"): ecs.EventTimeDecoder = "OdinTimeDecoder"
def configure_data_opts(self, datafile, explicitTags = False, datatype = None, diracversion = None) : if not isinstance(datafile, dict) : settings = self.get_data_settings(datafile, explicitTags, datatype, diracversion) else : settings = datafile if settings['DataType'] == None : if not datatype : raise ValueError("Couldn't determine DataType from LFNs and DataType isn't set manually!") settings['DataType'] = datatype if not 'CondDBtag' in settings : conddb = CondDB() conddb.LatestGlobalTagByDataType = settings['DataType'] self.extraobjs.add(conddb) for attr, val in settings.iteritems() : if hasattr(self.__class__, attr) : setattr(self, attr, val)
def patchBrunel(true_online_version): """ Instantiate the options to run Brunel with raw data @author M.Frank """ import Brunel.Configuration import OnlineEnv brunel = Brunel.Configuration.Brunel() brunel.OnlineMode = True try: brunel.DDDBtag = OnlineEnv.DDDBTag except: print "DDDBTag not found, use default" try: brunel.CondDBtag = OnlineEnv.CondDBTag except: print "CondDBTag not found, use default" conddb = CondDB() conddb.IgnoreHeartBeat = True # # Adjust to pickup the proper online conditions # import Online as RunChange_All conddb.setProp('RunChangeHandlerConditions', RunChange_All.ConditionMap) conddb.setProp('EnableRunChangeHandler', True) # # Brunel output configuration # brunel.WriteFSR = False # This crashes Jaap's stuff brunel.DataType = "2013" brunel.OutputType = '' EventLoopMgr().OutputLevel = MSG_DEBUG #ERROR EventLoopMgr().Warnings = False from Configurables import EventClockSvc EventClockSvc().InitialTime = 1322701200000000000 brunel.UseDBSnapshot = True # try it # brunel.PartitionName = "FEST" # Hack by Chris print "# Warning using CKThetaQuartzRefractCorrections = [ 0,-0.0001,0 ]" from Configurables import RichRecSysConf rConf = RichRecSysConf("RichOfflineRec") rConf.richTools().photonReco().CKThetaQuartzRefractCorrections = [ 0, -0.001, 0 ] brunel.OutputLevel = MSG_WARNING brunel.PrintFreq = -1 HistogramPersistencySvc().OutputFile = "" HistogramPersistencySvc().OutputLevel = MSG_ERROR #print brunel return brunel
def configure(datafiles, catalogs=[], castor=False): """ Job configuration """ from PhysConf.Filters import LoKi_Filters fltrs = LoKi_Filters( VOID_Code= " 0.5 < CONTAINS('/Event/Charm/Phys/DstarForPromptCharm/Particles') ") ## ## 1. Static configuration using "Configurables" ## from Configurables import DaVinci davinci = DaVinci( DataType='2010', InputType='MDST', PrintFreq=1000, EventPreFilters=fltrs.filters('Filters'), HistogramFile='RealDstar_CHARM_Histos.root', TupleFile='RealDstar_CHARM.root', ## Lumi=True) from Configurables import CondDB CondDB(UseLatestTags=['2010']) from Configurables import NTupleSvc ntSvc = NTupleSvc() ## define the input data: setData(datafiles, catalogs, castor) ## ## 2. Jump into the wonderful world of the actual Gaudi components! ## ## get the actual application manager (create if needed) gaudi = appMgr() ## create local algorithm: alg = Dstar( # 'Dstar', ## Algorithm name # ## RecoStripping-09 conventions! RootInTES='/Event/Charm', Inputs=['Phys/DstarForPromptCharm/Particles'] ## input particles ) ## finally inform Application Manager about our algorithm userSeq = gaudi.algorithm('GaudiSequencer/DaVinciUserSequence', True) userSeq.Members += [alg.name()] return SUCCESS
def initialize(self): """ Instantiate the options to run Brunel with raw data @author M.Frank """ import Brunel.Configuration from Configurables import CondDB, HistogramPersistencySvc, EventLoopMgr self.app = Brunel.Configuration.Brunel() conddb = CondDB() conddb.IgnoreHeartBeat = True self.app.WriteFSR = False # This crashes Jaap's stuff EventLoopMgr().OutputLevel = 5 EventLoopMgr().Warnings = False HistogramPersistencySvc().OutputFile = "" if self.true_online_version: self.app.OutputLevel = 999 self.app.PrintFreq = -1
def set_tags(stereo=5): LHCbApp().Simulation = True CondDB().Upgrade = True t = {#"DDDB": "dddb-20140606", "DDDB": "dddb-20140827", #latest and greatest "CondDB": "sim-20140204-vc-md100", #"Others": ["VP_UVP_Rotation"], #"Others": ["VP_UVP+RICH_2019+UT_UUT", # "FT_StereoAngle5", "Muon_NoM1", "Calo_NoSPDPRS"], } t = { "DDDB": "dddb-20131025", "CondDB": "sim-20130830-vc-md100", "Others": ["VP_UVP+RICH_2019+UT_UUT", "FT_StereoAngle%s"%stereo, "Muon_NoM1", "Calo_NoSPDPRS"], } LHCbApp().DDDBtag = t['DDDB'] LHCbApp().CondDBtag = t['CondDB'] if 'Others' in t: CondDB().AllLocalTagsByDataType = t['Others']
def defineGeometry(self): # DIGI is always simulation, as is usage of MC truth! if self.getProp("WithMC") or self.getProp( "InputType").upper() == 'DIGI': self.setProp("Simulation", True) # Delegate handling to LHCbApp configurable self.setOtherProps(LHCbApp(), ["DataType", "CondDBtag", "DDDBtag", "Simulation"]) # specify the use of the oracle database if self.getProp("UseOracle"): from Configurables import CondDB CondDB(UseOracle=True)
def EscherCommon(true_online_version, alignment_module): import GaudiConf.DstConf import Escher.Configuration from Configurables import MagneticFieldSvc from Configurables import TAlignment from TAlignment.VertexSelections import configuredPVSelection from Configurables import RunChangeHandlerSvc OnlineEnv = importOnline() import ConditionsMap escher = Escher.Configuration.Escher() escher.DataType = '2015' escher.DDDBtag = ConditionsMap.DDDBTag escher.CondDBtag = ConditionsMap.CondDBTag escher.OnlineMode = True escher.UseDBSnapshot = True escher.DBSnapshotDirectory = "/group/online/hlt/conditions/" if hasattr(OnlineEnv, "AlignXmlDir"): escher.OnlineAligWorkDir = os.path.join(OnlineEnv.AlignXmlDir, 'running') sys.path.insert(2, os.path.dirname(OnlineEnv.ConditionsMapping)) import Online as OnlineConds handlerConditions = OnlineConds.ConditionMap # if true_online_version and os.environ['PARTITION_NAME'] == 'TEST': # re_year = re.compile('(201\d)') # for k, v in handlerConditions.items(): # handlerConditions[re_year.sub('2014', k)] = v conddb = CondDB() conddb.RunChangeHandlerConditions = handlerConditions conddb.IgnoreHeartBeat = True config_module = importlib.import_module('AlignmentConfigurations.' + alignment_module) config_module.configureAlignment() return escher
def configure(inputdata, catalogs=[]): """ The configuration of the job """ ## Define event-level filters: from PhysConf.Filters import LoKi_Filters fltrs = LoKi_Filters(STRIP_Code=""" HLT_PASS_RE ( 'Stripping.*ForPromptCharm.*Decision' ) """, VOID_Code=""" ( 0.5 < CONTAINS ('/Event/Charm/Phys/DForPromptCharm/Particles' ) ) | ( 0.5 < CONTAINS ('/Event/Charm/Phys/DsForPromptCharm/Particles' ) ) """) filters = fltrs.filters('Filters') filters.reverse() from Configurables import DaVinci, GaudiSequencer DaVinci(DataType='2011', EventPreFilters=filters, Lumi=False, HistogramFile='Dplus_Histos.root', TupleFile='Dplus_Tuples.root') from Configurables import CondDB CondDB(IgnoreHeartBeat=True) setData(inputdata, catalogs) ## get/create Application Manager gaudi = appMgr() # modify/update the configuration: ## create the algorithm alg = SelectDplus( 'Dplus', ## Reco10-Stripping13 : RootInTES='/Event/Charm', # Inputs=[ 'Phys/DForPromptCharm/Particles', 'Phys/DsForPromptCharm/Particles' ]) ## add algorithm into DaVinci sequence dvUser = gaudi.algorithm('GaudiSequencer/DaVinciUserSequence', True) dvUser.Members += [alg.name()] return SUCCESS
def configure ( datafiles , catalogs = [] , castor = False , params = {} ) : """ Configure the job """ ## ## 1. Static configuration using "Configurables" ## the_year = '2012' from Configurables import DaVinci dv = DaVinci ( DataType = the_year , ) alg_name = 'MyAlg' davinci.UserAlgorithms += [ alg_name ] from Configurables import CondDB CondDB ( LatestGlobalTagByDataType = the_year ) from Configurables import LHCbApp LHCbApp().XMLSummary = 'summary.xml' from BenderTools.Utils import silence silence() ## define/set the input data setData ( datafiles , catalogs ) ## ## jump into the wonderful world of the actual Gaudi components! ## ## get the actual application manager (create if needed) gaudi = appMgr() ## create local algorithm: alg = Template( alg_name ## algorithm instance name ) return SUCCESS
def configure(datafiles, catalogs=[], castor=False): """ Job configuration """ ## ## 1. Static configuration using "Configurables" ## from Configurables import DaVinci davinci = DaVinci(DataType='2010', PrintFreq=1000, HistogramFile='Lam0_Akshay_Histos.root', TupleFile='Lam0_Akshay_Tuples.root', Lumi=False) from Configurables import CondDB CondDB(IgnoreHeartBeat=True) from StandardParticles import (StdLoosePions, StdNoPIDsDownPions, StdLooseProtons, StdNoPIDsDownProtons) InputParticles = [ StdLoosePions.outputLocation(), StdNoPIDsDownPions.outputLocation(), StdLooseProtons.outputLocation(), StdNoPIDsDownProtons.outputLocation() ] # ## define the input data: setData(datafiles, catalogs, castor) ## ## 2. Jump into the wonderful world of the actual Gaudi components! ## ## get the actual application manager (create if needed) gaudi = appMgr() ## create local algorithm: alg = Lam0( 'Lam0', ## Algorithm name Inputs=InputParticles) userSeq = gaudi.algorithm('GaudiSequencer/DaVinciUserSequence', True) userSeq.Members += [alg.name()] return SUCCESS
def startGaudiInspect(aligndb=""): global appMgr LHCbApp().DDDBtag = "" LHCbApp().CondDBtag = "" if aligndb: from Configurables import (CondDB, CondDBAccessSvc) counter = 1 for db in aligndb: alignCond = CondDBAccessSvc('AlignCond' + str(counter)) alignCond.ConnectionString = 'sqlite_file:' + db + '/LHCBCOND' CondDB().addLayer(alignCond) counter += 1 appConf = ApplicationMgr(OutputLevel=INFO, AppName='myBrunel') appMgr = GaudiPython.AppMgr()
def _configureDBSnapshot(self): from Configurables import CondDB conddb = CondDB() conddb.EnableRunStampCheck = False conddb.Tags["ONLINE"] = 'fake' conddb.setProp('IgnoreHeartBeat', self.getProp('IgnoreDBHeartBeat')) self.setOtherProps(conddb, [ 'UseDBSnapshot', 'DBSnapshotDirectory', 'EnableRunChangeHandler', 'RunChangeHandlerConditions' ]) # https://savannah.cern.ch/bugs/?94454#comment12 from Configurables import MagneticFieldSvc MagneticFieldSvc().UseSetCurrent = True
def initialise(dddbtag = '', datatype = '') : global pps if pps : return import PartProp.PartPropAlg import PartProp.Service from GaudiPython.Bindings import AppMgr import sys from Configurables import LHCbApp if dddbtag : LHCbApp().DDDBtag = dddbtag elif datatype: from Configurables import CondDB CondDB().LatestGlobalTagByDataType = datatype gaudi = AppMgr() # Annoyingly have to initialise the AppMgr to initialise the ppSvc gaudi.initialize() pps = gaudi.ppSvc()
def startInspect(): global appMgr LHCbApp().DDDBtag = "head-20100518" LHCbApp().CondDBtag = "head-20100518" try: if alignDB: from Configurables import ( CondDB, CondDBAccessSvc ) counter = 1 for db in alignDB: alignCond = CondDBAccessSvc( 'AlignCond' + str(counter) ) alignCond.ConnectionString = 'sqlite_file:' + db + '/LHCBCOND' CondDB().addLayer( alignCond ) counter += 1 except: pass appConf = ApplicationMgr( OutputLevel = INFO, AppName = 'myBrunel' ) appMgr = GaudiPython.AppMgr() print "/dd/Structure/LHCb/BeforeMagnetRegion/TT"
def configure( inputdata , catalogs = [] ) : """ The configuration of the job """ ## define event-levele filters: from PhysConf.Filters import LoKi_Filters fltrs = LoKi_Filters ( HLT_Code = " HLT_PASS_RE ('Hlt1MBMicro.*Decision') | HLT_PASS_RE ('Hlt1.*Hadron.*Decision') " , STRIP_Code = " HLT_PASS('StrippingK0SLineDecision') " , VOID_Code = " EXISTS ('/Event/V0') " ) from Configurables import DaVinci , GaudiSequencer DaVinci ( DataType = '2010' , EventPreFilters = fltrs.filters ('Filters') , Lumi = False ) from Configurables import CondDB CondDB ( IgnoreHeartBeat = True ) setData ( inputdata , catalogs ) ## get/create Application Manager gaudi = appMgr() # modify/update the configuration: ## create the algorithm alg = SelectKs ( 'SelectKs' , RootInTES = '/Event/V0' , InputLocations = [ 'StrippingK0S' ] ) ## add algorithm into main DaVinci sequence dvMain = gaudi.algorithm('GaudiSequencer/DaVinciMainSequence' , True ) dvMain.Members += [ alg.name() ] return SUCCESS
def configure( inputdata , catalogs = [] ) : """ The configuration of the job """ from Configurables import DaVinci , GaudiSequencer DaVinci ( DataType = '2010' , Simulation = True , ## ATTENTION!!! Lumi = False , HistogramFile = 'DplusMC_Histos.root' ) from Configurables import CondDB CondDB ( IgnoreHeartBeat = True ) setData ( inputdata , catalogs ) ## get/create Application Manager gaudi = appMgr() # modify/update the configuration: ## create the algorithm alg = SelectDplusMC ( 'DplusMC' , # Inputs = [ 'Phys/StdLooseKaons/Particles' , 'Phys/StdLoosePions/Particles' ] , # Use LoKi-fitters : ParticleCombiners = { '' : "LoKi::VertexFitter" } , # be efficient: use MC-truth only for charged particles: PP2MCs = [ 'Relations/Rec/ProtoP/Charged'] ) ## add algorithm into main DaVinci sequence dvUser = gaudi.algorithm('GaudiSequencer/DaVinciUserSequence' , True ) dvUser.Members += [ alg.name() ] return SUCCESS
def configure(self, configuration): from Configurables import LHCbApp app = LHCbApp() for (attr, value) in configuration.items(): if hasattr(app, attr): setattr(app, attr, value) self._config[attr] = value EventSelector().Input = self._config['Input'] if 'Catalogs' in self._config.keys(): FileCatalog().Catalogs = self._config['Catalogs'] from Configurables import DecodeRawEvent importOptions("$L0DUOPTS/L0DUConfig.opts") EventPersistencySvc().CnvServices.append('LHCb::RawDataCnvSvc') EventSelector().PrintFreq = 1000 from Configurables import CondDB CondDB().Online = True from Configurables import GaudiSequencer as Sequence from Configurables import createODIN, HltRoutingBitsFilter seq = Sequence("MonitorSequence") physFilter = HltRoutingBitsFilter("PhysFilter", RequireMask=[0x0, 0x4, 0x0]) co = createODIN() seq.Members = [co, physFilter] from DAQSys.Decoders import DecoderDB from itertools import product for stage, t in product(('Hlt1', 'Hlt2'), ('Dec', 'Sel', 'Vertex')): an = "{0}{1}ReportsDecoder".format(stage, t) seq.Members += [ DecoderDB["Hlt%sReportsDecoder/%s" % (t, an)].setup() ] ApplicationMgr().TopAlg = [seq] self._extra_config(seq)
from Gaudi.Configuration import * from Configurables import DetCondTest__TestConditionAlg as TestAlg from Configurables import LoadDDDB, DDDBConf, CondDB DDDBConf() # Configure the detector description conddb = CondDB() conddb.LatestGlobalTagByDataTypes = ['2012'] from Configurables import UpdateManagerSvc UpdateManagerSvc().ConditionsOverride += [ "Conditions/Alignment/TT/TTaXLayerR1Module1T := double_v dPosXYZ = 0. 0. 0.; double_v dRotXYZ = 0. 0. 1.;" ] testAlg = TestAlg("TestCond") testAlg.Conditions = [ "Conditions/Alignment/TT/TTaXLayerR1Module1T" ] app = ApplicationMgr() app.TopAlg = [ TestAlg("TestCond") ] app.EvtSel = "NONE" app.EvtMax = 1
pxml = None try: pxml = os.path.join(os.path.dirname(os.path.realpath(__file__)), "Parameters.xml") except: pxml = os.path.join(os.getcwd(), "Parameters.xml") actor.Parameters = "file://" + pxml actor.VisAttrs = os.path.join(os.getcwd(), "Visattrs.xml") #actor.Config = [os.path.join(os.getcwd(), "apps/DD4hep/examples/DDDB/data/VPOnly.xml")] example_alg = LbDD4hepExample() ApplicationMgr().TopAlg = [actor, example_alg] # Just instantiate the configurable... theApp = MyTest() ToolSvc.LogLevel=DEBUG cdb = CondDB() tag = { "DDDB": '' , "LHCBCOND": 'default' #, "SIMCOND" : 'upgrade/dd4hep' , "SIMCOND" : '' , "ONLINE" : 'fake' } cdb.Tags = tag cdb.setProp('IgnoreHeartBeat', True) cdb.setProp('EnableRunChangeHandler', True) #cdb.LogFile = "/tmp/cdb.log" cdb.Upgrade = True theApp.setOtherProps( cdb, [ 'UseDBSnapshot', 'DBSnapshotDirectory', 'PartitionName' ])
dv = DaVinci() dv.DataType = "2010" dv.Simulation = False dv.EvtMax = -1 dv.TupleFile = 'b2hh_stripped.root' dv.PrintFreq = 100 condDB = CondDB() condDB.UseOracle = True dv.DDDBtag = "head-20100518" dv.CondDBtag = "head-20100715" dv.Lumi = True dv.WriteFSR = True dv.UserAlgorithms = [ evttuple, preseltuple ]