def __init__(self, name, config): LineBuilder.__init__(self, name, config) ####################################################################### ### ### ### VELO BASED VERTEXING SEQUENCE ### ### ### ####################################################################### bestTracks = AutomaticData("Rec/Track/Best") withVeloTracksForVertexing = bestTracks if self.configurationParameter("VeloGEC")["Apply"]: from GaudiConfUtils.ConfigurableGenerators import VeloEventShapeCutsS20p3 veloGEC = VeloEventShapeCutsS20p3() self.validatedSetProps("VeloGEC", DisplVerticesLinesConf.veloGECCuts, veloGEC) withVeloTracksForVertexing = PassThroughSelection( "%sVeloGEC" % self.name(), RequiredSelection=withVeloTracksForVertexing, Algorithm=veloGEC) if self.configurationParameter("FilterVelo")["Apply"]: from GaudiConfUtils.ConfigurableGenerators import SelectVeloTracksNotFromPVS20p3 veloWithIP = SelectVeloTracksNotFromPVS20p3() self.validatedSetProps("FilterVelo", DisplVerticesLinesConf.veloWithIPCuts, veloWithIP) withVeloTracksForVertexing = Selection( "%sVeloFilteredTracks" % self.name(), RequiredSelections=[withVeloTracksForVertexing], Algorithm=veloWithIP) # Displaced Vertex reconstruction with best tracks (dominated by those with a Velo segment) from Configurables import PatPV3D, PVOfflineTool, PVSeed3DTool, LSAdaptPV3DFitter, LSAdaptPVFitter withVeloVertexAlg = PatPV3D("%sWithVeloVertexAlg" % self.name()) withVeloVertexFinder = addPrivateToolAndGet(withVeloVertexAlg, PVOfflineTool) withVeloVertexFinder.PVsChi2Separation = 0 withVeloVertexFinder.PVsChi2SeparationLowMult = 0 withVeloSeeder = addPrivateToolAndGet(withVeloVertexFinder, PVSeed3DTool) withVeloVertexFinder.PVSeedingName = withVeloSeeder.getTitleName() withVeloSeeder.MinCloseTracks = 3 withVeloFitter = addPrivateToolAndGet(withVeloVertexFinder, LSAdaptPV3DFitter) withVeloVertexFinder.PVFitterName = withVeloFitter.getTitleName() withVeloFitter.MinTracks = 4 withVeloVertexing = SelectionPatPV3DWrapper( "%sWithVeloVertexing" % self.name(), withVeloVertexAlg, RequiredSelections=[withVeloTracksForVertexing]) # Make Particles out of the RecVertices from GaudiConfUtils.ConfigurableGenerators import LLParticlesFromRecVertices rv2pWithVelo = LLParticlesFromRecVertices( VerticesFromVeloOnly=False, RequireUpstreamPV=False, WriteP2PVRelations=False, ForceP2PVBuild=False, VeloProtoParticlesLocation="Phys/%s/VeloProtoP" % self.name()) self.validatedSetProps( "RV2PWithVelo", DisplVerticesLinesConf.recoCuts + DisplVerticesLinesConf.singleCuts, rv2pWithVelo) withVeloCandidates = Selection("%sWithVeloCandidates" % self.name(), RequiredSelections=[withVeloVertexing], Algorithm=rv2pWithVelo, InputDataSetter="RecVertexLocations") ####################################################################### ### ### ### DOWNSTREAM VERTEXING SEQUENCE ### ### ### ####################################################################### from GaudiConfUtils.ConfigurableGenerators import CopyDownstreamTracks downTracks = Selection("%sDownstreamTracks" % self.name(), RequiredSelections=[bestTracks], Algorithm=CopyDownstreamTracks()) # Displaced Vertex reconstruction from downstream tracks downVertexAlg = PatPV3D("%sDownVertexAlg" % self.name()) downVertexFinder = addPrivateToolAndGet(downVertexAlg, PVOfflineTool) downVertexFinder.RequireVelo = False downVertexFinder.PVsChi2Separation = 0 downVertexFinder.PVsChi2SeparationLowMult = 0 downSeeder = addPrivateToolAndGet(downVertexFinder, PVSeed3DTool) downVertexFinder.PVSeedingName = downSeeder.getTitleName() downSeeder.TrackPairMaxDistance = 2.0 * units.mm downSeeder.zMaxSpread = 20.0 * units.mm downSeeder.MinCloseTracks = 4 downFitter = addPrivateToolAndGet(downVertexFinder, LSAdaptPVFitter) downVertexFinder.PVFitterName = downFitter.getTitleName() downFitter.MinTracks = 4 downFitter.maxChi2 = 400.0 downFitter.maxDeltaZ = 0.0005 * units.mm downFitter.maxDeltaChi2NDoF = 0.002 downFitter.acceptTrack = 0.000000001 downFitter.trackMaxChi2 = 9 downFitter.trackMaxChi2Remove = 64 downVertexing = SelectionPatPV3DWrapper( "%sDownVertexing" % self.name(), downVertexAlg, RequiredSelections=[downTracks]) # Make Particles out of the RecVertices rv2pDown = LLParticlesFromRecVertices(VerticesFromVeloOnly=False, RequireUpstreamPV=False, WriteP2PVRelations=False, ForceP2PVBuild=False #, OutputLevel = VERBOSE ) self.validatedSetProps( "RV2PDown", DisplVerticesLinesConf.recoCuts + DisplVerticesLinesConf.singleCuts, rv2pDown) downCandidates = Selection("%sDownCandidates" % self.name(), RequiredSelections=[downVertexing], Algorithm=rv2pDown, InputDataSetter="RecVertexLocations") ####################################################################### ### ### ### HLT JET SEQUENCE ### ### ### ####################################################################### # timing is already fine, so one algo with loose JetID is sufficient # Hlt prefilter and vertex candidates from Hlt2 from Configurables import HltVertexConverterS20p3 revivedHlt2Candidates = "Phys/%sHlt2Cand/Particles" % self.name() hltCandReviver = GaudiSequenceroid( ModeOR=True, ShortCircuit=False, Members=[ GaudiSequencer( "%sHlt2CandFilterTCK%s-%s" % (self.name(), tckBegin, tckEnd), Members=(LoKi_Filters( HLT2_Code= "in_range( {begin}, HLT_TCK % 0x40000000 , {end} ) & ( {decisions} )" .format(begin=tckBegin, end=tckEnd, decisions=" | ".join( "HLT_PASS('%s')" % ln for ln in hltLines))).filters( "%sHlt2DecisionFilterTCK%s-%s" % (self.name(), tckBegin, tckEnd)) + [ HltVertexConverterS20p3( "%sHltConverter%s-%s" % (self.name(), tckBegin, tckEnd), HltSelReports="Hlt2/SelReports", HltLines=hltLines, Recursive=True, Output=revivedHlt2Candidates, WriteP2PVRelations=False, ForceP2PVBuild=False) ])) for (tckBegin, tckEnd), hltLines in self.configurationParameter("HLT")["SignalLines"] ]) hltCandSelection = EventSelection("%sHltCandidates" % self.name(), Algorithm=hltCandReviver) hltVeloGEC = VeloEventShapeCutsS20p3() self.validatedSetProps("VeloGEC", DisplVerticesLinesConf.veloGECCuts, hltVeloGEC) hltVeloGEC.HistoProduce = False hltVeloGECSel = EventSelection("%sHltVeloGEC" % self.name(), Algorithm=hltVeloGEC) hlt2CandAndGECSelection = Selection( "".join((self.name(), "Hlt2CandVertices")), RequiredSelections=[ hltCandSelection, AutomaticData(revivedHlt2Candidates), hltVeloGECSel ], Algorithm=FilterDesktop( Code="( ABSID == '{pid}' )".format(pid=LLPLHCbName), WriteP2PVRelations=False, ForceP2PVBuild=False)) ####################################################################### ### ### ### LINE DEFINITIONS ### ### ### ####################################################################### # one line for every configuratoin key of the format # "Single.*Selection" # "JetSingle.*Selection" # "JetHltSingle.*Selection" # "Double.*Selection" # ".*HLTPS" # "HltEff.*Selection" ##============================== Single ===================================## singleLineNames = [ p.split("Single")[1].split("Selection")[0] for p in self.configKeys() if p.startswith("Single") and p.endswith("Selection") ] for lAcroName in singleLineNames: lShortName = "Single%s" % lAcroName # SingleMedium lSelName = "%sSelection" % lShortName # SingleMediumSelection lLineName = "%s%s" % (self.name(), lShortName ) # DisplVerticesSingleMedium # Choose between Velo-based and downstream vertexing input candidates = withVeloCandidates code = None if "Down" in lAcroName: candidates = downCandidates code = self.getLLPSelection( self.validatedGetProps( lSelName, DisplVerticesLinesConf.singleCuts + DisplVerticesLinesConf.downCuts)) else: code = self.getLLPSelection( self.validatedGetProps(lSelName, DisplVerticesLinesConf.singleCuts)) lineFilter = FilterDesktop( DecayDescriptor=LLPLHCbName, Preambulo=DisplVerticesLinesConf.llpSelectionPreambulo, Code=code, WriteP2PVRelations=False, ForceP2PVBuild=False #, OutputLevel = VERBOSE ) lineSel = Selection("".join((self.name(), lSelName)), RequiredSelections=[candidates], Algorithm=lineFilter) line = StrippingLine(lLineName, prescale=self.validatedGetProps( lSelName, ["PreScale"])["PreScale"], selection=lineSel, RequiredRawEvents=["Calo"], RelatedInfoTools=[{ "Type": "AddVeloEventShapeS21", "TopSelection": lineSel, "Location": "P2VES" }]) if lShortName in self.configurationParameter("HLT"): line.HLT2 = self.configurationParameter("HLT")[lShortName] self.registerLine(line) ##========================= Single with jets ==============================## jetSingleLineNames = [ p.split("JetSingle")[1].split("Selection")[0] for p in self.configKeys() if p.startswith("JetSingle") and p.endswith("Selection") ] for lAcroName in jetSingleLineNames: lShortName = "JetSingle%s" % lAcroName # JetSingleMedium lSelName = "%sSelection" % lShortName # JetSingleMediumSelection lLineName = "%s%s" % (self.name(), lShortName ) # DisplVerticesJetSingleMedium # Choose between Velo-based and downstream vertexing input vertexCandidates = withVeloCandidates code = self.getLLPSelection( self.validatedGetProps(lSelName, DisplVerticesLinesConf.singleCuts)) vertexFilter = FilterDesktop( DecayDescriptor=LLPLHCbName, Preambulo=DisplVerticesLinesConf.llpSelectionPreambulo, Code=code, WriteP2PVRelations=False, ForceP2PVBuild=False #, OutputLevel = VERBOSE ) goodVertices = Selection("".join( (self.name(), lSelName, "Vertices")), RequiredSelections=[vertexCandidates], Algorithm=vertexFilter) jetProps = self.validatedGetProps(lSelName, DisplVerticesLinesConf.jetCuts) vertWithJets = Selection("".join((self.name(), lSelName, "Jets")), RequiredSelections=[goodVertices], Algorithm=self.makeJetCandidateAlg( "".join((self.name(), lSelName, "JetAlg")), MinNumJets=jetProps["MinNumJets"], ConeSize=jetProps["ConeSize"], JetIDCut=jetProps["JetIDCut"], MinDOCABL=jetProps["MinDOCABL"])) jetCode = self.getLLPJetSelection(jetProps) jetCandFilter = FilterDesktop(DecayDescriptor=LLPLHCbName, Preambulo=self.jetSelectionPreambulo, Code=jetCode, WriteP2PVRelations=False, ForceP2PVBuild=False) lineSel = Selection("".join((self.name(), lSelName)), RequiredSelections=[vertWithJets], Algorithm=jetCandFilter) line = StrippingLine(lLineName, prescale=self.validatedGetProps( lSelName, ["PreScale"])["PreScale"], selection=lineSel, RequiredRawEvents=["Calo"], RelatedInfoTools=[{ "Type": "AddVeloEventShapeS21", "TopSelection": lineSel, "Location": "P2VES" }]) if lShortName in self.configurationParameter("HLT"): line.HLT2 = self.configurationParameter("HLT")[lShortName] self.registerLine(line) ##============= Single with jets based on Hlt candidate ==================## jetHltSingleLineNames = [ p.split("JetHltSingle")[1].split("Selection")[0] for p in self.configKeys() if p.startswith("JetHltSingle") and p.endswith("Selection") ] for lAcroName in jetHltSingleLineNames: lShortName = "JetHltSingle%s" % lAcroName # JetHltSingleMedium lSelName = "%sSelection" % lShortName # JetHltSingleMediumSelection lLineName = "%s%s" % (self.name(), lShortName ) # DisplVerticesJetHltSingleMedium jetProps = self.validatedGetProps(lSelName, DisplVerticesLinesConf.jetCuts) vertWithJets = Selection( "".join((self.name(), lSelName, "HltJets")), RequiredSelections=[hlt2CandAndGECSelection], Algorithm=self.makeJetCandidateAlg( "".join((self.name(), lSelName, "HltJetAlg")), MinNumJets=jetProps["MinNumJets"], ConeSize=jetProps["ConeSize"], JetIDCut=jetProps["JetIDCut"], MinDOCABL=jetProps["MinDOCABL"])) jetCode = self.getLLPJetSelection(jetProps) jetCandFilter = FilterDesktop(DecayDescriptor=LLPLHCbName, Preambulo=self.jetSelectionPreambulo, Code=jetCode, WriteP2PVRelations=False, ForceP2PVBuild=False) lineSel = Selection("".join((self.name(), lSelName)), RequiredSelections=[vertWithJets], Algorithm=jetCandFilter) line = StrippingLine(lLineName, prescale=self.validatedGetProps( lSelName, ["PreScale"])["PreScale"], selection=lineSel, RequiredRawEvents=["Calo"], RelatedInfoTools=[{ "Type": "AddVeloEventShapeS21", "TopSelection": lineSel, "Location": "P2VES" }]) if lShortName in self.configurationParameter("HLT"): line.HLT2 = self.configurationParameter("HLT")[lShortName] self.registerLine(line) ##============================== Double ===================================## doubleLineNames = [ p.split("Double")[1].split("Selection")[0] for p in self.configKeys() if p.startswith("Double") and p.endswith("Selection") ] for lAcroName in doubleLineNames: lShortName = "Double%s" % lAcroName lSelName = "%sSelection" % lShortName lLineName = "%s%s" % (self.name(), lShortName) combinationCut, motherCut = self.getResonanceSelection( self.validatedGetProps( lSelName, DisplVerticesLinesConf.doubleResonanceCuts)) lineFilter = CombineParticles( DecayDescriptor="H_10 -> %s %s" % (LLPLHCbName, LLPLHCbName), Preambulo=DisplVerticesLinesConf.llpSelectionPreambulo, DaughtersCuts={ LLPLHCbName: self.getLLPSelection( self.validatedGetProps( lSelName, DisplVerticesLinesConf.singleCuts)) }, CombinationCut=combinationCut, MotherCut=motherCut, WriteP2PVRelations=False, ForceP2PVBuild=False #, OutputLevel = VERBOSE ) lineSel = Selection("".join((self.name(), lSelName)), RequiredSelections=[withVeloCandidates], Algorithm=lineFilter) line = StrippingLine(lLineName, prescale=self.validatedGetProps( lSelName, ["PreScale"])["PreScale"], selection=lineSel, RequiredRawEvents=["Calo"], RelatedInfoTools=[{ "Type": "AddVeloEventShapeS21", "TopSelection": lineSel, "Location": "P2VES" }]) if lShortName in self.configurationParameter("HLT"): line.HLT2 = self.configurationParameter("HLT")[lShortName] self.registerLine(line) ##============================== HLT PS ===================================## hltPSLineNames = [ p.split("HLTPS")[0] for p in self.configKeys() if p.endswith("HLTPS") ] for lAcroName in hltPSLineNames: lShortName = "%sHLTPS" % lAcroName lLineName = "%s%s" % (self.name(), lShortName ) # DisplVerticesSingleMedium orFilters = [] for (tckBegin, tckEnd), hltFilter in self.validatedGetProps( "HLT", [lShortName])[lShortName]: filters = LoKi_Filters( HLT2_Code= "in_range( {begin}, HLT_TCK % 0x40000000, {end} ) & ( {decisions} )" .format(begin=tckBegin, end=tckEnd, decisions=hltFilter)).filters( "%sHlt2FilterTCK%s-%s" % (lLineName, tckBegin, tckEnd)) assert len(filters) == 1 orFilters.append(filters[0]) assert len(orFilters) == len( self.validatedGetProps("HLT", [lShortName])[lShortName]) hltSelection = EventSelection("%sHltFilter" % lLineName, Algorithm=GaudiSequenceroid( ModeOR=True, ShortCircuit=False, Members=orFilters)) line = StrippingLine( lLineName, prescale=self.validatedGetProps(lShortName, ["PreScale"])["PreScale"], selection=hltSelection, RequiredRawEvents=["Muon", "Calo", "Rich", "Velo", "Tracker"]) self.registerLine(line) ##============================== OTHER ===================================## hltEffLineNames = [ p.split("HltEff")[1].split("Selection")[0] for p in self.configKeys() if p.startswith("HltEff") and p.endswith("Selection") ] for lShortName in hltEffLineNames: lSelName = "HltEff%sSelection" % lShortName lLineName = "%s%s" % (self.name(), lShortName) # HltEff lines are single, Velo-vertexing based lines lineFilter = FilterDesktop( DecayDescriptor=LLPLHCbName, Preambulo=DisplVerticesLinesConf.llpSelectionPreambulo, Code=self.getLLPSelection( self.validatedGetProps(lSelName, DisplVerticesLinesConf.singleCuts)), WriteP2PVRelations=False, ForceP2PVBuild=False #, OutputLevel = VERBOSE ) lineSel = Selection("".join((self.name(), lSelName)), RequiredSelections=[withVeloCandidates], Algorithm=lineFilter) line = StrippingLine( lLineName, prescale=self.validatedGetProps(lSelName, ["PreScale"])["PreScale"] # these lines MUST have an HLT filter , HLT2=self.configurationParameter("HLT")[lShortName], selection=lineSel, RequiredRawEvents=["Muon", "Calo", "Rich", "Velo", "Tracker"], RelatedInfoTools=[{ "Type": "AddVeloEventShapeS21", "TopSelection": lineSel, "Location": "P2VES" }]) self.registerLine(line)