Esempio n. 1
0
def GetRunType():
    """Get the run type by reading the run-type setting in the partition from IS """

    #Get a logger so we can show formated messages
    from AthenaCommon.Logging import logging
    mlog = logging.getLogger('EventDisplays')

    #Try to get the partition name
    try:
        import os
        partition = os.environ['TDAQ_PARTITION']
    except KeyError:
        partition = "EventDisplays"
        mlog.warning(
            "TDAQ_PARTITION not defined in environment, using %s as default" %
            partition)

    mlog.debug('Probing partition %s for RunType' % partition)

    #now try and read the information from IS
    try:
        from ipc import IPCPartition
        from ispy import ISObject
        runparams = ISObject(IPCPartition(partition), 'RunParams.RunParams',
                             'RunParams')
        runparams.checkout()
        runType = runparams.run_type
    except UserWarning, err:
        mlog.error(err)
        #Set the default runtype
        runType = "collisions"
        mlog.warning("Failed to read run type from IS, using %s as default" %
                     runType)
Esempio n. 2
0
def GetAtlasReady():
    from ispy import ISObject, IPCPartition
    try:
        r4p = ISObject(IPCPartition("ATLAS"), 'RunParams.Ready4Physics',
                       'RunParams')
        r4p.checkout()
        return r4p.ready4physics
    except:
        print "#### Failed to determine if we are ready for physics"
        raise
Esempio n. 3
0
    def execute(self):
        if self.checkrun:
            try:
                eventInfo = PyEventTools.getEventInfo("")
            except LookupError as err:
                self.msg.warning("Could not retrieve EventInfo: %s", err)
                self.setFilterPassed(False)

        try:
            partition = IPCPartition("ATLAS")

            dictionary = ISInfoDictionary(partition)
            readyForPhysics = ISInfoAny()
            dictionary.getValue("RunParams.Ready4Physics", readyForPhysics)
            ready = readyForPhysics.get()

            runParams = ISObject(partition, 'RunParams.RunParams', 'RunParams')
            runParams.checkout()

        except UserWarning as err:
            self.msg.warning("Could not retrieve data from IS: %s", err)
            self.setFilterPassed(False)
            time.sleep(5)

        self.msg.debug(
            "IS publishes T0_project_tag %s and readyForPhysics %s for run %d",
            runParams.T0_project_tag, ready, runParams.run_number)

        if self.checkready and not ready:
            self.msg.info("ReadyForPhysics not set... rejecting event")
            self.setFilterPassed(False)
            time.sleep(1)

        elif runParams.T0_project_tag != self.t0project:
            self.msg.info("T0_project_tag is not %s (%s)... rejecting event",
                          self.t0project, runParams.T0_project_tag)
            self.setFilterPassed(False)
            time.sleep(1)

        elif self.checkrun and runParams.run_number != eventInfo.event_ID(
        ).run_number():
            self.msg.info(
                "Information in IS is not for this run (%d != %d)... rejecting event",
                runParams.run_number,
                eventInfo.event_ID().run_number())
            self.setFilterPassed(False)

        else:
            self.msg.info("Good event, passing into the public stream...")
            self.setFilterPassed(True)

        return StatusCode.Success
Esempio n. 4
0
def GetRunType():
    """Get the run type by reading the run-type setting in the partition from IS """

    #Get a logger so we can show formated messages
    from AthenaCommon.Logging import logging
    mlog = logging.getLogger('RecExOnline')

    #Try to get the partition name
    try:
        import os
        partition = os.environ['TDAQ_PARTITION']
        if partition == "EventDisplays":
            partition = "ATLAS"
    except KeyError:
        partition = "ATLAS"
        mlog.warning(
            "TDAQ_PARTITION not defined in environment, using %s as default" %
            partition)

    #now try and read the information from IS
    try:
        from ipc import IPCPartition
        from ispy import ISObject
        ipcPart = IPCPartition(partition)
        if not ipcPart.isValid():
            raise UserWarning(
                "Partition %s invalid - cannot access run type settings" %
                partition)
        runparams = ISObject(ipcPart, 'RunParams.RunParams', 'RunParams')
        runparams.checkout()
        beamEnergy = runparams.beam_energy
        projectTag = runparams.T0_project_tag
    except UserWarning, err:
        mlog.error(err)
        beamEnergy = None
        projectTag = None
Esempio n. 5
0
if 'Partition' not in dir():
    Partition="ATLAS"
ByteStreamEmonInputSvc.Partition = Partition

from ipc import IPCPartition
from ispy import ISObject
ipc_partition = IPCPartition(Partition);

if not ipc_partition.isValid():
    tilemon_log.error( 'Partition: ' + ipc_partition.name() + ' is not valid' )
    sys.exit(1)

### ATLAS partition: Read Global Run Parameters to configure the jobs
if ByteStreamEmonInputSvc.Partition == 'ATLAS':
    try:
        run_params = ISObject(ipc_partition, 'RunParams.SOR_RunParams', 'RunParams')
    except:
        tilemon_log.warning( "Could not find Run Parameters in IS - Set default beam type to 'cosmics'")
        beamType = 'cosmics'
    else:
        run_params.checkout()
        beam_type = run_params.beam_type
        beam_energy = run_params.beam_energy
        RunNumber = run_params.run_number
        project = run_params.T0_project_tag
        tilemon_log.info( "RUN CONFIGURATION: beam type: %i, beam energy: %i, run number: %i, project tag: %s" % (beam_type, beam_energy, RunNumber, project) )
        
        # define beam type based on project tag name
        if project[7:] == "cos" or project[5:] == "test":
            beamType = 'cosmics'
        elif project[7:] == '1beam':
Esempio n. 6
0
def GetBFields():

  #Get a logger so we can show formated messages
  from AthenaCommon.Logging import logging
  mlog = logging.getLogger( 'EventDisplays' )

  #BFields are read from initial partition
  partition='initial'
  mlog.debug("Trying to read magnetic field configuration from partition %s"%partition)

  #now try and read the information from IS
  try :
    from ipc import IPCPartition
    from ispy import ISObject
    #Get hold of the initial partition
    ipcPart = IPCPartition(partition);
    if not ipcPart.isValid():
      raise UserWarning("Partition %s invalid - cannot access magnetic field setting"%partition);
    #Get the current and valid status
    toroidCurrent = ISObject(ipcPart,'DCS_GENERAL.MagnetToroidsCurrent.value','DdcFloatInfo')
    solenoidCurrent = ISObject(ipcPart,'DCS_GENERAL.MagnetSolenoidCurrent.value','DdcFloatInfo')
    toroidInvalid = ISObject(ipcPart,'DCS_GENERAL.MagnetToroidsCurrent.invalid','DdcIntInfo')
    solenoidInvalid = ISObject(ipcPart,'DCS_GENERAL.MagnetSolenoidCurrent.invalid','DdcIntInfo')
    toroidCurrent.checkout()
    solenoidCurrent.checkout()
    toroidInvalid.checkout()
    solenoidInvalid.checkout()
    #And calculate the flags
    solenoidOn=((solenoidCurrent.value > 1000.) and (solenoidInvalid.value == 0))
    toroidOn=((toroidCurrent.value > 1000.) and (toroidInvalid.value == 0))
  except UserWarning as err:
    mlog.error(err)
    #Should always be able to access initial parititon
    mlog.fatal("Failed to read magnetic field configuration from IS, aborting")
    import sys
    sys.exit(1)

  #print the result
  mlog.info("Magnetic field in solenoid is %s" % ((solenoidOn and "ON") or "OFF"))
  mlog.info("Magnetic field in toroid is %s" % ((toroidOn and "ON") or "OFF"))

  #finally return our values
  return (solenoidOn,toroidOn)
Esempio n. 7
0
    logRecExOnline_globalconfig.info("is_T0_project_tag = %s" %
                                     is_T0_project_tag)

    part_name = 'initial'
    p = IPCPartition(part_name)
    toroidCurrent = 0
    toroidInvalid = 1
    solenoidCurrent = 0
    solenoidInvalid = 1

    # AL playing around: start
    #toroidCurrent   = ispy.ISInfoDynAny(p2, 'DdcFloatInfo')
    #solenoidCurrent = ispy.ISInfoDynAny(p2, 'DdcFloatInfo')
    #toroidInvalid   = ispy.ISInfoDynAny(p2, 'DdcIntInfo')
    #solenoidInvalid = ispy.ISInfoDynAny(p2, 'DdcIntInfo')
    solenoidCurrent = ISObject(p, 'DCS_GENERAL.MagnetSolenoidCurrent.value',
                               'DdcFloatInfo')
    solenoidCurrent.checkout()
    toroidCurrent = ISObject(p, 'DCS_GENERAL.MagnetToroidsCurrent.value',
                             'DdcFloatInfo')
    toroidCurrent.checkout()
    solenoidInvalid = ISObject(p, 'DCS_GENERAL.MagnetSolenoidCurrent.invalid',
                               'DdcIntInfo')
    solenoidInvalid.checkout()
    toroidInvalid = ISObject(p, 'DCS_GENERAL.MagnetToroidsCurrent.invalid',
                             'DdcIntInfo')
    toroidInvalid.checkout()

    #toroidInvalid.value=1
    #solenoidInvalid.value=1
    # AL playing around: end
Esempio n. 8
0
    def beginEvent(self):
        if not (self.StreamToFileTool and self.StreamToServerTool
                and self.VP1EventProducer):
            self.getJobOptions()

        try:
            eventInfo = PyEventTools.getEventInfo('EventInfo')
        except LookupError as err:
            self.msg.error("Could not retrieve EventInfo: %s" % err)
            return StatusCode.Recoverable

        try:
            # Read event info
            self.run = eventInfo.runNumber()
            self.event = eventInfo.eventNumber()

            # Retrieve trigger info
            streamTags = eventInfo.streamTags()
        except Exception as err:
            self.msg.error(
                "Exception occured while reading event/trigger info: %s" % err)
            return StatusCode.Recoverable

        # Retrieve the physics stream names from the trigger info
        streams = []
        for tag in streamTags:

            ## Added 08/03/15 - sjiggins - Wanted to see if events had physics stream tag or was from random trigger
            if tag.name():
                self.msg.debug(
                    "Event %d/%d has the corresponding streamTags: %s" %
                    (self.run, self.event, tag.type()))
            ##################################################################################
            if tag.type() == 'express' and tag.name():
                streams += [tag.type() + '_' + tag.name()]

            if tag.type() == 'physics' and tag.name():
                streams += [tag.type() + '_' + tag.name()]

        # Add special streams to the list Public
        try:
            for stream in streams:
                if stream in self.public:
                    ready4physics = ISInfoAny()
                    self.dict.getValue('RunParams.Ready4Physics',
                                       ready4physics)
                    print("Ready for physics: %s " % ready4physics.get())
                    runparams = ISObject(self.partition, 'RunParams.RunParams',
                                         'RunParams')
                    runparams.checkout()
                    physicsReady = ISObject(self.partition,
                                            'RunParams.Ready4Physics',
                                            'Ready4PhysicsInfo')
                    physicsReady.checkout()
                    print("Ready for physics: %r" %
                          (physicsReady.ready4physics))
                    #if ready4physics.get() and physicsReady.ready4physics and runparams.T0_project_tag in self.projecttags:
                    if physicsReady.ready4physics and runparams.T0_project_tag in self.projecttags:
                        streams += ['Public']
                    else:
                        self.msg.debug(
                            "RunParams.Ready4Physics is not set, run number is not set, or T0_project_tag is not set to any of %s"
                            % ", ".join(self.projecttags))
                        break
        except Exception as err:
            self.msg.error(
                "Exception occured while reading RunParams.Ready4Physics: %s" %
                err)

        # Randomize list of streams
        random.shuffle(streams)
        self.msg.debug("Event %d/%d has event display stream tags: %s" %
                       (self.run, self.event, ", ".join(streams)))

        # Start from the beginning and send the event to the first stream that passes our directory checks
        self.directory = ''
        for self.stream in streams:
            self.directory = "%s/%s" % (self.output, self.stream)
            if os.access(self.directory, os.F_OK):
                if os.path.isdir(self.directory) and os.access(
                        self.directory, os.W_OK):
                    self.msg.debug(
                        "Going to write file to existing directory: %s" %
                        self.directory)
                    if os.stat(self.directory).st_gid != self.DQMgid:
                        self.msg.debug(
                            "Setting group to 'DQM' for directory: %s" %
                            self.directory)
                        os.chown(self.directory, -1, self.DQMgid)
                    break
                else:
                    self.msg.warning(
                        "Directory \'%s\' is not usable, trying next alternative"
                        % self.directory)
                    self.directory = ''
            else:
                try:
                    os.mkdir(self.directory)
                    os.chmod(
                        self.directory, stat.S_IRWXU | stat.S_IRWXG
                        | stat.S_IROTH | stat.S_IXOTH)
                    os.chown(self.directory, -1, self.DQMgid)
                    self.msg.info(
                        "Created output directory \'%s\' for stream \'%s\'" %
                        (self.directory, self.stream))
                    break
                except OSError as err:
                    self.msg.warning(
                        "Failed to create output directory \'%s\' for stream \'%s\': %s",
                        (self.directory, self.stream, err.strerror))
                    self.directory = ''

        # Check if a suitable directory was found
        if self.directory:
            self.msg.debug("Event %d/%d will be streamed to: %s" %
                           (self.run, self.event, self.stream))
        else:
            # This event is hopelessly lost, send StatusCode.Recoverable in an attempt to abort.
            # But if Athena chooses to ignore that, set the output to the "Unknown" trashcan stream.
            self.stream = 'Unknown'
            self.directory = "%s/.Unknown" % self.output
        try:
            # Set output stream for JiveXML event streaming (file and server)
            self.StreamToServerTool.getProperty('StreamName').setValue(
                "%s" % self.stream)
            self.StreamToFileTool.getProperty('FileNamePrefix').setValue(
                "%s/JiveXML" % self.directory)

            # And also for the VP1 event producer algorithm
            #self.VP1EventProducer.getProperty('DestinationDirectory').setValue(self.directory) # lshi June 22 2020
        except Exception as err:
            self.msg.error("Exception occured while setting job options: %s" %
                           err)
            return StatusCode.Failure

        if not self.directory:
            return StatusCode.Recoverable
Esempio n. 9
0
if 'Partition' not in dir():
    Partition = 'TileTB'
ByteStreamEmonInputSvc.Partition = Partition


from ipc import IPCPartition
from ispy import ISObject
ipc_partition = IPCPartition(Partition);


if not ipc_partition.isValid():
    tilemon_log.error( 'Partition: ' + ipc_partition.name() + ' is not valid' )
    sys.exit(1)

try:
    run_params = ISObject(ipc_partition, 'RunParams.SOR_RunParams', 'RunParams')
except:
    tilemon_log.warning( "Could not find Run Parameters in IS - Set default beam type to 'cosmics'")
    beamType = 'cosmics'
    RunNumber = 000000
else:
    run_params.checkout()
    beam_type = run_params.beam_type
    beam_energy = run_params.beam_energy
    RunNumber = run_params.run_number
    project = run_params.T0_project_tag
    run_type = run_params.run_type
    tilemon_log.info( "RUN CONFIGURATION: run type: %s, beam type: %i, beam energy: %i, run number: %i, project tag: %s" 
                      %(run_type, beam_type, beam_energy, RunNumber, project) )

    if 'CIS mono' in run_type: