def __call__(self): from Configurables import EventClockSvc, FakeEventTime clkSvc = EventClockSvc() clkSvc.EventTimeDecoder = "FakeEventTime" clkSvc.addTool(FakeEventTime, "FakeEventTime") clkSvc.FakeEventTime.StartTime = self.__initialTime + 1 from Configurables import GaudiSequencer, createODIN initSeq = GaudiSequencer("InitEscherSeq") initSeq.Members.insert(0, createODIN())
def configureEventTime(): """ Configure EventClockSvc to get event time from RecHeader first and then from ODIN in case of failure. Returns EventClockSvs() Author: Marco Clemencic. """ #turn off setting that's done in DecodeRawEvent first DecodeRawEvent().EvtClockBank = "" ecs = EventClockSvc() ecs.addTool(TimeDecoderList, "EventTimeDecoder") tdl = ecs.EventTimeDecoder tdl.addTool(RecEventTime) tdl.addTool(OdinTimeDecoder) tdl.Decoders = [tdl.RecEventTime, tdl.OdinTimeDecoder] return ecs
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 setupOnline(): """ Setup the online environment: Buffer managers, event serialisation, etc. @author M.Frank """ from Configurables import LHCb__FILEEvtSelector as es from Configurables import LHCb__AlignDrv as Adrv from Configurables import EventClockSvc Online = importOnline() app = Gaudi.ApplicationMgr() app.AppName = '' app.HistogramPersistency = 'ROOT' app.SvcOptMapping.append('LHCb::FILEEvtSelector/EventSelector') app.SvcOptMapping.append('LHCb::FmcMessageSvc/MessageSvc') #app.EvtMax = 10000 Online.rawPersistencySvc() evtloop = Configs.EventLoopMgr('LHCb::OnlineRunable/EmptyEventLoop') evtloop.Warnings = False evtloop.EvtSel = "NONE" app.EventLoop = evtloop app.HistogramPersistency = "NONE" # runable = Configs.Runable # runable.MEPManager = "" app.AuditAlgorithms = False Configs.MonitorSvc().OutputLevel = MSG_ERROR Configs.MonitorSvc().UniqueServiceNames = 1 Configs.RootHistCnv__PersSvc("RootHistSvc").OutputLevel = MSG_ERROR app.OutputLevel = MSG_INFO def __propAtt(att, fr, to, d=None): if hasattr(fr, att): setattr(to, att, getattr(fr, att)) elif d: setattr(to, att, d) from Configurables import AlignOnlineIterator as Aiter ad = Adrv("AlignDrv") ad.PartitionName = Online.PartitionName ad.FitterClass = "AlignOnlineIterator" ad.FitterName = "AlIterator" __propAtt('RefFileName', Online, ad) ## The Alignment driver is the runable app.Runable = ad.getType() + "/" + ad.getName() ad.addTool(Aiter, ad.FitterName) ai = ad.AlIterator ai.PartitionName = Online.PartitionName ai.ASDFilePattern = "_Escher.out" ai.OutputLevel = 3 ai.MaxIteration = MAX_NITER ai.ServiceInfix = "" ai.ReferenceRunNr = Online.DeferredRuns[0] if hasattr( Online, "DeferredRuns") else -1 runType = os.environ.get('RUN_TYPE', 'Unknown') runType = runType.split('|')[-1].strip() if '|' in runType else runType if runType == 'Tracker': sds = ['TT', 'IT', 'OT'] ai.RunType = runType elif runType in ('Velo', 'Muon'): sds = [runType] ai.RunType = runType else: print 'WARNING: RUN_TYPE is not one of Velo, Tracker or Muon. Will assume all subdetectors' sds = ['Velo', 'TT', 'IT', 'OT', 'Muon'] ai.SubDetectors = sds # for attr, default in [('ASDDir', "/group/online/alignment/EscherOut/"), # ('OnlineXmlDir', "/group/online/alignment"), # ('AlignXmlDir', "/group/online/AligWork")]: for attr, default in [('ASDDir', "/calib/align/EscherOut/"), ('OnlineXmlDir', "/group/online/alignment"), ('AlignXmlDir', "/group/online/AligWork")]: __propAtt(attr, Online, ai, default) initialTime = long(time.time() * 1e9) clkSvc = EventClockSvc() clkSvc.InitialTime = initialTime from Configurables import FakeEventTime clkSvc.EventTimeDecoder = "FakeEventTime" clkSvc.addTool(FakeEventTime, "FakeEventTime") clkSvc.FakeEventTime.StartTime = initialTime
k = ks[i] excl=False; for j in range(len(excludeFiles)): if k.find(excludeFiles[j]) >= 0: excl = True break if excl : continue detxml = k[k.rfind('/')+1:] det = detxml[:detxml.rfind('.xml')] det = det.lower() dets.append(det) print "Moving to Offline DB the following detector Data ",dets ecs = EventClockSvc() ecs.InitialTime = RunOption.RunStartTime*1000000000 ecs.addTool(FakeEventTime,"EventTimeDecoder") ecs.EventTimeDecoder.StartTime = ecs.InitialTime ecs.EventTimeDecoder.TimeStep = 10 #xmlCnvSvc = XmlCnvSvc(AllowGenericConversion = True) DDDBConf() #detDataSvc = DetectorDataSvc() #DetectorPersistencySvc( CnvServices = [ xmlCnvSvc ] ) cdb = CondDB() cdb.RunChangeHandlerConditions=CondMap.ConditionMap cdb.EnableRunChangeHandler = True cdb.EnableRunStampCheck=False cdb.UseDBSnapshot = True cdb.Tags = { "DDDB" : RunOption.DDDBTag, "LHCBCOND" : RunOption.CondDbTag, "ONLINE" : 'fake'}
def extractAlignmentParameters( elementsWithTESAndCondDBNodes, since, until, valueExtractor=lambda detElm: getGlobalPositionFromGeometryInfo( detElm.geometry()), DDDBtag="default", CondDBtag="default", alignDBs=[]): """ The method talking to the detector svc Extract from all DetectorElements down from each element in elementsWithTESAndCondDBNodes ( format { elm : ( detTES, [ condDBNode ] ) } ), alignment parameters using valueExtractor, for all iovs between since and until (datetimes), using the CondDBNodes. The default database is configured with database tags DDDBtag and CondDBtag, and all alignDBs [ (tag, connectString) ] are added as layers to the CondDB. Returns a dict { element : [ ( (iovBegin, iovEnd), alignmentTree ) ] } """ # Static configuration of the application manager from Configurables import LHCbApp, ApplicationMgr from LHCbKernel.Configuration import FATAL, ERROR, WARNING, INFO, DEBUG, VERBOSE ApplicationMgr().AppName = "AlignmentCollector" ApplicationMgr().OutputLevel = ERROR LHCbApp().DDDBtag = DDDBtag LHCbApp().CondDBtag = CondDBtag # >>> This part stolen from Det/DetCond/tests/scripts/getIOVs.py ApplicationMgr().TopAlg = ["LoadDDDB"] from Configurables import EventClockSvc, FakeEventTime ecs = EventClockSvc( InitialTime=toTimeStamp(datetime(2010, 1, 1, 12, tzinfo=pytz.utc))) ecs.addTool(FakeEventTime, "EventTimeDecoder") ecs.EventTimeDecoder.StartTime = ecs.InitialTime ecs.EventTimeDecoder.TimeStep = toTimeStamp(timedelta(days=1)) # <<< + "lhcbcond" below layers = ["LHCBCOND"] if len(alignDBs) > 0: from Configurables import CondDB, CondDBAccessSvc for i, (connectString, tag) in enumerate(alignDBs): layerName = "AlignCond%i" % i alignCond = CondDBAccessSvc(layerName) alignCond.ConnectionString = connectString alignCond.DefaultTAG = tag CondDB().addLayer(alignCond) layers.append(layerName) # run a gaudi application from GaudiPython import AppMgr, gbl gaudi = AppMgr() gaudi.createSvc("UpdateManagerSvc") updateManagerSvc = gaudi.service("UpdateManagerSvc", interface="IUpdateManagerSvc") gaudi.initialize() conddbReaders = list( gaudi.service(name, gbl.ICondDBReader) for name in reversed(layers)) detDataSvc = updateManagerSvc.detDataSvc() alignmentTrees = dict( (detName, []) for detName in elementsWithTESAndCondDBNodes.iterkeys()) for detName, (detPath, condNodes) in elementsWithTESAndCondDBNodes.iteritems(): ### get the IOVs for all elements, and combine them timeLine = [("gap", (since, until))] for layerReader in conddbReaders: timeLineUpdated = list(timeLine) alreadyInserted = 0 for i, (typ, (gapBegin, gapEnd)) in enumerate(timeLine): if typ == "gap": iovs = combinedIOVs([ list((max(toDateTime(iov.since.ns()), gapBegin), min(toDateTime(iov.until.ns()), gapEnd)) for iov in layerReader.getIOVs( node, gbl.ICondDBReader.IOV( gbl.Gaudi.Time(toTimeStamp(gapBegin)), gbl.Gaudi.Time(toTimeStamp(gapEnd))), 0)) for node in TrackingAlignmentCondDBNodes[detName] ]) if len(iovs) != 0: updatedTimeSlice = list( ("iov", (begin, end)) for begin, end in iovs) if updatedTimeSlice[0][1][0] > gapBegin: updatedTimeSlice.insert( 0, ("gap", (gapBegin, updatedTimeSlice[0][1][0]))) if updatedTimeSlice[-1][1][1] < gapEnd: updatedTimeSlice.append( ("gap", (updatedTimeSlice[-1][1][1], gapEnd))) timeLineUpdated[i + alreadyInserted:i + alreadyInserted + 1] = updatedTimeSlice alreadyInserted += len(updatedTimeSlice) - 1 logging.debug("timeline after adding %s : %s" % (layerReader, timeLine)) timeLine = timeLineUpdated iovs = list(timespan for typ, timespan in timeLine if typ == "iov") ### For every IOV, extract the parameters for begin, end in iovs: detDataSvc.setEventTime( gbl.Gaudi.Time(toTimeStamp(begin + (end - begin) / 2))) updateManagerSvc.newEvent() motionSystem = None if detName != "Velo" else gaudi.detSvc( ).getObject("/dd/Conditions/Online/Velo/MotionSystem") logging.info("Extracting parameters for %s between %s and %s" % (detName, begin, end)) detTree = getAlignableTreeFromDetectorElement( gaudi.detSvc().getObject(detPath), nodeValue=valueExtractor, parentName=detPath, motionSystem=motionSystem) detTree.name = detName alignmentTrees[detName].append(((begin, end), detTree)) gaudi.finalize() gaudi.exit() return alignmentTrees
for i, v in DecoderDB.iteritems(): v.Properties["OutputLevel"] = VERBOSE if "Hlt" in i and "ReportsDecoder" in i: v.Active = False #v.Inputs={"InputRawEventLocation":"DAQ/RawEvent"} for b in ["UT", "FT", "FTCluster", "VP", "VL"]: if b in v.Banks: v.Active = False DecoderDB["MuonRec"].Active = False DecoderDB["createODIN"].Active = False #DecoderDB["OdinTimeDecoder/ToolSvc.OdinTimeDecoder"].Active=True from Configurables import EventClockSvc, OdinTimeDecoder, ODINDecodeTool ecs = EventClockSvc() ecs.addTool(OdinTimeDecoder, 'EventTimeDecoder') ecs.EventTimeDecoder.addTool(ODINDecodeTool) ecs.EventTimeDecoder.ODINDecodeTool.RawEventLocations = ['Crazy/RawEvent'] DecodeRawEvent().OverrideInputs = 999 from Configurables import GaudiSequencer #DecodeRawEvent().Sequencer=GaudiSequencer("SPAM") for i, v in DecoderDB.iteritems(): if v.Active: GaudiSequencer("SPAM").Members.append(v.setup()) from Configurables import StoreExplorerAlg StoreExplorerAlg().Load = True
def setup(): initialTime = long(time.time() * 1e9) OTGaudiSeq = GaudiSequencer("OTt0OnlineClbrSeq") OTt0OnlineClbrAlg = OTt0OnlineClbr("OTt0OnlineClbrAlg") #OTt0OnlineClbrAlg.InputFiles = [ "/hist/Savesets/2013/LHCb/Brunel/01/20/Brunel-135576-20130120T161302-EOR.root"] # OT T0 calibration algorithm OTt0OnlineClbrAlg.InputTasks = ["Brunel"] OTt0OnlineClbrAlg.Partition = partition OTt0OnlineClbrAlg.ReadInitialT0FromDB = False OTt0OnlineClbrAlg.SaveFits = False OTt0OnlineClbrAlg.RunOnline = True OTt0OnlineClbrAlg.CheckDataT0 = True OTt0OnlineClbrAlg.PublishedName = "OT/Calib" OTt0OnlineClbrAlg.XMLFilePath = "/group/online/alignment/OT/Calib" OTt0OnlineClbrAlg.OutputLevel = MSG_INFO OTt0OnlineClbrAlg.UseClockPhase = (partition != "FEST") OTt0OnlineClbrAlg.InitialTime = initialTime OTt0OnlineClbrAlg.Threshold = 0.1 OTt0OnlineClbrAlg.MaxDifference = 2 # Keep analysis task going. OTt0OnlineClbrAlg.StopAlgSequence = False OTGaudiSeq.Members += [OTt0OnlineClbrAlg] OTGaudiSeq.IgnoreFilterPassed = True ## Configure saving of histograms from Configurables import UpdateAndReset ur = UpdateAndReset() ur.saveHistograms = 1 ApplicationMgr().TopAlg.insert(0, ur) from Configurables import MonitorSvc MonitorSvc().disableDimPropServer = 1 MonitorSvc().disableDimCmdServer = 1 #import OnlineEnv MonitorSvc().ExpandCounterServices = 0 MonitorSvc().ExpandNameInfix = "<part>_x_<program>/" #MonitorSvc().PartitionName = OnlineEnv.PartitionName; MonitorSvc().PartitionName = partition MonitorSvc().ProgramName = "OTOnlineCalib_0" #setup the histograms and the monitoring service #ApplicationMgr().ExtSvc.append( 'MonitorSvc' ) from Configurables import RootHistCnv__PersSvc RootHistCnv__PersSvc().OutputEnabled = False ApplicationMgr().TopAlg += [OTGaudiSeq] ApplicationMgr().EvtSel = "NONE" ApplicationMgr().ExtSvc += [ "LHCb::PublishSvc", "MonitorSvc", "IncidentSvc" ] ApplicationMgr().Runable = "LHCb::OnlineRunable/Runable" from Configurables import CondDB conddb = CondDB() conddb.Tags["ONLINE"] = 'fake' conddb.IgnoreHeartBeat = True conddb.UseDBSnapshot = True conddb.DBSnapshotDirectory = "/group/online/hlt/conditions" from Configurables import EventClockSvc, FakeEventTime, EventDataSvc ecs = EventClockSvc() ecs.InitialTime = initialTime ecs.addTool(FakeEventTime, "EventTimeDecoder") ecs.EventTimeDecoder.StartTime = initialTime ecs.EventTimeDecoder.TimeStep = 10 EventDataSvc().ForceLeaves = True # Configure DB tags and per-run conditions to be used to be the same as what # the HLT1 reconstruction farm uses. This is done by directly importing the # python file to ensure the script can also start when LHCb is running # passthrough. conddb.EnableRunChangeHandler = True conddb.RunChangeHandlerConditions = { 'LHCb/2015/%d/ot.xml': ["Conditions/Calibration/OT/CalibrationGlobal"] } from Configurables import LHCbApp import ConditionsMap LHCbApp().CondDBtag = ConditionsMap.CondDBTag LHCbApp().DDDBtag = ConditionsMap.DDDBTag # LHCbApp().CondDBtag = 'cond-20150409-2' # LHCbApp().DDDBtag = 'dddb-20150119-3' LHCbApp().DataType = '2015'
def bindFakeEventTime(): from Configurables import EventClockSvc, FakeEventTime ecs = EventClockSvc() ecs.addTool(FakeEventTime, "FakeEventTime") ecs.FakeEventTime.StartTime = ecs.getProp("InitialTime")
#--Set the energy of the beam, #--the half effective crossing angle (in LHCb coordinate system), #--beta* and emittance (e_norm ~ 2 microns) Gauss().BeamMomentum = 5.023 * SystemOfUnits.TeV Gauss().BeamHCrossingAngle = -0.236 * SystemOfUnits.mrad Gauss().BeamVCrossingAngle = 0.0 Gauss().BeamEmittance = 0.0022 * SystemOfUnits.mm Gauss().BeamBetaStar = 3.0 * SystemOfUnits.m Gauss().BeamLineAngles = [0.0, 0.0] # Introduce a vertical crossing angle def setVCrossingAngle(): from Configurables import GenInit genInit = GenInit("GaussGen") genInit.VerticalCrossingAngle = 0.100 * SystemOfUnits.mrad from Gaudi.Configuration import * appendPostConfigAction(setVCrossingAngle) # #--Starting time, all events will have the same #--Can be used for beam conditions: YEBM (year,energy,bunch-spacing,field) ec = EventClockSvc() ec.addTool(FakeEventTime(), name="EventTimeDecoder") ec.EventTimeDecoder.StartTime = 2401.0 * SystemOfUnits.ms ec.EventTimeDecoder.TimeStep = 0.0