示例#1
0
    def configureServices(self):
        # Pass the input file names to the data service.
        from Configurables import TbDataSvc
        TbDataSvc().Input = self.getProp("InputFiles")
        TbDataSvc().AlignmentFile = self.getProp("AlignmentFile")
        TbDataSvc().PixelConfigFile = self.getProp("PixelConfigFile")
        TbDataSvc().TimingConfigFile = self.getProp("TimingConfigFile")
        TbDataSvc().EtaConfigFiles = self.getProp("EtaConfigFiles")
        ApplicationMgr().ExtSvc += [TbDataSvc()]

        # Add the geometry service which keeps track of alignment,
        # the timing service, which tracks event boundaries,
        # and the pixel service, which stores masked pixels,
        # clock phases and per column timing offsets.
        from Configurables import TbGeometrySvc, TbTimingSvc, TbPixelSvc
        ApplicationMgr().ExtSvc += [
            TbGeometrySvc(), TbTimingSvc(),
            TbPixelSvc()
        ]

        # Use TimingAuditor for timing, suppress printout from SequencerTimerTool
        from Configurables import AuditorSvc, SequencerTimerTool
        ApplicationMgr().ExtSvc += ['ToolSvc', 'AuditorSvc']
        ApplicationMgr().AuditAlgorithms = True
        AuditorSvc().Auditors += ['TimingAuditor']
        if not SequencerTimerTool().isPropertySet("OutputLevel"):
            SequencerTimerTool().OutputLevel = 4
示例#2
0
    def defineMonitors(self):

        # get all defined monitors
        monitors = self.getProp("Monitors") + LHCbApp().getProp("Monitors")
        # Currently no Brunel specific monitors, so pass them all to LHCbApp
        LHCbApp().setProp("Monitors", monitors)

        # Use TimingAuditor for timing, suppress printout from SequencerTimerTool
        from Configurables import (ApplicationMgr,AuditorSvc,SequencerTimerTool)
        ApplicationMgr().ExtSvc += [ 'ToolSvc', 'AuditorSvc' ]
        ApplicationMgr().AuditAlgorithms = True
        AuditorSvc().Auditors += [ 'TimingAuditor' ]
        if not SequencerTimerTool().isPropertySet( "OutputLevel" ):
            SequencerTimerTool().OutputLevel = 4
示例#3
0
    def __apply_configuration__(self):

        GaudiKernel.ProcessJobOptions.PrintOff()
        GaudiKernel.ProcessJobOptions.PrintOn()
        log.info("Initializing sequences!")
        self.setOtherProps(
            RecSysConf(), ["SpecialData", "Context", "OutputType", "DataType"])

        #if self.isPropertySet("RecoSequence") :
        #self.setOtherProp(RecSysConf(),["RecoSequence"])
        RecSysConf().RecoSequence = self.CheckRecoSequence()

        # there is a bug in setOtherProps, so we cannot use it to set the MoniSequence.
        if not self.getProp("OnlineMode"):
            self.setOtherProps(RecMoniConf(), ["Context", "DataType"])
            RecMoniConf().MoniSequence = self.getProp("MoniSequence")
        else:
            self.setOtherProps(RecMoniConf(), ["Context", "DataType"])
            RecMoniConf().MoniSequence = self.getProp("MoniSequence")
            RecMoniConf().Context = "Offline"
            RecMoniConf().OutputLevel = FATAL
            RecMoniConf().Histograms = "OfflineFull"

        self.defineGeometry()
        self.defineEvents()
        self.defineOptions()

        # database hacking for online.
        if self.getProp('UseDBSnapshot'): self.configureDBSnapshot()

        # Use TimingAuditor for timing, suppress printout from SequencerTimerTool
        from Configurables import (ApplicationMgr, AuditorSvc,
                                   SequencerTimerTool)
        ApplicationMgr().ExtSvc += ['ToolSvc', 'AuditorSvc']
        ApplicationMgr().AuditAlgorithms = True
        AuditorSvc().Auditors += ['TimingAuditor']
        SequencerTimerTool().OutputLevel = 4

        log.info(self)
        log.info(LHCbApp())
        log.info(RecSysConf())
        log.info(TrackSys())
        if not self.getProp("OnlineMode"):
            log.info(RecMoniConf())
        log.info(TAlignment())
        log.info(DstConf())
        GaudiKernel.ProcessJobOptions.PrintOff()
示例#4
0
    def _defineMonitors(self):
        """
        Define monitors
        """
        from Configurables import (ApplicationMgr, AuditorSvc,
                                   SequencerTimerTool)

        ApplicationMgr().ExtSvc += ['ToolSvc', 'AuditorSvc']
        ApplicationMgr().AuditAlgorithms = True
        AuditorSvc().Auditors += ['TimingAuditor']
        SequencerTimerTool().OutputLevel = 4
        # Do not print event number at every event
        printfreq = self.getProp("PrintFreq")
        if (printfreq == 0):
            log.warning("Print frequence cannot be 0")
            printfreq = 1000
        EventSelector().PrintFreq = printfreq

        # Change the column size of Timing table
        from Configurables import TimingAuditor, SequencerTimerTool
        TimingAuditor().addTool(SequencerTimerTool, name="TIMER")
        if not TimingAuditor().TIMER.isPropertySet("NameSize"):
            TimingAuditor().TIMER.NameSize = 50
示例#5
0
    def _outputLevel(self):
        """
        Set the print out of various tools, services, all algorithms, and properties of all things like algorithms
        Sensitive to the OutputLevel of Moore

        a) configure things independently of level
        b) configure things depending on level
           - ThresholdSettings via postConfigActions
           - TCKs via transforms

        defaults are now WARNING printouts only, so I need to handle the case the user wishes to switch back if a TCK has been generated with a warning

        """
        #firstly explicitly configure things not seen by TCK
        #firstly configure things which are level-independent

        # Usual output levels for services
        from Configurables import XmlParserSvc
        XmlParserSvc().OutputLevel = WARNING
        ApplicationMgr(
        ).OutputLevel = INFO  #I still want the Application Manager Finalized Sucessfully printout

        # Print algorithm name with 40 characters
        if not self.getProp("RunOnline"):
            if not MessageSvc().isPropertySet("Format"):
                MessageSvc().Format = '% F%40W%S%7W%R%T %0W%M'

        #this should be OK to do here...
        from Funcs import _minSetFileTypes

        #postconfig away common warnings
        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

        appendPostConfigAction(suppresswarningifneeded)

        #then configure things that depend on the level
        level = self.getProp("OutputLevel")
        from Configurables import LHCbSequencerTimerTool, SequencerTimerTool
        if level >= INFO: LHCbSequencerTimerTool().OutputLevel = WARNING
        if level >= INFO: SequencerTimerTool().OutputLevel = WARNING

        if level > DEBUG:
            from Configurables import LoKi__DistanceCalculator
            LoKi__DistanceCalculator().MaxPrints = 0
        if level > VERBOSE:
            from Configurables import LoKiSvc
            LoKiSvc().Welcome = False

        from Configurables import Hlt__Service
        if not Hlt__Service().isPropertySet('Pedantic'):
            Hlt__Service().Pedantic = (level < DEBUG)
        ###############################################################
        #if level is less than INFO, I don't need to edit anything else
        #it's up to the users to do that themselves!
        ###############################################################
        if level < INFO:
            return

        if level > INFO:
            if not self.getProp("RunOnline"):
                MessageSvc().OutputLevel = level
            ToolSvc().OutputLevel = level

        if level > INFO and hasattr(
                self, "EnableTimer") and self.getProp("EnableTimer") and type(
                    self.getProp("EnableTimer")) is not str:
            print "# WARNING: Timing table is too verbose for printing, consider outputting to a file instead please, Moore().EnableTimer='timing.csv', for example."

        #################################################
        # If the OutputLevel is set I need
        # Either a postConfigAction or a transform
        # to suppress the outputs properly
        #################################################

        #################################################
        # Running from thresholds, use post config action
        #################################################
        if not self.getProp("UseTCK") and level > INFO:
            #post config to really reset all the output to null
            from DAQSys.Decoders import DecoderDB
            from GaudiConf.Manipulations import recurseConfigurables, setPropertiesAndAddTools
            props = {}
            props["OutputLevel"] = level
            props["StatPrint"] = (level < WARNING)
            props["ErrorsPrint"] = (level < WARNING)
            props["PropertiesPrint"] = (level < WARNING)

            from DAQSys.Decoders import DecoderDB
            for k, v in DecoderDB.iteritems():
                for pk, pv in props.iteritems():
                    v.Properties[pk] = pv

            props["HistoCountersPrint"] = (level < WARNING)
            calo_tools = [
                "CaloECorrection/ECorrection",
                "CaloSCorrection/SCorrection",
                "CaloLCorrection/LCorrection",
                "CaloHypoEstimator",
                "CaloExtraDigits/SpdPrsExtraE",
                "CaloExtraDigits/SpdPrsExtraG",
                "CaloExtraDigits/SpdPrsExtraM",
                "CaloExtraDigits/SpdPrsExtraS",
                "CaloSelectCluster/PhotonCluster",
                "CaloSelectCluster/ElectronCluster",
                "CaloSelectChargedClusterWithSpd/ChargedClusterWithSpd",
                "CaloSelectClusterWithPrs/ClusterWithPrs",
                "CaloSelectNeutralClusterWithTracks/NeutralCluster",
                "CaloSelectNeutralClusterWithTracks/NotNeutralCluster",
                "CaloSelectorNOT/ChargedCluster",
                "CaloSelectNeutralClusterWithTracks/ChargedCluster.NeutralCluster",
            ]
            tools_per_type = {
                # turn off the calo tool finalize printout, there are *a lot* of tools here
                "CaloSinglePhotonAlg":
                calo_tools,
                "CaloElectronAlg":
                calo_tools,
                "CaloMergedPi0Alg":
                calo_tools,
                "NeutralProtoPAlg":
                calo_tools,
                # three extras for merged pi0
                "CaloMergedPi0Alg": [
                    "CaloCorrectionBase/ShowerProfile",
                    "CaloCorrectionBase/Pi0SCorrection",
                    "CaloCorrectionBase/Pi0LCorrection"
                ],
                # and one calo clustering
                "CellularAutomatonAlg": ["CaloClusterizationTool"],
            }
            func = partial(setPropertiesAndAddTools,
                           properties=props,
                           tools_per_type=tools_per_type,
                           force=True)

            # Instantiate a few public tools (members of the ToolService),
            # which means their output properties will also be set in the post config action
            from Configurables import LoKi__LifetimeFitter, CaloDigitFilterTool, CaloGetterTool, OTChannelMapTool, CaloClusterizationTool
            LoKi__LifetimeFitter("ToolSvc.lifetime")
            CaloDigitFilterTool("ToolSvc.FilterTool")
            CaloGetterTool("ToolSvc.CaloGetter")
            OTChannelMapTool("ToolSvc.OTChannelMapTool")
            CaloClusterizationTool("ToolSvc.CaloClusterizationTool")

            # visit_properties = ['Members', 'Filter0', 'Filter1', 'TopAlg']
            descend_properties = [
                'Members', 'Prescale', 'ODIN', 'L0DU', 'HLT', 'HLT1', 'HLT2',
                'Filter0', 'Filter1', 'Postscale'
            ]
            appendPostConfigAction(
                partial(recurseConfigurables,
                        func,
                        descend_properties=descend_properties,
                        descend_tools=True))

            #I still want to print "Application Manager Finalized Successfully"
            #and "End of event input reached" no matter what

            def AppMrgOP():
                if ApplicationMgr().getProp("OutputLevel") > INFO:
                    ApplicationMgr().OutputLevel = INFO
                if EventSelector().getProp("OutputLevel") > INFO:
                    EventSelector().OutputLevel = INFO

            appendPostConfigAction(AppMrgOP)

            def RestoreGenConfig():
                Moore().getConfigAccessSvc().OutputLevel = INFO
                from Configurables import HltGenConfig
                HltGenConfig().OutputLevel = INFO

            if self.getProp("generateConfig"):
                appendPostConfigAction(RestoreGenConfig)

            #################################################
            # Running from TCK define a similar transform
            #################################################
        elif self.getProp("UseTCK"):
            trans = {".*": {"OutputLevel": {"^.*$": str(level)}}}
            #turn certain things back on if INFO is set again...
            trans[".*"]["StatPrint"] = {"^.*$": str(level < WARNING)}
            trans[".*"]["ErrorsPrint"] = {"^.*$": str(level < WARNING)}
            trans[".*"]["PropertiesPrint"] = {"^.*$": str(level < WARNING)}
            trans[".*"]["HistoCountersPrint"] = {"^.*$": str(level < WARNING)}

            Funcs._mergeTransform(trans)

            #kill LoKi warnings
            set = 0
            if level < WARNING:
                set = 3
            trans = {
                ".*DistanceCalculator.*": {
                    "MaxPrints": {
                        "^.*$": str(set)
                    }
                }
            }
            Funcs._mergeTransform(trans)
            #kill one extra loki print in tool service
            from GaudiConf.Manipulations import recurseConfigurables, setPropertiesAndAddTools
            props = {}
            props["OutputLevel"] = level
            props["StatPrint"] = (level < WARNING)
            props["ErrorsPrint"] = (level < WARNING)
            props["PropertiesPrint"] = (level < WARNING)
            # postConfForAll(head=["LoKi::LifetimeFitter/ToolSvc.lifetime"],force=True,prop_value_dict=props)
            func = partial(setPropertiesAndAddTools,
                           properties=props,
                           force=True)
            appendPostConfigAction(
                partial(recurseConfigurables,
                        func,
                        head="LoKi::LifetimeFitter/ToolSvc.lifetime"))

            from Configurables import HltConfigSvc
            cfg = HltConfigSvc()
            #self-defeating warnings!
            cfg.OutputLevel = ERROR
示例#6
0
def rawDataToNtuple(options):
    #	print options
    required_options = [
        "runNumber", "start", "end", "outputdir", "nEvtsPerStep", "totsteps"
    ]

    for check_opts in required_options:
        if not options.has_key(check_opts):
            print "Please specify minimal options!"
            print "Option \'" + check_opts + "\' is missing!"
            sys.exit()

    start = options["start"]
    end = options["end"]
    runNumber = options["runNumber"]
    outputdir = options["outputdir"]
    totsteps = options["totsteps"]
    nEvtsPerStep = options["nEvtsPerStep"]

    from Configurables import DDDBConf, CondDB, CondDBAccessSvc, NTupleSvc, EventClockSvc, Brunel, LHCbApp
    #	if options.has_key("IgnoreHeartBeat"):
    #		CondDB().IgnoreHeartBeat = options["IgnoreHeartBeat"]

    if options.has_key("addCondDBLayer"):
        altag = "HEAD"
        if options.has_key("addCondDBLayer_tag"):
            altag = options["addCondDBLayer_tag"]
        CondDB().addLayer(
            CondDBAccessSvc("myCond",
                            ConnectionString="sqlite_file:" +
                            options["addCondDBLayer"] + "/LHCBCOND",
                            DefaultTAG=altag))

    # Need this line so as to not get db errors- should be fixed properly at some point
    CondDB().IgnoreHeartBeat = True
    CondDB().EnableRunStampCheck = False

    #	customDBs = glob.glob('/group/rich/ActiveDBSlices/*.db')
    #	for db in customDBs:
    #		CondDB().addLayer( CondDBAccessSvc(os.path.basename(db), ConnectionString="sqlite_file:"+db+"/LHCBCOND", DefaultTAG="HEAD") )

    #	importOptions('$STDOPTS/DecodeRawEvent.py')
    #importOptions("$STDOPTS/RootHist.opts")
    #importOptions("$STDOPTS/RawDataIO.opts")
    #DEBUG by DisplayingHitMaps=False
    from Configurables import MDMRich1Algorithm
    mdmAlg = MDMRich1Algorithm("Rich1MDCS")
    mdmAlg.NumberOfEventsPerStep = nEvtsPerStep
    mdmAlg.StoreHistos = False
    mdmAlg.DEBUG = False

    if options.has_key("StoreHistos"):
        mdmAlg.StoreHistos = options["StoreHistos"]

    if options.has_key("DEBUG"):
        mdmAlg.DEBUG = options["DEBUG"]

    print "start step: " + str(start)
    print "stop step: " + str(end)
    print "processing " + str(nEvtsPerStep * (end - start)) + " events"

    tuplestring = "NTuple_Run%i_Steps%04d-%04d.root" % (runNumber, start, end)

    if options.has_key("TupleName"):
        tuplestring = options["TupleName"]

    histoname = "Histos_Run%i_Steps%04d-%04d.root" % (runNumber, start, end)

    if options.has_key("HistoName"):
        histoname = options["HistoName"]

    if outputdir != "":
        tuplestring = "%s/%s" % (outputdir, tuplestring)
        histoname = "%s/%s" % (outputdir, histoname)

    tuplename = "RICHTUPLE1 DATAFILE=\'%s\' TYP=\'ROOT\' OPT=\'NEW\'" % (
        tuplestring)

    # Currently put in manually. Edit here to use correct db and conddb tags
    LHCbApp().DDDBtag = "dddb-20150724"
    LHCbApp().CondDBtag = "cond-20160123"

    if options.has_key("DDDBtag"):
        LHCbApp().DDDBtag = options["DDDBtag"]
    if options.has_key("CondDBtag"):
        LHCbApp().CondDBtag = options["CondDBtag"]

    #customDBs = glob.glob('/group/rich/ActiveDBSlices/*.db')
    #for db in customDBs:
    #	CondDB().addLayer( CondDBAccessSvc(os.path.basename(db), ConnectionString="sqlite_file:"+db+"/LHCBCOND", DefaultTAG="HEAD") )

    ApplicationMgr().TopAlg += [mdmAlg]
    ApplicationMgr().ExtSvc += ['DataOnDemandSvc']
    ApplicationMgr().EvtMax = end * nEvtsPerStep

    # Timing information for application
    from Configurables import AuditorSvc, SequencerTimerTool
    ApplicationMgr().ExtSvc += ['AuditorSvc']
    ApplicationMgr().AuditAlgorithms = True
    AuditorSvc().Auditors += ['TimingAuditor']
    SequencerTimerTool().OutputLevel = 4

    LHCbApp().TimeStamp = True

    HistogramPersistencySvc().OutputFile = histoname
    NTupleSvc().Output = [tuplename]
    EventSelector().PrintFreq = 10
    EventSelector().PrintFreq = nEvtsPerStep
    EventSelector().FirstEvent = start * nEvtsPerStep
    print "First event: " + str(start * nEvtsPerStep)
    print "Last event: " + str(end * nEvtsPerStep)

    #get data, will look in local cluster first, then on castor
    isLocal = True
    if options.has_key("isLocal"):
        isLocal = options["isLocal"]
    DATA_and_Year = (getData(runNumber, start, end, totsteps, isLocal))

    DATA = DATA_and_Year["DATA"]
    if not len(DATA) > 0:
        print "Data not found in local, switching to CASTOR"
        DATA_and_Year = getData(runNumber, start, end, totsteps, not isLocal)
        DATA = DATA_and_Year["DATA"]
    if not len(DATA) > 0:
        print "DATA not found anywhere!"
        sys.exit()
    LHCbApp.DataType = str(DATA_and_Year["year"])

    EventSelector().Input = DATA
    EventClockSvc().EventTimeDecoder = "OdinTimeDecoder"

    appMgr = GaudiPython.AppMgr()
    appMgr.HistogramPersistency = "ROOT"
    #appMgr.OutputLevel=DEBUG
    evtSvc = appMgr.evtSvc()

    esel = appMgr.evtsel()
    esel.PrintFreq = nEvtsPerStep
    appMgr.initialize()

    appMgr.run(nEvtsPerStep * (end - start))
    appMgr.stop()
    appMgr.finalize()
app.EvtMax = 100

from Configurables import HltOutputSvc, HltOutputSequence
outputSvc = HltOutputSvc()
ApplicationMgr().ExtSvc += [outputSvc]

from Configurables import GaudiSequencer as Sequence
from Configurables import LHCb__RawEventCopy as RawEventCopy
from Configurables import DeterministicPrescaler

from PRConfig.TestFileDB import test_file_db
test_file_db['2015HLTValidationData_L0filtered_0x0050'].run(configurable=app)

from Configurables import LHCbTimingAuditor, LHCbSequencerTimerTool, AuditorSvc
from Configurables import SequencerTimerTool
SequencerTimerTool().OutputLevel = 4
ApplicationMgr().ExtSvc.append('AuditorSvc')
ta = LHCbTimingAuditor('TIMER', Enable=True)
ta.addTool(LHCbSequencerTimerTool, name='TIMER')
AuditorSvc().Auditors.append(ta)

sequence = GaudiSequencer("TopSequence", IgnoreFilterPassed=True)


def groupName(subs):
    return sorted(subs)[0]


groups = {("Full", "TurboFull"): 0.5, ("Turbo", ): 0.2}
filters = {}
for substreams, fraction in groups.iteritems():