예제 #1
0
    def defineOptions(self):
        log.info("Defining options!")

        inputType = self.getProp("InputType").upper()
        if inputType not in ["MDF", "DST", "DIGI", "ETC", "RDST"]:
            raise TypeError("Invalid inputType '%s'" % inputType)

        outputType = self.getProp("OutputType").upper()
        if outputType not in ["NONE", "DST", "RDST"]:
            raise TypeError("Invalid outputType '%s'" % outputType)

        self.configureSequences()

        self.configurePersistency()

        self.configureInput(inputType)

        self.configureOutput(outputType)

        # ROOT persistency for histograms
        importOptions('$STDOPTS/RootHist.opts')
        from Configurables import RootHistCnv__PersSvc
        RootHistCnv__PersSvc('RootHistCnv').ForceAlphaIds = True

        # Use a default histogram file name if not already set
        if not hasattr(HistogramPersistencySvc(), "OutputFile"):
            histosName = self.getProp("DatasetName")
            if (self.evtMax() > 0):
                histosName += '-' + str(self.evtMax()) + 'ev'
            histosName += '-histos.root'
            HistogramPersistencySvc().OutputFile = histosName
예제 #2
0
    def __configureOutput(self):
        histoFile = self.getProp("OutputFile")
        if not histoFile:
            return

        from Configurables import HistogramPersistencySvc, RootHistCnv__PersSvc
        HistogramPersistencySvc().OutputFile = histoFile
        RootHistCnv__PersSvc().OutputFile = histoFile
예제 #3
0
 def suppresswarningifneeded():
     #histogram warning isn't needed if I didn't want histograms
     from Configurables import RootHistCnv__PersSvc
     if RootHistCnv__PersSvc().getProp(
             "OutputFile") == "UndefinedROOTOutputFileName" or not len(
                 RootHistCnv__PersSvc().getProp("OutputFile")):
         RootHistCnv__PersSvc().OutputEnabled = False
     if HistogramPersistencySvc().getProp(
             "OutputFile") == '' or not HistogramPersistencySvc(
             ).isPropertySet("OutputFile"):
         HistogramPersistencySvc().Warnings = False
     #error from IODataManager is pointless when I have MDFs
     from Funcs import _minSetFileTypes
     if Moore().getProp("RunOnline") or _minSetFileTypes() in [
             "MDF", "RAW"
     ]:
         from Configurables import IODataManager
         IODataManager().DisablePFNWarning = True
예제 #4
0
def configure(host_type=None, initial_file=""):
    OnlineEnv = importOnline()

    ## ApplicationMgr
    from Configurables import ApplicationMgr
    appMgr = ApplicationMgr()

    # from Gaudi.Configuration import importOptions
    # importOptions("$HLT2MONITORINGROOT/options/Hlt2Publisher.opts")

    from Utilities import host_regex
    hostname = socket.gethostname()
    host_re = re.compile(host_regex)
    r = host_re.match(hostname)
    ht = ''
    if host_type and host_type in ('top', 'node', 'subfarm'):
        ht = host_type
    elif r:
        if r.group(1) in ('01', '02'):
            ht = 'top'
        elif r.group('subfarm') and not r.group('node'):
            ht = 'subfarm'
        elif r.group('subfarm') and r.group('node'):
            ht = 'node'

    if not ht:
        print '[ERROR] cannot determine type of host for running.'
        return
    elif ht != 'top':
        print '[ERROR] attempting to start publish service on another node than the top.'
        return

    from Configurables import MonitorSvc
    MonitorSvc().disableDimPropServer = 1
    MonitorSvc().disableDimCmdServer = 1

    MonitorSvc().ExpandCounterServices = 0
    MonitorSvc().ExpandNameInfix = "<part>_x_<program>/"
    MonitorSvc().PartitionName = OnlineEnv.PartitionName
    MonitorSvc().ProgramName = 'Moore2Saver_00'

    # setup the histograms and the monitoring service
    from Configurables import RootHistCnv__PersSvc
    RootHistCnv__PersSvc().OutputEnabled = False

    ## Needed services
    appMgr.ExtSvc += [
        "IncidentSvc", "HistogramSvc", "HistogramDataSvc", "MonitorSvc"
    ]

    for alg in ("Hlt2RoutingBitsWriter", "Hlt2MassMonitor"):
        configurePublisher(appMgr, alg, initial_file)

    configOnline(appMgr, ht)
예제 #5
0
    def saveHistos(self):

        # ROOT persistency for histograms
        importOptions('$STDOPTS/RootHist.opts')
        from Configurables import RootHistCnv__PersSvc
        RootHistCnv__PersSvc('RootHistCnv').ForceAlphaIds = True

        histOpt = self.getProp("Histograms").capitalize()
        if histOpt == "None" or histOpt == "":
            # HistogramPersistency still needed to read in Muon background.
            # so do not set ApplicationMgr().HistogramPersistency = "NONE"
            return

        # Use a default histogram file name if not already set
        if not HistogramPersistencySvc().isPropertySet("OutputFile"):
            histosName = self.getProp("DatasetName")
            if histosName == "": histosName = "Boole"
            if (self.evtMax() > 0):
                histosName += '-' + str(self.evtMax()) + 'ev'
            if histOpt == "Expert": histosName += '-expert'
            histosName += '-histos.root'
            HistogramPersistencySvc().OutputFile = histosName
예제 #6
0
    def defineOptions(self):

        # Kept for Dirac backward compatibility
        if self.getProp( "NoWarnings" ) :
            log.warning("Brunel().NoWarnings=True property is obsolete and maintained for Dirac compatibility. Please use Brunel().ProductionMode=True instead")
            self.setProp( "ProductionMode", True )

        # Special settings for production
        if self.getProp( "ProductionMode" ) :
            if not self.isPropertySet( "OutputLevel" ) :
                self.setProp("OutputLevel", ERROR)
            if not LHCbApp().isPropertySet( "TimeStamp" ) :
                LHCbApp().setProp( "TimeStamp", True )
            if not self.isPropertySet( "PrintFreq" ) :
                self.setProp("PrintFreq", 1000)

        # HC does not exist in Run 1, so use appropriate split output
        if self.getProp( "DataType" ) in self.Run1DataTypes :
            if not self.isPropertySet( "SplitRawEventOutput" ) :
                self.setProp( "SplitRawEventOutput", 4.0 )

        # Online mode
        if self.getProp( "OnlineMode" ) :
            if not self.isPropertySet("Histograms") :
                self.setProp("Histograms","Online")
            if not CondDB().isPropertySet("Online") :
                CondDB().setProp("Online", True)

        inputType = self.getProp( "InputType" ).upper()
        if inputType not in self.KnownInputTypes:
            raise TypeError( "Invalid inputType '%s'"%inputType )

        outputType = self.getProp( "OutputType" ).upper()

        histOpt = self.getProp("Histograms")
        if histOpt not in self.KnownHistograms:
            raise RuntimeError("Unknown Histograms option '%s'"%histOpt)

        withMC = self.getProp("WithMC")
        if withMC:
            if inputType in [ "MDF" ]:
                log.warning( "WithMC = True, but InputType = '%s'. Forcing WithMC = False"%inputType )
                withMC = False # Force it, MDF never contains MC truth
            if outputType in [ "RDST" ]:
                log.warning( "WithMC = True, but OutputType = '%s'. Forcing WithMC = False"%inputType )
                withMC = False # Force it, RDST never contains MC truth

        if self.getProp("WriteFSR") and self.getProp("PackType").upper() in ["MDF"]:
            if hasattr( self, "WriteFSR" ): log.warning("Don't know how to write FSR to MDF output file")
            self.setProp("WriteFSR", False)

        if self.getProp( "MergeGenFSR") and not self.getProp( "Simulation" ):
            if hasattr( self, "MergeGenFSR" ): log.warning("Cannot MergeGenFSR on real data")
            self.setProp( "MergeGenFSR", False )
                
        # Do not look for Hlt errors in data without HltDecReports bank
        if self.getProp( "DataType" ) in [ "2008", "2009" ]:
            self.setProp( "VetoHltErrorEvents", False )
        # For simulation, change the default but allow to override
        if self.getProp( "Simulation" ) and not hasattr( self, "VetoHltErrorEvents" ):
            self.setProp( "VetoHltErrorEvents", False )


        # Flag to handle or not LumiEvents
        handleLumi = inputType in ["MDF"] and not withMC and not self.getProp('UseDBSnapshot')

        # Top level configuration for skipping tracking
        if self.getProp("SkipTracking"):
            if inputType in ["MDF", "DIGI" ]:
                raise RuntimeError( "Cannot skip tracking if tracks not present on the input file" )
            if withMC:
                raise RuntimeError( "SkipTracking not (yet) supported for simulation input" )
            if( self.getProp("DataType") is "Upgrade"):
                raise RuntimeError( "SkipTracking not (yet) supported for Upgrade configurations" )
            ApplicationMgr().ExtSvc += [ "DataOnDemandSvc" ] # to decode the tracks from the DST
            DstConf().setProp("EnableUnpack", ["Tracking"] )

        # veto Hlt Error Events
        vetoHltErrorEvents = self.getProp("VetoHltErrorEvents")

        self.configureSequences( withMC, handleLumi, vetoHltErrorEvents )

        self.configureInit( inputType )

        self.configureInput( inputType )

        self.configureOutput( outputType, withMC, handleLumi )

        if withMC:
            # Create associators for checking and for DST
            from Configurables import ProcessPhase
            ProcessPhase("MCLinks").DetectorList += self.getProp("MCLinksSequence")
            # Unpack Sim data
            GaudiSequencer("MCLinksUnpackSeq").Members += [ "UnpackMCParticle"]

            # particle gun uses MCVertex to fake a reconstructed one
            # unpacking again would lead to crash
            if "pGun" not in self.getProp("SpecialData"):
                GaudiSequencer("MCLinksUnpackSeq").Members += [ "UnpackMCVertex" ]
            else:
                # Cannot run trigger on pGun events...
                L0Conf().EnsureKnownTCK=False
            
            GaudiSequencer("MCLinksTrSeq").Members += [ "TrackAssociator" ]
            GaudiSequencer("MCLinksCaloSeq").Members += [ "CaloDigit2MCLinks2Table", "CaloClusterMCTruth", "CaloHypoMCTruth" ]

            # activate all configured checking (uses MC truth)
            self.configureCheck( histOpt == "Expert" )

            # data on demand needed to pack RichDigitSummary for DST, when reading unpacked DIGI
            # Also needed to unpack MCHit containers when expert checking enabled
            ApplicationMgr().ExtSvc += [ "DataOnDemandSvc" ]

        # ROOT persistency for histograms
        ApplicationMgr().HistogramPersistency = "ROOT"
        from Configurables import RootHistCnv__PersSvc
        RootHistCnv__PersSvc('RootHistCnv').ForceAlphaIds = True

        if histOpt == "None" or histOpt == "":
            # HistogramPersistency still needed to read in CaloPID DLLs.
            # so do not set ApplicationMgr().HistogramPersistency = "NONE"
            return

        # Pass expert checking option to RecSys and RecMoni
        if histOpt == "Expert":
            DstConf().EnablePackingChecks = True

        # Use a default histogram file name if not already set
        if not HistogramPersistencySvc().isPropertySet( "OutputFile" ):
            histosName   = self.getProp("DatasetName")
            if histosName == "": histosName = "Brunel"
            if self.getProp( "RecL0Only" ): histosName += '-L0Yes'
            if (self.evtMax() > 0): histosName += '-' + str(self.evtMax()) + 'ev'
            if histOpt == "Expert": histosName += '-expert'
            histosName += '-histos.root'
            HistogramPersistencySvc().OutputFile = histosName
            
        #reconfigure decoders to point to default location, if required!
        if DecodeRawEvent().isPropertySet("OverrideInputs") and DecodeRawEvent().getProp("OverrideInputs") is not None:
            #do nothing, it's been configured by someone else!
            pass
        elif self.isPropertySet("SplitRawEventInput") and self.getProp("SplitRawEventInput") is not None:
            #print "WAAAAH Overriding RawEvent Locations"
            DecodeRawEvent().setProp("OverrideInputs",self.getProp("SplitRawEventInput"))
        elif inputType in [ "MDF", "DIGI", "XDIGI" ]:
            #set to the default of what comes out of Moore
            DecodeRawEvent().setProp("OverrideInputs","Moore")
        #remember that the default is a long list of locations,
        #starting with places which only exist _after_ brunel has run!

        # Following needed to build RecSummary, even if tracking is skipped.
        if self.getProp("SkipTracking"):
            from TrackSys import RecoTracking
            RecoTracking.DecodeTracking(["FastVelo"])
예제 #7
0
    def _configureOnline(self):
        from Configurables import LoKiSvc
        LoKiSvc().Welcome = False

        import OnlineEnv
        EventLoopMgr().Warnings = False

        app = ApplicationMgr()

        # setup the histograms and the monitoring service
        from Configurables import MonitorSvc
        MonitorSvc().disableDimPropServer = 1
        MonitorSvc().disableDimCmdServer = 1
        MonitorSvc().disableMonRate = 0
        MonitorSvc().CounterUpdateInterval = 15
        app.ExtSvc.append('MonitorSvc')

        if self.getProp('EnableUpdateAndReset'):
            from Configurables import UpdateAndReset
            if not self.getProp('Simulation'):
                app.TopAlg = [UpdateAndReset()] + app.TopAlg

        HistogramPersistencySvc().OutputFile = ''
        HistogramPersistencySvc().Warnings = False
        from Configurables import RootHistCnv__PersSvc
        RootHistCnv__PersSvc().OutputEnabled = False

        # set up the event selector
        if 'EventSelector' in allConfigurables:
            del allConfigurables['EventSelector']

        # Enable Hlt2 ZeroMQ based monitoring
        if self.getProp("HltLevel") == "Hlt2":
            app.ExtSvc += ['HltMonitorSvc/Hlt2MonSvc', 'HltInfoSvc']

        ## Setup Checkpoint & forking: Do this EXACTLY here. Just befor the MEPManager & event selector.
        ## It will not work if these are created before.
        if OnlineEnv.MooreStartupMode == 1:
            self._configureOnlineForking()
        elif OnlineEnv.MooreStartupMode == 2:
            self._configureOnlineCheckpointing()

        importOptions('$MBM_SETUP_OPTIONS')
        mbm_setup = allConfigurables['OnlineEnv']
        task_type = os.environ['TASK_TYPE']

        input_buffer = mbm_setup.__getattribute__(task_type +
                                                  '_Input')  #'Events'
        output_buffer = mbm_setup.__getattribute__(task_type +
                                                   '_Output')  #'Send'
        self.__buffers = [input_buffer, output_buffer]
        TAE = (OnlineEnv.TAE != 0)
        mepMgr = OnlineEnv.mepManager(OnlineEnv.PartitionID,
                                      OnlineEnv.PartitionName, self.__buffers,
                                      False)
        mepMgr.PartitionBuffers = True
        mepMgr.PartitionName = OnlineEnv.PartitionName
        mepMgr.PartitionID = OnlineEnv.PartitionID
        mepMgr.ConnectWhen = 'start'

        app.Runable = OnlineEnv.evtRunable(mepMgr)
        app.ExtSvc.append(mepMgr)

        if TAE:
            eventSelector = OnlineEnv.mbmSelector(input=input_buffer,
                                                  TAE=TAE,
                                                  decode=False)
        elif self.getProp('HltLevel') == "Hlt2" or self.getProp(
                'ForceMDFInput'):
            eventSelector = OnlineEnv.mbmSelector(
                input=input_buffer, TAE=TAE,
                decode=False)  # decode=False for HLT2 ONLY!!!!!
        else:
            eventSelector = OnlineEnv.mbmSelector(input=input_buffer,
                                                  TAE=TAE,
                                                  decode=True)
        app.ExtSvc.append(eventSelector)

        OnlineEnv.evtDataSvc()
        if self.getProp('REQ1'): eventSelector.REQ1 = self.getProp('REQ1')

        from Configurables import AuditorSvc
        AuditorSvc().Auditors = []
        # Now setup the message service
        self._configureOnlineMessageSvc()
예제 #8
0
def configOnline(app, alg, name):
    from Configurables import ApplicationMgr, UpdateAndReset
    appMgr = ApplicationMgr()

    ## Configure saving of histograms
    ur = UpdateAndReset()
    ur.saveHistograms = 1
    appMgr.TopAlg.insert(0, ur)

    from Configurables import LoKiSvc
    LoKiSvc().Welcome = False

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

    from Configurables import CondDB
    conddb = CondDB()
    conddb.IgnoreHeartBeat = True
    conddb.UseDBSnapshot = True
    conddb.EnableRunChangeHandler = True
    conddb.EnableRunStampCheck = False
    conddb.Tags['ONLINE'] = 'fake'

    import ConditionsMap
    conddb.RunChangeHandlerConditions = ConditionsMap.RunChangeHandlerConditions

    from Gaudi.Configuration import EventLoopMgr
    EventLoopMgr().Warnings = False

    from Configurables import MonitorSvc
    MonitorSvc().disableDimPropServer      = 1
    MonitorSvc().disableDimCmdServer       = 1

    MonitorSvc().ExpandCounterServices = 0;
    MonitorSvc().ExpandNameInfix       = "<part>_x_<program>/";
    MonitorSvc().PartitionName         = OnlineEnv.PartitionName;
    MonitorSvc().ProgramName           = name + "_00";

    # setup the histograms and the monitoring service
    appMgr.ExtSvc.append( 'MonitorSvc' )
    from Configurables import RootHistCnv__PersSvc
    RootHistCnv__PersSvc().OutputEnabled = False

    from Gaudi.Configuration import allConfigurables
    # set up the event selector
    if 'EventSelector' in allConfigurables :
        del allConfigurables['EventSelector']

    input = 'Events'
    mepMgr = OnlineEnv.mepManager(OnlineEnv.PartitionID,OnlineEnv.PartitionName,[input],True)
    mepMgr.ConnectWhen = "start";

    appMgr.Runable = OnlineEnv.evtRunable(mepMgr)
    appMgr.SvcOptMapping.append('LHCb::OnlineEvtSelector/EventSelector')
    appMgr.SvcOptMapping.append('LHCb::FmcMessageSvc/MessageSvc')
    appMgr.ExtSvc.append(mepMgr)

    eventSelector = OnlineEnv.mbmSelector(input = input, type = 'ONE', decode = False, event_type = 2)
    appMgr.ExtSvc.append(eventSelector)
    appMgr.ExtSvc.append(mepMgr)
    appMgr.OutputLevel = 3

    OnlineEnv.evtDataSvc()
    eventSelector.REQ1 = 'EvType=2;TriggerMask=0x0,0x4,0x0,0x0;VetoMask=0,0,0,0x300;MaskType=ANY;UserType=USER;Frequency=PERC;Perc=100.0'
    appMgr.EvtSel = eventSelector

    from Configurables import AuditorSvc
    AuditorSvc().Auditors = []
    configMsgSvc( appMgr )
    OnlineEnv.end_config(False)
예제 #9
0
# set the Velo tuple monitoring to the ideal track container as input
Velo__VeloTrackMonitorNT().RunWithMC = False
Velo__VeloTrackMonitorNT().TracksInContainer = 'MC/Track/Ideal'
PrTrackAssociator().RootOfContainers = 'MC/Track/Ideal'
VeloClusterPosition().CalculateExactProjAngle = True

# setup a job to dump a VELO tuple with ideal PR tracks, no dst required
from Configurables import Brunel, DigiConf, L0Conf
Brunel().DataType = "2011"
Brunel().EvtMax = 10
Brunel().InputType = 'XDST'
Brunel().PrintFreq = 100
Brunel().Simulation = True
Brunel().WithMC = True
Brunel().OutputType = "NONE"
Brunel().WriteFSR = False
Brunel().MCLinksSequence = ["Tr"]
Brunel().MCCheckSequence = ["Pat", "Pr"]
DigiConf().EnableUnpack = True
L0Conf().EnsureKnownTCK = False

# set tuple output as root
ApplicationMgr().ExtSvc += [NTupleSvc()]
NTupleSvc().Output = [
    "FILE1 DATAFILE='brunel-mc11a-cheatedPR.root' TYP='ROOT' OPT='NEW'"
]

from Configurables import RootHistCnv__PersSvc
RootHistCnv__PersSvc('RootHistCnv').ForceAlphaIds = True
예제 #10
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'