def selMuonPParts(name, DataType, downstreamSeq): """ Make ProtoParticles out of Downstream tracks """ unpacker = UnpackTrack(name+"UnpackTrack") # do we need this or is it here for historical reason ? unpacker.InputName="pRec/Downstream/FittedTracks" unpacker.OutputName="Rec/Downstream/FittedTracks" idalg = MuonIDAlg(name+"IDalg") cm=ConfiguredMuonIDs.ConfiguredMuonIDs( DataType ) #data=DaVinci().getProp("DataType")) cm.configureMuonIDAlg(idalg) idalg.TrackLocation = "Rec/Downstream/FittedTracks" idalg.MuonIDLocation = "Rec/Muon/MuonPID/Downstream" idalg.MuonTrackLocation = "Rec/Track/MuonForDownstream" # I would call it FromDownstream …but just to be »Klugscheißer« downprotoseq = GaudiSequencer(name+"ProtoPSeq") downprotos = ChargedProtoParticleMaker(name+"ProtoPMaker") downprotos.Inputs = ["Rec/Downstream/FittedTracks"] downprotos.Output = "Rec/ProtoP/"+name+"ProtoPMaker/ProtoParticles" downprotos.addTool( DelegatingTrackSelector, name="TrackSelector" ) #tracktypes = [ "Long","Upstream","Downstream","Ttrack","Velo","VeloR" ] # only downstream needed … tracktypes = ["Downstream"] #if (trackcont == "Best") : # tracktypes = [ "Long" ] downprotos.TrackSelector.TrackTypes = tracktypes selector = downprotos.TrackSelector for tsname in tracktypes: selector.addTool(TrackSelector,name=tsname) ts = getattr(selector,tsname) # Set Cuts ts.TrackTypes = [tsname] # ts.MinNDoF = 1 ts.MaxChi2Cut = 10 addmuonpid = ChargedProtoParticleAddMuonInfo(name+"addmuoninfo") addmuonpid.InputMuonPIDLocation = "Rec/Muon/MuonPID/Downstream" addmuonpid.ProtoParticleLocation = "Rec/ProtoP/"+name+"ProtoPMaker/ProtoParticles" #addmuonpid.OutputLevel = 0 combinedll = ChargedProtoCombineDLLsAlg(name+"CombineDLL") combinedll.ProtoParticleLocation = "Rec/ProtoP/"+name+"ProtoPMaker/ProtoParticles" #combinedll.OutputLevel = 0 # DST post treatment #TrackToDST(name+"TrackToDST").TracksInContainer = "Rec/Downstream/Tracks" #downprotoseq.Members += [ TrackToDST(name+"TrackToDST"), downprotos, addmuonpid, combinedll ] downprotoseq.Members += [ downprotos, addmuonpid, combinedll ] # DataOnDemandSvc().AlgMap.update( { "/Event/Rec/Downstream/Tracks" : unpacker.getFullName(), "/Event/Rec/Muon/MuonPID/Downstream" : idalg.getFullName(), # "/Event/Rec/ProtoP/"+name+"ProtoPMaker" : downprotoseq.getFullName() } ) return GSWrapper(name="WrappedDownMuonProtoPSeqFor"+name, sequencer=downprotoseq, output='Rec/ProtoP/' + name +'ProtoPMaker/ProtoParticles', requiredSelections = [ downstreamSeq])
def muonTracksFORmuonAlignment(): # this still needs to be worked out from Configurables import Escher Escher().RecoSequence = [ "Hlt", "Decoding", "AlignTr", "Vertex", "RICH", "CALO", "MUON", "PROTO" ] # ???? Escher().MoniSequence = ["Tr", "OT"] # if the Escher hlt filter is not set, set it here if not hasattr(Escher(), "HltFilterCode") or not Escher().HltFilterCode: Escher( ).HltFilterCode = "HLT_PASS_RE( 'Hlt1DiMuonHighMass*Decision' )" # Hlt2-->Hlt1 requirement # revive only particles used for trigger print 'Hlt lines to be used: ' print ReviveHltTracks(['Hlt1DiMuonHighMassDecision']) # Now create the J/psi candidates from Configurables import CombineParticles, FilterDesktop from CommonParticles.StdAllLooseMuons import StdAllLooseMuons # requires IsMuon==1 from CommonParticles.StdLooseJpsi2MuMu import StdLooseJpsi2MuMu # requires (ADAMASS('J/psi')<100.*MeV)&(ADOCACHI2CUT(30,'')) && "(VFASPF(VCHI2) < 25.)" StdLooseJpsi2MuMu.DaughtersCuts = {"mu-": "( P> 6000*MeV)"} # momentum cut ## tighten the mass window for candidates used in alignment AlignJpsi2MuMu = FilterDesktop( "AlignJpsi2MuMu", Inputs=["Phys/StdLooseJpsi2MuMu"], Code="(ADMASS('J/psi(1S)') < 35.*MeV) & (VFASPF(VCHI2) < 10.)" ) # tighter requirements from Configurables import ChargedProtoParticleMaker, ChargedProtoParticleAddMuonInfo #####, ChargedProtoCombineDLLsAlg from Configurables import TrackParticleMonitor, GaudiSequencer recoJpsiSeq = GaudiSequencer("RecoJpsiSeq") recoJpsiSeq.Members = [ ChargedProtoParticleMaker('ChargedProtoPMaker'), ChargedProtoParticleAddMuonInfo('ChargedProtoPAddMuon'), ###ChargedProtoCombineDLLsAlg('ChargedProtoPCombDLLs'), StdAllLooseMuons, StdLooseJpsi2MuMu, TrackParticleMonitor( 'StdLooseJpsi2MuMuMonitor', InputLocation='/Event/Phys/StdLooseJpsi2MuMu/Particles', MinMass=3000, MaxMass=3190), AlignJpsi2MuMu, TrackParticleMonitor( 'AlignJpsi2MuMuMonitor', InputLocation='/Event/Phys/AlignJpsi2MuMu/Particles', MinMass=3000, MaxMass=3190), ] sel = ParticleSelection(Name='MufromJpsiMuMu', Location='/Event/Phys/AlignJpsi2MuMu/Particles', Algorithm=recoJpsiSeq) return sel
def _unpackProtoParticles(self): from Configurables import (GaudiSequencer, UnpackProtoParticle) # Neutrals # -------- neutralLoc = "/Event/Rec/ProtoP/Neutrals" unpackNeutrals = UnpackProtoParticle( name="UnpackNeutralProtos", OutputName=neutralLoc, InputName="/Event/pRec/ProtoP/Neutrals") DataOnDemandSvc().AlgMap[neutralLoc] = unpackNeutrals # Charged # ------- chargedLoc = "/Event/Rec/ProtoP/Charged" chargedSeq = GaudiSequencer("UnpackChargedProtosSeq") DataOnDemandSvc().AlgMap[chargedLoc] = chargedSeq # Unpacker unpackCharged = UnpackProtoParticle( name="UnpackChargedProtos", OutputName=chargedLoc, InputName="/Event/pRec/ProtoP/Charged") chargedSeq.Members += [unpackCharged] # Additional processing, not for MDST inputtype = self.getProp('DstType').upper() if inputtype != 'MDST': # PID calibration from Configurables import (ChargedProtoParticleAddRichInfo, ChargedProtoParticleAddMuonInfo, ChargedProtoCombineDLLsAlg, TESCheck) recalib = GaudiSequencer("ProtoParticleCombDLLs") recalib.IgnoreFilterPassed = False chargedSeq.Members += [recalib] # Filter to check in Protos exist recalib.Members += [ TESCheck(name="CheckChargedProtosExist", Inputs=[chargedLoc], OutputLevel=5, Stop=False) ] # Add Rich and Muon PID results to protoparticles recalib.Members += [ ChargedProtoParticleAddMuonInfo("ChargedProtoPAddMuon") ] recalib.Members += [ ChargedProtoParticleAddRichInfo("ChargedProtoPAddRich") ] # Combined DLLs recalib.Members += [ ChargedProtoCombineDLLsAlg("ChargedProtoPCombDLL") ]
def __hlt2ProbeMuonProtos(self): """ Charged muon protoparticles Requires chargedProtos and muon ID """ from Configurables import (ChargedProtoParticleAddMuonInfo, ChargedProtoCombineDLLsAlg, MuonIDAlg, ChargedProtoParticleMaker, DelegatingTrackSelector) from MuonID import ConfiguredMuonIDs ProbeMuonProtosOutputLocation = _baseProtoPLocation( "Hlt2", HltDefaultFitSuffix + "/" + TrackEffNames[self.trackType()]) Hlt2ProbeMuonProtoMaker = ChargedProtoParticleMaker( self.__pidAlgosAndToolsPrefix() + 'ProbeProtoPAlg') if (self.trackType() == "MuonTT"): # create the protos bm_members = [self.__hlt2MuonTTTracking()] Hlt2ProbeMuonProtoMaker.Inputs = [ self.__hlt2MuonTTTracking().outputSelection() ] Hlt2ProbeMuonProtoMaker.addTool(DelegatingTrackSelector) Hlt2ProbeMuonProtoMaker.Output = ProbeMuonProtosOutputLocation Hlt2ProbeMuonProtoMaker.DelegatingTrackSelector.TrackTypes = [ "Long" ] bm_members += [Hlt2ProbeMuonProtoMaker] elif (self.trackType() == "VeloMuon"): #build protos out of tracks bm_members = [self.__hlt2VeloMuonTracking()] Hlt2ProbeMuonProtoMaker.Inputs = [ self.__hlt2VeloMuonTracking().outputSelection() ] Hlt2ProbeMuonProtoMaker.Output = ProbeMuonProtosOutputLocation Hlt2ProbeMuonProtoMaker.addTool(DelegatingTrackSelector, name='delTrackSel') Hlt2ProbeMuonProtoMaker.delTrackSel.TrackTypes = ['Long'] bm_members += [Hlt2ProbeMuonProtoMaker] elif (self.trackType() == "FullDownstream"): # add muon ID bm_members = [self.__hlt2FullDownstreamTracking()] idalgname = self.__pidAlgosAndToolsPrefix() + "IDalg" cm = ConfiguredMuonIDs.ConfiguredMuonIDs( data=self.getProp("DataType")) idalg = cm.configureMuonIDAlgLite(idalgname) idalg.TracksLocations = [ self.__hlt2FullDownstreamTracking().outputSelection() ] idalg.MuonIDLocation = Hlt2TrackRoot + HltDefaultFitSuffix + "/" + HltSharedPIDPrefix + "/" + HltMuonIDSuffix idalg.MuonTrackLocation = Hlt2TrackRoot + HltDefaultFitSuffix + "/" + HltSharedPIDPrefix + "/" + HltMuonTracksName # Configure moun ID tools explicitly, would be better if the ConfiguredMuonIDs class # provided a comprehensive method. All tools are public, but should configure # everywhere, where they are used to be safe. import Configurables for tool, fun in (("CommonMuonTool", "IsMuonTool"), ("DLLMuonTool", "DLLMuonTool"), ("MakeMuonTool", "MakeMuonTool")): tool = getattr(Configurables, tool)() getattr(cm, "configure" + fun)(tool) # make protos Hlt2ProbeMuonProtoMaker.Inputs = [ self.__hlt2FullDownstreamTracking().outputSelection() ] Hlt2ProbeMuonProtoMaker.Output = ProbeMuonProtosOutputLocation Hlt2ProbeMuonProtoMaker.addTool(DelegatingTrackSelector, name="TrackSelector") tracktypes = ["Downstream"] Hlt2ProbeMuonProtoMaker.TrackSelector.TrackTypes = tracktypes addmuonpid = ChargedProtoParticleAddMuonInfo("addmuonpid") addmuonpid.InputMuonPIDLocation = idalg.MuonIDLocation addmuonpid.ProtoParticleLocation = Hlt2ProbeMuonProtoMaker.Output combinedll = ChargedProtoCombineDLLsAlg("combineDLL") combinedll.ProtoParticleLocation = Hlt2ProbeMuonProtoMaker.Output bm_members += [ idalg, Hlt2ProbeMuonProtoMaker, addmuonpid, combinedll ] from HltLine.HltLine import bindMembers # Build the bindMembers bm_name = self.__pidAlgosAndToolsPrefix() + "ProbeMuonProtosSeq" bm_output = ProbeMuonProtosOutputLocation return bindMembers(bm_name, bm_members).setOutputSelection(bm_output)
def applyConf(self): if not self.isPropertySet("RecoSequencer") : raise RuntimeError("ERROR : PROTO Sequencer not set") seq = self.getProp("RecoSequencer") seq.Context = self.getProp("Context") # Charged Proto particles from Configurables import ( GaudiSequencer, ChargedProtoParticleMaker, ChargedProtoParticleAddRichInfo, ChargedProtoParticleAddMuonInfo, ChargedProtoParticleAddEcalInfo, ChargedProtoParticleAddBremInfo, ChargedProtoParticleAddHcalInfo, ChargedProtoParticleAddPrsInfo, ChargedProtoParticleAddSpdInfo, ChargedProtoParticleAddVeloInfo, ChargedProtoCombineDLLsAlg, DelegatingTrackSelector ) cseq = GaudiSequencer("ChargedProtoParticles") seq.Members += [cseq] # Make Charged ProtoParticles charged = ChargedProtoParticleMaker("ChargedProtoPMaker") charged.addTool( DelegatingTrackSelector, name="TrackSelector" ) tracktypes = self.getProp("TrackTypes") charged.TrackSelector.TrackTypes = tracktypes for type in tracktypes : self.setupTypeTrackSelector( type, charged.TrackSelector ) # Add PID information rich = ChargedProtoParticleAddRichInfo("ChargedProtoPAddRich") muon = ChargedProtoParticleAddMuonInfo("ChargedProtoPAddMuon") ecal = ChargedProtoParticleAddEcalInfo("ChargedProtoPAddEcal") brem = ChargedProtoParticleAddBremInfo("ChargedProtoPAddBrem") hcal = ChargedProtoParticleAddHcalInfo("ChargedProtoPAddHcal") velo = ChargedProtoParticleAddVeloInfo("ChargedProtoPAddVeloDEDX") # Fill the Combined DLL information in the charged protoparticles combine = ChargedProtoCombineDLLsAlg("ChargedProtoPCombDLLs") # Fill the sequence cseq.Members += [ charged,ecal,brem,hcal] if not self.getProp("NoSpdPrs") : prs = ChargedProtoParticleAddPrsInfo("ChargedProtoPAddPrs") spd = ChargedProtoParticleAddSpdInfo("ChargedProtoPAddSpd") cseq.Members += [prs,spd ] cseq.Members += [ velo, rich,muon,combine ] # Neutrals from Configurables import NeutralProtoPAlg nseq = GaudiSequencer("NeutralProtoParticles") seq.Members += [nseq] neutral = NeutralProtoPAlg("NeutralProtoPMaker") nseq.Members += [ neutral ] # Set output levels if self.isPropertySet("OutputLevel"): level = self.getProp("OutputLevel") charged.OutputLevel = level rich.OutputLevel = level muon.OutputLevel = level ecal.OutputLevel = level brem.OutputLevel = level hcal.OutputLevel = level if not self.getProp("NoSpdPrs") : prs.OutputLevel = level spd.OutputLevel = level velo.OutputLevel = level combine.OutputLevel = level neutral.OutputLevel = level # ANN PID if self.getProp("AddANNPIDInfo") : nnpidseq = GaudiSequencer("ANNGPIDSeq") cseq.Members += [nnpidseq] annconf = ChargedProtoANNPIDConf() self.setOtherProps(annconf,["DataType","OutputLevel","Context"]) annconf.RecoSequencer = nnpidseq
def __apply_configuration__(self): """ HLT Afterburner configuration """ from HltTracking.Hlt2TrackingConfigurations import Hlt2BiKalmanFittedForwardTracking from HltTracking.Hlt2TrackingConfigurations import Hlt2BiKalmanFittedDownstreamTracking Afterburner = self.getProp("Sequence") if self.isPropertySet( "Sequence") else None if not Afterburner: return AfterburnerFilterSeq = Sequence("HltAfterburnerFilterSequence") Afterburner.Members += [AfterburnerFilterSeq] if self.getProp("Hlt2Filter"): from DAQSys.Decoders import DecoderDB decoder = DecoderDB["HltDecReportsDecoder/Hlt2DecReportsDecoder"] from Configurables import LoKi__HDRFilter as HDRFilter hlt2Filter = HDRFilter('HltAfterburnerHlt2Filter', Code=self.getProp("Hlt2Filter"), Location=decoder.listOutputs()[0]) AfterburnerFilterSeq.Members += [hlt2Filter] AfterburnerSeq = Sequence("HltAfterburnerSequence", IgnoreFilterPassed=True) AfterburnerFilterSeq.Members += [AfterburnerSeq] if self.getProp("EnableHltRecSummary"): from Configurables import RecSummaryAlg seq = Sequence("RecSummarySequence") tracks = Hlt2BiKalmanFittedForwardTracking().hlt2PrepareTracks() tracksDown = Hlt2BiKalmanFittedDownstreamTracking( ).hlt2PrepareTracks() muonID = Hlt2BiKalmanFittedForwardTracking().hlt2MuonID() from HltLine.HltDecodeRaw import DecodeVELO, DecodeIT, DecodeTT, DecodeSPD, DecodeMUON decoders = { "Velo": (DecodeVELO, "VeloLiteClustersLocation"), "TT": (DecodeTT, "clusterLocation"), "IT": (DecodeIT, "clusterLocation"), "SPD": (DecodeSPD, "DigitsContainer"), 'Muon': (DecodeMUON, "OutputLocation"), 'MuonTr': (muonID, "MuonTrackLocation") } decoders = { k: (bm.members(), bm.members()[-1].getProp(loc)) for (k, (bm, loc)) in decoders.iteritems() } from HltTracking.HltPVs import PV3D PVs = PV3D("Hlt2") from HltTracking.HltTrackNames import Hlt2TrackLoc recSeq = Sequence("RecSummaryRecoSequence", IgnoreFilterPassed=True) from itertools import chain from Hlt2Lines.Utilities.Utilities import uniqueEverseen recSeq.Members = list( uniqueEverseen( chain.from_iterable( [dec[0] for dec in decoders.itervalues()] + [tracks, tracksDown, muonID, PVs]))) summary = RecSummaryAlg( 'Hlt2RecSummary', SummaryLocation=self.getProp("RecSummaryLocation"), HltSplitTracks=True, SplitLongTracksLocation=tracks.outputSelection(), SplitDownTracksLocation=tracksDown.outputSelection(), PVsLocation=PVs.output, VeloClustersLocation=decoders['Velo'][1], ITClustersLocation=decoders['IT'][1], TTClustersLocation=decoders['TT'][1], SpdDigitsLocation=decoders['SPD'][1], MuonCoordsLocation=decoders['Muon'][1], MuonTracksLocation=decoders['MuonTr'][1]) seq.Members = [recSeq, summary] AfterburnerSeq.Members += [seq] if self.getProp("AddAdditionalTrackInfos"): from GaudiKernel.SystemOfUnits import mm from Configurables import LoKi__VoidFilter as Filter trackLocations = [ Hlt2BiKalmanFittedForwardTracking().hlt2PrepareTracks( ).outputSelection(), Hlt2BiKalmanFittedDownstreamTracking().hlt2PrepareTracks(). outputSelection() ] infoSeq = Sequence("TrackInfoSequence", IgnoreFilterPassed=True) # I don't want to pull in reconstruction if not run before, then there should be also no candidates needing this information # This is anyhow done by the RecSummary above members = [ Hlt2BiKalmanFittedForwardTracking().hlt2PrepareTracks( ).members() + Hlt2BiKalmanFittedDownstreamTracking(). hlt2PrepareTracks().members() ] infoSeq.Members += list( uniqueEverseen(chain.from_iterable(members))) prefix = "Hlt2" trackClones = Sequence(prefix + "TrackClonesSeq") #checkTracks = Filter(prefix+"CheckTrackLoc",Code = "EXISTS('%(trackLocLong)s') & EXISTS('%(trackLocDown)s')" % {"trackLocLong" : trackLocations[0], "trackLocDown" : trackLocations[1]}) #trackClones.Members += [checkTracks] from Configurables import TrackBuildCloneTable, TrackCloneCleaner cloneTable = TrackBuildCloneTable(prefix + "FindTrackClones") cloneTable.maxDz = 500 * mm cloneTable.zStates = [0 * mm, 990 * mm, 9450 * mm] cloneTable.klCut = 5e3 cloneTable.inputLocations = trackLocations cloneTable.outputLocation = trackLocations[ 0] + "Downstream" + "Clones" cloneCleaner = TrackCloneCleaner(prefix + "FlagTrackClones") cloneCleaner.CloneCut = 5e3 cloneCleaner.inputLocations = trackLocations cloneCleaner.linkerLocation = cloneTable.outputLocation trackClones.Members += [cloneTable, cloneCleaner] infoSeq.Members += [trackClones] AfterburnerSeq.Members += [infoSeq] # Add VeloCharge to protoparticles for dedx veloChargeSeq = Sequence("VeloChargeSequence") from Configurables import ChargedProtoParticleAddVeloInfo protoLocation = Hlt2BiKalmanFittedForwardTracking( ).hlt2ChargedAllPIDsProtos().outputSelection() checkProto = Filter("CheckProtoParticles", Code="EXISTS('%(protoLoc)s')" % {"protoLoc": protoLocation}) addVeloCharge = ChargedProtoParticleAddVeloInfo( "Hlt2AddVeloCharge") addVeloCharge.ProtoParticleLocation = protoLocation decodeVeloFullClusters = DecoderDB[ "DecodeVeloRawBuffer/createVeloClusters"].setup() veloChargeSeq.Members += [ checkProto, decodeVeloFullClusters, addVeloCharge ] AfterburnerSeq.Members += [veloChargeSeq] persistRecoLines = self._persistRecoLines() if self.getProp("AddPIDToDownstream") and ( len(persistRecoLines) > 0 or len(self.getProp("Hlt2DownstreamFilter")) > 0): from Configurables import LoKi__HDRFilter as HDRFilter if (len(persistRecoLines) > 0 and len(self.getProp("Hlt2DownstreamFilter")) > 0): code = self._persistRecoFilterCode( persistRecoLines) + " | " + self._filterCode( self.getProp("Hlt2DownstreamFilter")) elif len(persistRecoLines) > 0: code = self._persistRecoFilterCode(persistRecoLines) elif len(self.getProp("Hlt2DownstreamFilter")) > 0: code = self._filterCode(self.getProp("Hlt2DownstreamFilter")) # Activate Downstream RICH for all PersistReco lines from DAQSys.Decoders import DecoderDB decoder = DecoderDB["HltDecReportsDecoder/Hlt2DecReportsDecoder"] hlt2DownstreamFilter = HDRFilter('DownstreamHlt2Filter', Code=code, Location=decoder.listOutputs()[0]) downstreamPIDSequence = Sequence("Hlt2AfterburnerDownstreamPIDSeq") downstreamPIDSequence.Members += [hlt2DownstreamFilter] downstreamTracking = Hlt2BiKalmanFittedDownstreamTracking() tracksDown = downstreamTracking.hlt2PrepareTracks() protosDown = downstreamTracking.hlt2ChargedNoPIDsProtos() chargedProtosOutputLocation = protosDown.outputSelection() richPid = downstreamTracking.hlt2RICHID() downstreamPIDSequence.Members += list( uniqueEverseen( chain.from_iterable([tracksDown, protosDown, richPid]))) from Configurables import ChargedProtoParticleAddRichInfo, ChargedProtoParticleAddMuonInfo downstreamRichDLL_name = "Hlt2AfterburnerDownstreamProtoPAddRich" downstreamRichDLL = ChargedProtoParticleAddRichInfo( downstreamRichDLL_name) downstreamRichDLL.InputRichPIDLocation = richPid.outputSelection() downstreamRichDLL.ProtoParticleLocation = chargedProtosOutputLocation # Add the muon info to the DLL downstreamMuon_name = "Hlt2AfterburnerDownstreamProtoPAddMuon" downstreamMuon = ChargedProtoParticleAddMuonInfo( downstreamMuon_name) downstreamMuon.ProtoParticleLocation = chargedProtosOutputLocation downstreamMuon.InputMuonPIDLocation = downstreamTracking.hlt2MuonID( ).outputSelection() # Add the Calo info to the DLL # from Configurables import (ChargedProtoParticleAddEcalInfo, ChargedProtoParticleAddBremInfo, ChargedProtoParticleAddHcalInfo, ChargedProtoParticleAddPrsInfo, ChargedProtoParticleAddSpdInfo) caloPidLocation = downstreamTracking.hlt2CALOID().outputSelection() downstreamEcal = ChargedProtoParticleAddEcalInfo( "HltAfterburnerDownstreamProtoPAddEcal") downstreamBrem = ChargedProtoParticleAddBremInfo( "HltAfterburnerDownstreamProtoPAddBrem") downstreamHcal = ChargedProtoParticleAddHcalInfo( "HltAfterburnerDownstreamProtoPAddHcal") downstreamPrs = ChargedProtoParticleAddPrsInfo( "HltAfterburnerDownstreamProtoPAddPrs") downstreamSpd = ChargedProtoParticleAddSpdInfo( "HltAfterburnerDownstreamProtoPAddSpd") for alg in (downstreamEcal, downstreamBrem, downstreamHcal, downstreamPrs, downstreamSpd): alg.setProp("ProtoParticleLocation", chargedProtosOutputLocation) alg.setProp("Context", caloPidLocation) downstreamPIDSequence.Members += [alg] from Configurables import ChargedProtoCombineDLLsAlg, ChargedProtoANNPIDConf downstreamCombine_name = "Hlt2AfterburnerDownstreamRichCombDLLs" downstreamCombine = ChargedProtoCombineDLLsAlg( downstreamCombine_name) downstreamCombine.ProtoParticleLocation = downstreamTracking.hlt2ChargedNoPIDsProtos( ).outputSelection() from Hlt2Lines.Utilities.Utilities import uniqueEverseen downstreamPIDSequence.Members += [ downstreamMuon, downstreamRichDLL, downstreamCombine ] probNNDownSeqName = self._instanceName(ChargedProtoANNPIDConf) probNNDownSeq = GaudiSequencer(probNNDownSeqName + "Seq") annconfDown = ChargedProtoANNPIDConf(probNNDownSeqName) annconfDown.DataType = downstreamTracking.DataType annconfDown.TrackTypes = ["Downstream"] annconfDown.RecoSequencer = probNNDownSeq annconfDown.ProtoParticlesLocation = downstreamTracking.hlt2ChargedNoPIDsProtos( ).outputSelection() downstreamPIDSequence.Members += [probNNDownSeq] AfterburnerSeq.Members += [downstreamPIDSequence] # Configure and add the persist reco AfterburnerSeq.Members += [self._persistRecoSeq()]
def defaultHLTJPsiSelection(lines=[]): # this still needs to be worked out from Configurables import Escher Escher().RecoSequence = [ "Hlt", "Decoding", "AlignTr", "Vertex", "RICH", "CALO", "MUON", "PROTO" ] Escher().MoniSequence = ["Tr", "OT"] # if the Escher hlt filter is not set, set it here if not hasattr(Escher(), "HltFilterCode") or not Escher().HltFilterCode: Escher().HltFilterCode = "HLT_PASS_RE( 'Hlt2.*JPsi.*Decision' )" # revive only particles used for trigger print 'Hlt lines to be used: ' print ReviveHltTracks(lines if len(lines) else [ 'Hlt2ExpressJPsiDecision', 'Hlt2DiMuonDetachedJPsiDecision', 'Hlt2DiMuonJPsiDecision', 'Hlt2DiMuonJPsiHighPTDecision' ]) # Now create the J/psi candidates from Configurables import CombineParticles, FilterDesktop from CommonParticles.StdAllLooseMuons import StdAllLooseMuons from CommonParticles.StdLooseJpsi2MuMu import StdLooseJpsi2MuMu StdLooseJpsi2MuMu.DaughtersCuts = { "mu-": "(PIDmu-PIDK>5.0) & (PIDmu-PIDe>8.0)" } ## tighten the mass window for candidates used in alignment AlignJpsi2MuMu = FilterDesktop( "AlignJpsi2MuMu", Inputs=["Phys/StdLooseJpsi2MuMu"], Code="(ADMASS('J/psi(1S)') < 35.*MeV) & (VFASPF(VCHI2) < 7.)" ) # Tight requirements on vchi2 - test 18/5/2012 from Configurables import ChargedProtoParticleMaker, ChargedProtoParticleAddMuonInfo, ChargedProtoCombineDLLsAlg from Configurables import TrackParticleMonitor, GaudiSequencer recoJpsiSeq = GaudiSequencer("RecoJpsiSeq") recoJpsiSeq.Members = [ ChargedProtoParticleMaker('ChargedProtoPMaker'), ChargedProtoParticleAddMuonInfo('ChargedProtoPAddMuon'), ChargedProtoCombineDLLsAlg('ChargedProtoPCombDLLs'), StdAllLooseMuons, # we could also get this from the DoD StdLooseJpsi2MuMu, # we could also get this from the DoD TrackParticleMonitor( 'StdLooseJpsi2MuMuMonitor', InputLocation='/Event/Phys/StdLooseJpsi2MuMu/Particles', MinMass=3000, MaxMass=3190), AlignJpsi2MuMu, TrackParticleMonitor( 'AlignJpsi2MuMuMonitor', InputLocation='/Event/Phys/AlignJpsi2MuMu/Particles', MinMass=3000, MaxMass=3190), ] sel = ParticleSelection(Name='Jpsi2MuMu', Location='/Event/Phys/AlignJpsi2MuMu/Particles', Algorithm=recoJpsiSeq) return sel
def delphesForGauss(): from Configurables import (GaudiSequencer, SimInit, DelphesAlg, ApplicationMgr, DelphesHist, DelphesTuple, DelphesProto, DelphesCaloProto, BooleInit, PGPrimaryVertex) from Configurables import (DelphesRecoSummary, DelphesParticleId, ChargedProtoCombineDLLsAlg, ChargedProtoParticleAddRichInfo, ChargedProtoParticleAddMuonInfo) DelphesPID = DelphesParticleId( "DelphesParticleId", RichGan={ ###### New Yandex models 'mu+': "/eos/lhcb/user/l/landerli/FastSimulationModels/v20190503/FastFastRICH_Cramer_muon_tfScaler/", 'mu-': "/eos/lhcb/user/l/landerli/FastSimulationModels/v20190503/FastFastRICH_Cramer_muon_tfScaler/", 'p+': "/eos/lhcb/user/l/landerli/FastSimulationModels/v20190503/FastFastRICH_Cramer_proton_tfScaler/", 'p~-': "/eos/lhcb/user/l/landerli/FastSimulationModels/v20190503/FastFastRICH_Cramer_proton_tfScaler/", 'K+': "/eos/lhcb/user/l/landerli/FastSimulationModels/v20190503/FastFastRICH_Cramer_kaon_tfScaler/", 'K-': "/eos/lhcb/user/l/landerli/FastSimulationModels/v20190503/FastFastRICH_Cramer_kaon_tfScaler/", 'pi+': "/eos/lhcb/user/l/landerli/FastSimulationModels/v20190503/FastFastRICH_Cramer_pion_tfScaler/", 'pi-': "/eos/lhcb/user/l/landerli/FastSimulationModels/v20190503/FastFastRICH_Cramer_pion_tfScaler/", }, RichGanInput='x', RichGanOutput='QuantileTransformerTF_3/stack', MuonLLGan={ 'mu+': "/eos/lhcb/user/l/landerli/FastSimulationModels/v20190503/diamondGan-2019-04-2401_43_08.499323/", 'mu-': "/eos/lhcb/user/l/landerli/FastSimulationModels/v20190503/diamondGan-2019-04-2401_43_08.499323/", 'pi+': "/eos/lhcb/user/l/landerli/FastSimulationModels/v20190503/MuGanPion-2019-04-2913_16_04.022940/", 'pi-': "/eos/lhcb/user/l/landerli/FastSimulationModels/v20190503/MuGanPion-2019-04-2913_16_04.022940/", 'K+': "/eos/lhcb/user/l/landerli/FastSimulationModels/v20190503/MuGanKaon-2019-04-2913_16_43.860800/", 'K-': "/eos/lhcb/user/l/landerli/FastSimulationModels/v20190503/MuGanKaon-2019-04-2913_16_43.860800/", 'p+': "/eos/lhcb/user/l/landerli/FastSimulationModels/v20190503/MuGanProton-2019-04-3000_01_07.504122/", 'p~-': "/eos/lhcb/user/l/landerli/FastSimulationModels/v20190503/MuGanProton-2019-04-3000_01_07.504122/", }, MuonLLGanInput='X_gen', MuonLLGanOutput='output', isMuonMlp={ 'mu+': "/eos/lhcb/user/l/landerli/FastSimulationModels/v20190503/MuonIsMuon2019-05-03__11_11_19.978969/", 'mu-': "/eos/lhcb/user/l/landerli/FastSimulationModels/v20190503/MuonIsMuon2019-05-03__11_11_19.978969/", 'pi+': "/eos/lhcb/user/l/landerli/FastSimulationModels/v20190503/PionIsMuon2019-05-03__11_12_17.633997/", 'pi-': "/eos/lhcb/user/l/landerli/FastSimulationModels/v20190503/PionIsMuon2019-05-03__11_12_17.633997/", 'K+': "/eos/lhcb/user/l/landerli/FastSimulationModels/v20190503/KaonIsMuon2019-05-03__11_11_58.436823/", 'K-': "/eos/lhcb/user/l/landerli/FastSimulationModels/v20190503/KaonIsMuon2019-05-03__11_11_58.436823/", 'p+': "/eos/lhcb/user/l/landerli/FastSimulationModels/v20190503/ProtonIsMuon2019-05-03__11_09_52.500469/", 'p~-': "/eos/lhcb/user/l/landerli/FastSimulationModels/v20190503/ProtonIsMuon2019-05-03__11_09_52.500469/", }, isMuonMlpInput='inputds', isMuonMlpOutput='strided_slice', #OutputLevel = VERBOSE, ) DelphesRecStat = DelphesRecoSummary( 'DelphesRecoSummary', nTracksHistogramFile= "root://eosuser.cern.ch//eos/lhcb/user/l/landerli/FastSimulationModels/v20190503/KS0_nTracks_Brunel.root", nTracksHistogramName="dataHist", #OutputLevel = VERBOSE, ) #make the default card from LbDelphes.LbDelphesCardTemplates import DelphesCard c = DelphesCard.DelphesCard(name="delphes_card", year='2012', magPolarity='up', efficiencies=True, resolutions=True) # #configure the card here for expert users # #c.modules['ECAL'].custom_xy_binning(...) c.FinalizeCard() #PGPrimaryVertex().OutputLevel=DEBUG PGPrimaryVertex().OutputVerticesName = '/Event/Rec/Vertex/Primary' PGPrimaryVertex().InputVerticesName = '/Event/MCFast/MCVertices' DelphesAlg().LHCbDelphesCardLocation = '$PWD/' + c.name + '.tcl' DelphesAlg().DelphesTrackLocation = 'FinalTrackMerger/tracks' #DelphesAlg().OutputLevel=VERBOSE DelphesCaloProto().LHCbDelphesCardLocation = DelphesAlg( ).LHCbDelphesCardLocation DelphesProto().TrackLUT = "$LBDELPHESROOT/LookUpTables/lutTrack.dat" DelphesProto( ).TrackCovarianceLUT = "$LBDELPHESROOT/LookUpTables/lutCovarianceProf.dat" #DelphesProto().OutputLevel=VERBOSE #DelphesCaloProto().OutputLevel=DEBUG #DelphesTuple().OutputLevel=DEBUG delphesSeq = GaudiSequencer("DelphesSeq") delphesSeq.Members = [SimInit("InitDelphes")] delphesSeq.Members += [DelphesAlg("DelphesAlg")] delphesSeq.Members += [DelphesHist("DelphesHist")] delphesSeq.Members += [DelphesProto("DelphesProto")] #delphesSeq.Members += [ DelphesRecStat ] #delphesSeq.Members += [ DelphesPID ] delphesSeq.Members += [ ChargedProtoParticleAddRichInfo('ChargedProtoParticleAddRichInfo') ] delphesSeq.Members += [ ChargedProtoParticleAddMuonInfo('ChargedProtoParticleAddMuonInfo') ] delphesSeq.Members += [ ChargedProtoCombineDLLsAlg('ChargedProtoCombineDLLsAlg') ] delphesSeq.Members += [DelphesCaloProto("DelphesCaloProto")] delphesSeq.Members += [DelphesTuple("DelphesTuple")] delphesSeq.Members += [BooleInit("BooleInit", ModifyOdin=True)] delphesSeq.Members += [PGPrimaryVertex("PGPrimaryVertex")] delphesSeq.Members += [GaudiSequencer("DelphesMonitor")] ApplicationMgr().TopAlg += [delphesSeq]
def makeMyProtoP(trackcont): unpacker = UnpackTrack(trackcont + "UnpackTrack") unpacker.InputName = "pRec/Track/" + trackcont unpacker.OutputName = "Rec/Track/" + trackcont smeartracks = TrackSmeared(trackcont + "TrackSmeared") smeartracks.InputLocation = "Rec/Track/" + trackcont outputLocation = "Smeared" smeartracks.OutputLocation = outputLocation smeartracks.smearCopied = True smeartracks.smear = 1 #smeartracks.makePlots = 1 #smeartracks.OutputLevel = 2 protoseq = GaudiSequencer(trackcont + "ProtoPSeq") protos = ChargedProtoParticleMaker(trackcont + "ProtoPMaker") protos.InputTrackLocation = ["Rec/Track/" + outputLocation] protos.OutputProtoParticleLocation = "Rec/ProtoP/" + trackcont + "ProtoPMaker" protos.addTool(DelegatingTrackSelector, name="TrackSelector") #protos.OutputLevel = 0 tracktypes = ["Long", "Upstream", "Downstream", "Ttrack", "Velo", "VeloR"] protos.TrackSelector.TrackTypes = tracktypes selector = protos.TrackSelector for tsname in tracktypes: selector.addTool(TrackSelector, name=tsname) ts = getattr(selector, tsname) # Set Cuts ts.TrackTypes = [tsname] # Add PID information idalg = MuonIDAlg("BestIDalg") #idalg.OutputLevel = 5 cm = ConfiguredMuonIDs.ConfiguredMuonIDs( data=DaVinci().getProp("DataType")) cm.configureMuonIDAlg(idalg) idalg.TrackLocation = "Rec/Track/" + outputLocation idalg.MuonIDLocation = "Rec/Muon/MuonPID/" + outputLocation from Configurables import ( ChargedProtoParticleAddRichInfo, ChargedProtoParticleAddMuonInfo, ChargedProtoParticleAddEcalInfo, ChargedProtoParticleAddBremInfo, ChargedProtoParticleAddHcalInfo, ChargedProtoParticleAddPrsInfo, ChargedProtoParticleAddSpdInfo, ChargedProtoParticleAddVeloInfo, ChargedProtoCombineDLLsAlg) addmuonpid = ChargedProtoParticleAddMuonInfo("Bestaddmuoninfo") addmuonpid.InputMuonPIDLocation = "Rec/Muon/MuonPID/" + outputLocation addmuonpid.ProtoParticleLocation = "Rec/ProtoP/" + trackcont + "ProtoPMaker" addrichpid = ChargedProtoParticleAddRichInfo("Bestaddrichinfo") addrichpid.ProtoParticleLocation = "Rec/ProtoP/" + trackcont + "ProtoPMaker" # The rich pid is added to the track in TrackSmeared, thus only kaon pion pid is consistent # the others are not implemented. The modes smearBest and smearProto don't have the problems #addcalopid = ChargedProtoParticleAddCaloInfo("Bestaddcaloinfo") #addcalopid.InputRichCALOLocation = "Rec/Rich/"+outputLocation #addcalopid.ProtoParticleLocation = "Rec/ProtoP/"+trackcont+"ProtoPMaker" #ecal = ChargedProtoParticleAddEcalInfo("ChargedProtoPAddEcal") #ecal.ProtoParticleLocation = "Rec/ProtoP/"+trackcont+"ProtoPMaker" #brem = ChargedProtoParticleAddBremInfo("ChargedProtoPAddBrem") #brem.ProtoParticleLocation = "Rec/ProtoP/"+trackcont+"ProtoPMaker" #hcal = ChargedProtoParticleAddHcalInfo("ChargedProtoPAddHcal") #hcal.ProtoParticleLocation = "Rec/ProtoP/"+trackcont+"ProtoPMaker" #prs = ChargedProtoParticleAddPrsInfo("ChargedProtoPAddPrs") #prs.ProtoParticleLocation = "Rec/ProtoP/"+trackcont+"ProtoPMaker" #spd = ChargedProtoParticleAddSpdInfo("ChargedProtoPAddSpd") #spd.ProtoParticleLocation = "Rec/ProtoP/"+trackcont+"ProtoPMaker" #velo = ChargedProtoParticleAddVeloInfo("ChargedProtoPAddVeloDEDX") #velo.ProtoParticleLocation = "Rec/ProtoP/"+trackcont+"ProtoPMaker" combinedll = ChargedProtoCombineDLLsAlg("BestCombineDLL") combinedll.ProtoParticleLocation = "Rec/ProtoP/" + trackcont + "ProtoPMaker" #set up associators assoctr = TrackAssociator(trackcont + "AssocTr") assoctr.TracksInContainer = "Rec/Track/" + outputLocation assocpp = ChargedPP2MC(trackcont + "AssocPP") assocpp.TrackLocations = ["Rec/Track/" + outputLocation] assocpp.InputData = ["Rec/ProtoP/" + trackcont + "ProtoPMaker"] assocpp.OutputTable = "Relations/Rec/ProtoP/" + trackcont + "ProtoPMaker" # DST post treatment TrackToDST(trackcont + "TrackToDST").TracksInContainer = "Rec/Track/" + trackcont if not DaVinci().Simulation: protoseq.Members += [TrackToDST(trackcont + "TrackToDST"), protos] protoseq.Members += [ ecal, brem, hcal, prs, spd, velo, addrichpid, addmuonpid, combinedll ] DataOnDemandSvc().AlgMap.update({ "/Event/Rec/Track/" + trackcont: unpacker.getFullName(), "/Event/Rec/Track/" + outputLocation: smeartracks.getFullName(), "/Event/Rec/Rich/" + outputLocation: protoseq.getFullName(), "/Event/Rec/Muon/MuonPID/" + outputLocation: idalg.getFullName(), "/Event/Rec/ProtoP/" + trackcont + "ProtoPMaker": protoseq.getFullName(), "/Event/Relations/Rec/ProtoP/" + trackcont + "ProtoPMaker": protoseq.getFullName() }) else: if (DaVinci().Simulation): protoseq.Members += [ TrackToDST(trackcont + "TrackToDST"), assoctr, protos ] #protoseq.Members += [ ecal,brem,hcal,prs,spd,velo,addrichpid,addmuonpid,combinedll,assocpp ] protoseq.Members += [ idalg, addmuonpid, addrichpid, combinedll, assocpp ] DataOnDemandSvc().AlgMap.update({ "/Event/Rec/Track/" + trackcont: unpacker.getFullName(), "/Event/Rec/Track/" + outputLocation: smeartracks.getFullName(), "/Event/Rec/Rich/" + outputLocation: protoseq.getFullName(), "/Event/Rec/Muon/MuonPID/" + outputLocation: idalg.getFullName(), "/Event/Rec/ProtoP/" + trackcont + "ProtoPMaker": protoseq.getFullName(), "/Event/Relations/Rec/ProtoP/" + trackcont + "ProtoPMaker": protoseq.getFullName() })
def configureReco(self, init): """ Configure Reconstruction to be redone """ ## CaloReco & CaloPIDs on-demand clusters = ['Digits', 'Clusters'] from Configurables import CaloProcessor caloProc = CaloProcessor(EnableOnDemand=True, OutputLevel=self.getProp("OutputLevel")) caloProc.RecList = clusters # --- if self.getProp('DataType') == 'Upgrade': caloProc.NoSpdPrs = True ## General unpacking from Configurables import DstConf if self.isPropertySet('EnableUnpack'): DstConf().setProp('EnableUnpack', self.getProp('EnableUnpack')) ## unpack Calo Hypos ? from Configurables import CaloDstUnPackConf unpack = CaloDstUnPackConf() hypos = ['Photons', 'MergedPi0s', 'SplitPhotons', 'Electrons'] # CaloHypos if self.isPropertySet( 'EnableUnpack') and "Reconstruction" in self.getProp( 'EnableUnpack'): unpack.setProp('Enable', True) else: caloProc.RecList += hypos # enable caloHypos onDemand # Reprocess explicitely the full calo sequence in the init sequence ? inputtype = self.getProp('InputType').upper() if (self.getProp("CaloReProcessing") and inputtype != 'MDST'): caloProc.RecList = clusters + hypos caloSeq = caloProc.sequence( ) # apply the CaloProcessor configuration cSeq = GaudiSequencer('CaloReProcessing') cSeq.Members += [caloSeq] init.Members += [cSeq] unpack.setProp('Enable', False) # update CaloHypo->MC Linker if self.getProp('Simulation'): log.info( "CaloReprocessing : obsolete CaloHypo2MC Links is updated") from Configurables import (TESCheck, EventNodeKiller, CaloHypoMCTruth) caloMCLinks = ["Link/Rec/Calo"] caloMCSeq = GaudiSequencer("cleanCaloMCLinks") checkCaloMCLinks = TESCheck("checkCaloMCLinks") checkCaloMCLinks.Inputs = caloMCLinks checkCaloMCLinks.Stop = False killCaloMCLinks = EventNodeKiller("killCaloMCLinks") killCaloMCLinks.Nodes = caloMCLinks caloMCSeq.Members = [checkCaloMCLinks, killCaloMCLinks] init.Members += [caloMCSeq] update = self.getProp("UpdateCaloMCLinks") if update: redoCaloMCLinks = CaloHypoMCTruth("recreteCaloMCLinks") init.Members += [redoCaloMCLinks] else: caloProc.applyConf() if inputtype != 'MDST': log.info( "CaloReProcessing cannot be processed on reduced (m)DST data" ) # For backwards compatibility with MC09, we need the following to rerun # the Muon Reco on old data. To be removed AS SOON as this backwards compatibility # is no longer needed if (self.getProp("DataType") == 'MC09' and inputtype != 'MDST' and self.getProp("AllowPIDRerunning") and inputtype != 'RDST'): from Configurables import DataObjectVersionFilter, MuonRec, TESCheck from MuonID import ConfiguredMuonIDs rerunPIDSeq = GaudiSequencer("ReRunMuonPID") init.Members += [rerunPIDSeq] # Check data version, to see if this is needed or not rerunPIDSeq.Members += [ DataObjectVersionFilter( "MuonPIDVersionCheck", DataObjectLocation="/Event/Rec/Muon/MuonPID", MaxVersion=0) ] # Check raw event is available rerunPIDSeq.Members += [ TESCheck("TESCheckRawEvent", Inputs=["DAQ/RawEvent"], Stop=False) ] # Run Muon PID cm = ConfiguredMuonIDs.ConfiguredMuonIDs( data=self.getProp("DataType")) rerunPIDSeq.Members += [MuonRec(), cm.getMuonIDSeq()] # If muon PID has rerun, need to re make the Combined DLLS... from Configurables import (ChargedProtoParticleAddMuonInfo, ChargedProtoCombineDLLsAlg) rerunPIDSeq.Members += [ ChargedProtoParticleAddMuonInfo("CProtoPAddNewMuon"), ChargedProtoCombineDLLsAlg("CProtoPCombDLLNewMuon") ] # Compatibility with pre-2011 data, where Rec/Summary and Trigger/RawEvent are missing import PhysConf.CheckMissingTESData as DataCheck DataCheck.checkForMissingData()