def insertDump(seq, entry, outputname): dumpAlgs = [] from Configurables import EventNodeKiller dumpAlgs += [EventNodeKiller("killForDump")] EventNodeKiller("killForDump").Nodes = Gaudi.Excise['killAtLeast'] from Configurables import OutputStream, InputCopyStream dump = OutputStream("DumpEverything") dump.ItemList = Gaudi.Excise['copyNodes'] from GaudiConf import IOHelper dumpAlgs += IOHelper().outputAlgs(outputname, dump, writeFSR=True) return insertSomething(seq, entry, dumpAlgs)
def _doWritePOOL(self, dType, writer): """ Write a file in POOL format """ log.info("%s.ItemList = %s" % (self.getProp("Writer"), writer.ItemList)) log.info("%s.OptItemList = %s" % (self.getProp("Writer"), writer.OptItemList)) # In Minimal case, need to kill some nodes if dType == "Minimal": from Configurables import EventNodeKiller nodeKiller = EventNodeKiller("POOLNodeKiller") ApplicationMgr().OutStream.insert(0, nodeKiller) nodeKiller.Nodes += ["Link"] simDir = "MC" if self.getProp("EnablePack"): simDir = "pSim" nodeKiller.Nodes += [simDir + "/MCParticles"] nodeKiller.Nodes += [ simDir + "/Velo", simDir + "/PuVeto", simDir + "/TT", simDir + "/IT", simDir + "/OT", simDir + "/Rich", simDir + "/Prs", simDir + "/Spd", simDir + "/Ecal", simDir + "/Hcal", simDir + "/Muon", simDir + "VP", simDir + "UT", simDir + "FT" ] nodeKiller.Nodes += self.KnownSpillPaths
def configureInput(self, inputType): """ Tune initialisation according to input type """ # By default, Brunel only needs to open one input file at a time # Only set to zero if not previously set to something else. if not IODataManager().isPropertySet("AgeLimit") : IODataManager().AgeLimit = 0 if self._isReprocessing(inputType): # Kill knowledge of any previous Brunel processing from Configurables import ( TESCheck, EventNodeKiller ) InitReprocSeq = GaudiSequencer( "InitReprocSeq" ) if ( self.getProp("WithMC") and inputType in ["XDST","DST"] ): # Load linkers, to kill them (avoid appending to them later) InitReprocSeq.Members.append( "TESCheck" ) TESCheck().Inputs = ["Link/Rec/Track/Best"] killer = EventNodeKiller() killer.Nodes += [ "Raw", "Link/Rec" ] if self.getProp("SkipTracking"): killer.Nodes += [ "pRec/Rich", "pRec/Muon", "pRec/Calo", "pRec/Track/Muon", "pRec/ProtoP" ] else: killer.Nodes += [ "pRec", "Rec" ] InitReprocSeq.Members.append( killer ) ### see configureOutput to see how the remainder of the juggler is configured # Get the event time (for CondDb) from ODIN from Configurables import EventClockSvc EventClockSvc().EventTimeDecoder = "OdinTimeDecoder";
def _defineMonitors(self): if self.getProp("KillDAQ"): from Configurables import EventNodeKiller daqKiller = EventNodeKiller("DAQKiller") daqKiller.Nodes += ["DAQ"] ApplicationMgr().TopAlg += [daqKiller] ApplicationMgr().TopAlg += ["PrintHeader"] ApplicationMgr().ExtSvc += ["ToolSvc", "DataOnDemandSvc"] if self.getProp("LoadAll"): from Configurables import StoreExplorerAlg, TESFingerPrint storeExp = StoreExplorerAlg(Load=True, PrintFreq=1, ExploreRelations=1) fingerPrint = TESFingerPrint(HeuristicsLevel="Medium", OutputLevel=1) ApplicationMgr().TopAlg += [storeExp, fingerPrint] if self.getProp("DataContent").upper() == "DST": from Configurables import DumpTracks dumpTracks = DumpTracks(OutputLevel=2) ApplicationMgr().TopAlg += ["DumpTracks"] DstConf().EnableUnpack = ["Reconstruction", "Stripping"] if self.getProp("WithMC"): DigiConf().EnableUnpack = True SimConf().EnableUnpack = True ApplicationMgr().TopAlg += ["DumpMCEventAlg"] if self.getProp("DataContent").upper() == "SIM": ApplicationMgr().TopAlg += ["DumpHepMC"]
def patSeq(self, outputLevel=INFO): if not allConfigurables.get("PatSeq"): if outputLevel == VERBOSE: print "VERBOSE: Pat Sequencer not defined! Defining!" patSequencer = GaudiSequencer("PatSeq") patSequencer.MeasureTime = True from Configurables import (TESCheck, EventNodeKiller) patSequencer.Members.append( TESCheck(Inputs=["Link/Rec/Track/Best"], Stop=False)) patSequencer.Members.append( EventNodeKiller(Nodes=["Rec", "Raw", "Link/Rec"])) patSequencer.Members.append( GaudiSequencer("RecoVELOSeq", MeasureTime=True)) patSequencer.Members.append( GaudiSequencer("RecoTTSeq", MeasureTime=True)) patSequencer.Members.append( GaudiSequencer("RecoITSeq", MeasureTime=True)) patSequencer.Members.append( GaudiSequencer("RecoOTSeq", MeasureTime=True)) patSequencer.Members.append( GaudiSequencer("RecoTrSeq", MeasureTime=True)) patSequencer.Members.append( GaudiSequencer("RecoVertexSeq", MeasureTime=True)) #importOptions("$TRACKSYSROOT/options/RecoTracking.py") #importOptions("$TALIGNMENTROOT/options/PatRecognition.opts") from Configurables import TrackRemoveDoubleHits if allConfigurables.get("TrackForwardPatSeq"): trackFwdPatSeq = GaudiSequencer("TrackForwardPatSeq") trackRemoveDoubleHitsFwd = TrackRemoveDoubleHits( "FwdRemoveDoubleHits") trackRemoveDoubleHitsFwd.TracksLocation = "Rec/Track/Forward" trackFwdPatSeq.Members.append(trackRemoveDoubleHitsFwd) if allConfigurables.get("TrackMatchPatSeq"): trackMatchPatSeq = GaudiSequencer("TrackMatchPatSeq") trackRemoveDoubleHitsMatch = TrackRemoveDoubleHits( "MatchRemoveDoubleHits") trackRemoveDoubleHitsMatch.TracksLocation = "Rec/Track/Match" trackMatchPatSeq.Members.append(trackRemoveDoubleHitsMatch) from Configurables import (PatPVOffline) allConfigurables["RecoVertexSeq"].Members.append(PatPVOffline()) return patSequencer else: if outputLevel == VERBOSE: print "VERBOSE: Pat Sequencer already defined!" return allConfigurables.get("PatSeq")
def configureInput(self, inputType): """ Tune initialisation according to input type """ # POOL Persistency, now in LHCbApp #importOptions("$GAUDIPOOLDBROOT/options/GaudiPoolDbRoot.opts") # By default, Escher only needs to open one input file at a time # Only set to zero if not previously set to something else. if not IODataManager().isPropertySet("AgeLimit"): IODataManager().AgeLimit = 0 if inputType in ["XDST", "DST", "RDST", "ETC"]: # Kill knowledge of any previous Brunel processing from Configurables import (TESCheck, EventNodeKiller) InitReprocSeq = GaudiSequencer("InitReprocSeq") if (self.getProp("WithMC") and inputType in ["XDST", "DST"]): # Load linkers, to kill them (avoid appending to them later) InitReprocSeq.Members.append("TESCheck") TESCheck().Inputs = ["Link/Rec/Track/Best"] InitReprocSeq.Members.append("EventNodeKiller") EventNodeKiller().Nodes = ["pRec", "Rec", "Raw", "Link/Rec"] if inputType == "ETC": raise DeprecationWarning, "ETC are no longer supported by LHCb software" from Configurables import TagCollectionSvc ApplicationMgr().ExtSvc += [TagCollectionSvc("EvtTupleSvc")] # Read ETC selection results into TES for writing to DST IODataManager().AgeLimit += 1 #if inputType in [ "MDF", "RDST", "ETC" ]: # # In case raw data resides in MDF file # EventPersistencySvc().CnvServices.append("LHCb::RawDataCnvSvc") DecodeRawEvent() if self.getProp("UseFileStager"): import os, getpass from FileStager.Configuration import configureFileStager from Configurables import FileStagerSvc configureFileStager(keep=True) targetdir = '/tmp/' + getpass.getuser() + '/stagedfiles' if os.path.isdir('/pool/spool/'): targetdir = '/pool/spool/' + getpass.getuser() + '/stagedfiles' if not os.path.isdir(targetdir): os.makedirs(targetdir) FileStagerSvc().Tempdir = targetdir
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()]
def redoMCLinks(self,init): """ Redo MC links. """ if ( self.getProp("Simulation") ): redo = self.getProp("RedoMCLinks") if ( redo ): from Configurables import (GaudiSequencer,TESCheck,EventNodeKiller,TrackAssociator) mcKillSeq = GaudiSequencer("KillMCLinks") # The sequence killing the node of it exists tescheck = TESCheck("DaVinciEvtCheck") # Check for presence of node ... tescheck.Inputs = ["Link/Rec/Track/Best"] # tescheck.Stop = False # But don't stop tescheck.OutputLevel = 5 # don't print warnings evtnodekiller = EventNodeKiller("DaVinciEvtNodeKiller") # kill nodes evtnodekiller.Nodes = ["Link/Rec/Track"] # Kill that mcKillSeq.Members = [ tescheck, evtnodekiller, TrackAssociator() ] mcLinkSeq = GaudiSequencer("RedoMCLinks") # The sequence redoing the links mcLinkSeq.IgnoreFilterPassed = True # Run it always mcLinkSeq.Members = [ mcKillSeq, TrackAssociator() ] init.Members += [ mcLinkSeq ]
def addMCDigitSummaries(self, writer): simDir = "MC" if ((self.getProp("EnablePack")) and ("Rich" in self.getProp("Detectors"))): simDir = "pSim" packDigi = self.getProp("PackSequencer") from Configurables import DataPacking__Pack_LHCb__MCRichDigitSummaryPacker_ RichSumPack = DataPacking__Pack_LHCb__MCRichDigitSummaryPacker_( "MCRichDigitSummaryPacker") packDigi.Members += [RichSumPack] # Kill the unpacked Rich node from Configurables import EventNodeKiller nodeKiller = EventNodeKiller("MCRichNodeKiller") nodeKiller.Nodes += ["MC/Rich"] packDigi.Members += [nodeKiller] # Digitization summaries if "Rich" in self.getProp("Detectors"): writer.ItemList += ["/Event/" + simDir + "/Rich/DigitSummaries#1"] if "Muon" in self.getProp("Detectors"): writer.ItemList += ["/Event/MC/Muon/DigitsInfo#1"]
def killDAQ(nodes=['/Event/DAQ', '/Event/pRec'], logger=None): """ Configure node killing agents for uDST processing """ # if not logger: logger = log # from Configurables import EventNodeKiller killer = EventNodeKiller("KillDAQ") for node in nodes: if node in killer.Nodes: continue killer.Nodes.append(node) try: from Gaudi.Configuration import getConfigurable conf = getConfigurable('DaVinciEventInitSeq') conf.Members.insert(0, killer) logger.info("Add killer agent for: %s" % killer.Nodes) except: logger.error("Failed to add killer agent for: %s" % killer.Nodes)
def defineOutput(self): """ Set up output stream according to output data type """ knownOptions = ["MDF", "DIGI"] outputs = [] for option in self.getProp("Outputs"): if option not in knownOptions: raise RuntimeError("Unknown Boole().Outputs value '%s'" % option) outputs.append(option) if "DIGI" in outputs: seq = GaudiSequencer("PrepareDIGI") ApplicationMgr().TopAlg += [seq] # In Minimal case, filter the MCVertices before writing if self.getProp("DigiType").capitalize() == "Minimal": seq.Members = ["FilterMCPrimaryVtx"] # In packed case, run the packing algorithms if self.getProp("EnablePack"): DigiConf().PackSequencer = seq writerName = "DigiWriter" digiWriter = OutputStream(writerName, Preload=False) digiWriter.RequireAlgs.append("Filter") if self.getProp("NoWarnings" ) and not digiWriter.isPropertySet("OutputLevel"): digiWriter.OutputLevel = INFO # Set up the Digi content DigiConf().Writer = writerName DigiConf().OutputName = self.outputName() self.setOtherProps(DigiConf(), [ "DigiType", "TAEPrev", "TAENext", "UseSpillover", "DataType", ]) if self.getProp("UseSpillover"): self.setOtherProps(DigiConf(), ["SpilloverPaths"]) if "MDF" in outputs: # Make sure that file will have no knowledge of other nodes from Configurables import EventNodeKiller nodeKiller = EventNodeKiller("MDFKiller") nodeKiller.Nodes = [ "Rec", "Trig", "MC", "Raw", "Gen", "Link", "pSim" ] taePrev = self.getProp("TAEPrev") while taePrev > 0: nodeKiller.Nodes += ["Prev%" % taePrev] taePrev -= 1 taeNext = self.getProp("TAENext") while taeNext > 0: nodeKiller.Nodes += ["Next%s" % taeNext] taeNext -= 1 MyWriter = OutputStream("RawWriter", Preload=False, ItemList=["/Event/DAQ/RawEvent#1"]) if not MyWriter.isPropertySet("Output"): MyWriter.Output = "DATAFILE='PFN:" + self.outputName( ) + ".mdf' SVC='LHCb::RawDataCnvSvc' OPT='REC'" MyWriter.RequireAlgs.append("Filter") if self.getProp("NoWarnings" ) and not MyWriter.isPropertySet("OutputLevel"): MyWriter.OutputLevel = INFO ApplicationMgr().OutStream += [nodeKiller, MyWriter]
'/Event/Rich', '/Event/Other/RawEvent' ] extraLoad = [ '/Event/Link/MC/Rich/Hits2MCRichOpticalPhotons', '/Event/Link/MC/Particles2MCRichTracks' ] from Configurables import (TESCheck, EventNodeKiller) initBoole = GaudiSequencer("InitBooleSeq") xdigiLoader = TESCheck("XDIGILoader") xdigiLoader.Inputs = xdigiPaths + extraLoad xdigiLoader.Stop = False # If not MC do not expect all of the entries xdigiLoader.OutputLevel = ERROR xdigiKiller = EventNodeKiller("XDIGIKiller") xdigiKiller.Nodes = xdigiPaths xdigiHandler = GaudiSequencer("XDIGILoverHandler") xdigiHandler.Members += [xdigiLoader, xdigiKiller] xdigiHandler.IgnoreFilterPassed = True # keep going initBoole.Members += [xdigiHandler] from GaudiConf import IOHelper def patch(): OutputStream("DigiWriter").ItemList += ["/Event/Link/MC#1"] appendPostConfigAction(patch)
stripTESPrefix = 'Strip' from Configurables import ProcStatusCheck sc = StrippingConf(Streams=[MyStream], MaxCandidates=20000, AcceptBadEvents=False, BadEventSelection=ProcStatusCheck(), TESPrefix=stripTESPrefix, Verbose=True, DSTStreams=dstStreams) # So that we do not get all events written out MyStream.sequence().IgnoreFilterPassed = False #This deletes stripping objects from previous stripping versions in the DST file from Configurables import EventNodeKiller eventNodeKiller = EventNodeKiller('Stripkiller') eventNodeKiller.Nodes = ['/Event/AllStreams', '/Event/Strip'] DaVinci().appendToMainSequence([eventNodeKiller, sc.sequence()]) ############################################################################################## ##### HLT1 Emulation ############################################################################################## relinfoutput = MyStream.outputLocations()[0].replace("Particles", "HLT1Emulation") def getVars(i, j): combination = str(i) + "_" + str(j) Vars = {
def configureReco(self, init): """ Configure Reconstruction to be redone """ ## CaloReco & CaloPIDs on-demand clusters = ['Digits', 'Clusters'] from Configurables import CaloProcessor caloProc = CaloProcessor(EnableOnDemand=True, OutputLevel=self.getProp("OutputLevel")) caloProc.RecList = clusters # --- if self.getProp('DataType') == 'Upgrade': caloProc.NoSpdPrs = True ## General unpacking from Configurables import DstConf if self.isPropertySet('EnableUnpack'): DstConf().setProp('EnableUnpack', self.getProp('EnableUnpack')) ## unpack Calo Hypos ? from Configurables import CaloDstUnPackConf unpack = CaloDstUnPackConf() hypos = ['Photons', 'MergedPi0s', 'SplitPhotons', 'Electrons'] # CaloHypos if self.isPropertySet( 'EnableUnpack') and "Reconstruction" in self.getProp( 'EnableUnpack'): unpack.setProp('Enable', True) else: caloProc.RecList += hypos # enable caloHypos onDemand # Reprocess explicitely the full calo sequence in the init sequence ? inputtype = self.getProp('InputType').upper() if (self.getProp("CaloReProcessing") and inputtype != 'MDST'): caloProc.RecList = clusters + hypos caloSeq = caloProc.sequence( ) # apply the CaloProcessor configuration cSeq = GaudiSequencer('CaloReProcessing') cSeq.Members += [caloSeq] init.Members += [cSeq] unpack.setProp('Enable', False) # update CaloHypo->MC Linker if self.getProp('Simulation'): log.info( "CaloReprocessing : obsolete CaloHypo2MC Links is updated") from Configurables import (TESCheck, EventNodeKiller, CaloHypoMCTruth) caloMCLinks = ["Link/Rec/Calo"] caloMCSeq = GaudiSequencer("cleanCaloMCLinks") checkCaloMCLinks = TESCheck("checkCaloMCLinks") checkCaloMCLinks.Inputs = caloMCLinks checkCaloMCLinks.Stop = False killCaloMCLinks = EventNodeKiller("killCaloMCLinks") killCaloMCLinks.Nodes = caloMCLinks caloMCSeq.Members = [checkCaloMCLinks, killCaloMCLinks] init.Members += [caloMCSeq] update = self.getProp("UpdateCaloMCLinks") if update: redoCaloMCLinks = CaloHypoMCTruth("recreteCaloMCLinks") init.Members += [redoCaloMCLinks] else: caloProc.applyConf() if inputtype != 'MDST': log.info( "CaloReProcessing cannot be processed on reduced (m)DST data" ) # For backwards compatibility with MC09, we need the following to rerun # the Muon Reco on old data. To be removed AS SOON as this backwards compatibility # is no longer needed if (self.getProp("DataType") == 'MC09' and inputtype != 'MDST' and self.getProp("AllowPIDRerunning") and inputtype != 'RDST'): from Configurables import DataObjectVersionFilter, MuonRec, TESCheck from MuonID import ConfiguredMuonIDs rerunPIDSeq = GaudiSequencer("ReRunMuonPID") init.Members += [rerunPIDSeq] # Check data version, to see if this is needed or not rerunPIDSeq.Members += [ DataObjectVersionFilter( "MuonPIDVersionCheck", DataObjectLocation="/Event/Rec/Muon/MuonPID", MaxVersion=0) ] # Check raw event is available rerunPIDSeq.Members += [ TESCheck("TESCheckRawEvent", Inputs=["DAQ/RawEvent"], Stop=False) ] # Run Muon PID cm = ConfiguredMuonIDs.ConfiguredMuonIDs( data=self.getProp("DataType")) rerunPIDSeq.Members += [MuonRec(), cm.getMuonIDSeq()] # If muon PID has rerun, need to re make the Combined DLLS... from Configurables import (ChargedProtoParticleAddMuonInfo, ChargedProtoCombineDLLsAlg) rerunPIDSeq.Members += [ ChargedProtoParticleAddMuonInfo("CProtoPAddNewMuon"), ChargedProtoCombineDLLsAlg("CProtoPCombDLLNewMuon") ] # Compatibility with pre-2011 data, where Rec/Summary and Trigger/RawEvent are missing import PhysConf.CheckMissingTESData as DataCheck DataCheck.checkForMissingData()
from Configurables import EventNodeKiller, ApplicationMgr appConf = ApplicationMgr() appConf.ExtSvc += ['DataOnDemandSvc'] enk = EventNodeKiller('KillTrigRawEvent') enk.Nodes = [ "Hlt", "Hlt1", "Hlt2", "Trig", "Raw", "Trigger/RawEvent", "Trigger" ] appConf.TopAlg.insert(0, enk.getFullName()) from Configurables import L0App L0App().TCK = '0x0044' L0App().ReplaceL0Banks = True L0App().EvtMax = -1 L0App().DataType = '2012' L0App().DDDBtag = 'dddb-20130929-1' ## latest strip20 tags as of Jan2013 L0App().CondDBtag = 'sim-20131023-vc-md100' L0App().Simulation = True L0App().outputFile = '/tmp/ikomarov/With_new_L0.dst' from Configurables import EventSelector EventSelector().PrintFreq = 3 from Configurables import MessageSvc MessageSvc().OutputLevel = 3 from GaudiConf import IOHelper IOHelper().inputFiles(["/tmp/ikomarov/Rewrited.dst"]) from Configurables import RootCnvSvc RootCnvSvc().OutputLevel = 3
'/Event/pRec/Vertex/V0', '/Event/pRec/Vertex' ] extraLoad = [ '/Event/Link/MC/Rich/Hits2MCRichOpticalPhotons', '/Event/Link/MC/Particles2MCRichTracks' ] from Configurables import (TESCheck, EventNodeKiller) initBoole = GaudiSequencer("InitBooleSeq") xdstLoader = TESCheck("XDSTLoader") xdstLoader.Inputs = xdstPaths + extraLoad xdstLoader.Stop = False # If not MC do not expect all of the entries xdstLoader.OutputLevel = ERROR xdstKiller = EventNodeKiller("XDSTKiller") xdstKiller.Nodes = xdstPaths xdstHandler = GaudiSequencer("XDSTLoverHandler") xdstHandler.Members += [xdstLoader, xdstKiller] xdstHandler.IgnoreFilterPassed = True # keep going initBoole.Members += [xdstHandler] from GaudiConf import IOHelper def patch(): OutputStream("DigiWriter").ItemList += ["/Event/Link/MC#1"] appendPostConfigAction(patch)
def __apply_configuration__(self): #make sure the dictionaries are there... Hack! %TODO -> Remove this! RawEventFormatConf().loadIfRequired() #then get them ... locs, rec = _getDict() added_locations = [] if not self.isPropertySet("Output") or not self.isPropertySet("Input"): raise AttributeError( "You must set both the input and the output version, this can be a version number (float, int) or a name, see: " + rec.__str__()) #swap logical for numeric, and check it exists ov = _checkv(self.getProp("Output"), locs, rec) iv = _checkv(self.getProp("Input"), locs, rec) output_locations = ReverseDict(ov, locs, rec) input_locations = ReverseDict(iv, locs, rec) #check if a Trigger TCK is needed if len([ loc for loc in input_locations if self.getProp("TCKReplacePattern") in loc ]) or len([ loc for loc in output_locations if self.getProp("TCKReplacePattern") in loc ]): if (not self.isPropertySet("TCK")) and ( not RawEventFormatConf().isPropertySet("TCK")): raise AttributeError( "The raw event version you specified requires a TCK to be given. Set RawEventJuggler().TCK" ) for prop in ["TCK", "GenericReplacePatterns", "TCKReplacePattern"]: self.__safeset__(RawEventFormatConf(), prop) killBefore = [] loc_to_alg_dict = {} killAfter = [] ###################################### # Stage 1: KillBefore if requested ###################################### if self.isPropertySet("KillInputBanksBefore"): from Configurables import bankKiller #if KillBanks or KillNodes... has been requested, I can't use DoD, it's unsafe. I don't know what's "before" and "after" if self.getProp("DataOnDemand"): raise AttributeError( "You have asked for some killing of banks, and asked for DoD, which is not a safe way to run. Either cope with the extra banks, or use a sequencer instead of DoD" ) import re for loc in input_locations: #see if this location has banks to kill killBanks = [ abank for abank in input_locations[loc] if re.match(self.getProp("KillInputBanksBefore"), abank) ] if not len(killBanks): continue loc = _replaceWrap(loc) bk = bankKiller( ("kill_" + loc.replace("/", "_") + "_Before").replace( "__", "_")) killBefore.append(bk) bk.RawEventLocations = [loc] bk.BankTypes = killBanks ################################## # The part which does the juggling ################################## if iv != ov: ###################################### # Stage 2: Check options ###################################### #if a bank is needed to be added to an existing location, I can't do that. for loc in input_locations: if loc in output_locations: for abank in output_locations[loc]: if abank not in input_locations[loc]: print "# WARNING, don't know how to add new bank " + abank + " to existing location " + loc + " ...skipping..." output_locations[loc].remove(abank) #if banks need to be juggled, tell me how to do it, sequencer or DoD if not (self.getProp("DataOnDemand") or self.isPropertySet("Sequencer")): raise AttributeError( "You have asked for some juggling, but not told me where to put the algorithms. Set either DataOnDemand or pass a Sequencer" ) #if banks need to be juggled, tell me how to do it, sequencer or DoD if self.getProp("DataOnDemand") and self.isPropertySet( "Sequencer"): raise AttributeError( "You asked for DoD and also gave a sequencer, I can't do both at the same time" ) #if KillBanks or KillNodes... has been requested, I can't use DoD, it's unsafe. I don't know what's "before" and "after" if self.getProp("DataOnDemand") and ( self.getProp("KillExtraNodes") or self.isPropertySet("KillInputBanksBefore") or self.isPropertySet("KillInputBanksAfter") or self.getProp("KillExtraBanks")): raise AttributeError( "You have asked for some killing of banks, and asked for DoD, which is not a safe way to run. Either cope with the extra banks, or use a sequencer instead of DoD" ) if self.getProp("KillExtraDirectories" ) and not self.getProp("KillExtraNodes"): raise AttributeError( "In order to kill extra directories, you must also be killing the extra nodes (raw events)" ) #raise import error if you don't have the correct requirements from Configurables import RawEventMapCombiner, EventNodeKiller, bankKiller ############################################### # Stage 3: Recombine banks from given locations ############################################### #for each new location, add a RawEventMapCombiner to the DoD or to the sequencer loc_to_alg_dict = {} for loc in output_locations: if loc not in input_locations: #if none of the banks are available, skip if len([ abank for abank in output_locations[loc] if abank in locs[iv] ]) == 0: print "#WARNING, nowhere to copy any banks for " + loc + " from, skipping" continue wloc = _replaceWrap(loc) loc_to_alg_dict[wloc] = RawEventMapCombiner( ("create_" + wloc.replace("/", "_")).replace( "__", "_").rstrip("_")) loc_to_alg_dict[wloc].OutputRawEventLocation = wloc loc_to_alg_dict[wloc].RawBanksToCopy = {} added_locations.append(wloc) for abank in output_locations[loc]: if abank not in locs[iv]: print "#WARNING, nowhere to copy " + abank + " from, skipping" continue loc_to_alg_dict[wloc].RawBanksToCopy[ abank] = WhereBest(abank, iv, locs, rec) ############################################### # Stage 4: Clean up, kill after if requested ############################################### killAfter = [] if self.isPropertySet("KillInputBanksAfter") or self.getProp( "KillExtraBanks"): import re for loc in input_locations: #see if this location has banks to kill killBanks = [] if self.isPropertySet("KillInputBanksAfter"): killBanks += [ abank for abank in input_locations[loc] if re.match( self.getProp("KillInputBanksAfter"), abank) ] if self.getProp("KillExtraBanks"): killBanks += [ abank for abank in input_locations[loc] if (loc in output_locations and abank not in output_locations[loc]) ] if not len(killBanks): continue loc = _replaceWrap(loc) bk = bankKiller( ("kill_" + loc.replace("/", "_") + "_After").replace( "__", "_")) killAfter.append(bk) bk.RawEventLocations = [loc] bk.BankTypes = killBanks #for each missing location, kill that location? if self.getProp("KillExtraNodes"): if len([ loc for loc in input_locations if loc not in output_locations ]) > 0: enk = EventNodeKiller("KillRawEventNodes") enk.Nodes = [] killAfter.append(enk) for loc in input_locations: if loc not in output_locations: enk.Nodes.append(_replaceWrap(loc)) if self.getProp("KillExtraDirectories"): dloc = loc.replace("/RawEvent", "") flags = [ o.startswith(dloc) for o in output_locations ] if (True not in flags) and (dloc not in enk.Nodes): enk.Nodes.append(_replaceWrap(dloc)) elif self.isPropertySet("KillInputBanksAfter") or self.getProp( "KillExtraNodes") or self.isPropertySet("KillExtraBanks"): raise AttributeError( "You've asked to kill something from the input *after* copying, but you aren't actually doing any copying. Please kill them yourself without this configurable, or use KillInputBanksBefore!" ) ############################################### # Stage 5: Add to sequence or DoD ############################################### if self.getProp("DataOnDemand"): if len(loc_to_alg_dict): from Configurables import DataOnDemandSvc ApplicationMgr().ExtSvc = ["DataOnDemandSvc"] + [ svc for svc in ApplicationMgr().ExtSvc if svc is not "DataOnDemandSvc" ] for loc in loc_to_alg_dict: DataOnDemandSvc().AlgMap[loc] = loc_to_alg_dict[loc] else: for alg in killBefore: self.getProp("Sequencer").Members.append(alg) for loc in loc_to_alg_dict: self.getProp("Sequencer").Members.append(loc_to_alg_dict[loc]) for alg in killAfter: self.getProp("Sequencer").Members.append(alg) ############################################### # Stage 6: now handle the writers if appended ############################################### if self.isPropertySet("WriterOptItemList"): self.getProp("WriterOptItemList").OptItemList += self.__opWrap__( output_locations.keys()) if self.isPropertySet("WriterItemList"): self.getProp("WriterItemList").ItemList += self.__opWrap__( output_locations.keys())
def configureInit(self, tae, initDets): """ Set up the initialization sequence """ # Start the DataOnDemandSvc ahead of ToolSvc ApplicationMgr().ExtSvc += ["DataOnDemandSvc"] ApplicationMgr().ExtSvc += ["ToolSvc"] ProcessPhase("Init").DetectorList.insert( 0, "Boole") # Always run Boole initialisation first! initBoole = GaudiSequencer("InitBooleSeq") initBoole.Members += ["BooleInit"] # Kept for Dirac backward compatibility if self.getProp("NoWarnings"): log.warning( "Boole().NoWarnings=True property is obsolete and maintained for Dirac compatibility. Please use Boole().ProductionMode=True instead" ) self.setProp("ProductionMode", True) # Special settings for production if self.getProp("ProductionMode"): self.setProp("OutputLevel", ERROR) if not LHCbApp().isPropertySet("TimeStamp"): LHCbApp().setProp("TimeStamp", True) # OutputLevel self.setOtherProp(LHCbApp(), "OutputLevel") if self.isPropertySet("OutputLevel"): level = self.getProp("OutputLevel") if level == ERROR or level == WARNING: # Suppress known warnings importOptions("$BOOLEOPTS/SuppressWarnings.opts") # Additional information to be kept getConfigurable("BooleInit").OutputLevel = INFO # Do not print event number at every event (done already by BooleInit) EventSelector().PrintFreq = -1 # Load the spillover branches, then kill those not required to prevent further access spillPaths = self.getProp("SpilloverPaths") killPaths = [] if len(spillPaths) == 0: spillPaths = self.KnownSpillPaths self.setProp("SpilloverPaths", spillPaths) if self.getProp("UseSpillover"): if tae: killPaths = self.KnownSpillPaths else: self.setOtherProp(SimConf(), "SpilloverPaths") # Kill any spillover paths not required for spill in self.KnownSpillPaths: if spill not in spillPaths: killPaths.append(spill) else: # Kill all spillover paths killPaths = self.KnownSpillPaths from Configurables import EventNodeKiller, TESCheck spillLoader = TESCheck("SpilloverLoader") spillLoader.Inputs = spillPaths spillLoader.Stop = False # In case no spillover on input file spillLoader.OutputLevel = ERROR spillKiller = EventNodeKiller("SpilloverKiller") spillKiller.Nodes = killPaths spillHandler = GaudiSequencer("SpilloverHandler") spillHandler.Members += [spillLoader, spillKiller] spillHandler.IgnoreFilterPassed = True # In case no spillover on input file initBoole.Members += [spillHandler] if "Muon" in initDets: # Muon Background from Configurables import MuonBackground GaudiSequencer("InitMuonSeq").Members += [ MuonBackground("MuonLowEnergy") ] importOptions("$MUONBACKGROUNDROOT/options/MuonLowEnergy-G4.opts") if not tae: flatSpillover = MuonBackground("MuonFlatSpillover") GaudiSequencer("InitMuonSeq").Members += [flatSpillover] if self.getProp("DataType") == "2010": flatSpillover.NBXFullFull = 344 if self.getProp("DataType") == "2009": flatSpillover.NBXFullFull = 4 importOptions( "$MUONBACKGROUNDROOT/options/MuonFlatSpillover-G4.opts")
sc = StrippingConf(Streams=[stream], MaxCandidates=2000, AcceptBadEvents=False, BadEventSelection=filterBadEvents) #Define the node killer, and make sure to kill everything corresponding to #the stream which we want to swim outputs = [] for l in lines: for f in l.filterMembers(): if not hasattr(f, 'Output'): continue # Remove the last item so we get everything (Particle, relations, # decayVertices, etc... o = '/'.join(f.Output.split('/')[:-1]) outputs.append(o) mykiller = EventNodeKiller("killStripping") #Some default nodes which we will want to kill in all cases nodestokill = outputs + ['Strip', '/Event/Rec/Vertex/Primary'] mykiller.Nodes = nodestokill deathstar = GaudiSequencer("killStrippingSeq") deathstar.Members = [mykiller] # Configure DaVinci DaVinci().InputType = 'DST' DaVinci().DataType = options.datatype DaVinci().Simulation = options.forMC DaVinci().DDDBtag = options.dddb DaVinci().CondDBtag = options.conddb # The sequence for the swimming has to be configured # by hand inserting the node killer before it DaVinci().appendToMainSequence([deathstar]) DaVinci().appendToMainSequence([sc.sequence()])
Moore().CondDBtag = 'cond-20120831' #from RunDB Moore().EnableTimer = "timerdefault.csv" ########### L0-related things ####################### from Configurables import L0Conf L0Conf().EnsureKnownTCK = False Moore().ForceSingleL0Configuration = False ############# prepend a "killHltSeq" ############ #copied from Swimming/Configuration.py line 214 from Configurables import Swimming, GaudiSequencer, EventNodeKiller nodes = Swimming.__slots__["HltNodesToKill"] mykiller = EventNodeKiller("killHlt") mykiller.Nodes = nodes deathstar = GaudiSequencer("killHltSeq") deathstar.Members = [mykiller] class Deathstar(object): def __init__(self, seq): self._seq = seq def witnessTheFirepowerOfThisFullyArmedAndOperationalBattleStation(self): ApplicationMgr().TopAlg.insert(0, self._seq) d = Deathstar(deathstar) appendPostConfigAction(
from Configurables import ChargedProtoParticleMaker, CombinedParticleMaker, NoPIDsParticleMaker, BestPIDParticleMaker, DataOnDemandSvc, UnpackTrack, DelegatingTrackSelector, TrackSelector, GaudiSequencer, TrackToDST, ChargedPP2MC, TrackAssociator, EventNodeKiller, DaVinci, TrackSmeared from Configurables import ChargedProtoParticleAddMuonInfo, MuonIDAlg, ChargedProtoParticleAddRichInfo from MuonID import ConfiguredMuonIDs from Configurables import ProtoParticleMUONFilter, ChargedProtoCombineDLLsAlg, ProtoParticleCALOFilter # kill all links initseq = GaudiSequencer("AnalysisInitSeq") evtnodekiller = EventNodeKiller("KillLinks") evtnodekiller.Nodes = ["Link/Rec"] initseq.Members += [evtnodekiller] #TrackSmeared().OutputLevel = 0 #ChargedProtoParticleMaker().OutputLevel = 0 #NoPIDsParticleMaker().OutputLevel = 0 #MyOptions = [ "MC" ] print "OPTIONS OF MAKEMYPARTICLES" #print MyOptions def makeMyProtoP(trackcont): unpacker = UnpackTrack(trackcont + "UnpackTrack") unpacker.InputName = "pRec/Track/" + trackcont unpacker.OutputName = "Rec/Track/" + trackcont refitter = TrackSmeared(trackcont + "TrackSmeared") refitter.InputLocation = "Rec/Track/" + trackcont refitter.OutputLocation = "Refit" refitter.smear = 1 #refitter.makePlots = 1 #refitter.OutputLevel = 2 #idalg = MuonIDAlg("BestIDalg") #idalg.OutputLevel = 0
HistoPrint = True, ## N-tuple LUN NTupleLUN = "DTT", ## input particles from selection: Inputs = [ '/Event/SwimStrippingD2hhMDST_v14r8/CharmToBeSwum/Phys/D2hhPromptD2KPiLine/Particles' ], ## Primary vertices from mDST P2PVInputLocations = [ '/Event/SwimStrippingD2hhMDST_v14r8/CharmToBeSwum/Phys/D2hhPromptD2KPiLine/Particle2VertexRelations'], UseP2PVRelations = True, WriteP2PVRelations = False, Decay = "[[D0]cc -> ^K- ^pi+]cc" ) from DecayTreeTuple.Configuration import * ## Add appropriate tools from Configurables import EventNodeKiller killer=EventNodeKiller( Nodes = ["/Event/DAQ","/Event/pRec"] ) dtt.addBranches({ "D" : "[D0]cc : [[D0]cc -> K- pi+]cc" }) dtt.D.addTupleTool('TupleToolPropertime') ttsi = dtt.D.addTupleTool('TupleToolSwimmingInfo/TriggerInfo') ttsis = dtt.D.addTupleTool('TupleToolSwimmingInfo/StrippingInfo') ttsi.ReportsLocation = '/Event/SwimStrippingD2hhMDST_v14r8/CharmToBeSwum/Phys/D2hhPromptD2KPiLine/P2TPRelations' ttsis.ReportsLocation = '/Event/SwimStrippingD2hhMDST_v14r8/CharmToBeSwum/Phys/D2hhPromptD2KPiLine/P2TPRelations' ttsis.ReportStage = "Stripping" tttt = dtt.D.addTupleTool('TupleToolTISTOS') tttt.TriggerList = ['Hlt1TrackAllL0Decision', 'Hlt2CharmHadD02HH_D02KPiDecision'] tttt.VerboseHlt1 = True
def ConfigureMoore(): config = Swimming() from Swimming.HltTransforms import getTransform thisTransform = getTransform( config.getProp('TransformName'), config.getProp('Hlt1Triggers') + config.getProp('Hlt2Triggers')) from Configurables import (HltConfigSvc, EventNodeKiller, HltMoveVerticesForSwimming, Moore) #Global configuration mykiller = EventNodeKiller("killHlt") mykiller.Nodes = config.getProp('HltNodesToKill') deathstar = GaudiSequencer("killHltSeq") deathstar.Members = [mykiller] from Swimming import MooreSetup # dddb = config.getProp('DDDBtag') conddb = config.getProp('CondDBtag') tck = config.getProp('TCK') run = config.getProp('RunNumber') if not dddb and not conddb and not tck and run: import shelve tag_db = os.path.expandvars(config.getProp('TagDatabase')) if not os.path.exists(tag_db): raise OSError, "Tag database file %s does not exist" % config.getProp( 'TagDatabase') tag_db = shelve.open(tag_db, 'r') info = tag_db['info'] tags = info[run] Moore().DDDBtag = tags['DDDBtag'] Moore().CondDBtag = tags['CondDBtag'] Moore().InitialTCK = tags['TCK'] Swimming().TCK = tags['TCK'] elif dddb and conddb and tck and not run: Moore().DDDBtag = dddb Moore().CondDBtag = conddb Moore().InitialTCK = tck else: raise TypeError, 'You must specify either the CondDB tag, DDDB tag and TCK and _not_ the run number' + \ ' or only the run number.' Moore().Simulation = config.getProp('Simulation') Moore().DataType = config.getProp('DataType') Moore().outputFile = config.getProp('OutputFile') Moore().WriteFSR = config.getProp('WriteFSR') Moore().Persistency = config.getProp('Persistency') Moore().WriterRequires = [] # Add extra locations to writer from Configurables import InputCopyStream writer = InputCopyStream('Writer') writer.ItemList = [config.getProp('SwimmingPrefix') + '/Reports#1'] writer.OptItemList = list( set([ l + '/P2TPRelations#1' for l in config.getProp('OffCands').values() ])) # # Define the TCK transformation # HltConfigSvc().ApplyTransformation = thisTransform from pprint import pprint pprint(HltConfigSvc().ApplyTransformation) # # Define the swimming algorithm # myswimmer = HltMoveVerticesForSwimming("HltMovePVs4Swimming") myswimmer.SwimmingDistance = 0.0 loc = config.getProp( 'SwimmingPrefix') # TODO check differences with trunk more carefully myswimmer.Bcontainer = loc myswimmer.InputSelection = config.getProp('OnlinePV') myswimmer.OutputSelection = config.getProp('OutPVSel') myswimmer.OutputLevel = 4 # Configure an extra TisTos Tool and some decoder algos to debug TisTos issues prefix = config.getProp('SwimmingPrefix') from Configurables import HltDecReportsDecoder, HltSelReportsDecoder decoders = [(HltDecReportsDecoder, [('OutputHltDecReportsLocation', 'Hlt/DecReports')]), (HltSelReportsDecoder, [('OutputHltSelReportsLocation', 'Hlt/SelReports'), ('HltDecReportsLocation', 'Hlt/DecReports')])] from Configurables import TriggerTisTos ToolSvc().addTool(TriggerTisTos, 'SwimmingDebugTisTos') ToolSvc().SwimmingDebugTisTos.TOSFracMuon = 0.0 ToolSvc().SwimmingDebugTisTos.TOSFracTT = 0.0 for conf, d in decoders: configurable = conf('Swimming' + d[0][1].split('/')[-1]) print configurable try: configurable.InputRawEventLocation = 'PrevTrig/RawEvent' except: configurable.RawEventLocations = [ 'PrevTrig/RawEvent' ] + configurable.RawEventLocations output = None for prop, loc in d: if not output: output = prefix + '/' + loc setattr(configurable, prop, prefix + '/' + loc) DataOnDemandSvc().AlgMap[output] = configurable prop = d[0][0][6:] print prop, output setattr(ToolSvc().SwimmingDebugTisTos, prop, output) class Deathstar(object): def __init__(self, seq): self._seq = seq def insert(self): ApplicationMgr().TopAlg.insert(0, self._seq) d = Deathstar(deathstar) appendPostConfigAction(d.insert)
# # an options file to read data and create an ntuple. # ######################################################################## from Gaudi.Configuration import * from Configurables import DecayTreeTuple, TupleToolTrigger, TupleToolDecay, SubstitutePID from Configurables import LoKi__Hybrid__TupleTool, TupleToolDecayTreeFitter, TupleToolTISTOS from Configurables import LoKi__Hybrid__EvtTupleTool, TupleToolEventInfo, TupleToolTrackIsolation from Configurables import TupleToolMCTruth, TupleToolTrackInfo, TupleToolRICHPid, TupleToolMuonPid, TupleToolPid, TupleToolGeometry from Configurables import DaVinci from Configurables import PrintDecayTree from DecayTreeTuple.Configuration import * from Configurables import EventNodeKiller NodeKiller = EventNodeKiller('NodeKiller') NodeKiller.Nodes = ['DAQ', 'pRec'] #teslocation = "/Event/AllStreams/" #change to this for MC teslocation = "/Event/Bhadron/" #change to this for Data # #Momentum scale correction # from Configurables import TrackScaleState scaler = TrackScaleState('Scaler', RootInTES=teslocation) # ScaleSlope = 1 - 1.0e-3 , # DeltaSlope = 0.9e-3 ,
def ConfigureDaVinci(): config = Swimming() from Configurables import DaVinci from StrippingConf.Configuration import StrippingConf from Configurables import ProcStatusCheck from Configurables import EventNodeKiller, GaudiSequencer from PhysSelPython.Wrappers import (AutomaticData, SelectionSequence, MultiSelectionSequence) # Get the stripping line from StrippingSettings.Utils import lineBuilderConfiguration strippingFile = None if config.getProp('StrippingFile') != 'none': strippingFile = config.getProp('StrippingFile') else: strippingFile = config.getProp('StrippingLineGroup') myconfig = lineBuilderConfiguration(config.getProp('StrippingVersion'), config.getProp('StrippingLineGroup')) import StrippingArchive mylineconf = getattr( __import__( 'StrippingArchive.' + config.getProp('StrippingVersion') + '.Stripping' + strippingFile, globals(), locals(), [myconfig["BUILDERTYPE"]], -1), myconfig["BUILDERTYPE"]) mylinedict = myconfig["CONFIG"] substitutions = config.getProp('StrippingConfigSubstitutions') print "mylinedict before substitutions:", mylinedict print "stripping config substitutions:", substitutions mylinedict.update(substitutions) print "mylineconf:", mylineconf print "mylinedict after substitutions:", mylinedict from StrippingConf.StrippingStream import StrippingStream stream = StrippingStream(config.getProp('StrippingStream') + "Swimming") allLines = mylineconf(config.getProp('StrippingLineGroup'), mylinedict).lines() lines = [] #lineNames = [l.split('/')[-1] for l in config.getProp('StripCands').keys()] lineNames = config.getProp('StrippingLines') print "lineNames:", lineNames for l in allLines: for lineName in lineNames: if l.outputLocation().find(lineName) != -1: lines.append(l) print l.outputLocation() stream.appendLines(lines) # Define the stream filterBadEvents = ProcStatusCheck() sc = StrippingConf(Streams=[stream], MaxCandidates=2000, AcceptBadEvents=False, BadEventSelection=filterBadEvents) # Define the node killer, and make sure to kill everything corresponding to # the stream which we want to swim outputs = [] from Configurables import Swimming__PVReFitter as ReFitter for l in lines: for f in l.filterMembers(): if hasattr(f, 'ReFitPVs') and f.ReFitPVs: if not config.getProp('RefitPVs'): log.warning('RefitPVs is not set, but stripping line applies refitting. Refitted ' + \ 'PVs will be used for turning-point lifetime calculations.') config.setProp('RefitPVs', True) t = f.PVReFitters[''] f.PVReFitters = {'': 'Swimming::PVReFitter/PVReFitter'} f.addTool(ReFitter, 'PVReFitter') f.PVReFitter.PVReFitter = t elif not hasattr(f, 'Output'): continue # Remove the last item so we get everything (Particle, relations, # decayVertices, etc... o = '/'.join(f.Output.split('/')[:-1]) outputs.append(o) print "Outputs are", outputs mykiller = EventNodeKiller("killStripping") # Some default nodes which we will want to kill in all cases nodestokill = outputs + ['Strip', '/Event/Rec/Vertex/Primary'] mykiller.Nodes = nodestokill deathstar = GaudiSequencer("killStrippingSeq") deathstar.Members = [mykiller] # Configure DaVinci DaVinci().InputType = config.getProp('InputType') DaVinci().DataType = config.getProp('DataType') DaVinci().Simulation = config.getProp('Simulation') DaVinci().DDDBtag = config.getProp('DDDBtag') DaVinci().CondDBtag = config.getProp('CondDBtag') try: DaVinci().Persistency = config.getProp('Persistency') except AttributeError: print "DaVinci doesn't have a Persistency attribute to set" # The sequence for the swimming has to be configured # by hand inserting the node killer before it DaVinci().appendToMainSequence([deathstar]) DaVinci().appendToMainSequence([sc.sequence()]) # Since the name of the output file is configured in two places in DaVinci, # do some splitting. splitName = config.getProp('OutputFile').split(os.path.extsep) seqName = '' prefix = '' if len(splitName) <= 2: seqName = splitName[0] print "Warning, an output filename in three parts was specified. This does not work well, " + \ " so 'Swimming.' will be prefixed." prefix = 'Swimming' else: prefix = splitName[0] seqName = os.path.extsep.join(splitName[1:-1]) dstWriter = None print config.getProp('OutputType') # Offline candidate selection sequences sequences = [] offCands = config.getProp('OffCands').keys() for i, cands in enumerate(offCands): data = AutomaticData(Location=cands + "/Particles") offSeq = SelectionSequence("OfflineCandidates_%d" % i, TopSelection=data) sequences.append(offSeq) # selection sequence for offline candidates muCands = config.getProp('MuDSTCands') for i, cands in enumerate(muCands): # Add extra selections for additional MuDSTCands data = AutomaticData(Location=cands + "/Particles") seq = SelectionSequence("MuDSTCands_%d" % i, TopSelection=data) sequences.append(seq) selectionSeq = MultiSelectionSequence(seqName, Sequences=sequences) if config.getProp('OutputType') == 'MDST': pack = False isMC = config.getProp("Simulation") SwimmingConf = config.getProp('MicroDSTStreamConf') SwimmingElements = config.getProp('MicroDSTElements') if SwimmingConf == False: from DSTWriters.Configuration import stripMicroDSTStreamConf SwimmingConf = stripMicroDSTStreamConf(pack=pack, isMC=isMC) if len(SwimmingElements) == 0: from DSTWriters.Configuration import stripMicroDSTElements from DSTWriters.microdstelements import CloneSwimmingReports, CloneParticleTrees, CloneTPRelations mdstElements = stripMicroDSTElements(pack=pack, isMC=isMC) SwimmingElements = [CloneSwimmingReports()] for element in mdstElements: SwimmingElements += [element] if type(element) == CloneParticleTrees: SwimmingElements += [CloneTPRelations("P2TPRelations")] streamConf = {'default': SwimmingConf} elementsConf = {'default': SwimmingElements} try: from DSTWriters.__dev__.Configuration import MicroDSTWriter except: from DSTWriters.Configuration import MicroDSTWriter dstWriter = MicroDSTWriter('MicroDST', StreamConf=streamConf, MicroDSTElements=elementsConf, WriteFSR=config.getProp('WriteFSR'), OutputFileSuffix=prefix, SelectionSequences=[selectionSeq]) elif config.getProp('OutputType') == 'DST': try: from DSTWriters.__dev__.streamconf import OutputStreamConf from DSTWriters.__dev__.Configuration import SelDSTWriter except ImportError: from DSTWriters.streamconf import OutputStreamConf from DSTWriters.Configuration import SelDSTWriter streamConf = OutputStreamConf(streamType = InputCopyStream, fileExtension = '.dst', extraItems = [config.getProp('SwimmingPrefix') + '/Reports#1'] +\ list(set([l + '/P2TPRelations#1' for l in config.getProp('OffCands').values()]))) SelDSTWriterElements = {'default': []} SelDSTWriterConf = {'default': streamConf} dstWriter = SelDSTWriter('FullDST', StreamConf=SelDSTWriterConf, MicroDSTElements=SelDSTWriterElements, WriteFSR=config.getProp('WriteFSR'), OutputFileSuffix=prefix, SelectionSequences=[selectionSeq]) DaVinci().appendToMainSequence([dstWriter.sequence()])
This options file demonstrates how to run a stripping line from a specific stripping version on a local MC DST file It is based on the minimal DaVinci DecayTreeTuple example """ from StrippingConf.Configuration import StrippingConf, StrippingStream from StrippingSettings.Utils import strippingConfiguration from StrippingArchive.Utils import buildStreams from StrippingArchive import strippingArchive from Configurables import (EventNodeKiller, 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])