recreate L0Banks for LHCb HLT
Friday, July 11th, 2008To recreate L0 Banks for LHCb HLT to you can use this skript (stole most of it from Hans). It uses bankKiller and EventNodeKiller to clean the old L0Banks and recreates them. At the end it checks for all channel decisions involving muons or hadrons and writes out the events that had any such decision.
# strip rawdata from a dst, and replace L0DU bank with proper bank
# Checks for channeldesicions and writes only mu/had triggers
from Gaudi.Configuration import *
importOptions('$STDOPTS/LHCbApplication.opts') # import old opts file
importOptions('$STDOPTS/DstDicts.opts') # import old opts file
importOptions('$DDDBROOT/options/DC06.opts') # import old opts file
# L0 configuration
importOptions('$L0MUONROOT/options/l0muonAlg.opts') # import old opts file
importOptions('$L0DUROOT/options/L0DUConfig.opts') # import old opts file
#castor cards for mbias L0-stripped events from bookkeeping
#importOptions('/afs/cern.ch/user/d/dijkstra/python/l0-run/mb1-1.opts') # import old opts file
importOptions('$MOOREROOT/options/DC06_L0_v1_lumi2.opts')
# Gaudi.Configuration.Configurables is a ConfFacade - Object
# it is created upon first import of Gaudi.Configuration
# LHCbAlgs.LHCbAlgsConf.EventNodeKiller /software/releases/LHCB/LHCB_v23r7/InstallArea/python/LHCbAlgs
# L0Calo.L0CaloConf.L0CaloAlg /software/releases/LBCOM/LBCOM_v6r18/InstallArea/python/L0Calo
# L0Muon.L0MuonConf.L0MuonAlg /software/releases/LBCOM/LBCOM_v6r18/InstallArea/python/L0Muon
# PuVeto.PuVetoConf.PuVetoAlg /software/releases/LBCOM/LBCOM_v6r18/InstallArea/python/PuVeto
# L0DU.L0DUConf.L0DUAlg /software/releases/LBCOM/LBCOM_v6r18/InstallArea/python/L0DU
# DAQEvent.DAQEventConf.bankKiller /software/releases/LHCB/LHCB_v23r7/InstallArea/python/DAQEvent
from Configurables import EventNodeKiller,L0CaloAlg,L0MuonAlg,PuVetoAlg,L0DUAlg,bankKiller
RemoveL0Banks = bankKiller('RemoveL0Banks')
RemoveL0Banks.BankTypes =["L0DU", "L0Calo", "L0Muon"]
L0 = GaudiSequencer('L0')
#-----------------------------------------------------
# Run the whole L0 sequence including the L0Processors
#-----------------------------------------------------
L0.Members += [ "bankKiller/RemoveL0Banks"
,"L0CaloAlg/L0Calo"
,"L0MuonAlg/L0Muon"
,"PuVetoAlg/L0PuVeto"
,"L0DUAlg/L0DU"
,"EventNodeKiller/EventNodeKiller"
]
L0DU = L0DUAlg('L0DU')
L0DU.StoreInBuffer = True
rawwriter = OutputStream('RawWriter', Preload = False,
ItemList = ["/Event#1","/Event/DAQ#1","/Event/DAQ/RawEvent#1","/Event/DAQ/ODIN#1"],
Output = "DATAFILE='/local_home/snies/DC06_L0_v1_lumi2_MuonHadron.dst' TYP='POOL_ROOTTREE' OPT='REC' ")
appConf = ApplicationMgr( OutputLevel = INFO, AppName = 'L0DUextract')
appConf.OutStream = [rawwriter]
appConf.ExtSvc += ['DataOnDemandSvc']
DataOnDemandSvc().Algorithms += ["DATA='/Event/Trig/L0/L0DUReport' TYPE='GaudiSequencer/L0'"]
#appConf.TopAlg = ['GaudiSequencer/L0']
EventNodeKiller().Nodes = ["Rec", "MC", "Raw", "Gen", "Link", "pSim" , "Prev", "PrevPrev", "Next"]
EventSelector().PrintFreq = 50
import GaudiPython
#from gaudigadgets import *
appMgr = GaudiPython.AppMgr()
sel = appMgr.evtsel() #Event Selector (could be used to specify input files)
evt = appMgr.evtsvc() #Get event service for later use to access the transient event store
appMgr.algorithm('RawWriter').Enable = False # stop automatic execution of RawWriter
nevent=0 # loop variable
l0acc=0 # number of L0 accepted events
appMgr.run(1) #step one event
while nevent < 100000:
nevent = nevent + 1 # increase loop variable
appMgr.run(1) # read one event
if evt['Rec/Header'] == None : break # probably end of input
# check L0
L0dir = evt['Trig/L0/L0DUReport'] # get a container
# get channel decisions
Hadron = L0dir.channelDecisionByName('Hadron')
Muon = L0dir.channelDecisionByName('Muon')
DiMuon = L0dir.channelDecisionByName('DiMuon')
MuonNoGlob = L0dir.channelDecisionByName('MuonNoGlob')
if Hadron or Muon or DiMuon or MuonNoGlob:
l0acc = l0acc + 1 # count as L0 accepted event
rc = appMgr.algorithm('RawWriter').execute() # output the L0 accepted event
# rc probably a return code ? should be checked ?
print 'L0 accepted',l0acc,' in ',nevent,' events.'
print 'Read/Wrote ',nevent,l0acc