def decodingSeq(self, outputLevel=INFO): if not allConfigurables.get("DecodingSeq"): if outputLevel == VERBOSE: print "VERBOSE: Decoding Sequencer not defined! Defining!" decodingSequencer = GaudiSequencer("DecodingSeq") decodingSequencer.MeasureTime = True from DAQSys.Decoders import DecoderDB from DAQSys.DecoderClass import decodersForBank DecodeRawEvent().DataOnDemand = False decs = [] decs += decodersForBank(DecoderDB, "ODIN") decs += decodersForBank(DecoderDB, "Velo") decs += decodersForBank(DecoderDB, "IT") decs += decodersForBank(DecoderDB, "TT") for d in decs: d.Properties["OutputLevel"] = outputLevel decodingSequencer.Members = [d.setup() for d in decs] ## ST Decoding from Configurables import (STOfflinePosition) itClusterPosition = STOfflinePosition("ITClusterPosition", OutputLevel=outputLevel) itClusterPosition.ErrorVec = [0.22, 0.11, 0.24, 0.20] ## Muons (not yet) return decodingSequencer else: if outputLevel == VERBOSE: print "VERBOSE: Decoding Sequencer already defined!" return allConfigurables.get("DecodingSeq")
def _createWriter(self, sequence): ''' create writer sequence ''' debugOPL = self.getProp("OutputLevel") debugging = self.getProp("Debug") writeLumiSequence = _sequenceAppender( Sequence('writeLumiSeq', ModeOR = False, ShortCircuit = True, IgnoreFilterPassed = False, MeasureTime = True, OutputLevel = debugOPL ) ) from DAQSys.Decoders import DecoderDB from DAQSys.DecoderClass import decodersForBank # create ODIN by hand for d in decodersForBank(DecoderDB,"ODIN"): writeLumiSequence( d.setup() ) # verbose output if debugging: writeLumiSequence( RawEventDump( 'InputDump', DumpData = False, OutputLevel = debugOPL ) ) pass # select only the right Trigger Type writeLumiSequence( ODINFilter ( 'OdinTriggerTypes', Code = ' ( ODIN_TRGTYP == LHCb.ODIN.LumiTrigger ) ' )) ## Lumi only triggers # decode summary data for d in decodersForBank(DecoderDB,"HltLumiSummary"): writeLumiSequence( d.setup() ) # add filter to check if this was L0 triggered filterRan = FilterOnLumiSummary('LumiRandomFilter', CounterName = "Random", ValueName = "RandomMethod") #filterLow = FilterOnLumiSummary('LumiLowFilter', CounterName = "Method", ValueName = "L0RateMethod") writeLumiSequence( Sequence('filterLumi', Members = [filterRan], #, filterLow], ModeOR = True, ShortCircuit = True, IgnoreFilterPassed = False, MeasureTime = True ) ) # kill non-lumi banks if self.getProp('KillBanks') : writeLumiSequence( bankKiller( 'KillAll', BankTypes=[ 'ODIN','HltLumiSummary','HltRoutingBits','DAQ' ], DefaultIsKill=True ) ) # tag input file --- writeLumiSequence( FileIdBankWriter( OutputLevel = debugOPL ) ) # verbose output if debugging: writeLumiSequence( RawEventDump( 'OutputDump', DumpData = True, OutputLevel = debugOPL ) ) writeLumiSequence( MDFWriter( "MDFWriter" ) ) # configure somewhere else # and activate it sequence.Members+=[ Sequence('writeLumiSeq') ]
def DecodeTracking(trackAlgs, ExcludedLayers=[]): #configure the decoding from DAQSys.Decoders import DecoderDB from DAQSys.DecoderClass import decodersForBank decs = [] if "Velo" or "FastVelo" in trackAlgs: #clone an existing algorithm, in order to create both the full #and the partial clusters vdec = DecoderDB["DecodeVeloRawBuffer/createBothVeloClusters"] #set as active to make sure nobody tries to use the DoD service along side... vdec.Active = True #set the other algs to inactive, needed for re-running tracking in DaVinci... quite annoying really, see task #19106 #there is another way to do this, set vdec.Active=False, but then someone might run a decoder before the createBoth alg, and screw everything up DecoderDB["DecodeVeloRawBuffer/createVeloClusters"].Active = False DecoderDB["DecodeVeloRawBuffer/createVeloLiteClusters"].Active = False globalCuts = TrackSys().getProp("GlobalCuts") if ("Velo" in globalCuts): vdec.Properties["MaxVeloClusters"] = globalCuts["Velo"] decs = decs + [vdec] #from Configurables import RawBankToSTClusterAlg, RawBankToSTLiteClusterAlg decs = decs + decodersForBank(DecoderDB, "TT") decs = decs + decodersForBank(DecoderDB, "IT") GaudiSequencer("RecoDecodingSeq").Members += [d.setup() for d in decs] # Exclude ST layers: if len(ExcludedLayers) > 0: from TrackSys.RecoExcludeSTLayers import ExcludeSTLayers ExcludeSTLayers(ExcludedLayers) ## Special OT decoder for cosmics to merge spills. if TrackSys().cosmics(): from Configurables import (Tf__OTHitCreator) Tf__OTHitCreator( 'OTHitCreator').RawBankDecoder = 'OTMultiBXRawBankDecoder' ## note: this does not change the OTMeasurementProvider used in the fit. # also adapt the MasterExtrapolator in the TrackInterpolator from Configurables import TrackInterpolator TrackInterpolator( ).Extrapolator.ExtraSelector = 'TrackSimpleExtraSelector' d = DecoderDB["OTRawBankDecoder/ToolSvc.OTRawBankDecoder"] if "disableOTTimeWindow" in TrackSys().getProp("ExpertTracking"): from GaudiKernel.SystemOfUnits import ns d.Properties["TimeWindow"] = (-999.0 * ns, 999.0 * ns) #ensure the public tool is configured and marked as used d.setup()
def _createReader(self, sequence): ''' create reader sequence ''' debugOPL = self.getProp("OutputLevel") debugging = self.getProp("Debug") readLumiSequence = _sequenceAppender( Sequence('readLumiSeq', ModeOR=False, ShortCircuit=True, IgnoreFilterPassed=False, MeasureTime=True, OutputLevel=debugOPL)) from DAQSys.Decoders import DecoderDB from DAQSys.DecoderClass import decodersForBank # create ODIN by hand for d in decodersForBank(DecoderDB, "ODIN"): readLumiSequence(d.setup()) # select only the right Trigger Type readLumiSequence( ODINFilter('OdinTriggerTypes', Code=' ( ODIN_TRGTYP == LHCb.ODIN.LumiTrigger ) ')) # decode lumi for d in decodersForBank(DecoderDB, "HltLumiSummary"): readLumiSequence(d.setup()) # add filter to check if this was L0 triggered filterRan = FilterOnLumiSummary('LumiRandomFilter', CounterName="Random", ValueName="RandomMethod") filterLow = FilterOnLumiSummary('LumiLowFilter', CounterName="Method", ValueName="L0RateMethod") readLumiSequence( Sequence('filterLumi', Members=[filterRan, filterLow], ModeOR=True, ShortCircuit=True, IgnoreFilterPassed=False, MeasureTime=True)) # read and decode input file --- readLumiSequence(LumiFileReader(OutputLevel=debugOPL)) # verbose output if debugging: readLumiSequence( RawEventDump('InputDump', DumpData=True, OutputLevel=debugOPL)) # and activate it sequence.Members += [Sequence('readLumiSeq')]
def myAction(): from Gaudi.Configuration import GaudiSequencer from Configurables import (PrTrackAssociator, TrackResChecker, TrackOccupChecker, PrChecker, TrackSelector, MCReconstructible, MCParticleSelector, PrLHCbID2MCParticle, UnpackMCParticle, UnpackMCVertex, DebugTrackingLosses) from HltTracking.HltTrackNames import HltSharedTrackLoc, HltSharedTrackRoot from DAQSys.Decoders import DecoderDB from DAQSys.DecoderClass import decodersForBank decs = [] decs = decs + decodersForBank(DecoderDB, "TT", "IT") DecSeq = GaudiSequencer("MyDecodingSeq") DecSeq.Members += [d.setup() for d in decs] PatCheck = GaudiSequencer("CheckPatSeq") PatCheck.Members += [ UnpackMCParticle(), UnpackMCVertex(), PrLHCbID2MCParticle("PrLHCbID2MCParticle") ] PrChecker("PrChecker").TriggerNumbers = True PrChecker("PrChecker").Eta25Cut = True PrChecker("PrChecker").WriteForwardHistos = 1 PrChecker("PrChecker").WriteUpHistos = 0 PrChecker("PrChecker").WriteVeloHistos = 1 #(N.B.: container base for velo tracks was renamed to Hlt1) # Figure out which HLT is run from HltConf PrChecker("PrChecker").VeloTracks = HltSharedTrackLoc["Velo"] PrChecker("PrChecker").ForwardTracks = HltSharedTrackLoc[ "ForwardHPT"] #HltSharedForwardLocation PrChecker("PrChecker").UpTracks = HltSharedTrackLoc["VeloTTHPT"] PrChecker("PrChecker").HistoPrint = True #PrChecker("PrChecker").OutputLevel = 1 PrTrackAssociator("AssocAll").RootOfContainers = HltSharedTrackRoot #PrTrackAssociator("AssocAll").OutputLevel = 2 #PrTrackAssociator("AssocAll").SingleContainer = HltSharedTrackLoc["ForwardHPT"] PatCheck.Members += [PrTrackAssociator("AssocAll")] PatCheck.Members += [PrChecker("PrChecker")] EndMembers = GaudiSequencer("HltEndSequence").Members EndMembers.insert(0, DecSeq) EndMembers.insert(1, PatCheck)
def ReviveHltTracks(TriggerLines=[]): HltLines = TriggerLines # Default trigger lines from Escher filter from Configurables import Escher if len(TriggerLines) == 0: lines = Escher().HltFilterCode.split('\'') for l in lines: if l.find('Hlt') != -1 and l.find('Decision') - 1: HltLines.append(l) # revive only particles used for trigger from Configurables import GaudiSequencer trackseq = GaudiSequencer("RecoAlignTrSeq") from Configurables import HltTrackConverter hltTrackConv = HltTrackConverter("HltTrackConv") hltTrackConv.HltLinesToUse = HltLines hltTrackConv.TrackDestination = 'Rec/Track/AllBest' if Escher().DataType in ['2015']: hltTrackConv.SelReportsLocation = 'Hlt1/SelReports' ## TODO: Watch out for the HLT1/2 Split here!! ## probably the decoder DB will take care of it for you... from DAQSys.Decoders import DecoderDB hltdecs = [] if Escher().DataType in ['2015']: decDec = DecoderDB["HltDecReportsDecoder/Hlt1DecReportsDecoder"] selDec = DecoderDB["HltSelReportsDecoder/Hlt1SelReportsDecoder"] hltdecs += [decDec, selDec] else: from DAQSys.DecoderClass import decodersForBank hltdecs = decodersForBank(DecoderDB, "HltSelReports") trackseq.Members += [d.setup() for d in hltdecs] trackseq.Members += [hltTrackConv] # Add a filter to skip events with empty input container from Configurables import LoKi__VoidFilter as Filter fltr = Filter('TrackConvOutput', Code=" 1 < CONTAINS ( '%s') " % hltTrackConv.TrackDestination) trackseq.Members.append(fltr) # create a sequence that fits the tracks and does the hit-adding from TAlignment.Utils import configuredFitAndHitAdderSequence fitseq = configuredFitAndHitAdderSequence( Name='HltBest', InputLocation=hltTrackConv.TrackDestination, OutputLocation='Rec/Track/Best') trackseq.Members.append(fitseq) return HltLines
def SetEvtClock(bank, db=None): """ Add specific decoder to EvtClockSvc, replace disparate code """ if db is None: from DAQSys.Decoders import DecoderDB db = DecoderDB from DAQSys.DecoderClass import decodersForBank odinconfs = decodersForBank(db, bank) if len(odinconfs): #force to take the same public tool publicTool = odinconfs[0].PublicTools[0] from Configurables import EventClockSvc #force it to use the same public tool as the rest of the ODIN decoding EventClockSvc(EventTimeDecoder=publicTool.replace("ToolSvc.", "") + ":PUBLIC")
def protoParticlesFromHLTSelSequence(Name, HltDecision, ApplyRichID=False, ApplyMuonID=False): # create a sequence that # * revives tracks from an HLT sequence # * fits them # * runs rich or muon ID on demand # tracks will be stored at location 'Rec/Track/' + Name # protoparticles will be stored at location ???? trackListName = 'Rec/Track/' + Name from Configurables import GaudiSequencer seq = GaudiSequencer(Name + "Seq") # revive only particles used for trigger from Configurables import HltTrackConverter hltTrackConv = HltTrackConverter(Name + "HltTrackConv") hltTrackConv.ReadHltLinesFrom1stEvent = HltDecision hltTrackConv.TrackDestination = 'Rec/Track/' + Name + 'All' if Escher().DataType in ['2015']: hltTrackConv.SelReportsLocation = 'Hlt1/SelReports' ## TODO: Watch out for the HLT1/2 Split here!! ## probably the decoder DB will take care of it for you... from DAQSys.Decoders import DecoderDB hltdecs = [] if Escher().DataType in ['2015']: decDec = DecoderDB["HltDecReportsDecoder/Hlt1DecReportsDecoder"] selDec = DecoderDB["HltSelReportsDecoder/Hlt1SelReportsDecoder"] hltdecs += [decDec, selDec] else: from DAQSys.DecoderClass import decodersForBank hltdecs = decodersForBank(DecoderDB, "HltSelReports") trackseq.Members += [d.setup() for d in hltdecs] trackseq.Members += [hltTrackConv] # now fit those tracks and apply a selection from TAlignment.Utils import configuredFitAndHitAdderSequence fitseq = configuredFitAndHitAdderSequence(Name + 'Fit', trackListName + 'All', trackListName) seq.Members += [fitseq] # next step, prepare the RICH sequence, if we need it. #if ApplyRichID: return seq
def l0Filters(self): ## L0Report and HltDecReport missing in 2008 and 2009 data if (self.getProp("DataType") in ["2008", "2009"]): return [] from Configurables import (LoKi__HDRFilter, LoKi__L0Filter, GaudiSequencer) from DAQSys.Decoders import DecoderDB from DAQSys.DecoderClass import decodersForBank l0dec = [d.setup() for d in decodersForBank(DecoderDB, 'L0DU')] hltdec = DecoderDB["HltDecReportsDecoder/Hlt1DecReportsDecoder"].setup( ) return l0dec + [ LoKi__L0Filter("RichL0Filter", Code='L0_DECISION_PHYSICS'), hltdec, LoKi__HDRFilter( "RichHlt1Filter", Code="HLT_PASS('Hlt1L0AnyDecision','Hlt1MBNoBiasDecision')", Location=hltdec.OutputHltDecReportsLocation) ]
def __l0_monitoring(self, stage): from Configurables import HltL0GlobalMonitor from DAQSys.Decoders import DecoderDB from DAQSys.DecoderClass import decodersForBank l0decoder = decodersForBank(DecoderDB, 'L0DU') assert len(l0decoder) l0decoder = l0decoder[0].setup() decRepLoc = DecoderDB["HltDecReportsDecoder/%sDecReportsDecoder" % stage].listOutputs()[0] monitor = HltL0GlobalMonitor(stage + 'L0GlobalMonitor', DecReports=decRepLoc, HltDecName=stage + "Global") if self.getProp("EnableL0Monitor"): return [l0decoder, monitor] else: return []
def configureHltReportDecoding(trunk): """ Create HltDecReports and HltSelReports from DAQ/RawEvent banks. Fetches DAQ/RawEvent from trunk+DAQ/RawEvent, places reports in trunk + Hlt/DecReports and trunk + Hlt/SelReports respectively. Action is on-demand via the DataOnDemandSvs. """ locationRoot = fixTrunk(trunk) name = trunkName(trunk) rawEventLoc = locationRoot + "DAQ/RawEvent" #decReportLoc = locationRoot + "Hlt/DecReports" #selReportLoc = locationRoot + "Hlt/SelReports" ApplicationMgr().ExtSvc += [DataOnDemandSvc()] from DAQSys.Decoders import DecoderDB from DAQSys.DecoderClass import decodersForBank for bank in ["Sel", "Dec", "Vertex", "Track"]: for d in decodersForBank(DecoderDB, "Hlt" + bank + "Reports"): d.overrideInputs(rawEventLoc) d.overrideOutputs([locationRoot + loc for loc in d.listOutputs()])
Brunel().WithMC = True Brunel().PrintFreq = 100 Brunel().Simulation = True Brunel().EvtMax = 200*5 Brunel().DatasetName = "seeding-%i%s"%(stereo, "-XOnly" if x_only else "") Brunel().Detectors = ['VP', 'UT', 'FT', 'Rich1Pmt', 'Rich2Pmt', 'Spd', 'Prs', 'Ecal', 'Hcal', 'Muon', 'Magnet', 'Tr'] MessageSvc().Format = '% F%20W%S%7W%R%T %0W%M' GaudiSequencer("RecoHLTSeq").Members = ["GaudiSequencer/SeedingSeq"] seed_seq = GaudiSequencer("SeedingSeq") decs = [] decs.extend(decodersForBank(DecoderDB,"VP")) #decs.extend(decodersForBank(DecoderDB,"UT")) decs.extend(decodersForBank(DecoderDB,"FTCluster")) createUTLiteClusters = decodersForBank(DecoderDB, "UT") seed_seq.Members += [d.setup() for d in createUTLiteClusters] UT = STOfflinePosition('ToolSvc.UTClusterPosition') UT.DetType = "UT" seed_seq.Members += [d.setup() for d in decs] seed_seq.Members += [PrPixelTracking(), PrPixelStoreClusters(), PrForwardTracking(), PrSeedingXLayers() ] PrSeedingXLayers().XOnly = x_only
def endSequence(self): """ define end sequence (persistence + monitoring) """ from Configurables import GaudiSequencer as Sequence from Configurables import bankKiller from Configurables import LoKi__HDRFilter as HltFilter from Configurables import Hlt1SelReportsMaker, Hlt2SelReportsMaker, HltSelReportsWriter from Configurables import HltDecReportsWriter from Configurables import HltVertexReportsMaker, HltVertexReportsWriter from Configurables import HltTrackReportsWriter from Configurables import HltRoutingBitsWriter from Configurables import HltLumiWriter from Configurables import DeterministicPrescaler as Prescale from HltLine.HltDecodeRaw import DecodeIT, DecodeVELO, DecodeL0DU from Configurables import LoKi__VoidFilter as Filter sets = self.settings() if sets and hasattr(sets, 'StripEndSequence') and getattr( sets, 'StripEndSequence'): log.warning( '### Setting requests stripped down HltEndSequence ###') strip = getattr(sets, 'StripEndSequence') for option in [ 'EnableHltSelReports', 'EnableHltVtxReports', 'EnableHltTrkReports', 'EnableLumiEventWriting' ]: self._safeSet(option, (option in strip)) activehlt1lines, activehlt2lines = self._runHltLines() # make sure we encode from the locations the decoders will use... from DAQSys.Decoders import DecoderDB hlt1_decrep_loc = DecoderDB[ "HltDecReportsDecoder/Hlt1DecReportsDecoder"].listOutputs()[0] hlt2_decrep_loc = DecoderDB[ "HltDecReportsDecoder/Hlt2DecReportsDecoder"].listOutputs()[0] hlt1_selrep_loc = DecoderDB[ "HltSelReportsDecoder/Hlt1SelReportsDecoder"].listOutputs()[0] hlt2_selrep_loc = DecoderDB[ "HltSelReportsDecoder/Hlt2SelReportsDecoder"].listOutputs()[0] hlt1_vtxrep_loc = DecoderDB[ "HltVertexReportsDecoder/Hlt1VertexReportsDecoder"].listOutputs( )[0] hlt2_vtxrep_loc = DecoderDB[ "HltVertexReportsDecoder/Hlt2VertexReportsDecoder"].listOutputs( )[0] ## L0 decoder from DAQSys.DecoderClass import decodersForBank l0decoder = decodersForBank(DecoderDB, 'L0DU') assert len(l0decoder) l0decoder = l0decoder[0].setup() ### store the BDT response (and a bit more) through ExtraInfo on particles: sel_rep_opts = dict( InfoLevelDecision=3, InfoLevelTrack=3, InfoLevelRecVertex=3, InfoLevelCaloCluster=3, InfoLevelParticle=3, ) ### HLT2 rec summary location, empty if HltAfterburner is disabled if self.getProp("EnableHltAfterburner"): recSumLoc = HltAfterburnerConf().getProp("RecSummaryLocation") else: recSumLoc = "" ### FIXME/TODO: having the routing bits writer(s) in the postamble implies they do NOT run for rejected events. ### Is that really appropriate? Maybe we don't care, as those events (in the pit!) are never seen ### downstream, but eg. for MC they may be kept... ### So maybe the routingbits should be written in the end sequence instead, but then the code must take into ### account that Hlt2 missing on Hlt1 rejected events is not an error... _hlt1postamble = (("EnableHltRoutingBits", type(l0decoder), l0decoder.getName(), {}), ("EnableHltRoutingBits", HltRoutingBitsWriter, 'Hlt1RoutingBitsWriter', { 'Hlt1DecReportsLocation': hlt1_decrep_loc, 'Hlt2DecReportsLocation': '', }), ("EnableHltDecReports", HltDecReportsWriter, 'Hlt1DecReportsWriter', { 'SourceID': 1, 'InputHltDecReportsLocation': hlt1_decrep_loc }), ("EnableHltSelReports", Hlt1SelReportsMaker, 'Hlt1SelReportsMaker', dict(InputHltDecReportsLocation=hlt1_decrep_loc, OutputHltSelReportsLocation=hlt1_selrep_loc, **sel_rep_opts)), ("EnableHltSelReports", HltSelReportsWriter, 'Hlt1SelReportsWriter', { 'SourceID': 1, 'InputHltSelReportsLocation': hlt1_selrep_loc }), ("EnableHltTrkReports", HltTrackReportsWriter, 'Hlt1TrkReportsWriter', {}), ("EnableHltVtxReports", HltVertexReportsMaker, 'Hlt1VtxReportsMaker', { 'OutputHltVertexReportsLocation': hlt1_vtxrep_loc }), ("EnableHltVtxReports", HltVertexReportsWriter, 'Hlt1VtxReportWriter', { 'SourceID': 1, 'InputHltVertexReportsLocation': hlt1_vtxrep_loc })) _hlt2postamble = (("EnableHltRoutingBits", type(l0decoder), l0decoder.getName(), {}), ("EnableHltDecReports", HltDecReportsWriter, 'Hlt2DecReportsWriter', { 'SourceID': 2, 'InputHltDecReportsLocation': hlt2_decrep_loc }), ("EnableHltSelReports", Hlt2SelReportsMaker, 'Hlt2SelReportsMaker', dict(InputHltDecReportsLocation=hlt2_decrep_loc, OutputHltSelReportsLocation=hlt2_selrep_loc, RecSummaryLocation=recSumLoc, **sel_rep_opts)), ("EnableHltSelReports", HltSelReportsWriter, 'Hlt2SelReportsWriter', { 'SourceID': 2, 'InputHltSelReportsLocation': hlt2_selrep_loc }), ("EnableHltVtxReports", HltVertexReportsMaker, 'Hlt2VtxReportsMaker', { 'OutputHltVertexReportsLocation': hlt2_vtxrep_loc }), ("EnableHltVtxReports", HltVertexReportsWriter, 'Hlt2VtxReportWriter', { 'SourceID': 2, 'InputHltVertexReportsLocation': hlt2_vtxrep_loc })) # Don't try to decode L0 for the routing bits writer if no L0TCK has # been set. This allows forward compatibility. if self.getProp('L0TCK') is None: _hlt1postamble = _hlt1postamble[1:] _hlt2postamble = _hlt2postamble[1:] # make sure we only instantiate members which are used... instantiate = lambda name, cfg: Sequence( name, IgnoreFilterPassed=True, Members=[ tp(nm, **props) for (gate, tp, nm, props) in cfg if self.getProp(gate) ]) Monitoring = Sequence("HltMonitorSequence", IgnoreFilterPassed=True) End = Sequence('HltEndSequence', []) Hlt1PostAmble = instantiate('Hlt1Postamble', _hlt1postamble) Hlt2PostAmble = instantiate('Hlt2Postamble', _hlt2postamble) # Configure monitoring from HltMonitoring import HltMonitoringConf HltMonitoringConf().MonitorSequence = Monitoring # Disable L0 monitoring if no L0TCK has been set if self.getProp('L0TCK') is None: HltMonitoringConf().EnableL0Monitor = False # Set end sequence for output HltOutputConf().HltEndSequence = End if self.getProp('RequireL0ForEndSequence'): from Configurables import LoKi__L0Filter as L0Filter from HltLine.HltDecodeRaw import DecodeL0DU L0accept = Sequence( name='HltEndSequenceFilter', Members=DecodeL0DU.members() + [L0Filter('L0Pass', Code="L0_DECISION_PHYSICS")]) End.Members += [L0accept]
def overrideIfRequired(self, adecoder=None, setup=False): """ Override inputs to the decoders, the RawEventLocation, with a different location as specified in RawEventFormat DB. Will complain if what you're trying to go from/to is not possible. Will override any decoder which has either been set to active *or* was 'used' """ #print "IN OVERRIDE IF REQUIRED!!" if (not self.isPropertySet("OverrideInputs")) or ( self.getProp("OverrideInputs") is None): #print "RETURNING FOR SOME STUPID REASON" return #load dictionary of possible raw event locations RawEventFormatConf().loadIfRequired() from RawEventCompat.Configuration import WhereBest, WhereAll, KnownBanks v = self.getProp("OverrideInputs") if adecoder is None: #print "Finding the decoders!" #which banks, and which decoders will be overwritten from DAQSys.DecoderClass import decodersForBank, usedDecoders banks = self.allBanks() for d in usedDecoders(self.__db__()): for b in d.Banks: if b not in banks: banks.append(b) b_locs_toset = {} known = KnownBanks(v) for b in banks: if b not in known: #I can't reconfigure it if the bank type is not known! from DAQSys.DecoderClass import decodersForBank d = decodersForBank(self.__db__(), b) if len(d): names = [di.FullName for di in d] print "# WARNING: Re-configuration of inputs for " + names.__str__( ) + " could not be done, because the bank it decodes '" + b + "' does not appear in the list of available banks for target version '" + str( v ) + "' try setting this decoder to active=False and configuring yourself if really needed, or manually editing the contents of the RawEventFormat/Compat dictionaries" else: #there are no decoders for this bank, just ignore it pass else: #the bank type is known b_locs_toset[b] = WhereBest(b, v) reset_list = {} for b in b_locs_toset: from DAQSys.DecoderClass import decodersForBank, usedDecoders for d in decodersForBank(self.__db__(), b) + usedDecoders( self.__db__(), b): if d.listInputs()[0] != b_locs_toset[b]: if b not in reset_list: reset_list[b] = [d] elif d not in reset_list[b]: reset_list[b].append(d) if not len(reset_list): return for k, ds in reset_list.iteritems(): for d in ds: self.overrideIfRequired(d, setup=setup) return #when a decoder is passed... d = adecoder known = KnownBanks(v) #have to skip it if it decodes an unknown bank! for b in d.Banks: if b not in known: raise ValueError( "The algorithm " + d.FullName + " should not have been passed into the overrideInputs method, because it decodes '" + b + "' banks which do not exist in the target format version '" + str(v) + "' try setting this decoder to active=False and configuring yourself if really needed, or manually editing the contents of the RawEventFormat/Compat dictionaries" ) dest = WhereBest(d.Banks[0], v) #does it make sense to overwrite these banks? for b in d.Banks: if dest != WhereBest(b, v): raise ValueError( "The algorithm " + d.FullName + " decodes multiple banks, so they need to all be in the same location!" ) #am I able to overwrite these banks? if not d.isInputSettable(): if not d.Active: #ignore other not-Active things..., pah, not sure, new to enable overriding all "used" items... return flag = False whereall = WhereAll(d.Banks[0], v) for l in adecoder.listInputs(): if l in whereall: flag = True break if not flag: raise ValueError( "I cannot overwrite to this raw version, because the input for the alg " + d.FullName + " is not configurable") print "# WARNING: Re-configuration of inputs for " + d.FullName + " was not done, but it might be OK since at least one location is in the default decode list" return #overwrite them if able #print "# DecodeRawEvent: Overriding "+d.FullName+" from "+d.listInputs().__str__()+" to " +str(dest) d.overrideInputs(dest) if setup: d.setup(onlyInputs=True)
def applyConf(self) : # Get the sequence to fill sequence = self.getRecoSeq() if None == sequence : return # Common stuff self.applyCommonConf() # Get the context cont = self.getProp("Context") # Some preliminary stuff if self.getProp("ConfigurePrelims") : #----------------------------------------------------------------------------- # Preload the raw event #----------------------------------------------------------------------------- if self.getProp("PreloadRawEvent"): from Configurables import Rich__DAQ__LoadRawEvent raw = self.makeRichAlg( Rich__DAQ__LoadRawEvent, "LoadRawRichEvent"+cont ) sequence.Members += [ raw ] #----------------------------------------------------------------------------- # Preload the raw input tracks #----------------------------------------------------------------------------- if self.getProp("PreloadTracks"): from Configurables import Rich__Rec__Initialise trackInit = self.makeRichAlg( Rich__Rec__Initialise, "LoadRawTracks"+cont ) trackInit.LoadRawTracks = True sequence.Members += [ trackInit ] #----------------------------------------------------------------------------- # Enable this to run a full track refit prior to processing # Useful for running on DSTs. #----------------------------------------------------------------------------- if self.getProp("RefitTracks") : from DAQSys.Decoders import DecoderDB from DAQSys.DecoderClass import decodersForBank for det in ["Velo","TT","IT"] : sequence.Members += [ d.setup() for d in decodersForBank(DecoderDB,det) ] from TrackFitter.ConfiguredFitters import ConfiguredFit from Configurables import TrackStateInitAlg tracksLoc = self.trackConfig().getProp("InputTracksLocation") init = TrackStateInitAlg( name = "InitRichTrackStates", TrackLocation = tracksLoc ) fit = ConfiguredFit("RefitRichTracks",tracksLoc) #init.OutputLevel = 1 #fit.OutputLevel = 1 sequence.Members += [ init, fit ] #----------------------------------------------------------------------------- # Preload MC association information #----------------------------------------------------------------------------- if self.getProp("PreloadMCLinks") : sequence.Members += ["UnpackMCParticle","UnpackMCVertex","TrackAssociator"] #----------------------------------------------------------------------------- # RICH RawEvent decoding #----------------------------------------------------------------------------- if self.getProp("InitDecoding") : # Raw decoding algorithm # Parasite in on this with my database so that the # automatic reconfiguration of locations is spawned from DAQSys.Decoders import DecoderDB from DAQSys.DecoderClass import decodersForBank aname="DecodeRawRich"+cont # clone the pre-existing alg in the database first... decodeRich =DecoderDB["Rich::DAQ::RawBufferToRichDigitsAlg/RichRawEventToDigits"].clone("Rich::DAQ::RawBufferToRichDigitsAlg/"+aname) decodeRich.Properties["DecodeBufferOnly"]=True # with ["DecodeBufferOnly"]=True, alg produces no output ... decodeRich.Outputs=[] # set "Active" to auto reconfigure the input location if needed decodeRich.Active=True decodeRich=decodeRich.setup() # call the makeRichAlg anyway, even though it is already "made..." # just in case it is adapted to do other things in the future from Configurables import Rich__DAQ__RawBufferToRichDigitsAlg decodeRich = self.makeRichAlg( Rich__DAQ__RawBufferToRichDigitsAlg, aname ) sequence.Members += [ decodeRich ] # Configure the RICH processing if not self.usingTrackGroups() : # Run a single sequence for all track types if self.getProp("ConfigureAlgs") : self.configAlgorithms() else: # Run a seperate sequence for each track grouping # Get the track groupings tkGroups = self.getProp("TrackTypeGroups") # Global tracking cuts globalTkCuts = self.trackConfig().getProp("TrackCuts") # Seperated PID location s pidLocs = [ ] # Split by track type for tkTypeGroup in tkGroups: # Is at least one of the track types in this group in the track selection cuts ? if self.trackGroupSelected(tkTypeGroup) : # Build the reco sequence for this group groupConfig = RichRecSysBaseConf( self.getConfName(tkTypeGroup) ) # Context for this group groupcont = self.getConfContext(tkTypeGroup) # Set context with group name self.propagateContext( groupConfig, groupcont ) # Propagate all options self.propagateAllOptions( groupConfig ) # Then tweak things for this track group # Turn off stuff run once for all groupConfig.setProp("CheckProcStatus",False) groupConfig.setProp("PreloadRawEvent",False) groupConfig.setProp("PreloadTracks",False) groupConfig.setProp("RefitTracks",False) groupConfig.setProp("InitDecoding",False) # Turn off splitting again groupConfig.setProp("TrackTypeGroups",[]) # Proper context for this group self.propagateContext( groupConfig, groupcont ) # Clone tool registry tool list groupConfig.toolRegistry().Tools = self.toolRegistry().Tools # PID Output location pidLoc = self.getProp("RichPIDLocation")+self.trackGroupName(tkTypeGroup) groupConfig.setProp("RichPIDLocation",pidLoc) pidLocs += [pidLoc] # Construct the track selection cuts for this group tkCuts = { } for tkType in tkTypeGroup : tkCuts[tkType] = globalTkCuts[tkType] # Set the track selection for this group groupConfig.trackConfig().setProp("TrackCuts",tkCuts) # Make a sequence for this track group tkGroupSeq = self.makeRichAlg(GaudiSequencer,"RichRec"+groupcont+"Seq") sequence.Members += [tkGroupSeq] groupConfig.setProp("RecoSequencer",tkGroupSeq) #------------------------------------------------------------------------- # Finalise (merge results from various algorithms) #------------------------------------------------------------------------- pidMode = self.getProp("PidConfig") if pidMode != "None" : from Configurables import Rich__Rec__PIDMerge pidMerge = self.makeRichAlg(Rich__Rec__PIDMerge,"Merge"+cont+"RichPIDs") pidMerge.OutputLocation = self.getProp("RichPIDLocation") pidMerge.InputLocations = pidLocs sequence.Members += [pidMerge]
def RecoUpgradeTracking(exclude=[]): ## Start TransportSvc, needed by track fit ??? ApplicationMgr().ExtSvc.append("TransportSvc") subDets = [] from Configurables import LHCbApp #Test if LHCbApp has this method (same revision as property) if hasattr(LHCbApp(), "Detectors"): if LHCbApp().isPropertySet("Detectors"): subDets = LHCbApp().upgradeDetectors() trackTypes = TrackSys().getProp("TrackTypes") ### Sanity checks if "Forward" in trackTypes: if not ("Velo" in trackTypes): log.warning("Velo tracks added to tracking sequence.") trackTypes += ["Velo"] if not (("FT" in subDets)): raise RuntimeError("Specify T-Stations.") if "Upstream" in trackTypes: if not ("Velo" in trackTypes): log.warning("Velo tracks added to tracking sequence.") trackTypes += ["Velo"] if not (("UT" in subDets)): raise RuntimeError("Specify UT.") if "Downstream" in trackTypes: if not ("Seeding" in trackTypes): log.warning("Seed tracks added to tracking sequence.") trackTypes += ["Seeding"] if not (("UT" in subDets)): raise RuntimeError("Specify UT.") if "Velo" in trackTypes: if not (("VP" in subDets)): raise RuntimeError("Specify VP.") if "Seeding" in trackTypes: if not ("FT" in subDets): raise RuntimeError("Specify T-Stations.") if "Match" in trackTypes: if not ("Velo" in trackTypes): log.warning("Velo tracks added to tracking sequence.") trackTypes += ["Velo"] if not ("Seeding" in trackTypes): log.warning("Seed tracks added to tracking sequence.") trackTypes += ["Seeding"] ### Do the decoding of the detectors decodingSeq = GaudiSequencer("RecoDecodingSeq") from DAQSys.Decoders import DecoderDB from DAQSys.DecoderClass import decodersForBank decs = [] # Are these the right decoders? if "VP" in subDets: decs = decs + decodersForBank(DecoderDB, "VP") if "UT" in subDets: decs = decs + decodersForBank(DecoderDB, "UT") from Configurables import STOfflinePosition UT = STOfflinePosition('ToolSvc.UTClusterPosition') UT.DetType = "UT" if "FT" in subDets: decs = decs + decodersForBank(DecoderDB, "FTCluster") decodingSeq.Members += [d.setup() for d in decs] ### Define the pattern recognition if "Velo" in trackTypes: veloSeq = GaudiSequencer("TrVeloSeq") GaudiSequencer("RecoTrSeq").Members += [veloSeq] if "VP" in subDets: from Configurables import PrPixelTracking, PrPixelStoreClusters veloSeq.Members += [PrPixelTracking(), PrPixelStoreClusters()] if "Upstream" in trackTypes: upSeq = GaudiSequencer("TrUpSeq") GaudiSequencer("RecoTrSeq").Members += [upSeq] if "UT" in subDets: from Configurables import PrVeloUT prVeloUT = PrVeloUT() from Configurables import TrackMasterFitter prVeloUT.addTool(TrackMasterFitter, "Fitter") prVeloUT.Fitter.MeasProvider.IgnoreVelo = True prVeloUT.Fitter.MeasProvider.IgnoreVP = True prVeloUT.Fitter.MeasProvider.IgnoreTT = True prVeloUT.Fitter.MeasProvider.IgnoreIT = True prVeloUT.Fitter.MeasProvider.IgnoreOT = True prVeloUT.Fitter.MeasProvider.IgnoreUT = False if ("VP" in subDets): prVeloUT.Fitter.MeasProvider.IgnoreVP = False upSeq.Members += [PrVeloUT()] if "Forward" in trackTypes: forwardSeq = GaudiSequencer("TrForwardSeq") GaudiSequencer("RecoTrSeq").Members += [forwardSeq] if "FT" in subDets: from Configurables import PrForwardTracking forwardSeq.Members += [PrForwardTracking()] if "Seeding" in trackTypes: seedingSeq = GaudiSequencer("TrSeedingSeq") GaudiSequencer("RecoTrSeq").Members += [seedingSeq] if "FT" in subDets: #from Configurables import PrSeedingAlgorithm #seedingSeq.Members += [ PrSeedingAlgorithm() ] #from Configurables import PrSeedingXLayers #seedingSeq.Members += [PrSeedingXLayers()] from Configurables import PrHybridSeeding seedingSeq.Members += [PrHybridSeeding()] if "Match" in trackTypes: matchSeq = GaudiSequencer("TrMatchSeq") GaudiSequencer("RecoTrSeq").Members += [matchSeq] from Configurables import PrMatch #from Configurables import PatMatch, PatMatchTool, PrAddUTCoord matchSeq.Members += [PrMatch()] #PatMatch().addTool(PatMatchTool, "PatMatchTool") #PatMatch().PatMatchTool.AddTTClusters = True #PatMatch().PatMatchTool.AddTTClusterName = "PrAddUTCoord" if "Downstream" in trackTypes: downSeq = GaudiSequencer("TrDownSeq") GaudiSequencer("RecoTrSeq").Members += [downSeq] if "UT" in subDets: from Configurables import PrDownstream downSeq.Members += [PrDownstream()] # Do the Clone Killing and create Best tracks container bestSeq = GaudiSequencer("TrBestSeq") GaudiSequencer("RecoTrSeq").Members += [bestSeq] #Fill list of Tracks to write out tracklists = [] if "Velo" in trackTypes: tracklists += ["Rec/Track/Velo"] if "Seeding" in trackTypes: tracklists += ["Rec/Track/Seed"] if "Forward" in trackTypes: tracklists += ["Rec/Track/Forward"] if "Upstream" in trackTypes: tracklists += ["Rec/Track/VeloTT"] if "Downstream" in trackTypes: tracklists += ["Rec/Track/Downstream"] if "Match" in trackTypes: tracklists += ["Rec/Track/Match"] from Configurables import TrackBestTrackCreator, TrackMasterFitter from TrackFitter.ConfiguredFitters import ConfiguredMasterFitter bestTrackCreator = TrackBestTrackCreator(TracksInContainers=tracklists) bestTrackCreator.addTool(TrackMasterFitter, name="Fitter") bestTrackCreator.FitTracks = True bestTrackCreator.InitTrackStates = False ConfiguredMasterFitter(bestTrackCreator.Fitter) bestSeq.Members += [bestTrackCreator] ## Extra track information sequence extraInfos = TrackSys().getProp("TrackExtraInfoAlgorithms") if len(extraInfos) > 0: ## ghost probability using a Neural Net if "GhostProbability" in extraInfos: from Configurables import TrackAddNNGhostId, TrackNNGhostId ghostID = TrackAddNNGhostId() ghostID.GhostIdTool = "UpgradeGhostId" GaudiSequencer("TrackAddExtraInfoSeq").Members += [ghostID] addExtraInfoSeq = GaudiSequencer("TrackAddExtraInfoSeq") GaudiSequencer("RecoTrSeq").Members += [addExtraInfoSeq]
def uDstConf(rootInTes, killNodes=['/Event/DAQ', '/Event/pRec'], logger=None): """ Various settings for mDst # from PhysConf.MicroDST import uDstConf # uDstConf ( '/Event/Leptonic' ) # """ # if not logger: logger = log # # ## Never use gfal ... # from Configurables import Gaudi__IODataManager as IODataManager IODataManager("IODataManager").UseGFAL = False logger.info("Disable GFAL") # ## pick up all goodies from Juan # import MicroDSTConf.TriggerConfUtils as TCU # ## 'rootify' # if 0 != rootInTes.find('/Event/'): rootInTes = '/Event/' + rootInTes rootInTes = TCU.fixTrunk(rootInTes) logger.info("Reconfigure uDST to use RootInTES='%s'" % rootInTes) # ## configure L0,Hlt,e tc using Juan's functions: # TCU.configureL0AndHltDecoding(rootInTes) logger.info("Configure L0&HLT decoding RootInTES='%s'" % rootInTes) from Configurables import DataOnDemandSvc dod = DataOnDemandSvc() # ## extra configuration: # # it is more relevant for Stripping-17 data, # however it is backard compatible with other uDsts # # ## 0. Kill Event/DAQ # from Gaudi.Configuration import appendPostConfigAction def _killDAQ_(): return killDAQ(nodes=killNodes, logger=logger) appendPostConfigAction(_killDAQ_) logger.info("Configure DAQ-killer agent for %s " % killNodes) # ## 1. Copy/Link ODIN, RawEvent and RecSummary # from Configurables import Gaudi__DataLink as Link rawEvt = Link('LinkRawEvent', What='/Event/Trigger/RawEvent', Target=rootInTes + 'DAQ/RawEvent') odin = Link('LinkODIN', What='/Event/DAQ/ODIN', Target=rootInTes + 'DAQ/ODIN') summary = Link('LinkSummary', What='/Event/Rec/Summary', Target=rootInTes + 'Rec/Summary') header = Link('LinkHeader', What='/Event/Rec/Header', Target=rootInTes + 'Rec/Header') reports = Link('LinkStripReports', What='/Event/Strip/Phys/DecReports', Target=rootInTes + 'Strip/Phys/DecReports') dod.AlgMap[rawEvt.Target] = rawEvt dod.AlgMap[odin.Target] = odin dod.AlgMap[summary.Target] = summary dod.AlgMap[header.Target] = header dod.AlgMap[reports.Target] = reports hlt1_reports = Link('LinkHlt1Reports', What=rootInTes + 'Hlt1/DecReports', Target='/Event/Hlt1/DecReports') hlt2_reports = Link('LinkHlt2Reports', What=rootInTes + 'Hlt2/DecReports', Target='/Event/Hlt2/DecReports') dod.AlgMap[hlt1_reports.Target] = hlt1_reports dod.AlgMap[hlt2_reports.Target] = hlt2_reports logger.info("Configure ODIN,Raw,Summary&Reports RootInTES='%s'" % rootInTes) rawEventLoc = rootInTes + 'DAQ/RawEvent' from DAQSys.Decoders import DecoderDB from DAQSys.DecoderClass import decodersForBank for d in decodersForBank(DecoderDB, "L0PU"): d.overrideInputs(rawEventLoc)
from DAQSys.DecoderClass import Decoder, decodersForBank from DAQSys.Decoders import DecoderDB rich = decodersForBank(DecoderDB, "Rich") required = [] for r in rich: for req in r.allDaughters(): req = DecoderDB[req] if req not in required and req not in rich: required.append(req) #push into a smaller DB db = {} for r in rich + required: r.__db__ = db db[r.FullName] = r r0 = rich[0] r0.overrideOutputs("Dev/Null") expectname = "Rich::DAQ::RawBufferToRichDigitsAlg/DecodeRawRichOffline" prop = "DecodeBufferOnly" rclone = r0.clone(expectname) rclone.Properties[prop] = True r0.Properties[prop] = False rcloneset = rclone.setup()
from DAQSys.Decoders import DecoderDB as ddb from DAQSys.DecoderClass import decodersForBank from Configurables import GaudiSequencer, DecodeRawEvent, DataOnDemandSvc mySeq = GaudiSequencer("DecodeTest") mySeq.Members += [d.setup() for d in decodersForBank(ddb, "Velo")] newDec = ddb["OTTimeCreator"].clone("OTTimeCreator/Ot2") newDec.Properties["OutputLevel"] = 42 newDec.overrideInputs("Other/RawEvent") newDec.overrideOutputs("Other/OTTimes") DecodeRawEvent().OverrideInputs = "Strip20" DecodeRawEvent().DataOnDemand = True DecodeRawEvent().__apply_configuration__() if "Other/OTTimes" not in DataOnDemandSvc().AlgMap: raise KeyError("Other/OTTimes not correctly added to DataOnDemand") print "Pass"
from Gaudi.Configuration import * from Configurables import DecodeRawEvent, LHCbApp from Configurables import GaudiSequencer LHCbApp() mySeq = GaudiSequencer("Decoding") mySeq.OutputLevel = VERBOSE DecodeRawEvent().Sequencer = mySeq ApplicationMgr().TopAlg = [mySeq] from DAQSys.DecoderClass import decodersForBank from DAQSys.Decoders import DecoderDB as ddb #only calo banks for k, v in ddb.iteritems(): v.Active = False flagged = [] for b in ["PrsE", "EcalE", "HcalE", "ODIN"]: for d in decodersForBank(ddb, b, ignoreActive=True, addRequired=True): flagged.append(d) for k, v in ddb.iteritems(): if v not in flagged: v.Active = False #configure L0TCKs importOptions('$L0TCK/L0DUConfig.opts')
def _convert(db, bank): algs = [d.setup() for d in decodersForBank(db, bank)] return bindMembers(None, algs).ignoreOutputSelection()
Brunel().Simulation = True Brunel().EvtMax = 200 * 5 Brunel().DatasetName = "seeding-%i%s" % (stereo, "-XOnly" if x_only else "") Brunel().Detectors = [ 'VP', 'UT', 'FT', 'Rich1Pmt', 'Rich2Pmt', 'Spd', 'Prs', 'Ecal', 'Hcal', 'Muon', 'Magnet', 'Tr' ] MessageSvc().Format = '% F%20W%S%7W%R%T %0W%M' GaudiSequencer("RecoHLTSeq").Members = ["GaudiSequencer/SeedingSeq"] seed_seq = GaudiSequencer("SeedingSeq") decs = [] decs.extend(decodersForBank(DecoderDB, "VP")) #decs.extend(decodersForBank(DecoderDB,"UT")) decs.extend(decodersForBank(DecoderDB, "FTCluster")) createUTLiteClusters = decodersForBank(DecoderDB, "UT") seed_seq.Members += [d.setup() for d in createUTLiteClusters] UT = STOfflinePosition('ToolSvc.UTClusterPosition') UT.DetType = "UT" seed_seq.Members += [d.setup() for d in decs] seed_seq.Members += [ PrPixelTracking(), PrPixelStoreClusters(), PrForwardTracking(), PrSeedingXLayers() ]