def getAssocCA(config, sequencename='METAssociation', METName=''): components = ComponentAccumulator() from AthenaConfiguration.ComponentFactory import CompFactory AthSequencer = CompFactory.AthSequencer components.addSequence(AthSequencer(sequencename)) assocAlg = getMETAssocAlg(algName='METAssociation_' + METName, configs={config.suffix: config}) components.addEventAlgo(assocAlg, sequencename) if not METName == '': makerAlg = getMETMakerAlg(METName) components.addEventAlgo(makerAlg, sequencename) return components
associators, doPFlow=True, ) metFlags.METAssocConfigs()[cfg_akt4pf.suffix] = cfg_akt4pf metFlags.METAssocOutputList().append(cfg_akt4pf.suffix) from METReconstruction.METAssocConfig import getMETAssocAlg # Get the configuration directly from METRecoFlags # Can also provide a dict of configurations or list of RecoTools or both metAlg = getMETAssocAlg('METAssociation') filterseq += metAlg from METUtilities.METMakerConfig import getMETMakerAlg makerAlgEM = getMETMakerAlg("NewAntiKt4EMTopo", jetColl="AntiKt4EMTopoJets") # ToolSvc.METMaker_NewAntiKt4EMTopo.OutputLevel=VERBOSE ToolSvc.METMaker_NewAntiKt4EMTopo.DoRemoveElecTrks = False filterseq += makerAlgEM makerAlgPF = getMETMakerAlg("NewAntiKt4EMPFlow", jetColl="AntiKt4EMPFlowJets") # ToolSvc.METMaker_NewAntiKt4EMPFlow.OutputLevel=VERBOSE ToolSvc.METMaker_NewAntiKt4EMPFlow.DoRemoveElecTrks = False filterseq += makerAlgPF # filterseq += CfgMgr.met__METAssocTestAlg("TestMETAssocEMTopo", # OutputLevel=VERBOSE, # FailOnInconsistency=True, # METMapSuffix="NewAntiKt4EMTopo") # filterseq += CfgMgr.met__METAssocTestAlg("TestMETAssocEMPFlow", # OutputLevel=VERBOSE, # FailOnInconsistency=True,
metFlags.DoPFlow.set_Value(False) print "METReconstruction_jobOptions: detected cosmics/single-beam configuration -- switch off track-based MET reco" import METReconstruction.METConfig_Calo import METReconstruction.METConfig_Track if rec.doTruth(): import METReconstruction.METConfig_Truth from METReconstruction.METRecoConfig import getMETRecoAlg metAlg = getMETRecoAlg('METReconstruction') topSequence += metAlg # Set up default configurations import METReconstruction.METConfig_Associator from METReconstruction.METAssocConfig import getMETAssocAlg # Get the configuration directly from METRecoFlags # Can also provide a dict of configurations or list of RecoTools or both assocAlg = getMETAssocAlg('METAssociation') from AthenaCommon.AlgSequence import AlgSequence topSequence = AlgSequence() topSequence += assocAlg from METUtilities.METMakerConfig import getMETMakerAlg for key, conf in metFlags.METAssocConfigs().iteritems(): if not conf.doTruth: makerAlg = getMETMakerAlg(conf.suffix) topSequence += makerAlg
import AthenaPoolCnvSvc.ReadAthenaPool from AthenaCommon.AthenaCommonFlags import athenaCommonFlags from AthenaCommon.AppMgr import ServiceMgr from AthenaCommon import CfgMgr from glob import glob filelist = ["DAOD_JETM2.test.TruthAssoc.pool.root"] #filelist = ["/afs/cern.ch/work/r/rsmith/public/METUtilities_testfiles/valid1.110401.PowhegPythia_P2012_ttbar_nonallhad.recon.AOD.e3099_s1982_s1964_r6006_tid04628718_00/AOD.04628718._000158.pool.root.1"] ServiceMgr.EventSelector.InputCollections = filelist from METUtilities.METMakerConfig import getMETMakerAlg metAlg = getMETMakerAlg('AntiKt4EMTopo', 20e3) metAlg.METName = 'MET_Reco_AntiKt4EMTopo' metAlg_truth = getMETMakerAlg('Truth_AntiKt4EMTopo', 20e3) metAlg_truth.METSoftClName = 'SoftTruthAll' metAlg_truth.METSoftTrkName = 'SoftTruthCharged' metAlg_truth.METName = 'MET_Truth_AntiKt4EMTopo' from AthenaCommon.AlgSequence import AlgSequence topSequence = AlgSequence() topSequence += metAlg topSequence += metAlg_truth write_xAOD = True if write_xAOD: from OutputStreamAthenaPool.MultipleStreamManager import MSMgr xaodStream = MSMgr.NewPoolRootStream("StreamXAOD", "xAOD.METMaker.pool.root") # xaodStream.AddItem('xAOD::MissingETContainer#MET_Reco_AntiKt4EMTopo')
metFlags.METAssocConfigs()[cfg_akt4em2.suffix] = cfg_akt4em2 metFlags.METAssocOutputList().append(cfg_akt4em2.suffix) #from METReconstruction.METRecoFlags import metFlags from METReconstruction.METAssocConfig import getMETAssocAlg # Get the configuration directly from METRecoFlags # Can also provide a dict of configurations or list of RecoTools or both metAlg = getMETAssocAlg('METAssociation') topSequence += metAlg from METUtilities.METMakerConfig import getMETMakerAlg for key, conf in metFlags.METAssocConfigs().iteritems(): if not conf.doTruth: makerAlg = getMETMakerAlg(conf.suffix, jetColl="AntiKt4EMTopoJets") topSequence += makerAlg ToolSvc.METMaker_NewAntiKt4EMTopo.OutputLevel = 1 from Valkyrie.JobOptCfg import ValgrindSvc svcMgr += ValgrindSvc(OutputLevel=INFO, ProfiledAlgs=["METAssociation"], ProfiledIntervals=["METAssociation.execute"]) from PerfMonComps.PerfMonFlags import jobproperties as pmon_properties pmon_properties.PerfMonFlags.doSemiDetailedMonitoring = True write_xAOD = True if write_xAOD: # The list of output containers/maps is autogenerated and stored in metFlags
def other_postSystemRec(self, topSequence): """ Please seperate out this function into multiple functions """ from AthenaCommon.AppMgr import ToolSvc if self.isMC: from ParticleJetTools.ParticleJetToolsConf import CopyFlavorLabelTruthParticles from ParticleJetTools.ParticleJetToolsConf import ParticleJetDeltaRLabelTool ptypes = ["TausFinal", "BHadronsFinal", "CHadronsFinal"] for ptype in ptypes: AODFix_ctp = CopyFlavorLabelTruthParticles( "AODFix_CopyTruthTag" + ptype) AODFix_ctp.ParticleType = ptype AODFix_ctp.OutputName = "AODFix_TruthLabel" + ptype ToolSvc += AODFix_ctp AODFix_JetDeltaRLabelTool = ParticleJetDeltaRLabelTool( "AODFix_jetdrlabeler", LabelName="HadronConeExclTruthLabelID", BLabelName="ConeExclBHadronsFinal", CLabelName="ConeExclCHadronsFinal", TauLabelName="ConeExclTausFinal", BParticleCollection="AODFix_TruthLabelBHadronsFinal", CParticleCollection="AODFix_TruthLabelCHadronsFinal", TauParticleCollection="AODFix_TruthLabelTausFinal", PartPtMin=5000.0, JetPtMin=0.0, DRMax=0.3, MatchMode="MinDR") ToolSvc += AODFix_JetDeltaRLabelTool AODFix_FatJetDeltaRLabelTool = ParticleJetDeltaRLabelTool( "AODFix_fatjetdrlabeler", LabelName="HadronConeExclTruthLabelID", BLabelName="ConeExclBHadronsFinal", CLabelName="ConeExclCHadronsFinal", TauLabelName="ConeExclTausFinal", BParticleCollection="AODFix_TruthLabelBHadronsFinal", CParticleCollection="AODFix_TruthLabelCHadronsFinal", TauParticleCollection="AODFix_TruthLabelTausFinal", PartPtMin=5000.0, JetPtMin=0.0, DRMax=1.0, MatchMode="MinDR") ToolSvc += AODFix_FatJetDeltaRLabelTool AODFix_TrackJetDeltaRLabelTool = ParticleJetDeltaRLabelTool( "AODFix_trackjetdrlabeler", LabelName="HadronConeExclTruthLabelID", BLabelName="ConeExclBHadronsFinal", CLabelName="ConeExclCHadronsFinal", TauLabelName="ConeExclTausFinal", BParticleCollection="AODFix_TruthLabelBHadronsFinal", CParticleCollection="AODFix_TruthLabelCHadronsFinal", TauParticleCollection="AODFix_TruthLabelTausFinal", PartPtMin=5000.0, JetPtMin=4500.0, DRMax=0.3, MatchMode="MinDR") ToolSvc += AODFix_TrackJetDeltaRLabelTool from JetRec.JetRecConf import JetRecTool JetRecTool_AntiKt4EMTopo = JetRecTool( "AODFix_AntiKt4EMTopoJets", InputContainer="AntiKt4EMTopoJets", OutputContainer="AntiKt4EMTopoJets", JetModifiers=[ToolSvc.AODFix_jetdrlabeler]) ToolSvc += JetRecTool_AntiKt4EMTopo JetRecTool_AntiKt4LCTopo = JetRecTool( "AODFix_AntiKt4LCTopoJets", InputContainer="AntiKt4LCTopoJets", OutputContainer="AntiKt4LCTopoJets", JetModifiers=[ToolSvc.AODFix_jetdrlabeler]) ToolSvc += JetRecTool_AntiKt4LCTopo JetRecTool_AntiKt10LCTopo = JetRecTool( "AODFix_AntiKt10LCTopoJets", InputContainer="AntiKt10LCTopoJets", OutputContainer="AntiKt10LCTopoJets", JetModifiers=[ToolSvc.AODFix_fatjetdrlabeler]) ToolSvc += JetRecTool_AntiKt10LCTopo JetRecTool_AntiKt2PV0Track = JetRecTool( "AODFix_AntiKt2PV0TrackJets", InputContainer="AntiKt2PV0TrackJets", OutputContainer="AntiKt2PV0TrackJets", JetModifiers=[ToolSvc.AODFix_trackjetdrlabeler]) ToolSvc += JetRecTool_AntiKt2PV0Track JetRecTool_AntiKt3PV0Track = JetRecTool( "AODFix_AntiKt3PV0TrackJets", InputContainer="AntiKt3PV0TrackJets", OutputContainer="AntiKt3PV0TrackJets", JetModifiers=[ToolSvc.AODFix_trackjetdrlabeler]) ToolSvc += JetRecTool_AntiKt3PV0Track JetRecTool_AntiKt4PV0Track = JetRecTool( "AODFix_AntiKt4PV0TrackJets", InputContainer="AntiKt4PV0TrackJets", OutputContainer="AntiKt4PV0TrackJets", JetModifiers=[ToolSvc.AODFix_trackjetdrlabeler]) ToolSvc += JetRecTool_AntiKt4PV0Track from JetRec.JetRecConf import JetAlgorithm topSequence += JetAlgorithm( "jetalgAODFix", Tools=[ ToolSvc.AODFix_CopyTruthTagCHadronsFinal, ToolSvc.AODFix_CopyTruthTagBHadronsFinal, ToolSvc.AODFix_CopyTruthTagTausFinal, ToolSvc.AODFix_AntiKt2PV0TrackJets, ToolSvc.AODFix_AntiKt3PV0TrackJets, ToolSvc.AODFix_AntiKt4PV0TrackJets, ToolSvc.AODFix_AntiKt4EMTopoJets, ToolSvc.AODFix_AntiKt4LCTopoJets, ToolSvc.AODFix_AntiKt10LCTopoJets ]) JetCollectionList = [ 'AntiKt4EMTopoJets', 'AntiKt4LCTopoJets', 'AntiKt2TrackJets', 'AntiKt3TrackJets', 'AntiKt4TrackJets' ] SA = 'AODFix_' from BTagging.BTaggingConfiguration import getConfiguration BTagConf = getConfiguration("AODFix") BTagConf.PrefixxAODBaseName(False) BTagConf.PrefixVertexFinderxAODBaseName(False) BTagConf.doNotCheckForTaggerObstacles() from BTagging.BTaggingConf import Analysis__StandAloneJetBTaggerAlg as StandAloneJetBTaggerAlg btag = "BTagging_" AuthorSubString = [btag + name[:-4] for name in JetCollectionList] for i, jet in enumerate(JetCollectionList): try: btagger = BTagConf.setupJetBTaggerTool(ToolSvc, JetCollection=jet[:-4], AddToToolSvc=True, SetupScheme="Retag", TaggerList=[ 'IP3D', 'MV2c00', 'MV2c10', 'MV2c20', 'MV2c100', 'MV2m', 'MV2c10hp', 'MV2cl100', 'MVb' ]) jet = jet.replace("Track", "PV0Track") SAbtagger = StandAloneJetBTaggerAlg( name=SA + AuthorSubString[i].lower(), JetBTaggerTool=btagger, JetCollectionName=jet, ) topSequence += SAbtagger except AttributeError as error: print '#BTAG# --> ' + str(error) print '#BTAG# --> ' + jet print '#BTAG# --> ' + AuthorSubString[i] # MET AODFix from METReconstruction.METAssocConfig import AssocConfig, getAssociator from METReconstruction.METReconstructionConf import METBadTrackEventFilter from AthenaCommon.AlgSequence import AthSequencer METMapSequence = AthSequencer("MET_LCEM_SelectionSequence_AODFix") topSequence += METMapSequence from AthenaCommon import CfgMgr newtrkseltool = CfgMgr.InDet__InDetTrackSelectionTool( "IDTrkSel_METAssoc_AODFix", CutLevel="TightPrimary", maxZ0SinTheta=3, maxD0overSigmaD0=2) ToolSvc += newtrkseltool METMapSequence += METBadTrackEventFilter( "METBadTrackEventFilter_AODFix", TrackSelectorTool=newtrkseltool) LCtermlist = ['LCJet', 'Muon', 'Ele', 'Gamma', 'Tau', 'Soft'] LCAssociators = [ getAssociator(AssocConfig(config), suffix='AntiKt4LCTopo', doPFlow=False, trkseltool=newtrkseltool) for config in LCtermlist ] LCAssocTool = CfgMgr.met__METAssociationTool( 'MET_AssociationTool_AntiKt4LCTopo_AODFix', METAssociators=LCAssociators, METSuffix='AntiKt4LCTopo', AllowOverwrite=True, TCSignalState=1) # LC clusters ToolSvc += LCAssocTool EMtermlist = ['EMJet', 'Muon', 'Ele', 'Gamma', 'Tau', 'Soft'] EMAssociators = [ getAssociator(AssocConfig(config), suffix='AntiKt4EMTopo', doPFlow=False, trkseltool=newtrkseltool) for config in EMtermlist ] EMAssocTool = CfgMgr.met__METAssociationTool( 'MET_AssociationTool_AntiKt4EMTopo_AODFix', METAssociators=EMAssociators, METSuffix='AntiKt4EMTopo', AllowOverwrite=True, TCSignalState=0) # EM clusters ToolSvc += EMAssocTool METAssocAlg_LCEM = CfgMgr.met__METRecoAlg( name='METAssociation_LCEM_AODFix', RecoTools=[LCAssocTool, EMAssocTool]) METMapSequence += METAssocAlg_LCEM from METUtilities.METMakerConfig import getMETMakerAlg METMakerAlg_LC = getMETMakerAlg('AntiKt4LCTopo', confsuffix="_AODFix") METMakerAlg_LC.AllowOverwrite = True METMakerAlg_EM = getMETMakerAlg('AntiKt4EMTopo', confsuffix="_AODFix") METMakerAlg_EM.AllowOverwrite = True METMapSequence += METMakerAlg_LC METMapSequence += METMakerAlg_EM #Only run pflow AOD fix if input file contains AntKt4EMPFlowJets - should be the case for all samples, except HI samples from RecExConfig.ObjKeyStore import cfgKeyStore if cfgKeyStore.isInInputFile("xAOD::JetContainer", "AntiKt4EMPFlowJets"): #Now we need to rerun the particle flow jet finding #This configuration should be identical to the AntiKt4EMPflowJets configured in: #http://acode-browser2.usatlas.bnl.gov/lxr-rel20/source/atlas/Reconstruction/Jet/JetRec/share/JetRec_jobOptions.py #with the addJetFinder function (in the svn tag for 20.7) particleFlowJetFinder_AntiKt4 = CfgMgr.JetFinder( "AntiKt4EMPFlowJetsFinder_AODFix") particleFlowJetFinder_AntiKt4.JetAlgorithm = "AntiKt" particleFlowJetFinder_AntiKt4.JetRadius = 0.4 particleFlowJetFinder_AntiKt4.GhostArea = 0.01 particleFlowJetFinder_AntiKt4.PtMin = 2000 #Then we setup a jet builder to calculate the areas needed for the rho subtraction particleFlowJetBuilder_AntiKt4 = CfgMgr.JetFromPseudojet( "jblda_AODFix", Attributes=["ActiveArea", "ActiveArea4vec"]) ToolSvc += particleFlowJetBuilder_AntiKt4 particleFlowJetFinder_AntiKt4.JetBuilder = particleFlowJetBuilder_AntiKt4 ToolSvc += particleFlowJetFinder_AntiKt4 #Now we setup a JetRecTool which will use the above JetFinder particleFlowJetRecTool = CfgMgr.JetRecTool( "AntiKt4EMPFlowJets_AODFix") particleFlowJetRecTool.JetFinder = particleFlowJetFinder_AntiKt4 ToolSvc += particleFlowJetRecTool jpjretriever = CfgMgr.JetPseudojetRetriever("jpjretriever") ToolSvc += jpjretriever pflowRetriever = CfgMgr.CP__RetrievePFOTool( "pflowretriever_AODFix") ToolSvc += pflowRetriever trk_trackselloose = CfgMgr.InDet__InDetTrackSelectionTool( "trk_trackselloose_AODFix", CutLevel="Loose") ToolSvc += trk_trackselloose trackselloose = CfgMgr.JetTrackSelectionTool( "trackselloose", InputContainer="InDetTrackParticles", OutputContainer="JetSelectedTracks", Selector=trk_trackselloose) ToolSvc += trackselloose tracksel = CfgMgr.JetTrackSelectionTool( "tracksel_AODFix", InputContainer="InDetTrackParticles", OutputContainer="JetSelectedTracks_AODFix", Selector=trk_trackselloose) ToolSvc += tracksel tighttva = CfgMgr.CP__TightTrackVertexAssociationTool( "jetTighTVAtool_AODFix", dzSinTheta_cut=3, doPV=True) ToolSvc += tighttva tvassoc = CfgMgr.TrackVertexAssociationTool( "tvassoc_AODFix", TrackParticleContainer="InDetTrackParticles", TrackVertexAssociation="JetTrackVtxAssoc_AODFix", VertexContainer="PrimaryVertices", TrackVertexAssoTool=tighttva, ) ToolSvc += tvassoc # Ghost tracks. ghostScaleFactor = 1e-40 gtrackget = CfgMgr.TrackPseudoJetGetter( "gtrackget_AODFix", InputContainer=tracksel.OutputContainer, Label="GhostTrack", OutputContainer="PseudoJetGhostTracks_AODFix", TrackVertexAssociation=tvassoc.TrackVertexAssociation, SkipNegativeEnergy=True, GhostScale=ghostScaleFactor) ToolSvc += gtrackget # Muon segments gmusegget = CfgMgr.MuonSegmentPseudoJetGetter( "gmusegget_AODFix", InputContainer="MuonSegments", Label="GhostMuonSegment", OutputContainer="PseudoJetGhostMuonSegment_AODFix", Pt=1.e-20) ToolSvc += gmusegget # AntiKt2 track jets. gakt2trackget = CfgMgr.PseudoJetGetter( "gakt2trackget_AODFix", # give a unique name InputContainer="AntiKt2PV0TrackJets", # SG key Label= "GhostAntiKt2TrackJet", # this is the name you'll use to retrieve associated ghosts OutputContainer="PseudoJetGhostAntiKt2TrackJet_AODFix", SkipNegativeEnergy=True, GhostScale= ghostScaleFactor, # This makes the PseudoJet Ghosts, and thus the reco flow will treat them as so. ) ToolSvc += gakt2trackget # AntiKt3 track jets. gakt3trackget = CfgMgr.PseudoJetGetter( "gakt3trackget_AODFix", # give a unique name InputContainer="AntiKt3PV0TrackJets", # SG key Label= "GhostAntiKt3TrackJet", # this is the name you'll use to retrieve associated ghosts OutputContainer="PseudoJetGhostAntiKt3TrackJet_AODFix", SkipNegativeEnergy=True, GhostScale= ghostScaleFactor, # This makes the PseudoJet Ghosts, and thus the reco flow will treat them as so. ) ToolSvc += gakt3trackget # AntiKt4 track jets. gakt4trackget = CfgMgr.PseudoJetGetter( "gakt4trackget_AODFix", # give a unique name InputContainer="AntiKt4PV0TrackJets", # SG key Label= "GhostAntiKt4TrackJet", # this is the name you'll use to retrieve associated ghosts OutputContainer="PseudoJetGhostAntiKt4TrackJet_AODFix", SkipNegativeEnergy=True, GhostScale= ghostScaleFactor, # This makes the PseudoJet Ghosts, and thus the reco flow will treat them as so. ) ToolSvc += gakt4trackget # Truth. mctc = None truthpartcopy = None gtruthget = None gtruthgetters = [] rtools = [] rtools += [tracksel, tvassoc] if self.isMC: mctc = CfgMgr.MCTruthClassifier( name="JetMCTruthClassifier_AODFix", ParticleCaloExtensionTool="") ToolSvc += mctc truthpartcopy = CfgMgr.CopyTruthJetParticles( "truthpartcopy_AODFix", OutputName="JetInputTruthParticles_AODFix", MCTruthClassifier=mctc) ToolSvc += truthpartcopy gtruthget = CfgMgr.PseudoJetGetter( "gtruthget_AODFix", Label="GhostTruth", InputContainer=truthpartcopy.OutputName, OutputContainer="PseudoJetGhostTruth_AODFix", GhostScale=ghostScaleFactor, SkipNegativeEnergy=True, ) ToolSvc += gtruthget # Truth flavor tags. truthFlavourTags = [ "BHadronsInitial", "BHadronsFinal", "BQuarksFinal", "CHadronsInitial", "CHadronsFinal", "CQuarksFinal", "TausFinal", "WBosons", "ZBosons", "HBosons", "TQuarksFinal", "Partons", ] for ptype in truthFlavourTags: gtruthgetters.append( CfgMgr.PseudoJetGetter( "gtruthget_" + ptype + "_AODFix", InputContainer="TruthLabel" + ptype + "_AODFix", Label="Ghost" + ptype, OutputContainer="PseudoJetGhost" + ptype + "_AODFix", SkipNegativeEnergy=True, GhostScale=ghostScaleFactor, )) ToolSvc += gtruthgetters[-1] toolname = "CopyTruthTag" + ptype + "_AODFix" print "Scheduling " + toolname ptmin = 5000 if ptype == "Partons": ctp = CfgMgr.CopyTruthPartons(toolname) elif ptype in [ "WBosons", "ZBosons", "HBosons", "TQuarksFinal" ]: ctp = CfgMgr.CopyBosonTopLabelTruthParticles(toolname) ctp.ParticleType = ptype ptmin = 100000 else: ctp = CfgMgr.CopyFlavorLabelTruthParticles(toolname) ctp.ParticleType = ptype ctp.OutputName = "TruthLabel" + ptype + "_AODFix" ctp.PtMin = ptmin ToolSvc += ctp rtools.append(ctp) # build truth jet input : rtools += [truthpartcopy] jetrun = CfgMgr.JetToolRunner( "jetrun_AODFix", Tools=rtools, ) ToolSvc += jetrun #Setup a pseudojetgetter to deal with input objects empflowget = CfgMgr.PFlowPseudoJetGetter( "empflowget_AODFix", Label="EMPFlow", OutputContainer="PseudoJetEMPFlow_AODFix", RetrievePFOTool=pflowRetriever, InputIsEM=True, CalibratePFO=False, SkipNegativeEnergy=True, UseVertices=True) ToolSvc += empflowget empfgetters = [ empflowget, gtrackget, gmusegget, gakt2trackget, gakt3trackget, gakt4trackget ] if self.isMC: empfgetters += [gtruthget] + gtruthgetters particleFlowJetRecTool.PseudoJetGetters = empfgetters particleFlowJetRecTool.Overwrite = True particleFlowJetRecTool.OutputContainer = "AntiKt4EMPFlowJets" #setup calibration tools - only want to do area subtraction (as is done in Tier0) jetdefn = particleFlowJetFinder_AntiKt4.JetAlgorithm + str( int(10 * particleFlowJetFinder_AntiKt4.JetRadius + 0.1)) + empflowget.Label pflowJetCalibToolName_AODFix = "calib_" + jetdefn + "_pflow_A_AODFix" ToolSvc += CfgMgr.JetCalibrationTool( "pflowJetCalibTool_AODFix", JetCollection=jetdefn, ConfigFile="PFlowJES_September2014.config", CalibSequence="JetArea", RhoKey="Kt4EMPFlowEventShape") particleFlowJetRecTool.JetModifiers = [ ToolSvc.pflowJetCalibTool_AODFix ] #now we setup the other modifiers we need ToolSvc += CfgMgr.JetFilterTool("jetFilter_AODFix", PtMin=5000) particleFlowJetRecTool.JetModifiers += [ToolSvc.jetFilter_AODFix] #common_ungroomed_modifiers start here ToolSvc += CfgMgr.JetWidthTool("width_AODFix") particleFlowJetRecTool.JetModifiers += [ToolSvc.width_AODFix] ToolSvc += CfgMgr.JetIsolationTool( "jetisol_AODFix", IsolationCalculations=["IsoDelta:2:SumPt", "IsoDelta:3:SumPt"]) particleFlowJetRecTool.JetModifiers += [ToolSvc.jetisol_AODFix] ToolSvc += CfgMgr.KtDeltaRTool("ktdr_AODFix", JetRadius=0.4) particleFlowJetRecTool.JetModifiers += [ToolSvc.ktdr_AODFix] ToolSvc += CfgMgr.NSubjettinessTool("nsubjettiness_AODFix", Alpha=1.0) particleFlowJetRecTool.JetModifiers += [ ToolSvc.nsubjettiness_AODFix ] ToolSvc += CfgMgr.KTSplittingScaleTool("ktsplitter_AODFix") particleFlowJetRecTool.JetModifiers += [ToolSvc.ktsplitter_AODFix] ToolSvc += CfgMgr.AngularityTool("angularity_AODFix") particleFlowJetRecTool.JetModifiers += [ToolSvc.angularity_AODFix] ToolSvc += CfgMgr.DipolarityTool("dipolarity_AODFix", SubJetRadius=0.3) particleFlowJetRecTool.JetModifiers += [ToolSvc.dipolarity_AODFix] ToolSvc += CfgMgr.PlanarFlowTool("planarflow_AODFix") particleFlowJetRecTool.JetModifiers += [ToolSvc.planarflow_AODFix] ToolSvc += CfgMgr.KtMassDropTool("ktmassdrop_AODFix") particleFlowJetRecTool.JetModifiers += [ToolSvc.ktmassdrop_AODFix] ToolSvc += CfgMgr.EnergyCorrelatorTool("encorr_AODFix", Beta=1.0) particleFlowJetRecTool.JetModifiers += [ToolSvc.encorr_AODFix] ToolSvc += CfgMgr.CenterOfMassShapesTool("comshapes_AODFix") particleFlowJetRecTool.JetModifiers += [ToolSvc.comshapes_AODFix] #common_ungroomed_modifiers that are for MC only ## (JM) Now introduced an isMC flag, so can remove this suff. # #First we check if the file is MC or data using the metadata (not allowed to use reco flags om AODFix) # from AthenaCommon.AthenaCommonFlags import athenaCommonFlags # theInputFile_AODFix = athenaCommonFlags.PoolAODInput.get_Value()[0] # import PyUtils.AthFile as af # haveParticleJetTools_AODFix = False # f = af.fopen(theInputFile_AODFix) # if 'evt_type' in f.infos.keys(): # import re # if re.match(str(f.infos['evt_type'][0]), 'IS_SIMULATION') : # try: # haveParticleJetTools_AODFix = True # except: # haveParticleJetTools_AODFix = False # if haveParticleJetTools_AODFix: # ToolSvc += CfgMgr.Analysis__JetPartonTruthLabel("partontruthlabel_AODFix") # particleFlowJetRecTool.JetModifiers += [ToolSvc.partontruthlabel_AODFix] # ToolSvc += CfgMgr.Analysis__JetQuarkLabel("jetquarklabel_AODFix",McEventCollection = "TruthEvents") # ToolSvc += CfgMgr.Analysis__JetConeLabeling("truthpartondr_AODFix",JetTruthMatchTool = ToolSvc.jetquarklabel_AODFix) # particleFlowJetRecTool.JetModifiers += [ToolSvc.truthpartondr_AODFix] #This is the replacement if self.isMC: ToolSvc += CfgMgr.Analysis__JetPartonTruthLabel( "partontruthlabel_AODFix") particleFlowJetRecTool.JetModifiers += [ ToolSvc.partontruthlabel_AODFix ] ToolSvc += CfgMgr.Analysis__JetQuarkLabel( "jetquarklabel_AODFix", McEventCollection="TruthEvents") ToolSvc += CfgMgr.Analysis__JetConeLabeling( "truthpartondr_AODFix", JetTruthMatchTool=ToolSvc.jetquarklabel_AODFix) particleFlowJetRecTool.JetModifiers += [ ToolSvc.truthpartondr_AODFix ] ## end of JM modificatoin #common_ungroomed_modifiers end here # Modifiers for topo (and pflow) jets. jetens = CfgMgr.JetCaloEnergies("jetens_AODFix") ToolSvc += jetens larhvcorr = CfgMgr.JetLArHVTool("larhvcorr_AODFix") ToolSvc += larhvcorr caloqual_cluster = CfgMgr.JetCaloQualityTool( "caloqual_cluster_AODFix", TimingCuts=[5, 10], Calculations=[ "LArQuality", "N90Constituents", "FracSamplingMax", "NegativeE", "Timing", "HECQuality", "Centroid", "AverageLArQF", "BchCorrCell" ], ) ToolSvc += caloqual_cluster # Jet vertex fraction with selection. jvf = CfgMgr.JetVertexFractionTool( "jvf_AODFix", VertexContainer="PrimaryVertices", AssociatedTracks="GhostTrack", TrackVertexAssociation=tvassoc.TrackVertexAssociation, TrackSelector=trackselloose, JVFName="JVF") ToolSvc += jvf # Jet vertex tagger. jvt = CfgMgr.JetVertexTaggerTool( "jvt_AODFix", VertexContainer="PrimaryVertices", TrackParticleContainer="InDetTrackParticles", AssociatedTracks="GhostTrack", TrackVertexAssociation=tvassoc.TrackVertexAssociation, TrackSelector=trackselloose, JVTName="Jvt", K_JVFCorrScale=0.01, Z0Cut=3.0, PUTrkPtCut=30000.0) ToolSvc += jvt # Jet track info. trkmoms = CfgMgr.JetTrackMomentsTool( "trkmoms_AODFix", VertexContainer="PrimaryVertices", AssociatedTracks="GhostTrack", TrackVertexAssociation=tvassoc.TrackVertexAssociation, TrackMinPtCuts=[500, 1000], TrackSelector=trackselloose) ToolSvc += trkmoms charge = CfgMgr.JetChargeTool("charge_AODFix", K=1.0) ToolSvc += charge particleFlowJetRecTool.JetModifiers += [ jetens, larhvcorr, caloqual_cluster, jvf, jvt, trkmoms, charge ] if self.isMC: truthassoc = CfgMgr.JetPtAssociationTool( "truthassoc_AntiKt4_AODFix", InputContainer="AntiKt4TruthJets", AssociationName="GhostTruth") ToolSvc += truthassoc jetdrlabeler = CfgMgr.ParticleJetDeltaRLabelTool( "jetdrlabeler_AODFix", LabelName="HadronConeExclTruthLabelID", BLabelName="ConeExclBHadronsFinal", CLabelName="ConeExclCHadronsFinal", TauLabelName="ConeExclTausFinal", BParticleCollection="TruthLabelBHadronsFinal_AODFix", CParticleCollection="TruthLabelCHadronsFinal_AODFix", TauParticleCollection="TruthLabelTausFinal_AODFix", PartPtMin=5000.0, JetPtMin=4500.0, DRMax=0.3, MatchMode="MinDR") ToolSvc += jetdrlabeler particleFlowJetRecTool.JetModifiers += [ truthassoc, jetdrlabeler ] JetType = 'PFlowJet' PFtermlist = ['PFlowJet', 'Muon', 'Ele', 'Gamma', 'Tau', 'Soft'] newpfotool = CfgMgr.CP__RetrievePFOTool('MET_PFOTool_AODFix') ToolSvc += newpfotool PFAssociators = [ getAssociator(AssocConfig(config), suffix='AntiKt4EMPFlow', doPFlow=True, trkseltool=newtrkseltool, pfotool=newpfotool) for config in PFtermlist ] PFAssocTool = CfgMgr.met__METAssociationTool( 'MET_AssociationTool_AntiKt4EMPFlow_AODFix', METAssociators=PFAssociators, METSuffix='AntiKt4EMPFlow', AllowOverwrite=True) ToolSvc += PFAssocTool METAssocAlg_PFlow = CfgMgr.met__METRecoAlg( name='METAssociation_PFlow_AODFix', RecoTools=[PFAssocTool]) METMakerAlg_PF = getMETMakerAlg('AntiKt4EMPFlow', confsuffix="_AODFix") METMakerAlg_PF.AllowOverwrite = True #Set up our own sequence ParticleFlowJetSequence = AthSequencer( "ParticleFlowSelectionSequence") topSequence += ParticleFlowJetSequence #Add an event filter to our sequence ParticleFlowJetSequence += CfgMgr.ParticleFlowEventFilter_r207( "ParticleFlowEventFilter_r207") #Add the particle flow jet finding to our sequence ParticleFlowJetSequence += CfgMgr.JetAlgorithm( "pflowJetAlg_AODFix", Tools=[jetrun, ToolSvc.AntiKt4EMPFlowJets_AODFix]) #Add MET map builder to our sequence ParticleFlowJetSequence += METAssocAlg_PFlow #Build the reference MET container ParticleFlowJetSequence += METMakerAlg_PF
# associators, # doPFlow=True # ) # metFlags.METAssocConfigs()[cfg_akt4em.suffix] = cfg_akt4em # cfg_akt4em.associators["Tau"].OutputLevel = VERBOSE # metFlags.METAssocOutputList().append(cfg_akt4em.suffix) # Get the configuration directly from METRecoFlags # Can also provide a dict of configurations or list of RecoTools or both from METReconstruction.METAssocConfig import getMETAssocAlg metAlg = getMETAssocAlg('METAssociation') topSequence += metAlg from METUtilities.METMakerConfig import getMETMakerAlg makerAlgPF = getMETMakerAlg('AntiKt4EMPFlow', jetSelection='Default') makerAlgPF.METName = "MET_Reco_AntiKt4EMPFlow" #makerAlgPF.OutputLevel=VERBOSE #ToolSvc.METMaker_AntiKt4EMPFlow.OutputLevel=VERBOSE topSequence += makerAlgPF makerAlgEM = getMETMakerAlg('AntiKt4EMTopo', jetSelection='Default') makerAlgEM.METName = "MET_Reco_AntiKt4EMTopo" topSequence += makerAlgEM # topSequence += CfgMgr.met__METAssocTestAlg("TestMETAssocNewEMPFlow", # OutputLevel=VERBOSE, # FailOnInconsistency=True, # METMapSuffix="NewAntiKt4EMPFlow") # topSequence += CfgMgr.met__METAssocTestAlg("TestMETAssocEMTopo", # OutputLevel=VERBOSE, # FailOnInconsistency=True,
# metFlags.METAssocConfigs()[cfg_truthassoc_akt4pf.suffix] = cfg_truthassoc_akt4pf # metFlags.METAssocOutputList().append(cfg_truthassoc_akt4pf.suffix) # Get the configuration directly from METRecoFlags # Can also provide a dict of configurations or list of RecoTools or both from METReconstruction.METAssocConfig import getMETAssocAlg assocAlg = getMETAssocAlg('METAssociation') from METUtilities.METMakerConfig import getMETMakerAlg # metAlg = getMETMakerAlg('AntiKt4EMTopo',20e3) # metAlg.METName = 'MET_Reco_AntiKt4EMTopo' # metAlg_new = getMETMakerAlg('NewAntiKt4EMTopo',20e3,'AntiKt4EMTopoJets') # metAlg_new.METName = 'MET_Reco_NewAntiKt4EMTopo' metAlg_truth = getMETMakerAlg('Truth_AntiKt4EMTopo', 20e3) metAlg_truth.METSoftClName = 'SoftTruthAll' metAlg_truth.METSoftTrkName = 'SoftTruthCharged' #metAlg_truth.InputMuons="" ToolSvc.METMaker_Truth_AntiKt4EMTopo.JetConstitScaleMom = "" ToolSvc.METMaker_Truth_AntiKt4EMTopo.JetJvtCut = -1 metAlg_truth.METName = 'MET_Truth_AntiKt4EMTopo' metAlg_truthconst = getMETMakerAlg('TruthConst_AntiKt4EMTopo', 20e3) metAlg_truthconst.METSoftClName = 'SoftTruthAll' metAlg_truthconst.METSoftTrkName = 'SoftTruthCharged' metAlg_truthconst.METMapName = 'METAssoc_Truth_AntiKt4EMTopo' metAlg_truthconst.METCoreName = 'MET_Core_Truth_AntiKt4EMTopo' ToolSvc.METMaker_TruthConst_AntiKt4EMTopo.DoJetTruth = True ToolSvc.METMaker_TruthConst_AntiKt4EMTopo.JetConstitScaleMom = "" ToolSvc.METMaker_TruthConst_AntiKt4EMTopo.JetJvtCut = -1
from TauEmbdVal.TauEmbdValConf import TauEmbd__TauEmbdVal ## read xAOD or ESD files import AthenaPoolCnvSvc.ReadAthenaPool from AthenaCommon.AppMgr import ServiceMgr from GaudiSvc.GaudiSvcConf import THistSvc from AthenaCommon.AppMgr import ToolSvc from glob import glob svcMgr.EventSelector.InputCollections = [TestFile] # specify the number of events to be proccesed: theApp.EvtMax = 1000 ###### MET from METUtilities.METMakerConfig import getMETMakerAlg metAlg = getMETMakerAlg('AntiKt4EMTopo',20e3) metAlg.METName = 'MET_Reco_AntiKt4EMTopo' metAlg_truth = getMETMakerAlg('Truth_AntiKt4EMTopo',20e3) metAlg_truth.METSoftClName = 'SoftTruthAll' metAlg_truth.METSoftTrkName = 'SoftTruthCharged' metAlg_truth.METName = 'MET_Truth_AntiKt4EMTopo' # add your algorithm to the sequencer # fetch the AthAlgSeq, one of the master sequences where all algs should be added to algseq = CfgMgr.AthSequencer("AthAlgSeq") algseq += metAlg algseq += metAlg_truth write_xAOD = True if write_xAOD: