def trackingDownPreFilter(name, prefilter, seedcut): #Test code for debugging #Jpsi_already_there = LoKi__VoidFilter("Jpsi_already_there") #Jpsi_already_there.Code = "1 <= CONTAINS('Rec/Track/Downstream')" #Jpsi_not_yet_there = LoKi__VoidFilter("Jpsi_not_yet_there") #Jpsi_not_yet_there.Code = "1 > CONTAINS('Rec/Track/Downstream')" TrackToDST(name + "_DownTrackToDST" ).TracksInContainer = "Rec/" + name + "_Downstream/FittedTracks" jpsidotracking = GaudiSequencer("DownTrackingFor" + name) #Add seed tracking DownSeeding = PatSeeding(name + "_DownSeeding") DownSeeding.OutputTracksName = "Rec/" + name + "_DownSeeding/Tracks" PatAlgConf.SeedingConf().configureAlg(SeedAlg=DownSeeding) #DownSeeding.addTool(PatSeedingTool, name=name+"_PatSeedingTool") #DownSeeding.addTool(PatSeedingTool) #PatSeedingTool(name+"_PatSeedingTool").MinMomentum = seedcut seedtoolname = name + "_PatSeedingTool" DownSeeding.addTool(PatSeedingTool, name=seedtoolname) seedtool = getattr(DownSeeding, seedtoolname) seedtool.MinMomentum = seedcut jpsidotracking.Members += [DownSeeding] #Add Seed Fit jpsidotracking.Members += [GaudiSequencer(name + "_TrackSeedFitSeq")] #AddPatDownstream downstreamTracking = PatDownstream(name + "_PatDownstream") downstreamTracking.InputLocation = DownSeeding.OutputTracksName downstreamTracking.OutputLocation = 'Rec/' + name + '_Downstream/Tracks' jpsidotracking.Members += [downstreamTracking] #AddDownstreamFitSeq DownInitAlg = TrackStateInitAlg(name + "_InitSeedDownstream") jpsidotracking.Members += [DownInitAlg] DownInitAlg.TrackLocation = "Rec/" + name + "_Downstream/Tracks" downstreamFit = ConfiguredFitDownstream(name + "_FitDownstream") downstreamFit.TracksInContainer = 'Rec/' + name + '_Downstream/Tracks' downstreamFit.TracksOutContainer = 'Rec/' + name + '_Downstream/FittedTracks' jpsidotracking.Members += [downstreamFit] jpsidotracking.Members += [TrackToDST(name + "_DownTrackToDST")] return GSWrapper(name="WrappedDownstreamTracking" + name, sequencer=jpsidotracking, output='Rec/' + name + '_Downstream/FittedTracks', requiredSelections=[prefilter])
def MakeVeloTracks(self,prefilter): if self.__confdict__["DoVeloDecoding"]: from DAQSys.Decoders import DecoderDB from DAQSys.DecoderClass import decodersForBank decs=[] vdec=DecoderDB["DecodeVeloRawBuffer/createBothVeloClusters"] vdec.Active=True DecoderDB["DecodeVeloRawBuffer/createVeloClusters"].Active=False DecoderDB["DecodeVeloRawBuffer/createVeloLiteClusters"].Active=False decs=decs+[vdec] VeloDecoding = GaudiSequencer("RecoDecodingSeq") VeloDecoding.Members += [d.setup() for d in decs ] MyFastVeloTracking = FastVeloTracking("For%sFastVelo"%self.name,OutputTracksName=self.VeloTrackOutputLocation) MyFastVeloTracking.OnlyForward = True MyFastVeloTracking.ResetUsedFlags = True ### prepare for fitting preve = TrackStateInitAlg("For%sInitSeedFit"%self.name,TrackLocation = self.VeloTrackOutputLocation) preve.StateInitTool.VeloFitterName = "FastVeloFitLHCbIDs" copyVelo = TrackContainerCopy( "For%sCopyVelo"%self.name ) copyVelo.inputLocations = [self.VeloTrackOutputLocation] copyVelo.outputLocation = self.FittedVeloTrackOutputLocation ### fitting if self.__confdict__["VeloFitter"] == "ForwardStraightLine": MyVeloFit = ConfiguredForwardStraightLineEventFitter(Name="For%sVeloRefitterAlg"%self.name, TracksInContainer=self.FittedVeloTrackOutputLocation) elif self.__confdict__["VeloFitter"] == "SimplifiedGeometry": MyVeloFit = ConfiguredEventFitter(Name="For%sVeloRefitterAlg"%self.name, TracksInContainer=self.FittedVeloTrackOutputLocation, SimplifiedGeometry = True) else: MyVeloFit = ConfiguredEventFitter(Name="For%sVeloRefitterAlg"%self.name, TracksInContainer=self.FittedVeloTrackOutputLocation) #### making the proto particles MakeVeloProtos = ChargedProtoParticleMaker('For%sVeloProtoMaker'%self.name) MakeVeloProtos.Inputs=[self.FittedVeloTrackOutputLocation] MakeVeloProtos.Output = self.VeloProtoOutputLocation MakeVeloProtos.addTool( DelegatingTrackSelector, name="TrackSelector" ) MakeVeloProtos.TrackSelector.TrackTypes = [ "Velo" ] #### the full sequence makeparts = GaudiSequencer('For%sMakeVeloTracksGS'%self.name) if self.__confdict__["DoVeloDecoding"]: makeparts.Members += [ VeloDecoding ] makeparts.Members += [ MyFastVeloTracking ] makeparts.Members += [ preve ] makeparts.Members += [ copyVelo ] makeparts.Members += [ MyVeloFit ] makeparts.Members += [ MakeVeloProtos ] #### some python magic to maek this appear like a "Selection" return GSWrapper(name="For%sWrappedVeloTrackingFor"%self.name, sequencer=makeparts, output=self.VeloProtoOutputLocation, requiredSelections = prefilter)
def trackingDownPreFilter(name, prefilter): #Jpsi_already_there = LoKi__VoidFilter("Jpsi_already_there") #Jpsi_already_there.Code = "1 <= CONTAINS('Rec/Track/Downstream')" #Jpsi_not_yet_there = LoKi__VoidFilter("Jpsi_not_yet_there") #Jpsi_not_yet_there.Code = "1 > CONTAINS('Rec/Track/Downstream')" TrackToDST( "DownTrackToDST").TracksInContainer = "Rec/Downstream/FittedTracks" #TrackSys().setProp('SpecialData', ['earlyData']) jpsidotracking = GaudiSequencer("DownTrackingFor" + name) #Add seed tracking jpsidotracking.Members += [PatSeeding("PatSeeding")] PatAlgConf.SeedingConf().configureAlg() #Add Seed Fit jpsidotracking.Members += [GaudiSequencer("TrackSeedFitSeq")] #AddPatDownstream downstreamTracking = PatDownstream() downstreamTracking.OutputLocation = 'Rec/Downstream/Tracks' jpsidotracking.Members += [downstreamTracking] #AddDownstreamFitSeq jpsidotracking.Members += [TrackStateInitAlg("InitSeedDownstream")] TrackStateInitAlg( "InitSeedDownstream").TrackLocation = "Rec/Downstream/Tracks" downstreamFit = ConfiguredFitDownstream() downstreamFit.TracksInContainer = 'Rec/Downstream/Tracks' downstreamFit.TracksOutContainer = 'Rec/Downstream/FittedTracks' jpsidotracking.Members += [downstreamFit] jpsidotracking.Members += [TrackToDST("DownTrackToDST")] #alg = GaudiSequencer("JpsitracksFor" + name, # Members = [Jpsi_already_there, # jpsidotracking], # ModeOR = True, # ShortCircuit = True) return GSWrapper(name="WrappedDownstreamTracking", sequencer=jpsidotracking, output='Rec/Downstream/FittedTracks', requiredSelections=[prefilter])
def configureFastKalmanFit(self, init=TrackStateInitAlg("VeloOnlyInitAlg")): '''Configure the fast Kalman fit to fit the Velo tracks for the PV''' # fit with fast Kalman filter init.TrackLocation = "Rec/Track/FittedHLT1VeloTracks" init.addTool(TrackStateInitTool, name="StateInitTool") init.StateInitTool.VeloFitterName = "FastVeloFitLHCbIDs" init.StateInitTool.addTool(TrackMasterExtrapolator, "Extrapolator") init.StateInitTool.Extrapolator.addTool(SimplifiedMaterialLocator, name="MaterialLocator") init.StateInitTool.addTool(FastVeloFitLHCbIDs, name="FastVeloFitLHCbIDs") init.StateInitTool.FastVeloFitLHCbIDs.UseKalmanFit = True
def fittedVelo(inputTracks, outputTracks, name='VeloOnlyFitterAlg'): from Configurables import TrackEventFitter, TrackInitFit from Configurables import TrackStateInitTool, TrackMasterFitter if HltRecoConf().getProp("FastFitVelo"): # For now use the save option where Velo tracks are copied and the original ones are not changed from Configurables import TrackStateInitAlg, TrackStateInitTool,FastVeloFitLHCbIDs from Configurables import TrackContainerCopy copy = TrackContainerCopy(name+"CopyVelo") copy.inputLocations = [ inputTracks ] copy.outputLocation = outputTracks init = TrackStateInitAlg(name) init.TrackLocation = copy.outputLocation init.addTool(TrackStateInitTool, name="StateInitTool") init.StateInitTool.VeloFitterName = "FastVeloFitLHCbIDs" init.StateInitTool.addTool(TrackMasterExtrapolator, "Extrapolator") init.StateInitTool.Extrapolator.addTool(SimplifiedMaterialLocator, name = "MaterialLocator") init.StateInitTool.addTool(FastVeloFitLHCbIDs,name="FastVeloFitLHCbIDs") init.StateInitTool.FastVeloFitLHCbIDs.UseKalmanFit = True return [copy,init] else: fa = TrackEventFitter(name) fa.TracksInContainer = inputTracks fa.TracksOutContainer = outputTracks fa.Fitter = "TrackInitFit/Fit" fa.addTool(TrackInitFit, "Fit") fa.Fit.Init = "TrackStateInitTool/VeloOnlyStateInit" fa.Fit.addTool(TrackStateInitTool, "VeloOnlyStateInit") fa.Fit.VeloOnlyStateInit.VeloFitterName = "FastVeloFitLHCbIDs" fa.Fit.VeloOnlyStateInit.addTool(TrackMasterExtrapolator, "Extrapolator") fa.Fit.VeloOnlyStateInit.Extrapolator.addTool(SimplifiedMaterialLocator, name = "MaterialLocator") fa.Fit.Fit = "TrackMasterFitter/Fit" fa.Fit.addTool(TrackMasterFitter, name = "Fit") from TrackFitter.ConfiguredFitters import ConfiguredForwardFitter fitter = ConfiguredForwardFitter(fa.Fit.Fit) return [ fa ]
def trackingDownPreFilter(name, prefilter): #Test code for debugging #Jpsi_already_there = LoKi__VoidFilter("Jpsi_already_there") #Jpsi_already_there.Code = "1 <= CONTAINS('Rec/Track/Downstream')" #Jpsi_not_yet_there = LoKi__VoidFilter("Jpsi_not_yet_there") #Jpsi_not_yet_there.Code = "1 > CONTAINS('Rec/Track/Downstream')" TrackToDST( "DownTrackToDST").TracksInContainer = "Rec/Downstream/FittedTracks" jpsidotracking = GaudiSequencer("DownTrackingFor" + name) #Add seed tracking jpsidotracking.Members += [PatSeeding("PatSeeding")] PatAlgConf.SeedingConf().configureAlg() #Add Seed Fit jpsidotracking.Members += [GaudiSequencer("TrackSeedFitSeq")] #AddPatDownstream downstreamTracking = PatDownstream() downstreamTracking.OutputLocation = 'Rec/Downstream/Tracks' jpsidotracking.Members += [downstreamTracking] #AddDownstreamFitSeq jpsidotracking.Members += [TrackStateInitAlg("InitSeedDownstream")] TrackStateInitAlg( "InitSeedDownstream").TrackLocation = "Rec/Downstream/Tracks" downstreamFit = ConfiguredFitDownstream() downstreamFit.TracksInContainer = 'Rec/Downstream/Tracks' downstreamFit.TracksOutContainer = 'Rec/Downstream/FittedTracks' jpsidotracking.Members += [downstreamFit] jpsidotracking.Members += [TrackToDST("DownTrackToDST")] return GSWrapper(name="WrappedDownstreamTracking", sequencer=jpsidotracking, output='Rec/Downstream/FittedTracks', requiredSelections=[prefilter])
def configuredFitAndHitAdderSequence(Name, InputLocation, OutputLocation): from TrackFitter.ConfiguredFitters import ConfiguredEventFitter from Configurables import (TrackHitAdder, TrackContainerCopy, TrackSelector, GaudiSequencer, TrackStateInitAlg) # create the sequence if isinstance(Name, GaudiSequencer): seq = Sequence Name = seq.name() Name.replace('Sequence', '') Name.replace('Seq', '') else: seq = GaudiSequencer(Name + 'Seq') # I am lazy: use the DOD to get the decoded clusters #importOption( "$STDOPTS/DecodeRawEvent.py" ) # now setup the fitters seq.Members += [ TrackStateInitAlg(Name + 'FitInit', TrackLocation=InputLocation), ConfiguredEventFitter(Name + 'FitBeforeHitAdder', TracksInContainer=InputLocation), TrackHitAdder(Name + 'HitAdder', TrackLocation=InputLocation), ConfiguredEventFitter(Name + 'FitAfterHitAdder', TracksInContainer=InputLocation) ] tracksel = TrackContainerCopy(Name + 'CopyAndSelect', inputLocations=[InputLocation], outputLocation=OutputLocation, Selector=TrackSelector()) # also apply a selection tracksel.Selector.MaxChi2Cut = 5 tracksel.Selector.MaxChi2PerDoFMatch = 5 tracksel.Selector.MaxChi2PerDoFVelo = 5 tracksel.Selector.MaxChi2PerDoFDownstream = 5 seq.Members.append(tracksel) return seq
def RecoTrackingHLT1(exclude=[], simplifiedGeometryFit=True, liteClustersFit=True): '''Function that defines the pattern recognition algorithms for the HLT1 sequence of the Run 2 offline tracking''' ## Start TransportSvc, needed by track fit ApplicationMgr().ExtSvc.append("TransportSvc") ## -------------------------------------------------------------------- ## Pattern Recognition and Fitting ## -------------------------------------------------------------------- # Which algs to run ? trackAlgs = TrackSys().getProp("TrackPatRecAlgorithms") # Which data type is it? dataType = TrackSys().getProp("DataType") # Decode the RAW banks ExcludedLayers = TrackSys().getProp("ExcludedLayers") DecodeTracking(trackAlgs, ExcludedLayers) from Configurables import STOfflinePosition IT = STOfflinePosition('ITClusterPosition') IT.DetType = "IT" TT = STOfflinePosition('TTClusterPosition') TT.DetType = "TT" from STTools import STOfflineConf STOfflineConf.DefaultConf().configureTools() ## Make sure the default extrapolator and interpolator use simplified material from Configurables import TrackMasterExtrapolator, TrackInterpolator, SimplifiedMaterialLocator, DetailedMaterialLocator if TrackSys().simplifiedGeometry() and ('SimpleGeom' not in exclude): TrackMasterExtrapolator().MaterialLocator = 'SimplifiedMaterialLocator' TrackInterpolator().addTool(TrackMasterExtrapolator( MaterialLocator='SimplifiedMaterialLocator'), name='Extrapolator') ### This configures public tools to use the new multiple scattering description without the log term from Configurables import StateThickMSCorrectionTool me = TrackMasterExtrapolator() me.addTool(DetailedMaterialLocator(), name="MaterialLocator") me.MaterialLocator.addTool(StateThickMSCorrectionTool, name="StateMSCorrectionTool") me.MaterialLocator.StateMSCorrectionTool.UseRossiAndGreisen = True ti = TrackInterpolator() ti.addTool(me) from Configurables import TrackStateProvider tsp = TrackStateProvider() tsp.addTool(TrackInterpolator, name="Interpolator") tsp.addTool(TrackMasterExtrapolator, name="Extrapolator") tsp.Interpolator.addTool(TrackMasterExtrapolator, name='Extrapolator') if simplifiedGeometryFit or (TrackSys().simplifiedGeometry() and ('SimpleGeom' not in exclude)): tsp.Extrapolator.addTool(SimplifiedMaterialLocator, name="MaterialLocator") tsp.Interpolator.Extrapolator.addTool(SimplifiedMaterialLocator, name="MaterialLocator") else: tsp.Extrapolator.addTool(DetailedMaterialLocator, name="MaterialLocator") tsp.Interpolator.Extrapolator.addTool(DetailedMaterialLocator, name="MaterialLocator") tsp.Extrapolator.MaterialLocator.addTool(StateThickMSCorrectionTool, name="StateMSCorrectionTool") tsp.Extrapolator.MaterialLocator.StateMSCorrectionTool.UseRossiAndGreisen = True tsp.Interpolator.Extrapolator.MaterialLocator.addTool( StateThickMSCorrectionTool, name="StateMSCorrectionTool") tsp.Interpolator.Extrapolator.MaterialLocator.StateMSCorrectionTool.UseRossiAndGreisen = True ### ## Velo tracking ## Why is Velo not in the tracking sequence? if "FastVelo" in trackAlgs: from Configurables import FastVeloTracking GaudiSequencer("RecoVELOSeq").Members += [ FastVeloTracking("FastVeloTracking") ] if TrackSys().timing(): FastVeloTracking().TimingMeasurement = True ## Tracking sequence from Configurables import ProcessPhase track = ProcessPhase("TrackHLT1") GaudiSequencer("RecoTrHLT1Seq").Members += [track] from Configurables import MagneticFieldSvc if TrackSys().fieldOff(): MagneticFieldSvc().ForcedSignedCurrentScaling = 0. if "noDrifttimes" in TrackSys().getProp("ExpertTracking"): from Configurables import (Tf__OTHitCreator) Tf__OTHitCreator("OTHitCreator").NoDriftTimes = True # Get the fitters from TrackFitter.ConfiguredFitters import ConfiguredFit, ConfiguredFitSeed, ConfiguredMasterFitter # Clone killer tracklists = [] # Is this standard sequence? stdSeq = "fastSequence" not in TrackSys().getProp("ExpertTracking") ## Velo-TT pattern if "VeloTT" in trackAlgs: track.DetectorList += ["VeloTTPat"] from Configurables import PatVeloTTHybrid GaudiSequencer("TrackHLT1VeloTTPatSeq").Members += [ PatVeloTTHybrid("PatVeloTTHybrid") ] from PatVeloTT import PatVeloTTAlgConf PatVeloTTAlgConf.PatVeloTTConf().configureAlgRun2HLT1() if TrackSys().timing(): PatVeloTTHybrid("PatVeloTTHybrid").TimingMeasurement = True tracklists += ["Rec/Track/VeloTT"] ## Forward pattern if "ForwardHLT1" in trackAlgs: if "VeloTT" not in trackAlgs: raise RuntimeError("Cannot run HLT1 forward without VeloTT") track.DetectorList += ["ForwardPatHLT1"] from Configurables import PatForward, PatForwardTool GaudiSequencer("TrackHLT1ForwardPatHLT1Seq").Members += [ PatForward("PatForwardHLT1") ] # should be replaced by more 'global' tracking configuration from PatAlgorithms import PatAlgConf PatAlgConf.ForwardConf().configureAlgRun2HLT1() if TrackSys().timing(): PatForward("PatForwardHLT1").TimingMeasurement = True tracklists += ["Rec/Track/ForwardHLT1"] ## Fitting all HLT1 tracks track.DetectorList += ["FitHLT1"] from Configurables import TrackEventFitter, TrackInitFit, TrackStateInitTool, TrackStateInitAlg, TrackMasterExtrapolator, TrackMasterFitter from Configurables import SimplifiedMaterialLocator, DetailedMaterialLocator from Configurables import TrackContainerCopy ###### ### Fitter for Velo tracks ###### if "FastVelo" in trackAlgs: if "VeloForwardKalmanHLT1" in TrackSys().getProp("ExpertTracking"): # This is the option for the 2015 early measurements veloFitter = TrackEventFitter('VeloOnlyFitterAlg') veloFitter.TracksInContainer = "Rec/Track/Velo" veloFitter.TracksOutContainer = "Rec/Track/FittedHLT1VeloTracks" veloFitter.Fitter = "TrackInitFit/Fit" veloFitter.addTool(TrackInitFit, "Fit") veloFitter.Fit.Init = "TrackStateInitTool/VeloOnlyStateInit" veloFitter.Fit.addTool(TrackStateInitTool, "VeloOnlyStateInit") veloFitter.Fit.VeloOnlyStateInit.VeloFitterName = "FastVeloFitLHCbIDs" veloFitter.Fit.VeloOnlyStateInit.addTool(TrackMasterExtrapolator, "Extrapolator") if (simplifiedGeometryFit): veloFitter.Fit.VeloOnlyStateInit.Extrapolator.addTool( SimplifiedMaterialLocator, name="MaterialLocator") else: veloFitter.Fit.VeloOnlyStateInit.Extrapolator.addTool( DetailedMaterialLocator, name="MaterialLocator") veloFitter.Fit.Fit = "TrackMasterFitter/Fit" veloFitter.Fit.addTool(TrackMasterFitter, name="Fit") from TrackFitter.ConfiguredFitters import ConfiguredForwardFitter ConfiguredForwardFitter(veloFitter.Fit.Fit, LiteClusters=liteClustersFit) GaudiSequencer("TrackHLT1FitHLT1Seq").Members += [veloFitter] else: # and this is the option for after the early measurements # copy tracks from pat reco output container to a new one copyVeloTracks = TrackContainerCopy("CopyVeloTracks") copyVeloTracks.inputLocations = ["Rec/Track/Velo"] copyVeloTracks.outputLocation = "Rec/Track/FittedHLT1VeloTracks" from FastVelo import FastVeloAlgConf stateInit = TrackStateInitAlg('VeloOnlyInitAlg') FastVeloAlgConf.FastVeloKalmanConf().configureFastKalmanFit( init=stateInit) GaudiSequencer("TrackHLT1FitHLT1Seq").Members += [ copyVeloTracks, stateInit ] ###### ### Fitter for Forward tracks ### Need to be careful: This is all a little fragile, so if you plan to change something, check that everything configures the way you expect ### The Extrapolator for the StateInitTool does not use material corrections, so don't need to explicitely add the StateThickMSCorrectionTool ###### if "ForwardHLT1" in trackAlgs: fwdFitter = TrackEventFitter('ForwardHLT1FitterAlg') fwdFitter.TracksInContainer = "Rec/Track/ForwardHLT1" fwdFitter.TracksOutContainer = "Rec/Track/FittedHLT1ForwardTracks" # Keep only good tracks, this cut should be aligned with the one in the TrackBestTrackCreator fwdFitter.MaxChi2DoF = 4.0 fwdFitter.Fitter = "TrackInitFit/Fit" fwdFitter.addTool(TrackInitFit, "Fit") fwdFitter.Fit.Init = "TrackStateInitTool/FwdStateInit" fwdFitter.Fit.addTool(TrackStateInitTool, "FwdStateInit") fwdFitter.Fit.FwdStateInit.addTool(TrackMasterExtrapolator, "Extrapolator") fwdFitter.Fit.FwdStateInit.UseFastMomentumEstimate = True fwdFitter.Fit.FwdStateInit.VeloFitterName = "FastVeloFitLHCbIDs" if (simplifiedGeometryFit): fwdFitter.Fit.FwdStateInit.Extrapolator.addTool( SimplifiedMaterialLocator, name="MaterialLocator") else: fwdFitter.Fit.FwdStateInit.Extrapolator.addTool( DetailedMaterialLocator, name="MaterialLocator") fwdFitter.Fit.Fit = "TrackMasterFitter/Fit" fwdFitter.Fit.addTool(TrackMasterFitter, name="Fit") from TrackFitter.ConfiguredFitters import ConfiguredMasterFitter ConfiguredMasterFitter(fwdFitter.Fit.Fit, SimplifiedGeometry=simplifiedGeometryFit, LiteClusters=liteClustersFit, MSRossiAndGreisen=True) GaudiSequencer("TrackHLT1FitHLT1Seq").Members += [fwdFitter]
from Configurables import ApplicationMgr, NTupleSvc, GaudiSequencer from Configurables import (IdealTracksCreator, TrackStateInitAlg, TrackBestTrackCreator, PrTrackAssociator, Velo__VeloTrackMonitorNT, VeloClusterPosition, TrackEventFitter) from TrackFitter.ConfiguredFitters import ConfiguredFit importOptions("$ASSOCIATORSROOT/options/MCParticleToMCHit.py") # set the event fitter to use ideal tracks (no outlier rejections) TrackEventFitter('FitVelo').Fitter.MaxNumberOutliers = 0 TrackEventFitter('TrackRefitter').Fitter.MaxNumberOutliers = 0 TrackEventFitter().TracksInContainer = 'MC/Track/Ideal' # set the Velo and tracking monitor sequences to reconstruct ideal tracks GaudiSequencer("MoniVELOSeq").Members = [ TrackStateInitAlg("InitIdealFit", TrackLocation="MC/Track/Ideal"), ConfiguredFit("IdealFit", "MC/Track/Ideal"), Velo__VeloTrackMonitorNT() ] GaudiSequencer("RecoTrSeq").Members += [ IdealTracksCreator('IdealTracksCreator', TrueStatesAtMCHits=True, TrackTypes=[3]) ] TrackBestTrackCreator().TracksInContainers = ['MC/Track/Ideal'] # set the Velo tuple monitoring to the ideal track container as input Velo__VeloTrackMonitorNT().RunWithMC = False Velo__VeloTrackMonitorNT().TracksInContainer = 'MC/Track/Ideal' PrTrackAssociator().RootOfContainers = 'MC/Track/Ideal' VeloClusterPosition().CalculateExactProjAngle = 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 RecoTracking(exclude=[]): '''What used to be in the options file, moved here''' ## Start TransportSvc, needed by track fit ApplicationMgr().ExtSvc.append("TransportSvc") ## -------------------------------------------------------------------- ## Pattern Recognition and Fitting ## -------------------------------------------------------------------- # Which algs to run ? trackAlgs = TrackSys().getProp("TrackPatRecAlgorithms") # Which data type is it? dataType = TrackSys().getProp("DataType") # Decode the RAW banks DecodeTracking(trackAlgs) from Configurables import STOfflinePosition IT = STOfflinePosition('ITClusterPosition') IT.DetType = "IT" TT = STOfflinePosition('TTClusterPosition') TT.DetType = "TT" from STTools import STOfflineConf STOfflineConf.DefaultConf().configureTools() #importOptions( "$STTOOLSROOT/options/Brunel.opts" ) ## Velo tracking if "FastVelo" in trackAlgs: from Configurables import FastVeloTracking GaudiSequencer("RecoVELOSeq").Members += [FastVeloTracking()] if TrackSys().timing(): FastVeloTracking().TimingMeasurement = True if "Velo" in trackAlgs: from Configurables import Tf__PatVeloGeneralTracking if TrackSys().veloOpen(): if TrackSys().beamGas(): from Configurables import Tf__PatVeloGeneric GaudiSequencer("RecoVELOSeq").Members += [ Tf__PatVeloGeneric("PatVeloGeneric"), Tf__PatVeloGeneralTracking("PatVeloGeneralTracking") ] else: from Configurables import Tf__PatVeloTrackTool GaudiSequencer("RecoVELOSeq").Members += [ Tf__PatVeloGeneralTracking("PatVeloGeneralTracking") ] Tf__PatVeloGeneralTracking( "PatVeloGeneralTracking").PointErrorMin = 2 * mm Tf__PatVeloGeneralTracking("PatVeloGeneralTracking").addTool( Tf__PatVeloTrackTool("PatVeloTrackTool")) Tf__PatVeloTrackTool("PatVeloTrackTool").highChargeFract = 0.5 if TrackSys().timing(): Tf__PatVeloGeneralTracking( "PatVeloGeneralTracking").TimingMeasurement = True else: from Configurables import (Tf__PatVeloRTracking, Tf__PatVeloSpaceTool, Tf__PatVeloSpaceTracking) GaudiSequencer("RecoVELOSeq").Members += [ Tf__PatVeloRTracking("PatVeloRTracking"), Tf__PatVeloSpaceTracking("PatVeloSpaceTracking"), Tf__PatVeloGeneralTracking("PatVeloGeneralTracking") ] Tf__PatVeloSpaceTracking("PatVeloSpaceTracking").addTool( Tf__PatVeloSpaceTool(), name="PatVeloSpaceTool") Tf__PatVeloSpaceTracking("PatVeloSpaceTracking" ).PatVeloSpaceTool.MarkClustersUsed = True if TrackSys().timing(): Tf__PatVeloSpaceTracking( "PatVeloSpaceTracking").TimingMeasurement = True Tf__PatVeloRTracking( "PatVeloRTracking").TimingMeasurement = True Tf__PatVeloGeneralTracking( "PatVeloGeneralTracking").TimingMeasurement = True ## Make sure the default extrapolator and interpolator use simplified material if TrackSys().simplifiedGeometry() and ('SimpleGeom' not in exclude): from Configurables import TrackMasterExtrapolator, TrackInterpolator TrackMasterExtrapolator().MaterialLocator = 'SimplifiedMaterialLocator' TrackInterpolator().addTool(TrackMasterExtrapolator( MaterialLocator='SimplifiedMaterialLocator'), name='Extrapolator') ## Tracking sequence from Configurables import ProcessPhase track = ProcessPhase("Track") GaudiSequencer("RecoTrSeq").Members += [track] from Configurables import MagneticFieldSvc if TrackSys().fieldOff(): MagneticFieldSvc().ForcedSignedCurrentScaling = 0. if "noDrifttimes" in TrackSys().getProp("ExpertTracking"): from Configurables import (Tf__OTHitCreator) Tf__OTHitCreator("OTHitCreator").NoDriftTimes = True # Get the fitters from TrackFitter.ConfiguredFitters import ConfiguredFit, ConfiguredFitSeed, ConfiguredMasterFitter # Clone killer tracklists = [] # Is this standard sequence? stdSeq = "fastSequence" not in TrackSys().getProp("ExpertTracking") # TrackMatching not supported anymore, raise error if "Match" in trackAlgs: raise RuntimeError( "TrackMatching not supported anymore. If you think this is wrong, report to [email protected]" ) ## Forward pattern if "Forward" in trackAlgs: track.DetectorList += ["ForwardPat"] from Configurables import PatForward GaudiSequencer("TrackForwardPatSeq").Members += [ PatForward("PatForward") ] from PatAlgorithms import PatAlgConf PatAlgConf.ForwardConf().configureAlg() if TrackSys().timing(): PatForward("PatForward").TimingMeasurement = True tracklists += ["Rec/Track/Forward"] ## Seed pattern if "TsaSeed" in trackAlgs and "PatSeed" in trackAlgs: raise RuntimeError("Cannot run both Tsa and Pat Seeding at once") if "TsaSeed" in trackAlgs: track.DetectorList += ["SeedPat"] from Configurables import Tf__Tsa__Seed, Tf__Tsa__SeedTrackCnv GaudiSequencer("TrackSeedPatSeq").Members += [ Tf__Tsa__Seed("TsaSeed"), Tf__Tsa__SeedTrackCnv("TsaSeedTrackCnv") ] from TsaAlgorithms import TsaAlgConf TsaAlgConf.TsaSeedConf().configureAlg() if TrackSys().timing(): Tf__Tsa__Seed("TsaSeed").TimingMeasurement = True if "PatSeed" in trackAlgs: track.DetectorList += ["SeedPat"] from Configurables import PatSeeding GaudiSequencer("TrackSeedPatSeq").Members += [PatSeeding("PatSeeding")] from PatAlgorithms import PatAlgConf PatAlgConf.SeedingConf().configureAlg() if TrackSys().timing(): PatSeeding("PatSeeding").TimingMeasurement = True if TrackSys().cosmics(): from PatAlgorithms import PatAlgConf PatAlgConf.CosmicConf().configureAlg() if "TsaSeed" in trackAlgs or "PatSeed" in trackAlgs: tracklists += ["Rec/Track/Seed"] # TrackMatching not supported anymore, comment for the moment in case anything breaks #if "Match" in trackAlgs : # Fit now #track.DetectorList += [ "SeedFit" ] ## Seed fit initialization #from Configurables import TrackStateInitAlg, TrackStateInitTool #initSeedFit = TrackStateInitAlg("InitSeedFit", # TrackLocation = "Rec/Track/Seed") #GaudiSequencer("TrackSeedFitSeq").Members += [initSeedFit] #if "FastVelo" in trackAlgs : # initSeedFit.StateInitTool.VeloFitterName = "FastVeloFitLHCbIDs" # Use small ErrorQoP fitter, needed for Match #GaudiSequencer("TrackSeedFitSeq").Members += [ConfiguredFitSeed()] # TrackMatching not supported anymore, comment for the moment in case anything breaks ## Match #if "Match" in trackAlgs and "PatMatch" in trackAlgs : # raise RuntimeError("Cannot run both TrackMatching and PatMatch at once") #if "Match" in trackAlgs : # track.DetectorList += [ "MatchPat" ] # from Configurables import TrackMatchVeloSeed # GaudiSequencer("TrackMatchPatSeq").Members += [ TrackMatchVeloSeed("TrackMatch") ] # from TrackMatching import TrackMatchConf # TrackMatchConf.MatchingConf().configureAlg() # TrackMatchVeloSeed("TrackMatch").LikCut = -99999. # if TrackSys().timing() : # TrackMatchVeloSeed("TrackMatch").TimingMeasurement = True; if "PatMatch" in trackAlgs: track.DetectorList += ["MatchPat"] from Configurables import PatMatch GaudiSequencer("TrackMatchPatSeq").Members += [PatMatch("PatMatch")] if "Match" in trackAlgs or "PatMatch" in trackAlgs: tracklists += ["Rec/Track/Match"] ## Downstream if "Downstream" in trackAlgs: track.DetectorList += ["DownstreamPat"] from Configurables import PatDownstream GaudiSequencer("TrackDownstreamPatSeq").Members += [PatDownstream()] tracklists += ["Rec/Track/Downstream"] from PatAlgorithms import PatAlgConf #PatAlgConf.DownstreamConf().configureAlg() if TrackSys().timing(): PatDownstream("PatDownstream").TimingMeasurement = True ## Velo-TT pattern if "VeloTT" in trackAlgs: track.DetectorList += ["VeloTTPat"] # from 2015 on, 'VeloTTHybrid' is used (as in the HLT) # on python configuration is used if dataType is "2015": from Configurables import PatVeloTTHybrid GaudiSequencer("TrackVeloTTPatSeq").Members += [ PatVeloTTHybrid("PatVeloTTHybrid") ] if TrackSys().timing(): PatVeloTTHybrid("PatVeloTTHybrid").TimingMeasurement = True # for everything older, the old 'PatVeloTT' is run else: from Configurables import PatVeloTT GaudiSequencer("TrackVeloTTPatSeq").Members += [ PatVeloTT("PatVeloTT") ] from PatVeloTT.PatVeloTTAlgConf import PatVeloTTConf PatVeloTTConf().configureAlg() if TrackSys().timing(): PatVeloTT("PatVeloTT").TimingMeasurement = True tracklists += ["Rec/Track/VeloTT"] ### Clean clone and fit track.DetectorList += ["Fit"] if TrackSys().getProp("OldCloneKiller"): from Configurables import TrackEventCloneKiller, TrackStateInitAlg, TrackContainerCopy cloneKiller = TrackEventCloneKiller() cloneKiller.TracksInContainers = tracklists cloneKiller.TracksOutContainer = "Rec/Track/AllBest" GaudiSequencer("TrackFitSeq").Members += [cloneKiller] stateInitAlg = TrackStateInitAlg("InitBestFit") stateInitAlg.TrackLocation = "Rec/Track/AllBest" if "FastVelo" in trackAlgs: stateInitAlg.StateInitTool.VeloFitterName = "FastVeloFitLHCbIDs" GaudiSequencer("TrackFitSeq").Members += [stateInitAlg] GaudiSequencer("TrackFitSeq").Members += [ ConfiguredFit("FitBest", "Rec/Track/AllBest") ] copyBest = TrackContainerCopy("CopyBest") copyBest.inputLocations = ["Rec/Track/AllBest"] GaudiSequencer("TrackFitSeq").Members += [copyBest] ## Velo fitting if "Velo" in trackAlgs or "FastVelo" in trackAlgs: ## Prepare the velo tracks for the fit track.DetectorList += ["VeloFit"] from Configurables import TrackPrepareVelo GaudiSequencer("TrackVeloFitSeq").Members += [TrackPrepareVelo()] ## Fit the velo tracks GaudiSequencer("TrackVeloFitSeq").Members += [ ConfiguredFit("FitVelo", "Rec/Track/PreparedVelo") ] ## copy the velo tracks to the "best" container copyVelo = TrackContainerCopy("CopyVelo") copyVelo.inputLocations = ["Rec/Track/PreparedVelo"] GaudiSequencer("TrackVeloFitSeq").Members += [copyVelo] else: # complete the list of track lists if "Velo" in trackAlgs or "FastVelo" in trackAlgs: tracklists += ["Rec/Track/Velo"] # create the best track creator from Configurables import TrackBestTrackCreator bestTrackCreator = TrackBestTrackCreator(TracksInContainers=tracklists) # configure its fitter and stateinittool ConfiguredMasterFitter(bestTrackCreator.Fitter) if "FastVelo" in trackAlgs: bestTrackCreator.StateInitTool.VeloFitterName = "FastVeloFitLHCbIDs" # add to the sequence GaudiSequencer("TrackFitSeq").Members.append(bestTrackCreator) ### Change dEdx correction for simulated data if TrackSys().getProp("Simulation"): from Configurables import StateDetailedBetheBlochEnergyCorrectionTool, DetailedMaterialLocator if TrackSys().getProp("OldCloneKiller"): from Configurables import TrackEventFitter, TrackMasterFitter fitBest = TrackEventFitter("FitBest") fitBest.Fitter.MaterialLocator.addTool( StateDetailedBetheBlochEnergyCorrectionTool("GeneralDedxTool")) fitBest.Fitter.MaterialLocator.GeneralDedxTool.EnergyLossFactor = 0.76 else: from Configurables import TrackBestTrackCreator fitter = TrackBestTrackCreator().Fitter fitter.MaterialLocator.addTool( StateDetailedBetheBlochEnergyCorrectionTool("GeneralDedxTool")) fitter.MaterialLocator.GeneralDedxTool.EnergyLossFactor = 0.76 ## Extra track information sequence extraInfos = TrackSys().getProp("TrackExtraInfoAlgorithms") if len(extraInfos) > 0: track.DetectorList += ["AddExtraInfo"] ## Clone finding and flagging if "CloneFlagging" in extraInfos: from Configurables import TrackBuildCloneTable, TrackCloneCleaner trackClones = GaudiSequencer("TrackClonesSeq") GaudiSequencer("TrackAddExtraInfoSeq").Members += [trackClones] if TrackSys().timing(): trackClones.MeasureTime = True cloneTable = TrackBuildCloneTable("FindTrackClones") cloneTable.maxDz = 500 * mm cloneTable.zStates = [0 * mm, 990 * mm, 9450 * mm] cloneTable.klCut = 5e3 cloneCleaner = TrackCloneCleaner("FlagTrackClones") cloneCleaner.CloneCut = 5e3 trackClones.Members += [cloneTable, cloneCleaner] ## Add expected hit information #if "ExpectedHits" in extraInfos : # GaudiSequencer("TrackAddExtraInfoSeq").Members += [ TrackComputeExpectedHits() ] ## Add the likelihood information if "TrackLikelihood" in extraInfos and ('TrackLikelihood' not in exclude): from Configurables import TrackAddLikelihood, TrackLikelihood trackAddLikelihood = TrackAddLikelihood() trackAddLikelihood.addTool(TrackLikelihood, name="TrackMatching_likTool") trackAddLikelihood.TrackMatching_likTool.otEff = 0.9 GaudiSequencer("TrackAddExtraInfoSeq").Members += [ trackAddLikelihood ] ## ghost probability using a Neural Net if "GhostProbability" in extraInfos: from Configurables import TrackAddNNGhostId, TrackNNGhostId nn = TrackAddNNGhostId() GaudiSequencer("TrackAddExtraInfoSeq").Members += [nn] track.DetectorList += ["EraseExtraInformation"] from Configurables import TrackEraseExtraInfo GaudiSequencer("TrackEraseExtraInformationSeq").Members += [ TrackEraseExtraInfo() ] ## Muon alignment tracks if "MuonAlign" in trackAlgs: from Configurables import TrackEventFitter, AlignMuonRec track.DetectorList += ["MuonRec"] GaudiSequencer("TrackMuonRecSeq").Members += [ AlignMuonRec("AlignMuonRec"), TrackEventFitter("MuonTrackFitter") ] importOptions("$TRACKSYSROOT/options/AlignMuonRec.opts") if TrackSys().fieldOff(): AlignMuonRec("AlignMuonRec").BField = False importOptions("$STDOPTS/DstContentMuonAlign.opts")