def AddConfiguredJPsiTPAlg(name_suffix="myProbes", ProbeKind = "CaloTag", # options: "CaloTag","MS", "Truth", "ID" MatchContainer="Muons", doID=False, doCB=True, doLoose=True, doMedium=True, doTight=True, doHighPt=True, doStandalone=False, doCaloTag=False, doIndividualAuthors=False, writeNtuple=False, useTrigger=True, doDRSys = False, doClosure=False, DoProbeMatchPlots=True, ProduceEfficiencies=False): from AthenaCommon.AlgSequence import AlgSequence from AthenaCommon.AppMgr import ToolSvc job = AlgSequence() MuonContainerToUse = "Muons" #if hasattr(job, "MuonQualityUpdater"): #MuonContainerToUse = "UpdatedMuons" ProbeContainer=MuonContainerToUse if ProbeKind == "MSTrackPart": ProbeContainer = "ExtrapolatedMuonTrackParticles" ProbeKind = "MS" if ProbeKind == "ID": ProbeContainer = "InDetTrackParticles" if ProbeKind == "Truth": ProbeContainer = "MuonTruthParticles" theAlg = CommonMuonTPConfig.AddTagProbeAlg(name="JPsiTPAlg_%s"%name_suffix, ProbeCont=ProbeContainer, MatchCont=MatchContainer) theAlg.TopLevelFolderName = "JPsiTPReco" #AddMuonSelectionTool() # add a plotting tool #PlotTool = AddPlottingTool(name="JPsiTPPlottingTool_%s"%name_suffix,EffiFlag=name_suffix) # add J/Psi TP selection tools SelectionTools = [] SelectionTools += [CommonMuonTPConfig.AddJPsiTPSelectionTool(name="JPsiTPSelectionTool_OC_%s"%name_suffix,EffiFlag="%s_OC"%name_suffix, ProbeType = ProbeKind, UseTrigger = useTrigger)] PlotTools = [] # add plotting tools in slices PlotTools = [CommonMuonTPConfig.AddPlottingTool(name="JPsiTPPlottingTool_%s_All"%name_suffix,EffiFlag=name_suffix+"_All",applySF = False,DoProbeMatchPlots=DoProbeMatchPlots,ProduceEfficiencies=ProduceEfficiencies)] for thetool in PlotTools: thetool.doJPsiKinematicPlots = True thetool.doJPsiDileptonPlots = True # add any desired matching tools MATCH_DR = 0.05 MatchingTools = [] if doID: thistoolID = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool(name="JPsiTPEfficiencyTool_%s_ID"%name_suffix,EffiFlag="IDTracks") thistoolID.MatchToID = True thistoolID.ApplyScaleFactors = False thistoolID.MaximumDrCut = MATCH_DR MatchingTools += [thistoolID] if doDRSys: thistoolID_dRdown = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool(name="JPsiTPEfficiencyTool_%s_ID_dRdown"%name_suffix,EffiFlag="IDTracks_dRDown") thistoolID_dRdown.MatchToID = True thistoolID_dRdown.ApplyScaleFactors = False thistoolID_dRdown.IsNominal=False thistoolID_dRdown.MaximumDrCut = 0.5 *MATCH_DR MatchingTools += [thistoolID_dRdown] thistoolID_dRUp = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool(name="JPsiTPEfficiencyTool_%s_ID_dRUp"%name_suffix,EffiFlag="IDTracks_dRUp") thistoolID_dRUp.MatchToID = True thistoolID_dRUp.ApplyScaleFactors = False thistoolID_dRUp.IsNominal=False thistoolID_dRUp.MaximumDrCut = 2 * MATCH_DR MatchingTools += [thistoolID_dRUp] if doLoose: thistoolLoose = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool(name="JPsiTPEfficiencyTool_%s_Loose"%name_suffix,EffiFlag="LooseMuons") thistoolLoose.MatchToLoose = True thistoolLoose.ApplyScaleFactors = False thistoolLoose.MaximumDrCut = MATCH_DR MatchingTools += [thistoolLoose] if doDRSys: thistoolLoose_dRdown = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool(name="JPsiTPEfficiencyTool_%s_Loose_dRdown"%name_suffix,EffiFlag="LooseMuons_dRDown") thistoolLoose_dRdown.MatchToLoose = True thistoolLoose_dRdown.ApplyScaleFactors = False thistoolLoose_dRdown.IsNominal=False thistoolLoose_dRdown.MaximumDrCut = 0.5 *MATCH_DR MatchingTools += [thistoolLoose_dRdown] thistoolLoose_dRUp = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool(name="JPsiTPEfficiencyTool_%s_Loose_dRUp"%name_suffix,EffiFlag="LooseMuons_dRUp") thistoolLoose_dRUp.MatchToLoose = True thistoolLoose_dRUp.ApplyScaleFactors = False thistoolLoose_dRUp.IsNominal=False thistoolLoose_dRUp.MaximumDrCut = 2 * MATCH_DR MatchingTools += [thistoolLoose_dRUp] # also run a version without CaloTag thistoolLoose_noCaloTag = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool(name="JPsiTPEfficiencyTool_%s_Loose_noCaloTag"%name_suffix,EffiFlag="LooseMuons_noCaloTag") thistoolLoose_noCaloTag.MatchToLoose_noCaloTag = True thistoolLoose_noCaloTag.ApplyScaleFactors = False thistoolLoose_noCaloTag.MaximumDrCut = MATCH_DR MatchingTools += [thistoolLoose_noCaloTag] if doDRSys: thistoolLoose_noCaloTag_dRdown = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool(name="JPsiTPEfficiencyTool_%s_Loose_noCaloTag_dRdown"%name_suffix,EffiFlag="LooseMuons_noCaloTag_dRDown") thistoolLoose_noCaloTag_dRdown.MatchToLoose_noCaloTag = True thistoolLoose_noCaloTag_dRdown.ApplyScaleFactors = False thistoolLoose_noCaloTag_dRdown.IsNominal=False thistoolLoose_noCaloTag_dRdown.MaximumDrCut = 0.5 *MATCH_DR MatchingTools += [thistoolLoose_noCaloTag_dRdown] thistoolLoose_noCaloTag_dRUp = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool(name="JPsiTPEfficiencyTool_%s_Loose_noCaloTag_dRUp"%name_suffix,EffiFlag="LooseMuons_noCaloTag_dRUp") thistoolLoose_noCaloTag_dRUp.MatchToLoose_noCaloTag = True thistoolLoose_noCaloTag_dRUp.ApplyScaleFactors = False thistoolLoose_noCaloTag_dRUp.IsNominal=False thistoolLoose_noCaloTag_dRUp.MaximumDrCut = 2 * MATCH_DR MatchingTools += [thistoolLoose_noCaloTag_dRUp] if doMedium: thistoolMed = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool(name="JPsiTPEfficiencyTool_%s_Medium"%name_suffix,EffiFlag="MediumMuons") thistoolMed.MatchToMedium = True thistoolMed.ApplyScaleFactors = False thistoolMed.MaximumDrCut = MATCH_DR MatchingTools += [thistoolMed] if doDRSys: thistoolMedium_dRdown = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool(name="JPsiTPEfficiencyTool_%s_Medium_dRdown"%name_suffix,EffiFlag="MediumMuons_dRDown") thistoolMedium_dRdown.MatchToMedium = True thistoolMedium_dRdown.IsNominal=False thistoolMedium_dRdown.ApplyScaleFactors = False thistoolMedium_dRdown.MaximumDrCut = 0.5 *MATCH_DR MatchingTools += [thistoolMedium_dRdown] thistoolMedium_dRUp = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool(name="JPsiTPEfficiencyTool_%s_Medium_dRUp"%name_suffix,EffiFlag="MediumMuons_dRUp") thistoolMedium_dRUp.MatchToMedium = True thistoolMedium_dRUp.IsNominal=False thistoolMedium_dRUp.ApplyScaleFactors = False thistoolMedium_dRUp.MaximumDrCut = 2 * MATCH_DR MatchingTools += [thistoolMedium_dRUp] if doTight: thistoolTight = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool(name="JPsiTPEfficiencyTool_%s_Tight"%name_suffix,EffiFlag="TightMuons") thistoolTight.MatchToTight = True thistoolTight.ApplyScaleFactors = False thistoolTight.MaximumDrCut = MATCH_DR MatchingTools += [thistoolTight] if doDRSys: thistoolTight_dRdown = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool(name="JPsiTPEfficiencyTool_%s_Tight_dRdown"%name_suffix,EffiFlag="TightMuons_dRDown") thistoolTight_dRdown.MatchToTight = True thistoolTight_dRdown.ApplyScaleFactors = False thistoolTight_dRdown.IsNominal=False thistoolTight_dRdown.MaximumDrCut = 0.5 *MATCH_DR MatchingTools += [thistoolTight_dRdown] thistoolTight_dRUp = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool(name="JPsiTPEfficiencyTool_%s_Tight_dRUp"%name_suffix,EffiFlag="TightMuons_dRUp") thistoolTight_dRUp.MatchToTight = True thistoolTight_dRUp.IsNominal=False thistoolTight_dRUp.ApplyScaleFactors = False thistoolTight_dRUp.MaximumDrCut = 2 * MATCH_DR MatchingTools += [thistoolTight_dRUp] if doHighPt: thistoolHighPt = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool(name="JPsiTPEfficiencyTool_%s_HighPt"%name_suffix, EffiFlag="HighPtMuons") thistoolHighPt.MatchToHighPt = True thistoolHighPt.ScaleFactorTool = CommonMuonTPConfig.AddMuonEfficiencyScaleFactors("Tight") # UPDATE when SF available for high pt thistoolHighPt.ApplyScaleFactors=doClosure thistoolHighPt.MaximumDrCut = MATCH_DR MatchingTools += [thistoolHighPt] if doDRSys: thistoolHighPt_dRDown = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool(name="JPsiTPEfficiencyTool_%s_HighPt_dRDown"%name_suffix, EffiFlag="HighPtMuons_dRDown") thistoolHighPt_dRDown.MatchToHighPt = True thistoolHighPt_dRDown.IsNominal=False thistoolHighPt_dRDown.ScaleFactorTool = CommonMuonTPConfig.AddMuonEfficiencyScaleFactors("HighPt") # UPDATE when SF available for high pt #thistoolHighPt_dRDown.ApplyScaleFactors = True thistoolHighPt_dRDown.MaximumDrCut = 0.5 * MATCH_DR MatchingTools += [thistoolHighPt_dRDown] thistoolHighPt_dRUp = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool(name="JPsiTPEfficiencyTool_%s_HighPt_dRUp"%name_suffix, EffiFlag="HighPtMuons_dRUp") thistoolHighPt_dRUp.MatchToHighPt = True thistoolHighPt_dRUp.IsNominal=False thistoolHighPt_dRUp.ScaleFactorTool = CommonMuonTPConfig.AddMuonEfficiencyScaleFactors("Tight") # UPDATE when SF available for high pt #thistoolHighPt_dRUp.ApplyScaleFactors = True thistoolHighPt_dRUp.MaximumDrCut = 2 * MATCH_DR MatchingTools += [thistoolHighPt_dRUp] ntuples = [] if writeNtuple: ntuples.append(CommonMuonTPConfig.AddTreeTool(name="JPsiTPTreeTool_%s"%name_suffix, EffiFlag="Trees",WriteSFInfo=doClosure)) # create the TP tool itself TheTPTool = CommonMuonTPConfig.AddMuonTPTool(name = "JPsiTPTool_%s"%name_suffix,EffiFlag=name_suffix) TheTPTool.MuonTPSelectionTools = SelectionTools TheTPTool.PlottingTools = PlotTools TheTPTool.MuonTPEfficiencyTools = MatchingTools TheTPTool.TreeTools = ntuples theAlg.MuonTPTools += [TheTPTool]
def AddConfiguredMuonTPAlg(name_suffix="MuonProbe_JPsi", MatchContainer="Muons", doIso=True, doTrig=True, doTrigEtaSlices=True, doIsolEtaSlices=False, doIsolPlots=False, doTriggerPlots=True, writeNtuple=False, doClosure=False, doDRSys=False, doDPhiTPSys=False, doProbeCharSys=False, doVeryLooseProbes=False, doLooseProbes=False, doMediumProbes=False, doTightProbes=False, doHighPtProbes=False, doTruthProbes=False, DoProbeMatchPlots=True, ProduceEfficiencies=False, doL1=False, doL2=False, doEF=False, doHLT=False): from AthenaCommon.AlgSequence import AlgSequence from AthenaCommon.AppMgr import ToolSvc job = AlgSequence() MuonContainerToUse = "Muons" if hasattr(job, "MuonQualityUpdater"): MuonContainerToUse = "UpdatedMuons" ProbeContainer = MuonContainerToUse theAlg = CommonMuonTPConfig.AddTagProbeAlg(name="JPsiTPMuonAlg_%s" % name_suffix, ProbeCont=ProbeContainer, MatchCont=MatchContainer) theAlg.TopLevelFolderName = "JPsiTPMuon" SelectionTools = [] if doLooseProbes: SelecToolsOC_LooseProbes = CommonMuonTPConfig.AddJPsiTPSelectionTool( name="JPsiTPSelectionTool_OC_LooseProbes_%s" % name_suffix, EffiFlag="%s_OC_LooseProbes" % name_suffix, ProbeType="Loose") SelecToolsOC_LooseProbes.UseLooseProbes = True SelectionTools.append(SelecToolsOC_LooseProbes) SelecToolsSC_LooseProbes = CommonMuonTPConfig.AddJPsiTPSelectionTool( name="JPsiTPSelectionTool_SC_LooseProbes_%s" % name_suffix, EffiFlag="%s_SC_LooseProbes" % name_suffix, ProbeType="Loose", SameSign=True) SelecToolsSC_LooseProbes.UseLooseProbes = True SelectionTools.append(SelecToolsSC_LooseProbes) if doDPhiTPSys: SelecToolsOC_LooseProbesDPhiCut = CommonMuonTPConfig.AddJPsiTPSelectionTool( name="JPsiTPSelectionTool_OC_LooseProbesDPhiCut_%s" % name_suffix, EffiFlag="%s_OC_LooseProbesDPhiCut" % name_suffix, ProbeType="Loose") SelecToolsOC_LooseProbesDPhiCut.DeltaPhiCut = 3.04 SelecToolsOC_LooseProbesDPhiCut.IsNominal = False SelectionTools.append(SelecToolsOC_LooseProbesDPhiCut) SelecToolsSC_LooseProbesDPhiCut = CommonMuonTPConfig.AddJPsiTPSelectionTool( name="JPsiTPSelectionTool_SC_LooseProbesDPhiCut_%s" % name_suffix, EffiFlag="%s_SC_LooseProbesDPhiCut" % name_suffix, ProbeType="Loose", SameSign=True) SelecToolsSC_LooseProbesDPhiCut.DeltaPhiCut = 3.04 SelecToolsSC_LooseProbesDPhiCut.IsNominal = False SelectionTools.append(SelecToolsSC_LooseProbesDPhiCut) if doProbeCharSys: SelecToolsOC_LooseProbesPos = CommonMuonTPConfig.AddJPsiTPSelectionTool( name="JPsiTPSelectionTool_OC_LooseProbesPos_%s" % name_suffix, EffiFlag="%s_OC_LooseProbesPos" % name_suffix, ProbeType="Loose") SelecToolsOC_LooseProbesPos.doProbeChargeSys = True SelecToolsOC_LooseProbesPos.ProbeCharge = "positive" SelecToolsOC_LooseProbesPos.IsNominal = False SelectionTools.append(SelecToolsOC_LooseProbesPos) SelecToolsOC_LooseProbesNeg = CommonMuonTPConfig.AddJPsiTPSelectionTool( name="JPsiTPSelectionTool_OC_LooseProbesNeg_%s" % name_suffix, EffiFlag="%s_OC_LooseProbesNeg" % name_suffix, ProbeType="Loose") SelecToolsOC_LooseProbesNeg.doProbeChargeSys = True SelecToolsOC_LooseProbesNeg.IsNominal = False SelecToolsOC_LooseProbesNeg.ProbeCharge = "negative" SelectionTools.append(SelecToolsOC_LooseProbesNeg) SelecToolsSC_LooseProbesPos = CommonMuonTPConfig.AddJPsiTPSelectionTool( name="JPsiTPSelectionTool_SC_LooseProbesPos_%s" % name_suffix, EffiFlag="%s_SC_LooseProbesPos" % name_suffix, ProbeType="Loose", SameSign=True) SelecToolsSC_LooseProbesPos.doProbeChargeSys = True SelecToolsSC_LooseProbesPos.ProbeCharge = "positive" SelecToolsSC_LooseProbesPos.IsNominal = False SelectionTools.append(SelecToolsSC_LooseProbesPos) SelecToolsSC_LooseProbesNeg = CommonMuonTPConfig.AddJPsiTPSelectionTool( name="JPsiTPSelectionTool_SC_LooseProbesNeg_%s" % name_suffix, EffiFlag="%s_SC_LooseProbesNeg" % name_suffix, ProbeType="Loose", SameSign=True) SelecToolsSC_LooseProbesNeg.doProbeChargeSys = True SelecToolsSC_LooseProbesNeg.IsNominal = False SelecToolsSC_LooseProbesNeg.ProbeCharge = "negative" SelectionTools.append(SelecToolsSC_LooseProbesNeg) if doMediumProbes: SelecToolsOC_MediumProbes = CommonMuonTPConfig.AddJPsiTPSelectionTool( name="JPsiTPSelectionTool_OC_MediumProbes_%s" % name_suffix, EffiFlag="%s_OC_MediumProbes" % name_suffix, ProbeType="Medium") SelecToolsOC_MediumProbes.UseMediumProbes = True SelectionTools.append(SelecToolsOC_MediumProbes) SelecToolsSC_MediumProbes = CommonMuonTPConfig.AddJPsiTPSelectionTool( name="JPsiTPSelectionTool_SC_MediumProbes_%s" % name_suffix, EffiFlag="%s_SC_MediumProbes" % name_suffix, ProbeType="Medium", SameSign=True) SelecToolsSC_MediumProbes.UseMediumProbes = True SelectionTools.append(SelecToolsSC_MediumProbes) if doDPhiTPSys: SelecToolsOC_MediumProbesDPhiCut = CommonMuonTPConfig.AddJPsiTPSelectionTool( name="JPsiTPSelectionTool_OC_MediumProbesDPhiCut_%s" % name_suffix, EffiFlag="%s_OC_MediumProbesDPhiCut" % name_suffix, ProbeType="Medium") SelecToolsOC_MediumProbesDPhiCut.DeltaPhiCut = 3.04 SelecToolsOC_MediumProbesDPhiCut.IsNominal = False SelectionTools.append(SelecToolsOC_MediumProbesDPhiCut) SelecToolsSC_MediumProbesDPhiCut = CommonMuonTPConfig.AddJPsiTPSelectionTool( name="JPsiTPSelectionTool_SC_MediumProbesDPhiCut_%s" % name_suffix, EffiFlag="%s_SC_MediumProbesDPhiCut" % name_suffix, ProbeType="Medium", SameSign=True) SelecToolsSC_MediumProbesDPhiCut.DeltaPhiCut = 3.04 SelecToolsSC_MediumProbesDPhiCut.IsNominal = False SelectionTools.append(SelecToolsSC_MediumProbesDPhiCut) if doProbeCharSys: SelecToolsOC_MediumProbesPos = CommonMuonTPConfig.AddJPsiTPSelectionTool( name="JPsiTPSelectionTool_OC_MediumProbesPos_%s" % name_suffix, EffiFlag="%s_OC_MediumProbesPos" % name_suffix, ProbeType="Medium") SelecToolsOC_MediumProbesPos.doProbeChargeSys = True SelecToolsOC_MediumProbesPos.ProbeCharge = "positive" SelecToolsOC_MediumProbesPos.IsNominal = False SelectionTools.append(SelecToolsOC_MediumProbesPos) SelecToolsOC_MediumProbesNeg = CommonMuonTPConfig.AddJPsiTPSelectionTool( name="JPsiTPSelectionTool_OC_MediumProbesNeg_%s" % name_suffix, EffiFlag="%s_OC_MediumProbesNeg" % name_suffix, ProbeType="Medium") SelecToolsOC_MediumProbesNeg.doProbeChargeSys = True SelecToolsOC_MediumProbesNeg.IsNominal = False SelecToolsOC_MediumProbesNeg.ProbeCharge = "negative" SelectionTools.append(SelecToolsOC_MediumProbesNeg) SelecToolsSC_MediumProbesPos = CommonMuonTPConfig.AddJPsiTPSelectionTool( name="JPsiTPSelectionTool_SC_MediumProbesPos_%s" % name_suffix, EffiFlag="%s_SC_MediumProbesPos" % name_suffix, ProbeType="Medium", SameSign=True) SelecToolsSC_MediumProbesPos.doProbeChargeSys = True SelecToolsSC_MediumProbesPos.ProbeCharge = "positive" SelecToolsSC_MediumProbesPos.IsNominal = False SelectionTools.append(SelecToolsSC_MediumProbesPos) SelecToolsSC_MediumProbesNeg = CommonMuonTPConfig.AddJPsiTPSelectionTool( name="JPsiTPSelectionTool_SC_MediumProbesNeg_%s" % name_suffix, EffiFlag="%s_SC_MediumProbesNeg" % name_suffix, ProbeType="Medium", SameSign=True) SelecToolsSC_MediumProbesNeg.doProbeChargeSys = True SelecToolsSC_MediumProbesNeg.IsNominal = False SelecToolsSC_MediumProbesNeg.ProbeCharge = "negative" SelectionTools.append(SelecToolsSC_MediumProbesNeg) if doTightProbes: SelecToolsOC_TightProbes = CommonMuonTPConfig.AddJPsiTPSelectionTool( name="JPsiTPSelectionTool_OC_TightProbes_%s" % name_suffix, EffiFlag="%s_OC_TightProbes" % name_suffix, ProbeType="Tight") SelecToolsOC_TightProbes.UseTightProbes = True SelectionTools.append(SelecToolsOC_TightProbes) SelecToolsSC_TightProbes = CommonMuonTPConfig.AddJPsiTPSelectionTool( name="JPsiTPSelectionTool_SC_TightProbes_%s" % name_suffix, EffiFlag="%s_SC_TightProbes" % name_suffix, ProbeType="Tight", SameSign=True) SelecToolsSC_TightProbes.UseTightProbes = True SelectionTools.append(SelecToolsSC_TightProbes) if doDPhiTPSys: SelecToolsOC_TightProbesDPhiCut = CommonMuonTPConfig.AddJPsiTPSelectionTool( name="JPsiTPSelectionTool_OC_TightProbesDPhiCut_%s" % name_suffix, EffiFlag="%s_OC_TightProbesDPhiCut" % name_suffix, ProbeType="Tight") SelecToolsOC_TightProbesDPhiCut.DeltaPhiCut = 3.04 SelecToolsOC_TightProbesDPhiCut.IsNominal = False SelectionTools.append(SelecToolsOC_TightProbesDPhiCut) SelecToolsSC_TightProbesDPhiCut = CommonMuonTPConfig.AddJPsiTPSelectionTool( name="JPsiTPSelectionTool_SC_TightProbesDPhiCut_%s" % name_suffix, EffiFlag="%s_SC_TightProbesDPhiCut" % name_suffix, ProbeType="Tight", SameSign=True) SelecToolsSC_TightProbesDPhiCut.DeltaPhiCut = 3.04 SelecToolsSC_TightProbesDPhiCut.IsNominal = False SelectionTools.append(SelecToolsSC_TightProbesDPhiCut) if doProbeCharSys: SelecToolsOC_TightProbesPos = CommonMuonTPConfig.AddJPsiTPSelectionTool( name="JPsiTPSelectionTool_OC_TightProbesPos_%s" % name_suffix, EffiFlag="%s_OC_TightProbesPos" % name_suffix, ProbeType="Tight") SelecToolsOC_TightProbesPos.doProbeChargeSys = True SelecToolsOC_TightProbesPos.ProbeCharge = "positive" SelecToolsOC_TightProbesPos.IsNominal = False SelectionTools.append(SelecToolsOC_TightProbesPos) SelecToolsOC_TightProbesNeg = CommonMuonTPConfig.AddJPsiTPSelectionTool( name="JPsiTPSelectionTool_OC_TightProbesNeg_%s" % name_suffix, EffiFlag="%s_OC_TightProbesNeg" % name_suffix, ProbeType="Tight") SelecToolsOC_TightProbesNeg.doProbeChargeSys = True SelecToolsOC_TightProbesNeg.IsNominal = False SelecToolsOC_TightProbesNeg.ProbeCharge = "negative" SelectionTools.append(SelecToolsOC_TightProbesNeg) SelecToolsSC_TightProbesPos = CommonMuonTPConfig.AddJPsiTPSelectionTool( name="JPsiTPSelectionTool_SC_TightProbesPos_%s" % name_suffix, EffiFlag="%s_SC_TightProbesPos" % name_suffix, ProbeType="Tight", SameSign=True) SelecToolsSC_TightProbesPos.doProbeChargeSys = True SelecToolsSC_TightProbesPos.ProbeCharge = "positive" SelecToolsSC_TightProbesPos.IsNominal = False SelectionTools.append(SelecToolsSC_TightProbesPos) SelecToolsSC_TightProbesNeg = CommonMuonTPConfig.AddJPsiTPSelectionTool( name="JPsiTPSelectionTool_SC_TightProbesNeg_%s" % name_suffix, EffiFlag="%s_SC_TightProbesNeg" % name_suffix, ProbeType="Tight", SameSign=True) SelecToolsSC_TightProbesNeg.doProbeChargeSys = True SelecToolsSC_TightProbesNeg.IsNominal = False SelecToolsSC_TightProbesNeg.ProbeCharge = "negative" SelectionTools.append(SelecToolsSC_TightProbesNeg) if doHighPtProbes: SelecToolsOC_HighPtProbes = CommonMuonTPConfig.AddJPsiTPSelectionTool( name="JPsiTPSelectionTool_OC_HighPtProbes_%s" % name_suffix, EffiFlag="%s_OC_HighPtProbes" % name_suffix, ProbeType="HighPt") SelecToolsOC_HighPtProbes.UseHighPtProbes = True SelectionTools.append(SelecToolsOC_HighPtProbes) SelecToolsSC_HighPtProbes = CommonMuonTPConfig.AddJPsiTPSelectionTool( name="JPsiTPSelectionTool_SC_HighPtProbes_%s" % name_suffix, EffiFlag="%s_SC_HighPtProbes" % name_suffix, ProbeType="HighPt", SameSign=True) SelecToolsSC_HighPtProbes.UseHighPtProbes = True SelectionTools.append(SelecToolsSC_HighPtProbes) if doDPhiTPSys: SelecToolsOC_HighPtProbesDPhiCut = CommonMuonTPConfig.AddJPsiTPSelectionTool( name="JPsiTPSelectionTool_OC_HighPtProbesDPhiCut_%s" % name_suffix, EffiFlag="%s_OC_HighPtProbesDPhiCut" % name_suffix, ProbeType="HighPt") SelecToolsOC_HighPtProbesDPhiCut.DeltaPhiCut = 3.04 SelecToolsOC_HighPtProbesDPhiCut.IsNominal = False SelectionTools.append(SelecToolsOC_HighPtProbesDPhiCut) SelecToolsSC_HighPtProbesDPhiCut = CommonMuonTPConfig.AddJPsiTPSelectionTool( name="JPsiTPSelectionTool_SC_HighPtProbesDPhiCut_%s" % name_suffix, EffiFlag="%s_SC_HighPtProbesDPhiCut" % name_suffix, ProbeType="HighPt", SameSign=True) SelecToolsSC_HighPtProbesDPhiCut.DeltaPhiCut = 3.04 SelecToolsSC_HighPtProbesDPhiCut.IsNominal = False SelectionTools.append(SelecToolsSC_HighPtProbesDPhiCut) if doProbeCharSys: SelecToolsOC_HighPtProbesPos = CommonMuonTPConfig.AddJPsiTPSelectionTool( name="JPsiTPSelectionTool_OC_HighPtProbesPos_%s" % name_suffix, EffiFlag="%s_OC_HighPtProbesPos" % name_suffix, ProbeType="HighPt") SelecToolsOC_HighPtProbesPos.doProbeChargeSys = True SelecToolsOC_HighPtProbesPos.ProbeCharge = "positive" SelecToolsOC_HighPtProbesPos.IsNominal = False SelectionTools.append(SelecToolsOC_HighPtProbesPos) SelecToolsOC_HighPtProbesNeg = CommonMuonTPConfig.AddJPsiTPSelectionTool( name="JPsiTPSelectionTool_OC_HighPtProbesNeg_%s" % name_suffix, EffiFlag="%s_OC_HighPtProbesNeg" % name_suffix, ProbeType="HighPt") SelecToolsOC_HighPtProbesNeg.doProbeChargeSys = True SelecToolsOC_HighPtProbesNeg.IsNominal = False SelecToolsOC_HighPtProbesNeg.ProbeCharge = "negative" SelectionTools.append(SelecToolsOC_HighPtProbesNeg) SelecToolsSC_HighPtProbesPos = CommonMuonTPConfig.AddJPsiTPSelectionTool( name="JPsiTPSelectionTool_SC_HighPtProbesPos_%s" % name_suffix, EffiFlag="%s_SC_HighPtProbesPos" % name_suffix, ProbeType="HighPt", SameSign=True) SelecToolsSC_HighPtProbesPos.doProbeChargeSys = True SelecToolsSC_HighPtProbesPos.ProbeCharge = "positive" SelecToolsSC_HighPtProbesPos.IsNominal = False SelectionTools.append(SelecToolsSC_HighPtProbesPos) SelecToolsSC_HighPtProbesNeg = CommonMuonTPConfig.AddJPsiTPSelectionTool( name="JPsiTPSelectionTool_SC_HighPtProbesNeg_%s" % name_suffix, EffiFlag="%s_SC_HighPtProbesNeg" % name_suffix, ProbeType="HighPt", SameSign=True) SelecToolsSC_HighPtProbesNeg.doProbeChargeSys = True SelecToolsSC_HighPtProbesNeg.IsNominal = False SelecToolsSC_HighPtProbesNeg.ProbeCharge = "negative" SelectionTools.append(SelecToolsSC_HighPtProbesNeg) from AthenaCommon.GlobalFlags import globalflags if doTruthProbes and not globalflags.DataSource() == 'data': SelecToolsOC_TruthProbes = CommonMuonTPConfig.AddJPsiTPSelectionTool( name="JPsiTPSelectionTool_OC_TruthProbes_%s" % name_suffix, EffiFlag="%s_TruthProbes" % name_suffix, ProbeType="TruthMatchedMuons") SelectionTools.append(SelecToolsOC_TruthProbes) for thetool in SelectionTools: thetool.ProbeTrackIsoCut = -1 thetool.ProbeTrackAntiIsoCut = -1 thetool.ProbeCaloIsoCut = -1 thetool.ProbeCaloAntiIsoCut = -1 # also accept high eta muons thetool.ProbeEtaCut = 4.5 PlotTools = [] # first the trigger plots if doTrig and doTriggerPlots: PlotTools += JPsiTPTrigAnalysis.AddTrigPlots( name_suffix=name_suffix, doEtaSlices=doTrigEtaSlices, doClosure=doClosure, DoProbeMatchPlots=DoProbeMatchPlots, ProduceEfficiencies=ProduceEfficiencies) # then the isolation plots if doIso and doIsolPlots: PlotTools += JPsiTPIsolAnalysis.AddIsolPlots( name_suffix=name_suffix, doEtaSlices=doIsolEtaSlices, doClosure=doClosure, DoProbeMatchPlots=DoProbeMatchPlots, ProduceEfficiencies=ProduceEfficiencies) MatchingTools = [] if doTrig: MatchingTools += JPsiTPTrigAnalysis.AddTrigMatchTools( name_suffix=name_suffix, doL1=doL1, doL2=doL2, doEF=doEF, doHLT=doHLT, doDRSys=doDRSys) if doIso: MatchingTools += JPsiTPIsolAnalysis.AddIsolMatchTools(name_suffix) ntuples = [] if writeNtuple: ntuples.append( CommonMuonTPConfig.AddTreeTool(name="JPsiTPMuonTreeTool_%s" % name_suffix, EffiFlag="Trees", WriteSFInfo=doClosure)) for ntuple in ntuples: if doIso: ntuple.AddExtendedIsolation = True # create the TP tool itself TheTPTool = CommonMuonTPConfig.AddMuonTPTool(name="MuonProbeTPTool_%s" % name_suffix, EffiFlag=name_suffix) TheTPTool.MuonTPSelectionTools = SelectionTools TheTPTool.PlottingTools = PlotTools TheTPTool.MuonTPEfficiencyTools = MatchingTools TheTPTool.TreeTools = ntuples theAlg.MuonTPTools += [TheTPTool]
def AddConfiguredZmumuTPAlg( name_suffix="myProbes", ProbeKind="CaloTag", # options: "CaloTag","MS", "Truth", "ID" MatchContainer="Muons", doID=False, doCB=True, doLoose=True, doMedium=True, doTight=True, doHighPt=True, doStandalone=False, doCaloTag=False, doIndividualAuthors=False, doEtaSlices=False, writeNtuple=False, doClosure=False, doDRSys=False, DoProbeMatchPlots=True, ProduceEfficiencies=False): from AthenaCommon.AlgSequence import AlgSequence from AthenaCommon.AppMgr import ToolSvc job = AlgSequence() MuonContainerToUse = "Muons" #if hasattr(job, "MuonQualityUpdater"): #MuonContainerToUse = "UpdatedMuons" ProbeContainer = MuonContainerToUse if ProbeKind == "MSTrackPart": ProbeContainer = "ExtrapolatedMuonTrackParticles" ProbeKind = "MS" if ProbeKind == "ID": ProbeContainer = "InDetTrackParticles" if ProbeKind == "Truth": ProbeContainer = "MuonTruthParticles" theAlg = CommonMuonTPConfig.AddTagProbeAlg(name="ZmumuTPAlg_%s" % name_suffix, ProbeCont=ProbeContainer, MatchCont=MatchContainer) theAlg.TopLevelFolderName = "ZmumuTPReco" #AddMuonSelectionTool() # add a plotting tool #PlotTool = AddPlottingTool(name="ZmumuTPPlottingTool_%s"%name_suffix,EffiFlag=name_suffix) # add four TP selection tools (iso and antiiso OC and SC) SelectionTools = [] SelectionTools += [ CommonMuonTPConfig.AddZmumuTPSelectionTool( name="ZmumuTPSelectionTool_OC_%s" % name_suffix, EffiFlag="%s_OC" % name_suffix, ProbeType=ProbeKind) ] SelectionTools += [ CommonMuonTPConfig.AddZmumuTPSelectionTool( name="ZmumuTPSelectionTool_SC_%s" % name_suffix, EffiFlag="%s_SC" % name_suffix, ProbeType=ProbeKind, SameSign=True) ] SelectionTools += [ CommonMuonTPConfig.AddZmumuTPSelectionTool( name="ZmumuTPSelectionTool_OCAntiIso_%s" % name_suffix, EffiFlag="%s_OCAntiIso" % name_suffix, ProbeType=ProbeKind, AntiIso=True) ] SelectionTools += [ CommonMuonTPConfig.AddZmumuTPSelectionTool( name="ZmumuTPSelectionTool_SCAntiIso_%s" % name_suffix, EffiFlag="%s_SCAntiIso" % name_suffix, ProbeType=ProbeKind, SameSign=True, AntiIso=True) ] PlotTools = [] # add plotting tools in slices if doEtaSlices: Slices = { "All": (0.0, 10.0), "noCrack": (0.1, 10.0), "Crack": (0.0, 0.1), "Barrel": (0.1, 1.1), "Transition": (1.1, 1.3), "Endcap": (1.3, 2.0), "CSC": (2.0, 2.7) } for etaslice, interval in Slices.iteritems(): PlotTool = CommonMuonTPConfig.AddPlottingTool( name="ZmumuTPPlottingTool_%s_%s" % (name_suffix, etaslice), EffiFlag=name_suffix + "_" + etaslice, applySF=False, DoProbeMatchPlots=DoProbeMatchPlots, ProduceEfficiencies=ProduceEfficiencies) PlotTool.ProbeAbsEtaMin = interval[0] PlotTool.ProbeAbsEtaMax = interval[1] PlotTools.append(PlotTool) if doClosure: PlotToolCL = CommonMuonTPConfig.AddPlottingTool( name="ZmumuTPPlottingToolClosure_%s_%s" % (name_suffix, etaslice), EffiFlag=name_suffix + "_" + etaslice + "_Closure", applySF=True, DoProbeMatchPlots=DoProbeMatchPlots, ProduceEfficiencies=ProduceEfficiencies) PlotToolCL.ProbeAbsEtaMin = interval[0] PlotToolCL.ProbeAbsEtaMax = interval[1] PlotTools.append(PlotToolCL) else: PlotTools = [ CommonMuonTPConfig.AddPlottingTool( name="ZmumuTPPlottingTool_%s_All" % name_suffix, EffiFlag=name_suffix + "_All", applySF=False, DoProbeMatchPlots=DoProbeMatchPlots, ProduceEfficiencies=ProduceEfficiencies) ] if doClosure: PlotTools.append( CommonMuonTPConfig.AddPlottingTool( name="ZmumuTPPlottingToolClosure_%s_All" % name_suffix, EffiFlag=name_suffix + "_All_Closure", applySF=True, DoProbeMatchPlots=DoProbeMatchPlots, ProduceEfficiencies=ProduceEfficiencies)) # Config the plot tools for thetool in PlotTools: thetool.doZmumuKinematicPlots = False thetool.doFineEtaPhiPlots = True thetool.doDetectorRegionPlots = True # add any desired matching tools MATCH_DR = 0.05 MatchingTools = [] if doCB: thistoolCB = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool( name="ZmumuTPEfficiencyTool_%s_CB" % name_suffix, EffiFlag="CombinedMuons") thistoolCB.MatchToCB = True thistoolCB.ScaleFactorTool = CommonMuonTPConfig.AddMuonEfficiencyScaleFactors( "Medium") thistoolCB.ApplyScaleFactors = doClosure thistoolCB.MaximumDrCut = MATCH_DR MatchingTools += [thistoolCB] if doDRSys: thistoolCB_dRDown = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool( name="ZmumuTPEfficiencyTool_%s_CB_dRDown" % name_suffix, EffiFlag="CombinedMuons_dRDown") thistoolCB_dRDown.IsNominal = False thistoolCB_dRDown.MatchToCB = True thistoolCB_dRDown.ScaleFactorTool = CommonMuonTPConfig.AddMuonEfficiencyScaleFactors( "Medium") #thistoolCB_dRDown.ApplyScaleFactors = True thistoolCB_dRDown.MaximumDrCut = 0.5 * MATCH_DR MatchingTools += [thistoolCB_dRDown] thistoolCB_dRUp = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool( name="ZmumuTPEfficiencyTool_%s_CB_dRUp" % name_suffix, EffiFlag="CombinedMuons_dRUp") thistoolCB_dRUp.MatchToCB = True thistoolCB_dRUp.IsNominal = False thistoolCB_dRUp.ScaleFactorTool = CommonMuonTPConfig.AddMuonEfficiencyScaleFactors( "Medium") #thistoolCB_dRUp.ApplyScaleFactors = True thistoolCB_dRUp.MaximumDrCut = 2. * MATCH_DR MatchingTools += [thistoolCB_dRUp] if doLoose: thistoolLoose = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool( name="ZmumuTPEfficiencyTool_%s_Loose" % name_suffix, EffiFlag="LooseMuons") thistoolLoose.MatchToLoose = True thistoolLoose.ScaleFactorTool = CommonMuonTPConfig.AddMuonEfficiencyScaleFactors( "Loose") thistoolLoose.ApplyScaleFactors = doClosure #thistoolLoose.ApplyScaleFactors = True thistoolLoose.MaximumDrCut = MATCH_DR MatchingTools += [thistoolLoose] if doDRSys: thistoolLoose_dRDown = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool( name="ZmumuTPEfficiencyTool_%s_Loose_dRDown" % name_suffix, EffiFlag="LooseMuons_dRDown") thistoolLoose_dRDown.MatchToLoose = True thistoolLoose_dRDown.IsNominal = False thistoolLoose_dRDown.ScaleFactorTool = CommonMuonTPConfig.AddMuonEfficiencyScaleFactors( "Loose") #thistoolLoose_dRDown.ApplyScaleFactors = True thistoolLoose_dRDown.MaximumDrCut = 0.5 * MATCH_DR MatchingTools += [thistoolLoose_dRDown] thistoolLoose_dRUp = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool( name="ZmumuTPEfficiencyTool_%s_Loose_dRUp" % name_suffix, EffiFlag="LooseMuons_dRUp") thistoolLoose_dRUp.MatchToLoose = True thistoolLoose_dRUp.IsNominal = False thistoolLoose_dRUp.ScaleFactorTool = CommonMuonTPConfig.AddMuonEfficiencyScaleFactors( "Loose") #thistoolLoose_dRUp.ApplyScaleFactors = True thistoolLoose_dRUp.MaximumDrCut = 2 * MATCH_DR MatchingTools += [thistoolLoose_dRUp] # also run a version without CaloTag thistoolLoose_noCaloTag = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool( name="ZmumuTPEfficiencyTool_%s_Loose_noCaloTag" % name_suffix, EffiFlag="LooseMuons_noCaloTag") thistoolLoose_noCaloTag.MatchToLoose_noCaloTag = True thistoolLoose_noCaloTag.ScaleFactorTool = CommonMuonTPConfig.AddMuonEfficiencyScaleFactors( "Loose") thistoolLoose_noCaloTag.ApplyScaleFactors = doClosure #thistoolLoose_noCaloTag.ApplyScaleFactors = True thistoolLoose_noCaloTag.MaximumDrCut = MATCH_DR MatchingTools += [thistoolLoose_noCaloTag] if doDRSys: thistoolLoose_noCaloTag_dRDown = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool( name="ZmumuTPEfficiencyTool_%s_Loose_noCaloTag_dRDown" % name_suffix, EffiFlag="LooseMuons_noCaloTag_dRDown") thistoolLoose_noCaloTag_dRDown.MatchToLoose_noCaloTag = True thistoolLoose_noCaloTag_dRDown.ScaleFactorTool = CommonMuonTPConfig.AddMuonEfficiencyScaleFactors( "Loose") #thistoolLoose_noCaloTag_dRDown.ApplyScaleFactors = True thistoolLoose_noCaloTag_dRDown.IsNominal = False thistoolLoose_noCaloTag_dRDown.MaximumDrCut = 0.5 * MATCH_DR MatchingTools += [thistoolLoose_noCaloTag_dRDown] thistoolLoose_noCaloTag_dRUp = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool( name="ZmumuTPEfficiencyTool_%s_Loose_noCaloTag_dRUp" % name_suffix, EffiFlag="LooseMuons_noCaloTag_dRUp") thistoolLoose_noCaloTag_dRUp.MatchToLoose_noCaloTag = True thistoolLoose_noCaloTag_dRUp.ScaleFactorTool = CommonMuonTPConfig.AddMuonEfficiencyScaleFactors( "Loose") #thistoolLoose_noCaloTag_dRUp.ApplyScaleFactors = True thistoolLoose_noCaloTag_dRUp.IsNominal = False thistoolLoose_noCaloTag_dRUp.MaximumDrCut = 2 * MATCH_DR MatchingTools += [thistoolLoose_noCaloTag_dRUp] if doMedium: thistoolMed = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool( name="ZmumuTPEfficiencyTool_%s_Medium" % name_suffix, EffiFlag="MediumMuons") thistoolMed.MatchToMedium = True thistoolMed.ScaleFactorTool = CommonMuonTPConfig.AddMuonEfficiencyScaleFactors( "Medium") thistoolMed.ApplyScaleFactors = doClosure thistoolMed.MaximumDrCut = MATCH_DR MatchingTools += [thistoolMed] if doDRSys: thistoolMed_dRDown = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool( name="ZmumuTPEfficiencyTool_%s_Medium_dRDown" % name_suffix, EffiFlag="MediumMuons_dRDown") thistoolMed_dRDown.MatchToMedium = True thistoolMed_dRDown.IsNominal = False thistoolMed_dRDown.ScaleFactorTool = CommonMuonTPConfig.AddMuonEfficiencyScaleFactors( "Medium") #thistoolMed_dRDown.ApplyScaleFactors = True thistoolMed_dRDown.MaximumDrCut = 0.5 * MATCH_DR MatchingTools += [thistoolMed_dRDown] thistoolMed_dRUp = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool( name="ZmumuTPEfficiencyTool_%s_Medium_dRUp" % name_suffix, EffiFlag="MediumMuons_dRUp") thistoolMed_dRUp.MatchToMedium = True thistoolMed_dRUp.IsNominal = False thistoolMed_dRUp.ScaleFactorTool = CommonMuonTPConfig.AddMuonEfficiencyScaleFactors( "Medium") #thistoolMed_dRUp.ApplyScaleFactors = True thistoolMed_dRUp.MaximumDrCut = 2 * MATCH_DR MatchingTools += [thistoolMed_dRUp] thistoolMed_PtrMatch = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool( name="ZmumuTPEfficiencyTool_PtrMatch_%s_Medium" % name_suffix, EffiFlag="MediumMuons_PtrMatching") thistoolMed_PtrMatch.MatchToMedium = True thistoolMed_PtrMatch.ScaleFactorTool = CommonMuonTPConfig.AddMuonEfficiencyScaleFactors( "Medium") thistoolMed_PtrMatch.ApplyScaleFactors = doClosure #thistoolMed_PtrMatch.ApplyScaleFactors = True thistoolMed_PtrMatch.MaximumDrCut = MATCH_DR MatchingTools += [thistoolMed_PtrMatch] if doTight: thistoolTight = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool( name="ZmumuTPEfficiencyTool_%s_Tight" % name_suffix, EffiFlag="TightMuons") thistoolTight.MatchToTight = True thistoolTight.ScaleFactorTool = CommonMuonTPConfig.AddMuonEfficiencyScaleFactors( "Tight") thistoolTight.ApplyScaleFactors = doClosure #thistoolTight.ApplyScaleFactors = True thistoolTight.MaximumDrCut = MATCH_DR MatchingTools += [thistoolTight] if doDRSys: thistoolTight_dRDown = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool( name="ZmumuTPEfficiencyTool_%s_Tight_dRDown" % name_suffix, EffiFlag="TightMuons_dRDown") thistoolTight_dRDown.MatchToTight = True thistoolTight_dRDown.IsNominal = False thistoolTight_dRDown.ScaleFactorTool = CommonMuonTPConfig.AddMuonEfficiencyScaleFactors( "Tight") #thistoolTight_dRDown.ApplyScaleFactors = True thistoolTight_dRDown.MaximumDrCut = 0.5 * MATCH_DR MatchingTools += [thistoolTight_dRDown] thistoolTight_dRUp = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool( name="ZmumuTPEfficiencyTool_%s_Tight_dRUp" % name_suffix, EffiFlag="TightMuons_dRUp") thistoolTight_dRUp.MatchToTight = True thistoolTight_dRUp.IsNominal = False thistoolTight_dRUp.ScaleFactorTool = CommonMuonTPConfig.AddMuonEfficiencyScaleFactors( "Tight") #thistoolTight_dRUp.ApplyScaleFactors = True thistoolTight_dRUp.MaximumDrCut = 2 * MATCH_DR MatchingTools += [thistoolTight_dRUp] if doHighPt: thistoolHighPt = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool( name="ZmumuTPEfficiencyTool_%s_HighPt" % name_suffix, EffiFlag="HighPtMuons") thistoolHighPt.MatchToHighPt = True thistoolHighPt.ScaleFactorTool = CommonMuonTPConfig.AddMuonEfficiencyScaleFactors( "Tight") # UPDATE when SF available for high pt thistoolHighPt.ApplyScaleFactors = doClosure #thistoolHighPt.ApplyScaleFactors = True thistoolHighPt.MaximumDrCut = MATCH_DR MatchingTools += [thistoolHighPt] if doDRSys: thistoolHighPt_dRDown = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool( name="ZmumuTPEfficiencyTool_%s_HighPt_dRDown" % name_suffix, EffiFlag="HighPtMuons_dRDown") thistoolHighPt_dRDown.MatchToHighPt = True thistoolHighPt_dRDown.IsNominal = False thistoolHighPt_dRDown.ScaleFactorTool = CommonMuonTPConfig.AddMuonEfficiencyScaleFactors( "HighPt") # UPDATE when SF available for high pt #thistoolHighPt_dRDown.ApplyScaleFactors = True thistoolHighPt_dRDown.MaximumDrCut = 0.5 * MATCH_DR MatchingTools += [thistoolHighPt_dRDown] thistoolHighPt_dRUp = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool( name="ZmumuTPEfficiencyTool_%s_HighPt_dRUp" % name_suffix, EffiFlag="HighPtMuons_dRUp") thistoolHighPt_dRUp.MatchToHighPt = True thistoolHighPt_dRUp.IsNominal = False thistoolHighPt_dRUp.ScaleFactorTool = CommonMuonTPConfig.AddMuonEfficiencyScaleFactors( "Tight") # UPDATE when SF available for high pt #thistoolHighPt_dRUp.ApplyScaleFactors = True thistoolHighPt_dRUp.MaximumDrCut = 2 * MATCH_DR MatchingTools += [thistoolHighPt_dRUp] if doStandalone: thistoolSA = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool( name="ZmumuTPEfficiencyTool_%s_SA" % name_suffix, EffiFlag="StandaloneMuons") thistoolSA.MatchToAnyMS = True thistoolSA.IDhitCut = False thistoolSA.ApplyScaleFactors = doClosure thistoolSA.MaximumDrCut = MATCH_DR MatchingTools += [thistoolSA] if doDRSys: thistoolSA_dRDown = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool( name="ZmumuTPEfficiencyTool_%s_SA_dRDown" % name_suffix, EffiFlag="StandaloneMuons_dRDown") thistoolSA_dRDown.MatchToAnyMS = True thistoolSA_dRDown.IDhitCut = False thistoolSA_dRDown.IsNominal = False thistoolSA_dRDown.ApplyScaleFactors = doClosure thistoolSA_dRDown.MaximumDrCut = 0.5 * MATCH_DR MatchingTools += [thistoolSA_dRDown] thistoolSA_dRUp = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool( name="ZmumuTPEfficiencyTool_%s_SA_dRUp" % name_suffix, EffiFlag="StandaloneMuons_dRUp") thistoolSA_dRUp.MatchToAnyMS = True thistoolSA_dRUp.IDhitCut = False thistoolSA_dRUp.IsNominal = False thistoolSA_dRUp.ApplyScaleFactors = doClosure thistoolSA_dRUp.MaximumDrCut = 2 * MATCH_DR MatchingTools += [thistoolSA_dRUp] if doCaloTag: thistoolCT = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool( name="ZmumuTPEfficiencyTool_%s_CT" % name_suffix, EffiFlag="CaloTaggedMuons") thistoolCT.MatchToCaloTag = True thistoolCT.ScaleFactorTool = CommonMuonTPConfig.AddMuonEfficiencyScaleFactors( "Loose") thistoolCT.ApplyScaleFactors = doClosure #thistoolCT.ApplyScaleFactors = True thistoolCT.MaximumDrCut = MATCH_DR MatchingTools += [thistoolCT] if doDRSys: thistoolCT_dRDown = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool( name="ZmumuTPEfficiencyTool_%s_CT_dRDown" % name_suffix, EffiFlag="CaloTaggedMuons_dRDown") thistoolCT_dRDown.MatchToCaloTag = True thistoolCT_dRDown.ScaleFactorTool = CommonMuonTPConfig.AddMuonEfficiencyScaleFactors( "Loose") #thistoolCT_dRDown.ApplyScaleFactors = True thistoolCT_dRDown.IsNominal = False thistoolCT_dRDown.MaximumDrCut = 0.5 * MATCH_DR MatchingTools += [thistoolCT_dRDown] thistoolCT_dRUp = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool( name="ZmumuTPEfficiencyTool_%s_CT_dRUp" % name_suffix, EffiFlag="CaloTaggedMuons_dRUp") thistoolCT_dRUp.MatchToCaloTag = True thistoolCT_dRUp.ScaleFactorTool = CommonMuonTPConfig.AddMuonEfficiencyScaleFactors( "Loose") #thistoolCT_dRUp.ApplyScaleFactors = True thistoolCT_dRUp.IsNominal = False thistoolCT_dRUp.MaximumDrCut = 2 * MATCH_DR MatchingTools += [thistoolCT_dRUp] if doID: thistoolID = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool( name="ZmumuTPEfficiencyTool_%s_ID" % name_suffix, EffiFlag="IDTracks") thistoolID.MatchToID = True thistoolID.ApplyScaleFactors = doClosure thistoolID.MaximumDrCut = MATCH_DR MatchingTools += [thistoolID] if doDRSys: thistoolID_dRUp = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool( name="ZmumuTPEfficiencyTool_%s_ID_dRUp" % name_suffix, EffiFlag="IDTracks_dRUp") thistoolID_dRUp.MatchToID = True thistoolID_dRUp.ApplyScaleFactors = doClosure thistoolID_dRUp.MaximumDrCut = 2 * MATCH_DR thistoolID_dRUp.IsNominal = False MatchingTools += [thistoolID_dRUp] thistoolID_dRDown = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool( name="ZmumuTPEfficiencyTool_%s_ID_dRDown" % name_suffix, EffiFlag="IDTracks_dRDown") thistoolID_dRDown.MatchToID = True thistoolID_dRDown.ApplyScaleFactors = doClosure thistoolID_dRDown.MaximumDrCut = 0.5 * MATCH_DR thistoolID_dRDown.IsNominal = False MatchingTools += [thistoolID_dRDown] #thistoolID_noMCPcuts = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool(name="ZmumuTPEfficiencyTool_%s_ID_noMCP"%name_suffix,EffiFlag="IDTracks_noMCP") #thistoolID_noMCPcuts.MatchToID = True #thistoolID_noMCPcuts.IDhitCut = False #thistoolID_noMCPcuts.ApplyScaleFactors = doClosure #thistoolID_noMCPcuts.MaximumDrCut = MATCH_DR #MatchingTools += [thistoolID_noMCPcuts] #if doDRSys: #thistoolID_noMCPcuts_dRUp = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool(name="ZmumuTPEfficiencyTool_%s_ID_noMCP_dRUp"%name_suffix,EffiFlag="IDTracks_noMCP_dRUp") #thistoolID_noMCPcuts_dRUp.MatchToID = True #thistoolID_noMCPcuts_dRUp.ApplyScaleFactors = doClosure #thistoolID_noMCPcuts_dRUp.MaximumDrCut = 2 * MATCH_DR #MatchingTools += [thistoolID_noMCPcuts_dRUp] #thistoolID_noMCPcuts_dRDown = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool(name="ZmumuTPEfficiencyTool_%s_ID_noMCP_dRDown"%name_suffix,EffiFlag="IDTracks_noMCP_dRDown") #thistoolID_noMCPcuts_dRDown.MatchToID = True #thistoolID_noMCPcuts_dRDown.ApplyScaleFactors = doClosure #thistoolID_noMCPcuts_dRDown.MaximumDrCut = 0.5 * MATCH_DR #MatchingTools += [thistoolID_noMCPcuts_dRDown] if doIndividualAuthors: thistoolMuidCB = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool( name="ZmumuTPEfficiencyTool_%s_MuidCB" % name_suffix, EffiFlag="MuidCB") thistoolMuidCB.MatchToMuidCB = True thistoolMuidCB.ApplyScaleFactors = doClosure thistoolMuidCB.MaximumDrCut = MATCH_DR MatchingTools += [thistoolMuidCB] if doDRSys: thistoolMuidCB_dRDown = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool( name="ZmumuTPEfficiencyTool_%s_MuidCB_dRDown" % name_suffix, EffiFlag="MuidCB_dRDown") thistoolMuidCB_dRDown.MatchToMuidCB = True thistoolMuidCB_dRDown.ApplyScaleFactors = doClosure thistoolMuidCB_dRDown.MaximumDrCut = 0.5 * MATCH_DR thistoolMuidCB_dRDown.IsNominal = False MatchingTools += [thistoolMuidCB_dRDown] thistoolMuidCB_dRUp = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool( name="ZmumuTPEfficiencyTool_%s_MuidCB_dRUp" % name_suffix, EffiFlag="MuidCB_dRUp") thistoolMuidCB_dRUp.MatchToMuidCB = True thistoolMuidCB_dRUp.ApplyScaleFactors = doClosure thistoolMuidCB_dRUp.MaximumDrCut = 2 * MATCH_DR thistoolMuidCB_dRUp.IsNominal = False MatchingTools += [thistoolMuidCB_dRUp] thistoolSTACO = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool( name="ZmumuTPEfficiencyTool_%s_STACO" % name_suffix, EffiFlag="STACO") thistoolSTACO.MatchToSTACO = True thistoolSTACO.ApplyScaleFactors = doClosure thistoolSTACO.MaximumDrCut = MATCH_DR MatchingTools += [thistoolSTACO] if doDRSys: thistoolSTACO_dRDown = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool( name="ZmumuTPEfficiencyTool_%s_STACO_dRDown" % name_suffix, EffiFlag="STACO_dRDown") thistoolSTACO_dRDown.MatchToSTACO = True thistoolSTACO_dRDown.ApplyScaleFactors = doClosure thistoolSTACO_dRDown.IsNominal = False thistoolSTACO_dRDown.MaximumDrCut = 0.5 * MATCH_DR MatchingTools += [thistoolSTACO_dRDown] thistoolSTACO_dRUp = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool( name="ZmumuTPEfficiencyTool_%s_STACO_dRUp" % name_suffix, EffiFlag="STACO_dRUp") thistoolSTACO_dRUp.MatchToSTACO = True thistoolSTACO_dRUp.ApplyScaleFactors = doClosure thistoolSTACO_dRUp.IsNominal = False thistoolSTACO_dRUp.MaximumDrCut = 2 * MATCH_DR MatchingTools += [thistoolSTACO_dRUp] thistoolMuTag = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool( name="ZmumuTPEfficiencyTool_%s_MuTag" % name_suffix, EffiFlag="MuTag") thistoolMuTag.MatchToMuTag = True thistoolMuTag.ApplyScaleFactors = doClosure thistoolMuTag.MaximumDrCut = MATCH_DR MatchingTools += [thistoolMuTag] if doDRSys: thistoolMuTag_dRDown = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool( name="ZmumuTPEfficiencyTool_%s_MuTag_dRDown" % name_suffix, EffiFlag="MuTag_dRDown") thistoolMuTag_dRDown.MatchToMuTag = True thistoolMuTag_dRDown.ApplyScaleFactors = doClosure thistoolMuTag_dRDown.IsNominal = False thistoolMuTag_dRDown.MaximumDrCut = 0.5 * MATCH_DR MatchingTools += [thistoolMuTag_dRDown] thistoolMuTag_dRUp = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool( name="ZmumuTPEfficiencyTool_%s_MuTag_dRUp" % name_suffix, EffiFlag="MuTag_dRUp") thistoolMuTag_dRUp.MatchToMuTag = True thistoolMuTag_dRUp.ApplyScaleFactors = doClosure thistoolMuTag_dRUp.IsNominal = False thistoolMuTag_dRUp.MaximumDrCut = 2 * MATCH_DR MatchingTools += [thistoolMuTag_dRUp] thistoolMuTagIMO = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool( name="ZmumuTPEfficiencyTool_%s_MuTagIMO" % name_suffix, EffiFlag="MuTagIMO") thistoolMuTagIMO.MatchToMuTagIMO = True thistoolMuTagIMO.ApplyScaleFactors = doClosure thistoolMuTagIMO.MaximumDrCut = MATCH_DR MatchingTools += [thistoolMuTagIMO] if doDRSys: thistoolMuTagIMO_dRDown = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool( name="ZmumuTPEfficiencyTool_%s_MuTagIMO_dRDown" % name_suffix, EffiFlag="MuTagIMO_dRDown") thistoolMuTagIMO_dRDown.MatchToMuTagIMO = True thistoolMuTagIMO_dRDown.ApplyScaleFactors = doClosure thistoolMuTagIMO_dRDown.IsNominal = False thistoolMuTagIMO_dRDown.MaximumDrCut = 0.5 * MATCH_DR MatchingTools += [thistoolMuTagIMO_dRDown] thistoolMuTagIMO_dRUp = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool( name="ZmumuTPEfficiencyTool_%s_MuTagIMO_dRUp" % name_suffix, EffiFlag="MuTagIMO_dRUp") thistoolMuTagIMO_dRUp.MatchToMuTagIMO = True thistoolMuTagIMO_dRUp.ApplyScaleFactors = doClosure thistoolMuTagIMO_dRUp.IsNominal = False thistoolMuTagIMO_dRUp.MaximumDrCut = 2 * MATCH_DR MatchingTools += [thistoolMuTagIMO_dRUp] thistoolMuidSA = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool( name="ZmumuTPEfficiencyTool_%s_MuidSA" % name_suffix, EffiFlag="MuidSA") thistoolMuidSA.MatchToMuidSA = True thistoolMuidSA.ApplyScaleFactors = doClosure thistoolMuidSA.IDhitCut = False thistoolMuidSA.MaximumDrCut = MATCH_DR MatchingTools += [thistoolMuidSA] if doDRSys: thistoolMuidSA_dRDown = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool( name="ZmumuTPEfficiencyTool_%s_MuidSA_dRDown" % name_suffix, EffiFlag="MuidSA_dRDown") thistoolMuidSA_dRDown.MatchToMuidSA = True thistoolMuidSA_dRDown.ApplyScaleFactors = doClosure thistoolMuidSA_dRDown.IsNominal = False thistoolMuidSA_dRDown.MaximumDrCut = 0.5 * MATCH_DR MatchingTools += [thistoolMuidSA_dRDown] thistoolMuidSA_dRUp = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool( name="ZmumuTPEfficiencyTool_%s_MuidSA_dRUp" % name_suffix, EffiFlag="MuidSA_dRUp") thistoolMuidSA_dRUp.MatchToMuidSA = True thistoolMuidSA_dRUp.ApplyScaleFactors = doClosure thistoolMuidSA_dRUp.IsNominal = False thistoolMuidSA_dRUp.MaximumDrCut = 2 * MATCH_DR MatchingTools += [thistoolMuidSA_dRUp] thistoolMuGirl = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool( name="ZmumuTPEfficiencyTool_%s_MuidGirl" % name_suffix, EffiFlag="MuGirl") thistoolMuGirl.MatchToMuGirl = True thistoolMuGirl.ApplyScaleFactors = doClosure thistoolMuGirl.MaximumDrCut = MATCH_DR MatchingTools += [thistoolMuGirl] if doDRSys: thistoolMuGirl_dRDown = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool( name="ZmumuTPEfficiencyTool_%s_MuidGirl_dRDown" % name_suffix, EffiFlag="MuGirl_dRDown") thistoolMuGirl_dRDown.MatchToMuGirl = True thistoolMuGirl_dRDown.ApplyScaleFactors = doClosure thistoolMuGirl_dRDown.IsNominal = False thistoolMuGirl_dRDown.MaximumDrCut = 0.5 * MATCH_DR MatchingTools += [thistoolMuGirl_dRDown] thistoolMuGirl_dRUp = CommonMuonTPConfig.AddMuonRecoTPEfficiencyTool( name="ZmumuTPEfficiencyTool_%s_MuidGirl_dRUp" % name_suffix, EffiFlag="MuGirl_dRUp") thistoolMuGirl_dRUp.MatchToMuGirl = True thistoolMuGirl_dRUp.IsNominal = False thistoolMuGirl_dRUp.ApplyScaleFactors = doClosure thistoolMuGirl_dRUp.MaximumDrCut = 2 * MATCH_DR MatchingTools += [thistoolMuGirl_dRUp] ntuples = [] if writeNtuple: ntuples.append( CommonMuonTPConfig.AddTreeTool(name="ZmumuTPTreeTool_%s" % name_suffix, EffiFlag="Trees", WriteSFInfo=doClosure)) # create the TP tool itself TheTPTool = CommonMuonTPConfig.AddMuonTPTool(name="ZmumuTPTool_%s" % name_suffix, EffiFlag=name_suffix) TheTPTool.MuonTPSelectionTools = SelectionTools TheTPTool.PlottingTools = PlotTools TheTPTool.MuonTPEfficiencyTools = MatchingTools TheTPTool.TreeTools = ntuples theAlg.MuonTPTools += [TheTPTool]