Ejemplo n.º 1
0
 def __set_init_time__(self, utcDatetime):
     """
     Configure the initialization time,
     depends on the value of self.IntitialTime
     Default: using the lower between the proposed time and the current time
     'Now' : use the higher between the current time and the proposed time
     dateime : use this datetime
     """
     #default situation
     if self.getProp("InitialTime").lower()=="safe" or not len(self.getProp("InitialTime")):
         #default situation
         utcDatetime = min(datetime.utcnow(), utcDatetime)
     elif self.getProp("InitialTime").lower()=="now":
         #Moore!
         utcDatetime = max(datetime.utcnow(), utcDatetime)
     else:
         raise TypeError("DDDBConf.InitialTime, I don't have a good way to convert "+self.getProp("InitialTime")+" to a datetime, please use 'Now' or 'Safe'")
     from Configurables import EventClockSvc
     ecs = EventClockSvc()
     # do not overwrite already set values
     if not ecs.isPropertySet("InitialTime"):
         dt = utcDatetime - datetime(1970, 1, 1, 0)
         ns = (dt.days * 24 * 60 * 60 + dt.seconds) * 1000000000
         ecs.InitialTime = ns
     else:
         t = datetime(1970, 1, 1, 0) + timedelta(seconds=ecs.InitialTime/1000000000)
         log.warning("EventClockSvc().InitialTime already set to %s UTC (requested %s UTC)",
                     t.isoformat(), utcDatetime.isoformat())
Ejemplo n.º 2
0
def patchEscher(true_online_version, alignment_module, n=-1):
    import GaudiConf.DstConf
    import Escher.Configuration
    from Configurables import MagneticFieldSvc
    from Configurables import TAlignment
    from TAlignment.VertexSelections import configuredPVSelection
    Online = importOnline()

    from Configurables import EventClockSvc
    initialTime = long(time.time() * 1e9)
    clkSvc = EventClockSvc()
    clkSvc.InitialTime = initialTime

    from Gaudi.Configuration import appendPostConfigAction
    appendPostConfigAction(fakeEventTime(initialTime))

    TAlignment().RunList = Online.DeferredRuns if hasattr(
        Online, "DeferredRuns") else []
    sys.stdout.flush()
    sys.stderr.flush()
    escher = EscherCommon(true_online_version, alignment_module)
    hostname = HostName()
    escher.InputType = "MDF"
    escher.PrintFreq = 10000
    #   escher.EvtMax=300
    #   asddir = Online.ASDDir + "/" if hasattr(Online, "ASDDir") else "/group/online/alignment/EscherOut/"
    asddir = Online.ASDDir + "/" if hasattr(
        Online, "ASDDir") else "/calib/align/EscherOut/"
    if n == -1:
        suffix = "_Escher.out"
    else:
        suffix = ("_%02d_Escher.out" % n)
    TAlignment().OutputDataFile = asddir + hostname + suffix
    TAlignment().UpdateInFinalize = False
    return escher
Ejemplo n.º 3
0
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
Ejemplo n.º 4
0
for i in range(len(ks)):
  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,
Ejemplo n.º 5
0
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'
Ejemplo n.º 6
0
# Configure Brunel
from Configurables import LHCbApp
app = LHCbApp()
app.DataType = '2015'
app.Simulation = False
app.EvtMax = 1

import HLT2Params
app.DDDBtag = HLT2Params.DDDBTag
app.CondDBtag = HLT2Params.CondDBTag


from Configurables import EventClockSvc, FakeEventTime, EventDataSvc
ecs = EventClockSvc()
ecs.InitialTime = arguments.start[0]
ecs.addTool(FakeEventTime, "EventTimeDecoder")
ecs.EventTimeDecoder.TimeStep = 10
ecs.EventTimeDecoder.StartTime = arguments.start[0]

from Configurables import DumpConditions
DumpConditions().RunStartTime = arguments.start[0]
DumpConditions().RunNumber = arguments.run[0]
DumpConditions().OutFile= arguments.output[0]
DumpConditions().Conditions = list_conditions

from Configurables import CondDB
cdb = CondDB()
if arguments.online:
    import CondMap
    cdb.RunChangeHandlerConditions = CondMap.ConditionMap