Пример #1
0
def main():
    import sys
    import user

    #    sys.path.append("../i686-slc5-gcc43-opt/")

    # output
    outputFile = "out1.root"
    # input
    inputFiles = sys.argv[1].split(',')

    from GaudiPython import AppMgr
    theApp = AppMgr()
    theApp.EvtMax = 1
    # Verboseness threshold level: 0=NIL,1=VERBOSE, 2=DEBUG, 3=INFO, 4=WARNING, 5=ERROR, 6=FATAL, 7=ALWAYS
    #    theApp.outputLevel = 4
    #    MessageSvc.OutputLevel = 4
    #    EventSelector.OutputLevel = 4
    theApp.JobOptionsType = "NONE"
    theApp.EvtSel = "NONE"
    theApp.Dlls = ["GaudiAlg", "MiniNtuple"]

    myNtp = theApp.algorithm("TMiniNtuple")
    myNtp.InputFileName = inputFiles
    myNtp.OutputFileName = outputFile
    myNtp.Debug = False
    myNtp.ApplyLeptonSkim = True
    myNtp.MinLeptonPt = 9000.

    theApp.topAlg = ["TMiniNtuple"]

    theApp.config()
    theApp.initialize()
    theApp.run(1)
    theApp.exit()
Пример #2
0
def main():

    # Setup the option parser
    usage = "usage: %prog [options] inputfile <inputfile>"
    parser = optparse.OptionParser(usage=usage)
    parser.add_option("-d",
                      "--datatype",
                      action="store",
                      dest="DataType",
                      default="2015",
                      help="DataType to run on.")
    parser.add_option("-n",
                      "--evtmax",
                      type="int",
                      action="store",
                      dest="EvtMax",
                      default=10000,
                      help="Number of events to run")
    parser.add_option("--dddbtag",
                      action="store",
                      dest="DDDBtag",
                      default='MC09-20090602',
                      help="DDDBTag to use")
    parser.add_option("--conddbtag",
                      action="store",
                      dest="CondDBtag",
                      default='sim-20090402-vc-md100',
                      help="CondDBtag to use")
    parser.add_option("--settings",
                      action="store",
                      dest="ThresholdSettings",
                      default='Physics_25ns_September2015',
                      help="ThresholdSettings to use")
    parser.add_option("-s",
                      "--simulation",
                      action="store_true",
                      dest="Simulation",
                      default=False,
                      help="Run on simulated data")
    parser.add_option("--dbsnapshot",
                      action="store_true",
                      dest="UseDBSnapshot",
                      default=False,
                      help="Use a DB snapshot")
    parser.add_option("-v",
                      "--verbose",
                      action="store_true",
                      dest="Verbose",
                      default=False,
                      help="Verbose output")
    parser.add_option("--rch",
                      action="store_true",
                      dest="RunChangeHandler",
                      default=False,
                      help="Use the RunChangeHandler")

    # Parse the arguments
    (options, args) = parser.parse_args()

    # Make sure there is data to run on

    # Put the options into the Moore configurable
    Moore().ThresholdSettings = options.ThresholdSettings

    #Moore().OutputLevel="VERBOSE"
    Moore().EvtMax = options.EvtMax

    #Moore().UseDBSnapshot = options.UseDBSnapshot # DEPRECATED
    from Configurables import CondDB
    CondDB().UseDBSnapshot = options.UseDBSnapshot
    #
    Moore().DDDBtag = options.DDDBtag
    Moore().CondDBtag = options.CondDBtag
    Moore().Simulation = options.Simulation
    Moore().DataType = options.DataType
    Moore().inputFiles = args

    EventSelector().PrintFreq = 100

    # Instanciate the AppMgr to get the Hlt lines from their Sequences
    appMgr = AppMgr()

    hlt1Seq = Sequence("Hlt1")
    hlt1Lines = set()
    for m in hlt1Seq.Members:
        hlt1Lines.add(m.name())

    hlt2Seq = Sequence("Hlt2")
    hlt2Lines = set()
    for m in hlt2Seq.Members:
        hlt2Lines.add(m.name())

    # The AppMgr is no longer needed
    appMgr.exit()

    print "HLT1LINES"
    for line in hlt1Lines:
        print line
    print "HLT2LINES"
    for line in hlt2Lines:
        print line
Пример #3
0
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
Пример #4
0
def main():
    import sys
    import user
    import glob
    import os

    fpath = '/UserDisk2/othrif/data/MiniNtuple/v44-3/'
    #    folder = sys.argv[1]
    filename = sys.argv[1]

    # output
    #    outputFile = os.path.join(fpath, 'user.othrif.'+filename)
    outputFile = os.path.join(fpath, filename)

    # input
    path = os.path.join('/UserDisk2/othrif/data/Ximo/v44-3/' + filename)
    inputFiles = glob.glob(path)

    #    outputFile = "/tmp/test_out1.root"
    #    inputFiles = glob.glob('/UserDisk2/othrif/susy/mc_method/Ximo.v18/user.jpoveda.t0616_v18.00270816.physics_Main.DAOD_SUSY2.f611_m1463_p2375_output.root/*.root')
    #   inputFiles = glob.glob('/UserDisk2/othrif/susy/test/mc15_13TeV.370602.MGPy8EG_A14N23LO_NUHM2_m12_400_strong.merge.DAOD.e4209_a766_a777_r6282.root')

    #    filename = sys.argv[1]
    # output
    #    outputFile = "/tmp/test_out1.root"
    #    outputFile = '/tmp/',filename,'.root'
    # input
    #    inputFiles = glob.glob('/users/orifki/workarea/susy_ss3l/input/user.jpoveda.5286937._000001.output.root')
    #    inputFiles = glob.glob('/data3/orifki/gtt_above_diag_FULL/validation/mc12_8TeV.156581.Herwigpp_UEEE3_CTEQ6L1_Gtt_G1100_T2500_L200.merge.NTUP_SUSY.e1221_s1469_s1470_r3542_r3549_p1328_tid01151387_00/NTUP_SUSY.01151387._000001.root.1')

    # run over data
    #    inputFiles = glob.glob('/data3/orifki/susy/cutflow/user.jpoveda.t0609_v12.00266904.physics_Main.DAOD_SUSY9.f594_m1435_p2361_output.root.30695488/user.jpoveda.5632900._000001.output.root')
    #    inputFiles = glob.glob('/afs/cern.ch/user/o/othrif/data/user.jpoveda.t0609_v12.00266904.physics_Main.DAOD_SUSY9.f594_m1435_p2361_output.root.30695488/user.jpoveda.5632900._000001.output.root')

    #    inputFiles = glob.glob('/afs/cern.ch/user/o/othrif/data/user.jpoveda.t0609_v12.410000.PowhegPythiaEvtGen_P2012_ttbar_hdamp172p5_nonallhad.DAOD_SUSY1.s2608_r6633_p2353_output.root.*/*.root')

    #    inputFiles = glob.glob('/UserDisk2/othrif/susy/mc_method/user.jpoveda.t0615_v17.00266904.physics_Main.DAOD_SUSY9.r6847_p2358_p2361_output.root/*.root')

    #    inputFiles = glob.glob('/UserDisk2/othrif/susy/mc_method/user.jpoveda.t0616_v18.410067.MadGraphPythia8EvtGen_A14NNPDF23LO_ttW_Np1.DAOD_SUSY2.s2608_r6793_p2375_output.root/user.jpoveda.6120928._000001.output.root')

    #    inputFiles = glob.glob('/UserDisk2/othrif/susy/mc_method/user.jpoveda.t0615_v17.361106.PowhegPythia8EvtGen_AZNLOCTEQ6L1_Zee.DAOD_SUSY2.s2576_r6630_p2375_output.root/*.root')

    from GaudiPython import AppMgr
    theApp = AppMgr()
    theApp.EvtMax = 100
    # Verboseness threshold level: 0=NIL,1=VERBOSE, 2=DEBUG, 3=INFO, 4=WARNING, 5=ERROR, 6=FATAL, 7=ALWAYS
    #    theApp.outputLevel = 4
    #    MessageSvc.OutputLevel = 4
    #    EventSelector.OutputLevel = 4
    theApp.JobOptionsType = "NONE"
    theApp.EvtSel = "NONE"
    theApp.Dlls = ["GaudiAlg", "MiniNtuple"]

    myNtp = theApp.algorithm("TMiniNtuple")
    myNtp.InputFileName = inputFiles
    myNtp.OutputFileName = outputFile
    myNtp.Debug = False
    myNtp.ApplyLeptonSkim = True
    myNtp.MinLeptonPt = 13000.

    theApp.topAlg = ["TMiniNtuple"]

    theApp.config()
    theApp.initialize()
    theApp.run(1)
    theApp.exit()
Пример #5
0
def main():

    # Setup the option parser
    usage = "usage: %prog [options] inputfile <inputfile>"
    parser = optparse.OptionParser(usage=usage)
    parser.add_option("-d",
                      "--datatype",
                      action="store",
                      dest="DataType",
                      default="2009",
                      help="DataType to run on.")
    parser.add_option("-n",
                      "--evtmax",
                      type="int",
                      action="store",
                      dest="EvtMax",
                      default=1e4,
                      help="Number of events to run")
    parser.add_option("--dddbtag",
                      action="store",
                      dest="DDDBtag",
                      default='MC09-20090602',
                      help="DDDBTag to use")
    parser.add_option("--conddbtag",
                      action="store",
                      dest="CondDBtag",
                      default='sim-20090402-vc-md100',
                      help="CondDBtag to use")
    parser.add_option("--settings",
                      action="store",
                      dest="ThresholdSettings",
                      default='Physics_10000Vis_1000L0_40Hlt1_Apr09',
                      help="ThresholdSettings to use")
    parser.add_option("-s",
                      "--simulation",
                      action="store_true",
                      dest="Simulation",
                      default=False,
                      help="Run on simulated data")
    parser.add_option("--dbsnapshot",
                      action="store_true",
                      dest="UseDBSnapshot",
                      default=False,
                      help="Use a DB snapshot")
    parser.add_option("--snd",
                      action="store",
                      dest="SnapshotDirectory",
                      default='/user/graven/MOORE/conditions',
                      type="string",
                      help="DB Snapshot directory")
    parser.add_option("--oracle",
                      action="store_true",
                      dest="UseOracle",
                      default=False,
                      help="Use Oracle")
    parser.add_option("-v",
                      "--verbose",
                      action="store_true",
                      dest="Verbose",
                      default=False,
                      help="Verbose output")
    parser.add_option("--acceptslow",
                      action="store_true",
                      dest="AcceptIfSlow",
                      default=False,
                      help="Accept slow events")
    parser.add_option("--hlt1lines",
                      action="store",
                      dest="Hlt1Lines",
                      default="",
                      help="Colon seperated list of additional hlt1 lines")
    parser.add_option("--hlt2lines",
                      action="store",
                      dest="Hlt2Lines",
                      default="",
                      help="Colon seperated list of additional hlt2 lines")
    parser.add_option("--rch",
                      action="store_true",
                      dest="RunChangeHandler",
                      default=False,
                      help="Use the RunChangeHandler")
    parser.add_option("--l0",
                      action="store_true",
                      dest="L0",
                      default=False,
                      help="Rerun L0")
    parser.add_option("--site",
                      action="store",
                      type="string",
                      dest="Site",
                      default="",
                      help="Site at which we run")
    parser.add_option("--tempdir",
                      action="store",
                      type="string",
                      dest="Tempdir",
                      default="/tmpdir",
                      help="Tempdir for the filestager")
    parser.add_option("--tuplefile",
                      action="store",
                      type="string",
                      dest="TupleFile",
                      default="tuples.root",
                      help="NTuple filename")
    parser.add_option("-f",
                      "--filestager",
                      action="store_true",
                      dest="FileStager",
                      default=False,
                      help="Use the filestager")
    parser.add_option(
        "-c",
        "--verbose_classes",
        action="store",
        type="string",
        dest="VerboseClasses",
        default="",
        help="Colon seperated list of classes to be made verbose.")

    # Parse the command line arguments
    (options, args) = parser.parse_args()

    # Put the options into the Moore configurable
    Moore().ThresholdSettings = options.ThresholdSettings

    Moore().Verbose = options.Verbose
    Moore().EvtMax = options.EvtMax

    Moore().UseDBSnapshot = options.UseDBSnapshot
    Moore().DBSnapshotDirectory = options.SnapshotDirectory
    Moore().DDDBtag = options.DDDBtag
    Moore().CondDBtag = options.CondDBtag
    Moore().Simulation = options.Simulation
    Moore().DataType = options.DataType
    Moore().EnableAcceptIfSlow = options.AcceptIfSlow
    Moore().outputFile = ""
    Moore().ForceSingleL0Configuration = False
    Moore().RequireRoutingBits = [0x0, 0x4, 0x0]
    Moore().L0 = options.L0
    Moore().ReplaceL0BanksWithEmulated = options.L0

    if options.UseOracle:
        CondDB().UseOracle = True
        site = 'UNKNOWN'
        try:
            site = os.environ['DIRACSITE']
        except KeyError:
            if len(options.Site):
                site = options.Site
                config = ConfigLFC(site)
                appendPostConfigAction(config.setLFCSite)

    # Inputdata is now handled through separate option files, this is for
    # testing/convenience
    if len(args):
        Moore().inputFiles = args

    try:
        descriptor = EventSelector().Input[0]
        if descriptor.find(".raw") != -1:
            from Configurables import LHCb__RawDataCnvSvc as RawDataCnvSvc
            EventPersistencySvc().CnvServices.append(
                RawDataCnvSvc('RawDataCnvSvc'))
        elif descriptor.find(".dst") != -1:
            importOptions('$GAUDIPOOLDBROOT/options/GaudiPoolDbRoot.opts')
    except IndexError:
        pass

    freq = 0
    if (len(options.VerboseClasses)):
        freq = 1
    else:
        freq = 100
    EventSelector().PrintFreq = freq

    # RunChangeHandler
    if options.RunChangeHandler:
        Moore().EnableRunChangeHandler = True
        from Configurables import MagneticFieldSvc
        MagneticFieldSvc().UseSetCurrent = True

    # XMLSummary
    from Configurables import LHCbApp
    LHCbApp().XMLSummary = 'summary.xml'

    # Use the filestager?
    if options.FileStager:
        from FileStager.Configuration import configureFileStager
        configureFileStager()

    # Put the comma separated lists of lines into lists
    hlt1Lines = []
    for line in options.Hlt1Lines.split(";"):
        if (len(line.strip())):
            hlt1Lines.append(line)

    hlt2Lines = []
    for line in options.Hlt2Lines.split(";"):
        if (len(line.strip())):
            hlt2Lines.append(line)

    # parse the specification of the classes to set to verbose
    verboseClasses = []
    for cl in options.VerboseClasses.split(";"):
        cl = cl.strip()
        if (len(cl)):
            verboseClasses.append(cl.replace("::", "__"))

    # Instantiate the class to apply the required configuration
    config = Config(hlt1Lines, hlt2Lines)
    appendPostConfigAction(config.postConfigAction)

    # Set the OutputLevel for requested classed
    if len(verboseClasses):
        configOL = ConfigOutputLevel(verboseClasses, 1)
        appendPostConfigAction(configOL.setOutputLevel)

    # Add the TupleHltDecReports alg to the sequence
    if options.TupleFile:
        tupleAlg = TupleHltDecReports("TupleHltDecReports")
        addTupleAlg = ConfigTupleAlg(filename=options.TupleFile)
        appendPostConfigAction(addTupleAlg.addTupleAlg)

    # Instantiate the AppMgr
    appMgr = AppMgr()

    # Make sure that we have Hlt lines to run
    if not len(Sequence("Hlt1").Members) or not len(Sequence("Hlt2").Members):
        print "error, no lines to run\n"
        return 2

    # Run the required number of events
    sc = appMgr.run(Moore().EvtMax)
    if sc.isFailure(): return 2

    # Done
    sc = appMgr.exit()
    if sc.isFailure():
        return 2
    else:
        return 0
Пример #6
0
    for o in options:
        logging.debug(o)
        exec o in g, l

## Instantiate application manager
from GaudiPython.Bindings import AppMgr
appMgr = AppMgr()
evtSel = appMgr.evtSel()
evtSel.OutputLevel = 1
mainSeq = appMgr.algorithm("EscherSequencer")
print evtSel.Input

for i in range(opts.numiter):
    print "Iteration nr: ", i
    mainSeq.Enable = False
    evtSel.rewind()
    mainSeq.Enable = True
    # steer the monitor sequence depending on the iteration
    appMgr.algorithm('AlignMonitorSeq').Enable = (i == 0)
    appMgr.algorithm('Moni').Enable = (i == 0)
    if opts.numiter > 1:
        appMgr.algorithm('AlignPostMonitorSeq').Enable = (i == opts.numiter -
                                                          1)

    resetHistos("AlignSensors")
    appMgr.run(opts.numevents)
    fitSensorResiduals("AlignSensors")

#exit the appmgr for finalize
appMgr.exit()
Пример #7
0
class EventWriter(Task):
    def __init__(self, name, queues, condition):
        Task.__init__(self, name)
        self._inQueue = queues[0]
        self._outQueue = queues[1]
        self._condition = condition
        self._config = dict()

    def configure(self, configuration):
        # Configure the writing process
        from Configurables import LHCbApp
        for (attr, value) in configuration.items():
            if hasattr(LHCbApp, attr):
                setattr(LHCbApp, attr, value)
            self._config[attr] = value

        if not 'Output' in self._config:
            print "An output filename must be specified."
            raise Exception

        if not 'Input' in self._config:
            print "Input must be specified."
            raise Exception

        EventDataSvc().RootCLID = 1
        from Configurables import LHCb__RawDataCnvSvc as RawDataCnvSvc
        EventPersistencySvc().CnvServices.append(
            RawDataCnvSvc('RawDataCnvSvc'))

        EventSelector().Input = self._config['Input']
        EventSelector().PrintFreq = 100
        FileCatalog().Catalogs = self._config['Catalogs']

        from Configurables import LHCb__MDFWriter as MDFWriter
        writer = MDFWriter('MDFWriter',
                           Compress=0,
                           ChecksumType=1,
                           GenerateMD5=True,
                           Connection=self._config['Output'])
        writer.OutputLevel = INFO
        ApplicationMgr().OutStream = [writer]

    def initialize(self):
        # Initialize the application manager
        self._appMgr = AppMgr()
        self._appMgr.initialize()
        # Disable the execution of the MDFWriter
        algo = self._appMgr.algorithm('MDFWriter')
        self._appMgr.algorithm('MDFWriter').Enable = False

    def run(self):
        # Run the required number of events
        nEvents = self._config['EvtMax']
        event = 0

        nWait = self._config['NPrevious']
        wait = 0

        while True:
            write = self._inQueue.get()
            if type(write) == type(""):
                if write == "DONE":
                    # self.notify()
                    break
            if write == True:
                self._appMgr.algorithm('MDFWriter').Enable = True
                # Write the events
                sc = self._appMgr.run(wait + 1)
                if sc == FAILURE:
                    # No more events in input
                    break
                wait = 0
                self._appMgr.algorithm('MDFWriter').Enable = False
                # print "Writing event " + str( event )
                # self._appMgr.algorithm('MDFWriter').execute()
            else:
                if wait < nWait:
                    wait += 1
                else:
                    sc = self._appMgr.run(1)
                    if sc == FAILURE:
                        # No more events in input
                        break

            # Notify the main program
            self.notify()
            event += 1

    def finalize(self):
        self._appMgr.exit()

    def notify(self):
        self._condition.acquire()
        self._condition.notify()
        self._condition.release()
Пример #8
0
class EventReporter(Task):
    def __init__(self, name, queues, condition):
        Task.__init__(self, name)
        self._config = dict()
        self._inQueue = queues[0]
        self._outQueue = queues[1]
        self._condition = condition

    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']
        FileCatalog().Catalogs = self._config['Catalogs']

        EventDataSvc().RootCLID = 1
        from Configurables import LHCb__RawDataCnvSvc as RawDataCnvSvc
        EventPersistencySvc().CnvServices.append(
            RawDataCnvSvc('RawDataCnvSvc'))

        EventSelector().PrintFreq = 100

        from Configurables import GaudiSequencer as Sequence
        from Configurables import createODIN
        seq = Sequence("OdinSequence")
        co = createODIN()
        seq.Members = [co]
        ApplicationMgr().TopAlg = [seq]

    def initialize(self):
        self._appMgr = AppMgr()
        self._appMgr.initialize()

    def run(self):
        evt = self._appMgr.evtsvc()
        nEvents = self._config['EvtMax']
        event = 1
        while True:
            self._condition.acquire()
            self._appMgr.run(1)
            # Get the ODIN
            odin = evt['DAQ/ODIN']
            info = None
            if odin:
                info = (odin.runNumber(), odin.eventNumber())
            else:
                self.done()
                break
            # Put the event info on the queue
            self._outQueue.put(info)
            event += 1
            if event == nEvents:
                self.done()
                break
            else:
                self._condition.wait()
                self._condition.release()

    def finalize(self):
        self._appMgr.exit()

    def done(self):
        # Max events reached, signal done to the main process
        self._outQueue.put('DONE')
        self._condition.release()
Пример #9
0
class DecisionReporter(Task):
    def __init__(self, name, queues, condition):
        Task.__init__(self, name)
        self._config = dict()
        self._inQueue = queues[0]
        self._outQueue = queues[1]
        self._condition = condition

    def configure(self, configuration):
        from Configurables import Moore
        moore = Moore()
        for (attr, value) in configuration.items():
            if attr in moore.__slots__:
                setattr(moore, attr, value)
            self._config[attr] = value

        hlt1Lines = self._config['Hlt1Lines']
        hlt2Lines = self._config['Hlt2Lines']

        #if 'L0' in self._config and self._config[ 'L0' ]:
        #from Configurables import L0MuonAlg
        #L0MuonAlg( "L0Muon" ).L0DUConfigProviderType = "L0DUConfigProvider"

        if 'Dataset' in self._config:
            from PRConfig import TestFileDB
            TestFileDB.test_file_db[self._config['Dataset']].run(
                configurable=Moore())
        else:
            EventSelector().Input = self._config['Input']

        EventSelector().PrintFreq = 100
        FileCatalog().Catalogs = self._config['Catalogs']

        config = Config(hlt1Lines, hlt2Lines)
        appendPostConfigAction(config.postConfigAction)

    def initialize(self):
        self._appMgr = AppMgr()
        self._appMgr.initialize()

    def run(self):
        evt = self._appMgr.evtsvc()
        nEvents = self._config['EvtMax']
        event = 1
        while True:
            if self.wait():
                self._condition.acquire()
            self._appMgr.run(1)
            # Check if there is still event data
            if not bool(evt['/Event']):
                self.done()
                break
            odin = evt['DAQ/ODIN']
            reports = dict()
            reports['event'] = odin.eventNumber()
            reports['run'] = odin.runNumber()
            # Grab the HltDecReports and put the decisions in a dict by line name
            if evt['Hlt1/DecReports']:
                decReports1 = evt['Hlt1/DecReports']
                names1 = decReports1.decisionNames()
                for name in names1:
                    reports[name] = decReports1.decReport(name).decision()
            if evt['Hlt2/DecReports']:
                decReports2 = evt['Hlt2/DecReports']
                names2 = decReports2.decisionNames()
                for name in names2:
                    reports[name] = decReports2.decReport(name).decision()
            # Put our dict on the queue
            self._outQueue.put(reports)
            event += 1
            if event == nEvents:
                self.done()
                break
            elif self.wait():
                self._condition.wait()
                self._condition.release()

    def finalize(self):
        self._appMgr.exit()

    def done(self):
        # Max events reached, signal done to the main process
        self._outQueue.put('DONE')
        if self.wait():
            self._condition.release()

    def wait(self):
        if 'Wait' in self._config:
            return self._config['Wait']
        else:
            return True