def setupMuonCalib(): global topSequence, ToolSvc if not rec.doMuon() or not DetFlags.Muon_on(): logMuon.warning( "Not setting up requested Muon Calibration because Muons are off") return logMuon.info("Setting up Muon Calibration") try: from MuonCnvExample.MuonCalibFlags import muonCalibFlags muonCalibFlags.setDefaults() configs = getCalibConfigs() # # MuonSegmentToCalibSegment # calibConfig = muonRec.allConfigs()[0].getCalibConfig( ) #muonRec.getConfig(muonCalibFlags.EventTag()).getCalibConfig() MuonSegmentToCalibSegment = getMuonSegmentToCalibSegment() # # MuonCalibAlg # MuonCalibAlg = getMuonCalibAlg(muonCalibFlags.EventTag()) from MdtCalibTools.MdtCalibToolsConf import MuonCalib__MdtCalibTool MuonCalibTool = MuonCalib__MdtCalibTool() calibMode = muonCalibFlags.Mode() if calibMode == 'regionNtuple': from MdtCalibTools.MdtCalibToolsConf import MuonCalib__MdtCalibNtupleMakerTool MdtCalibTool = MuonCalib__MdtCalibNtupleMakerTool() else: raise RuntimeError("Unknown Muon Calibration Mode: %r" % calibMode) ToolSvc += MdtCalibTool MuonCalibTool.MdtCalibTool = MdtCalibTool ToolSvc += MuonCalibTool MuonCalibAlg.MuonCalibTool = MuonCalibTool except: from AthenaCommon.Resilience import treatException treatException( "Problem in MuonCalib - Muon Calibration configuration probably incomplete" )
MuonCalibTool = MuonCalib__MdtCalibTool() calibMode = muonCalibFlags.Mode() if calibMode == 'regionNtuple': from MdtCalibTools.MdtCalibToolsConf import MuonCalib__MdtCalibNtupleMakerTool MdtCalibTool = MuonCalib__MdtCalibNtupleMakerTool() else: raise RuntimeError("Unknown Muon Calibration Mode: %r" % calibMode) ToolSvc += MdtCalibTool MuonCalibTool.MdtCalibTool = MdtCalibTool ToolSvc += MuonCalibTool MuonCalibAlg.MuonCalibTool = MuonCalibTool except: from AthenaCommon.Resilience import treatException treatException( "Problem in MuonCalib - Muon Calibration configuration probably incomplete" ) # chose the setup if muonRecFlags.doCalibNtuple(): setupMuonCalibNtuple() elif muonRecFlags.doCalib(): setupMuonCalib() else: logMuon.warning( "Loading %s but not setting up any MuonCalibration or Ntuple" % __name__)
def setupMuonCalibNtuple(): global topSequence, muonRecFlags, beamFlags, ToolSvc, rec, DetFlags if not rec.doMuon() or not DetFlags.Muon_on(): logMuon.warning( "Not setting up requested Muon Calibration Ntuple because Muons are off" ) return logMuon.info("Setting up Muon Calibration Ntuple") try: configs = getCalibConfigs() # MuonSegmentToCalibSegment is only needed if we want segments if muonRecFlags.calibNtupleSegments and muonRecFlags.calibMuonStandalone: MuonSegmentToCalibSegment = getMuonSegmentToCalibSegment() # MuonCalibAlg is always needed eventTag = "UNKNOWN" if (muonRecFlags.calibNtupleSegments or muonRecFlags.calibNtupleTracks ) and muonRecFlags.calibMuonStandalone: if len(configs) >= 1: eventTag = configs[0]["eventTag"] elif muonRecFlags.calibNtupleTrigger: eventTag = "TRIG" else: eventTag = "HITS" MuonCalibAlg = getMuonCalibAlg(eventTag) # configure for writing ntuple from MuonCalibTools.MuonCalibToolsConf import MuonCalib__PatternNtupleMaker MuonCalibTool = MuonCalib__PatternNtupleMaker( "MuonCalibPatternNtupleMaker") MuonCalibTool.FillTruth = rec.doTruth() MuonCalibTool.DoRawTGC = (muonRecFlags.doTGCs() and muonRecFlags.calibNtupleRawTGC()) ToolSvc += MuonCalibTool MuonCalibAlg.MuonCalibTool = MuonCalibTool # MuonCalibExtraTree only if we want to write tracks if muonRecFlags.calibNtupleTracks: MuonCalibTool.DelayFinish = True from MuonCalibExtraTreeAlg.MuonCalibExtraTreeAlgConf import MuonCalib__MuonCalibExtraTreeAlg MuonCalibExtraTreeAlg = MuonCalib__MuonCalibExtraTreeAlg( "MuonCalibExtraTreeAlg", NtupleName="PatternNtupleMaker", ) segmentOnTrackSelector = None if hasattr(topSequence, "MuonSegmentToCalibSegment"): from MuonCalibExtraTreeAlg.MuonCalibExtraTreeAlgConf import MuonCalib__SegmentOnTrackSelector segmentOnTrackSelector = MuonCalib__SegmentOnTrackSelector() segmentOnTrackSelector.PattternLocation = "PatternsForCalibration" ToolSvc += segmentOnTrackSelector MuonCalibExtraTreeAlg.SegmentOnTrackSelector = segmentOnTrackSelector if not rec.doMuonCombined(): tool_nr = 0 from MuonCalibExtraTreeAlg.MuonCalibExtraTreeAlgConf import MuonCalib__ExtraTreeTrackFillerTool resPullCalc = getPublicTool("ResidualPullCalculator") for config in configs: trackDumpTool = MuonCalib__ExtraTreeTrackFillerTool( "ExtraTreeTrackFillerTool" + str(tool_nr)) trackDumpTool.TrackCollectionKey = config['tracksKey'] trackDumpTool.SegmentAuthors = [config['segmentAuthor']] trackDumpTool.TrackAuthor = config['trackAuthor'] trackDumpTool.PullCalculator = resPullCalc ToolSvc += trackDumpTool MuonCalibExtraTreeAlg.TrackFillerTools.append( trackDumpTool) tool_nr += 1 # configure needed tools # add to topSequence topSequence += MuonCalibExtraTreeAlg # MuonCalibExtraTreeTriggerAlg only if trigger is available if muonRecFlags.calibNtupleTrigger: # and DetFlags.detdescr.LVL1_on() and DetFlags.haveRDO.LVL1_on(): # protect against running without AtlasTrigger project doMuCTPI = True if doMuCTPI: try: from TrigT1RPCRecRoiSvc import TrigT1RPCRecRoiConfig from TrigT1TGCRecRoiSvc import TrigT1TGCRecRoiConfig except ImportError: logMuon.warning( "MuonCalibExtraTreeTriggerAlg.doMuCTPI = False because AtlasTrigger is not available" ) doMuCTPI = False # delay writing of MuonCalibAlg MuonCalibTool.DelayFinish = True # also delay MuonCalibExtraTreeAlg if it is running try: topSequence.MuonCalibExtraTreeAlg.DelayFinish = True except AttributeError: pass from MuonCalibExtraTreeAlg.MuonCalibExtraTreeAlgConf import MuonCalib__MuonCalibExtraTreeTriggerAlg topSequence += MuonCalib__MuonCalibExtraTreeTriggerAlg( 'MuonCalibExtraTreeTriggerAlg', doMuCTPI=doMuCTPI, doLVL1Calo=rec.doTile() or rec.doLArg() or DetFlags.haveRDO.Calo_on(), doMBTS=rec.doTile() or DetFlags.haveRDO.Tile_on()) except: from AthenaCommon.Resilience import treatException treatException( "Problem in MuonCalib - Muon Calibration Ntuple configuration probably incomplete" )
return DCMathSegmentMaker(name,extraFlags,**kwargs) # end of factory function DCMathSegmentMaker def MuonLayerHoughTool(name='MuonLayerHoughTool',extraFlags=None,**kwargs): kwargs.setdefault("DoTruth", rec.doTruth() ) return CfgMgr.Muon__MuonLayerHoughTool(name,**kwargs) if DetFlags.detdescr.Muon_on() and rec.doMuon(): # until all clients explicitly get their tools and services, load some explicitly getPublicTool("ResidualPullCalculator") getPublicTool("MuonHoughPatternTool") getPublicTool("MuonCombinePatternTool") getPublicTool("MuonPhiHitSelector") getPublicTool("MuonEDMPrinterTool") getPublicTool("MuonSegmentMomentum") getPublicTool("MuonClusterOnTrackCreator") getPublicTool("CscClusterOnTrackCreator") getPublicTool("CscBroadClusterOnTrackCreator") getPublicTool("MdtDriftCircleOnTrackCreator") getPublicTool("MdtTubeHitOnTrackCreator") #getService("SomeService") else: # not (DetFlags.Muon_on() and rec.doMuon()) logMuon.warning("Muon reconstruction tools only loaded on-demand because Muons")