def copyGoodEvents(filename, extraitems=[], incident='GoodEvent'): """ Utitity to copy ``good/tagged'' events It is based on configurables, thus it needs to be invoked BEFORE GaudiPython # ##Configurables: # from Bender.Utils import copyGoodEvents copyGoodEvents ( filename = 'SelectedEvents' ) """ from GaudiConf import IOHelper ioh = IOHelper('ROOT', 'ROOT') algs = ioh.outputAlgs(filename, 'InputCopyStream/%s' % incident) ioh.setupServices() from Configurables import Gaudi__IncidentFilter as Tagger tag = Tagger("%sInc" % incident, Incidents=[incident]) from Configurables import GaudiSequencer seq = GaudiSequencer('%sSeq' % incident, Members=[tag] + algs) from Configurables import ApplicationMgr AM = ApplicationMgr() if not AM.OutStream: AM.OutStream = [] AM.OutStream.append(seq) logger.info("Prepare the file %s to keep ``%s'' incidents" % (filename, incident))
print stream.Connection ioh.convertStreams() print "- after conversion" for stream in ioh.activeStreams(): if hasattr( stream, "Output" ): # or (hasattr(stream,"__slots__") and "Output" in stream.__slots__): print stream.Output elif hasattr(stream, "Connection"): print stream.Connection #preload with some MDFs, check they make it through the conversions ioh = IOHelper("MDF", "MDF") ioh.outputAlgs("file1.mdf", writeFSR=False) ioh.outputAlgs("file2.mdf", "LHCb::MDFWriter", writeFSR=False) #add a bare InputCopyStream to a GaudiSequencer, check it's OK from Gaudi.Configuration import ApplicationMgr from Configurables import GaudiSequencer ApplicationMgr().TopAlg = ["Rubbish", GaudiSequencer("MoreRubbish")] GaudiSequencer("MoreRubbish").Members = ["InputCopyStream"] persistencies = [None, "ROOT", "MDF"] if IOHelper().isPoolSupported(): persistencies.append("POOL") for persistency in persistencies: print '=============================' print persistency
def __init__(self, selSequence, outputStreamConfiguration, writeFSR=True, extras=None, persistency=None): from GaudiConf import IOHelper outputStreamConfiguration.name = selSequence.name() #self.stream = outputStream(outputStreamConfiguration) #self.fsrStream = fsrStream(outputStreamConfiguration) conf = outputStreamConfiguration dstName = conf.filePrefix + conf.name + conf.extension ioh = IOHelper(persistency, persistency) writer = conf.streamType(conf.name + '_OStream') writer.OptItemList += conf.extraItems if len(conf.vetoItems) > 0: writer.TESVetoList += conf.vetoItems #writer.OutputLevel = 1 algs = ioh.outputAlgs(filename=dstName, writer=writer, writeFSR=writeFSR) self.name = "DSTWriter" + selSequence.name() self.algos = [selSequence.sequence()] self.mainSeq = None if extras is not None: for _algs in [x(selSequence) for x in extras]: self.algos += _algs # Extract Raw Events to keep for this stream, line by line. if outputStreamConfiguration.selectiveRawEvent: try: rawEvents = selSequence.getRequiredRawEvents() rawEvPropName = 'AlgDependentItemList' if hasattr(writer, rawEvPropName): writer.setProp(rawEvPropName, rawEvents) else: print "WARNING : Output Writer", writer.name( ), "does not have property", rawEvPropName except: raise Exception( "Sequence '" + selSequence.name() + "' does not have support for selective raw event saving. **NO** Raw Event banks will be saved. To save them, set selectiveRawEvent=False in your SelDSTWriter stream Configuration." ) # Collects the data available on the input file, for subsequent DST streams. # Must be run once per event, before *any* TES address killing. # Only one instance needed, so run an instance here that is not stream specific. from Configurables import FixInputCopyStream self.algos.append(FixInputCopyStream()) if outputStreamConfiguration.killTESAddressHistory: from Configurables import AddressKillerAlg self.algos.append( AddressKillerAlg(name="KillTESAddresses_" + conf.name)) for alg in algs: if ioh.detectStreamType(alg) in ["FSR"]: #FSR stream if writeFSR: self.algos = [alg] + self.algos else: #event data stream self.algos += [alg] if extras is not None: alg.OptItemList += extras.output