Example #1
0
def outputLocations(stripping, lineName, lines=[], archive=None):
    '''
    Return the output location(s) [as a list] of a given line in a given stripping
    if lines is an empty list, outputLocations will instantiate the lines itself
    or else it is assumed they are proper line objects with an outputLocation method

    e.g.:

    line=lineBuilder('Stripping15','B0q2DplusMuX')
    oneline=line.lines()[0]

    location=outputLocations('Stripping15', 'B0q2DplusMuX', [oneline])

    Essentially it returns /Event/<stream>/Phys/<line>/Particles, avoiding the need for
    the user to construct this manually
    '''

    if isinstance(stripping, basestring) :
        _db = _sConf( stripping )
        from StrippingArchive import strippingArchive
        archive=strippingArchive(stripping)
    else :
        _db = stripping

    if lineName not in _db:
        raise KeyError, "the line "+lineName+" does not exist in the chosen stripping"

    if len(lines)==0:
        _line=lineBuilder(_db, lineName, archive)
        lines=_line.lines()

    _conf=_db[lineName]

    retlist=[]
    #add individual lines if the lines are a dictionary
    if isinstance(_conf['STREAMS'],dict):
            for stream in _conf['STREAMS']:
                for linename in _conf['STREAMS'][streams]:
                    line = lineFromList( _line, lines )
                    if line: retlist.append('/Event/'+stream+'/'+line.outputLocation().replace('/Event','').strip('/'))
    #add whole list if the streams are a list
    elif isinstance(_conf['STREAMS'],list):
        for aline in lines:
            for stream in _conf['STREAMS']:
                retlist.append('/Event/'+stream+'/'+aline.outputLocation().replace('/Event','').strip('/'))

    else:
        raise Exception( 'Unsupported type, expected list ' +
                         'or dict for line-to-STREAM mapping' )
    return retlist
Example #2
0
def buildStreams(stripping,archive=None, WGs = None) :
    """
    Build and return a set of StrippingStreams for a given stripping
    configuration.
    Usage:

    >>> streams = buildStreams('Stripping13')
    >>> for s in streams :
    ...   print s.name(), s.lines


    It is also possible to use a configuration dictionary directly:

    >>> conf = strippingConfiguration('Stripping13')
    >>> archive = strippingArchive('Stripping13')
    >>> streams = buildStreams(conf,archive)

    """
    from StrippingConf.StrippingStream import StrippingStream

    streams = {}

    if isinstance(stripping, basestring) :
        scdb = _sConf(stripping)
        from StrippingArchive import strippingArchive
        archive=strippingArchive(stripping)
    else :
        scdb = stripping

    for k, v in scdb.iteritems() :
        if 'STREAMS' in v.keys() and not WGs or 'WGs' in v.keys():
            if not WGs or any( WG for WG in v['WGs'] if WG in WGs ):
                lb = archive.lineBuilders()[v['BUILDERTYPE']](k,v['CONFIG'])
                addBuilderToStreamGrouping( streams, v, lb )
        else:
            raise Exception('Config',k,'missing either STREAM or WG data data.')

    strippingStreams=[]
    for stream in streams:
        lines = [ line for line in streams[stream] ]
        print ( 'Creating ' + stream + ' stream with '
                + str( len(lines) ) + ' lines' )
        strippingStreams.append( StrippingStream( stream, Lines = lines ) )

    return strippingStreams
Example #3
0
def lineBuilder(stripping, lineBuilderName, archive=None) :
    """
    Create a line builder from a stripping version and a line builder
    instance name.  The instance name must be registered in the database.
    Usage:
    lb = lineBuilder('Stripping13', 'B2XGamma')
    print lb.lines()
    This already configures the line builder with the stripping cuts
    """
    if isinstance(stripping, basestring) :
        _config = _lbConf(stripping, lineBuilderName)
        from StrippingArchive import strippingArchive
        archive=strippingArchive(stripping)
    else :
        _config = stripping[lineBuilderName]

    return archive.lineBuilders()[_config['BUILDERTYPE']](lineBuilderName,
                                                          _config['CONFIG'])
Example #4
0
def lineBuilderAndConf(stripping, lineBuilderName, archive=None):
    """
    If you want to try new cuts on an old line, better to get just the builder itself
    returns a tuple of (builder, config)
    modify config as you wish, then instantiate the lines

    builder,config = lineBuilderAndConf("Stripping13","B0q2DplusMuX")
    config["Tuned"]["MuPT"]=1000 #MeV / c
    lines=builder("MyB0q2DplusMuX",config).lines()
    """

    if isinstance(stripping, basestring) :
        _config = _lbConf(stripping, lineBuilderName)
        from StrippingArchive import strippingArchive
        archive=strippingArchive(stripping)
    else :
        _config = stripping[lineBuilderName]

    return (archive.lineBuilders()[_config['BUILDERTYPE']], _config['CONFIG'])
Example #5
0
def buildStream(stripping, streamName = '', archive=None, WGs = None ):
    """
    Create a StrippingStream from the lineBuilder database
    Usage:
    >>> streamDimuon = strippingStream('Stripping13','Dimuon')
    or:
    >>> conf = strippingConfiguration('Stripping13')
    >>> streamDimuon = strippingStream(conf,'Dimuon')

    """

    from StrippingConf.StrippingStream import StrippingStream

    stream = StrippingStream( streamName )

    if isinstance(stripping, basestring) :
        _db = _sConf( stripping )
        from StrippingArchive import strippingArchive
        archive=strippingArchive(stripping)
    else :
        _db = stripping

    for key in _db.keys():
        _conf = _db[key]
        if stream.name() in _conf['STREAMS']:
            if WGs and not any( WG for WG in _conf['WGs'] if WG in WGs): continue
            _lb = archive.lineBuilders()[_conf['BUILDERTYPE']](key,_conf['CONFIG'])

            if isinstance(_conf['STREAMS'],dict):
                for linename in _conf['STREAMS'][stream.name()]:
                    line = _lfName( _lb, linename )
                    if line:
                        stream.appendLines( [ line ] )
                    else:
                        raise Exception('The line you have requested does not exist '+linename)
            elif isinstance(_conf['STREAMS'],list):
                stream.appendLines( _lb.lines() )
            else:
                raise Exception( 'Unsupported type, expected list ' +
                                 'or dict for line-to-STREAM mapping' )

            
    return stream
Example #6
0
def ReStrip(mylines, stripping="stripping21r0p1", streamname=None):

    from Configurables import EventNodeKiller, ProcStatusCheck
    from StrippingArchive.Utils import buildStreams
    from StrippingArchive import strippingArchive
    from StrippingConf.Configuration import StrippingStream
    from StrippingConf.Configuration import StrippingConf
    from StrippingSettings.Utils import strippingConfiguration

    NodeKiller = EventNodeKiller("StripKiller")
    NodeKiller.Nodes = ["/Event/AllStreams", "/Event/Strip"]

    from StrippingSelections import buildersConf
    from StrippingSelections.Utils import lineBuilder, buildStreamsFromBuilder

    config = strippingConfiguration(stripping)
    archive = strippingArchive(stripping)
    streams = buildStreams(stripping=config, archive=archive)

    #confs = buildersConf()

    mystream = StrippingStream("MyStream")
    #for name in confnames:
    #    streams = buildStreamsFromBuilder(confs,name)
    for stream in streams:
        #if streamname not in stream : continue
        for line in stream.lines:
            print line
            if line.name() in mylines:
                print "Adding ", line.name(), "for restripping"
                mystream.appendLines([line])

    restrip = StrippingConf(Streams=[mystream],
                            MaxCandidates=2000,
                            AcceptBadEvents=False,
                            BadEventSelection=ProcStatusCheck(),
                            TESPrefix='Strip',
                            ActiveMDSTStream=True)
    #Verbose = True,
    #MicroDSTStreams = streams )
    return restrip, [NodeKiller, restrip.sequence()]
Example #7
0
DecodeRawEvent().setProp("OverrideInputs", 4.2)

########################

#
# Build the streams and stripping object
#
from StrippingConf.Configuration import StrippingConf, StrippingStream
from StrippingSettings.Utils import strippingConfiguration
from StrippingArchive.Utils import buildStreams, cloneLinesFromStream
from StrippingArchive import strippingArchive

#get the configuration dictionary from the database
config = strippingConfiguration(stripping)
#get the line builders from the archive
archive = strippingArchive(stripping)

#########################
# Fix Bu2LLK config for S29r2, which was not updated in Settings but is correct in Archive
from StrippingArchive.Stripping29r2.StrippingRD.StrippingBu2LLK import default_config as Bu2LLK_config
config = dict(config)
config['Bu2LLK']['CONFIG'] = Bu2LLK_config['CONFIG']

# only in this stripping. Now sure what's the need of this in our case
#########################

streams = buildStreams(stripping=config, archive=archive)

#OUTPUT STREAM NAME
AllStreams = StrippingStream("b2dhh.Strip")
Example #8
0
    ProcStatusCheck,
    DaVinci,
    DecayTreeTuple
)
from GaudiConf import IOHelper
from DecayTreeTuple.Configuration import *

# Node killer: remove the previous Stripping
event_node_killer = EventNodeKiller('StripKiller')
event_node_killer.Nodes = ['/Event/AllStreams', '/Event/Strip']

# Build a new stream called 'CustomStream' that only
# contains the desired line
strip = 'stripping21'
streams = buildStreams(stripping=strippingConfiguration(strip),
                       archive=strippingArchive(strip))

custom_stream = StrippingStream('CustomStream')
custom_line = 'StrippingD2hhCompleteEventPromptDst2D2RSLine'

for stream in streams:
    for line in stream.lines:
        if line.name() == custom_line:
            custom_stream.appendLines([line])

line = 'D2hhCompleteEventPromptDst2D2RSLine'

# Create the actual Stripping configurable
filterBadEvents = ProcStatusCheck()

sc = StrippingConf(Streams=[custom_stream],
Example #9
0
 def __init__(self, version) :
     self.version = prepend_stripping(version)
     self.config  = strippingConfiguration(self.version)
     self.archive = strippingArchive(self.version)
     self.streams = buildStreams(stripping=self.config, archive=self.archive) 
Example #10
0
from StrippingArchive import strippingArchive, _relinfo_obsolete_strippings, _duplicate_strippings

import commands

print "RelInfo-obsolete strippings are"
print _relinfo_obsolete_strippings


obsoleteduplicates=[]
for i,k in _duplicate_strippings.iteritems():
    if k in _relinfo_obsolete_strippings:
        obsoleteduplicates.append(i)

strippings = [s for s in strippingArchive() if s not in _relinfo_obsolete_strippings+obsoleteduplicates]

print "looping over:"
print strippings

for astripping in strippings:
    print '============================================='
    print astripping,':'
    print '============================================='
    status,stdout=commands.getstatusoutput('python -c "from StrippingArchive.Utils import buildStreams; buildStreams('+"'"+astripping+"'"+');"')
    print stdout
    if status!=0:
        print '----------FAILED----------'
        print astripping,'failed',status
# restrip
if not (restripversion == ""):

    # kill old stripping banks
    from Configurables import EventNodeKiller
    eventNodeKiller = EventNodeKiller('Stripkiller')
    eventNodeKiller.Nodes = ['/Event/AllStreams', '/Event/Strip']

    from StrippingConf.Configuration import StrippingConf, StrippingStream
    from StrippingArchive import strippingArchive
    from StrippingArchive.Utils import buildStreams
    from StrippingSettings.Utils import strippingConfiguration

    # Note: can only  get stripping versions with certain DaVinci versions
    config = strippingConfiguration(restripversion)
    archive = strippingArchive(restripversion)
    streams = buildStreams(stripping=config, archive=archive)

    # get our stripping line from archive
    MyStream = StrippingStream("MyStream")
    MyLines = ['Stripping' + lines[0]]  # note: only for one line!
    for stream in streams:
        for line in stream.lines:
            if line.name() in MyLines:
                MyStream.appendLines([line])

    from Configurables import ProcStatusCheck
    filterBadEvents = ProcStatusCheck()
    sc = StrippingConf(Streams=[MyStream],
                       MaxCandidates=2000,
                       AcceptBadEvents=False,
def get_streams(version) :
    config  = strippingConfiguration(version)
    archive = strippingArchive(version)
    streams = buildStreams(stripping=config, archive=archive) 
    return streams