def configure(self):
        mlog = logging.getLogger(self._name + '::configure :')

        from MuonAlignGenTools.MuonAlignRefitToolGetter import MuonAlignRefitToolGetter
        muonAlignRefitTool = MuonAlignRefitToolGetter(
        ).MuonAlignRefitToolHandle()

        # create tool instance
        from MuonAlignGenTools.MuonAlignGenToolsConf import Muon__MuonTrackCollectionProvider
        muonTrackCollectionProvider = Muon__MuonTrackCollectionProvider(
            "MuonTrackCollectionProvider",
            OutputLevel=align.OutputLevel(),
            InputMuonCol=mualign.MuonContainerName(),
            InputTrackCol=align.inputTrkCol(),
            InputIDTrackCol=mualign.inputIDTrackCol(),
            UseStandaloneTracks=mualign.useStandaloneTracks(),
            TrackType=mualign.inputTrackCollectionType(),
            MomentumCut=mualign.momentumCut(),
            MuonAlignRefitTool=muonAlignRefitTool)

        self._muonTrackCollectionProviderHandle = muonTrackCollectionProvider

        mlog.info(" now adding to ToolSvc")
        from __main__ import ToolSvc
        ToolSvc += self.MuonTrackCollectionProviderHandle()

        mlog.info(" leaving configure")

        return True
    def configure ( self ) :
        mlog = logging.getLogger( self._name+'::configure :' )

        muonIO = MuonAlignmentIOFiles()

        # create tool instance

        from __main__ import ToolSvc

        from MuonAlignGenTools.MuonAlignGenToolsConf import Muon__CscAlignDBTool
        muonAlignDBTool = Muon__CscAlignDBTool(OutputLevel = align.OutputLevel(),
                                               ABLineDbTool = ToolSvc.MGM_AlignmentDbTool,
                                               ASZTOutputFile = muonIO.asztOutputFile(),
                                               AlternateASZTFile = str(''),
                                               SigmaOutputFile = '',
                                               SigmaInputFile = '',
                                               UseMultiLevelDbTool = mualign.doMultiLevelAlignment()) 
        if mualign.useAlternateASZT() : 
            muonAlignDBTool.AlternateASZTFile = muonIO.asztInputFile()
        self._CscAlignDBToolHandle = muonAlignDBTool

        if mualign.doMultiLevelAlignment :
            MultiLevelAlignmentDbTool = ToolSvc.MultiLevelAlignmentDbTool
        else:
            from MuonCondTool.MuonCondToolConf import MultiLevelAlignmentDbTool
            MultiLevelAlignmentDbTool = MultiLevelAlignmentDbTool("MultiLevelAlignmentDbTool")
            MultiLevelAlignmentDbTool.ABLineDbTool = ToolSvc.MGM_AlignmentDbTool

        mlog.info(" leaving configure" )

        return True
    def configure ( self ) :
        mlog = logging.getLogger( self._name+'::configure :' )

        # create tool instance
        from TrkAlignGenTools.AlignResidualCalculatorGetter import AlignResidualCalculatorGetter
        resCalc = AlignResidualCalculatorGetter().ResidualPullCalculatorHandle()
        
        from MuonAlignGenTools.MuonAlignGenToolsConf import Muon__MuonFillNtupleTool
        from MuonAlignGenTools.MuonAlignmentIOFiles import MuonAlignmentIOFiles
        muonIO = MuonAlignmentIOFiles()
        muonFillNtupleTool = Muon__MuonFillNtupleTool(OutputLevel = align.OutputLevel(),
                                                      ResidualPullCalculator = resCalc,
                                                      MuonContainer = mualign.MuonContainerName())

        from MuonAlignGenTools.MuonAlignModuleToolGetter import MuonAlignModuleToolGetter
        muonAlignModuleTool = MuonAlignModuleToolGetter().MuonAlignModuleToolHandle()
        muonFillNtupleTool.AlignModuleTool = muonAlignModuleTool
        muonFillNtupleTool.BigNtuple = mualign.doBigNtuple()

        
        from MuTagTools.MuTagToolsConf import MuTagEDMHelper
        ConfiguredMuTagEDMHelper = MuTagEDMHelper("ConfiguredMuTagEDMHelper")
        from __main__ import ToolSvc
        ToolSvc += ConfiguredMuTagEDMHelper        
        muonFillNtupleTool.muTagEDMHelperTool = ConfiguredMuTagEDMHelper

        self._MuonFillNtupleToolHandle = muonFillNtupleTool

        mlog.info(" leaving configure" )

        return True
Exemple #4
0
 def __init__(self):
     mlog = logging.getLogger('MuonAlignmentIOFiles::__init__')
     if not MuonAlignmentIOFiles._rootFilePathIsSet:
         self.setRootFilePath(align.outputPath())
     if not MuonAlignmentIOFiles._asztFilePathIsSet:
         self.setAsztFilePath(mualign.asztFilePath())
     if not MuonAlignmentIOFiles._initialAsztFilePathIsSet:
         self.setInitialAsztFilePath(mualign.initialAsztFilePath())
Exemple #5
0
 def setL3(self):
     if mualign.alignMDT():
         align.derivativeType = 'Numerical'
     elif mualign.alignCSC():
         align.derivativeType = 'Analytical'
     else:
         align.derivativeType = 'unknown'
     align.alignmentLevel = 3
     self.setFullReco(False)
Exemple #6
0
    def newConfigureSolveAlignment(self):

        self.setAlignmentDbTool()

        # setup MCTB fitter (not used but needed for AlignTrackPreProcessor)

        # get AlignAlg without muon-specific tools
        from TrkAlignGenAlgs.AlignAlgGetter import AlignAlgGetter
        solveAlign = AlignAlgGetter().AlignAlgHandle()

        # add muon-specific tools using current MuonAlignment flags

        # MuonGeometryManagerTool
        from MuonAlignGenTools.MuonGeometryManagerToolGetter import MuonGeometryManagerToolGetter
        solveAlign.GeometryManagerTool = MuonGeometryManagerToolGetter(
        ).MuonGeometryManagerToolHandle()

        # Csc/MdtAlignDBTool
        if mualign.alignMDT():
            from MuonAlignGenTools.MdtAlignDBToolGetter import MdtAlignDBToolGetter
            solveAlign.AlignDBTool = MdtAlignDBToolGetter(
            ).MdtAlignDBToolHandle()
        elif mualign.alignCSC():
            from MuonAlignGenTools.CscAlignDBToolGetter import CscAlignDBToolGetter
            solveAlign.AlignDBTool = CscAlignDBToolGetter(
            ).CscAlignDBToolHandle()
        else:
            print '************ At the moment set to MdtAlignDBTool  *************'
            print '*********** but please make sure what you are doing ***********'
            from MuonAlignGenTools.MdtAlignDBToolGetter import MdtAlignDBToolGetter
            solveAlign.AlignDBTool = MdtAlignDBToolGetter(
            ).MdtAlignDBToolHandle()

# create MuonAlignModuleTool and configure tools
        from MuonAlignGenTools.MuonAlignModuleToolGetter import MuonAlignModuleToolGetter
        alignModTool = MuonAlignModuleToolGetter().MuonAlignModuleToolHandle()
        solveAlign.AlignTool.AlignModuleTool = alignModTool
        solveAlign.AlignTool.MatrixTool.AlignModuleTool = alignModTool

        # set matrix tool output to DEBUG
        solveAlign.AlignTool.MatrixTool.OutputLevel = 2

        # configure GlobalChi2AlignTool's output tree
        globalChi2AlignTool = solveAlign.AlignTool
        globalChi2AlignTool.DoShiftDerivTree = mualign.doShiftDerivTree()

        # add RegionSelectionSvc
        self.addRegionSelectionSvc()

        solveAlign.SolveOnly = True
Exemple #7
0
    def configure(self):
        mlog = logging.getLogger(self._name + '::configure :')

        from TrkAlignGenTools.AlignmentTrackFitter import AlignmentTrackFitter
        #from MuonTrackFinderTools.MuonTrackFinderToolsConf import Muon__MuonRefitTool
        from MuonTrackFinderTools.MuonTrackFinderToolsConf import Muon__MuonRefitTool
        muonRefitTool = Muon__MuonRefitTool(
            "MuonRefitToolForAlignment",
            OutputLevel=align.OutputLevel(),
            Fitter=AlignmentTrackFitter().fitter())

        from __main__ import ToolSvc
        ToolSvc += muonRefitTool

        # create tool instance
        from MuonAlignGenTools.MuonAlignGenToolsConf import Muon__MuonAlignRefitTool
        muonAlignRefitTool = Muon__MuonAlignRefitTool(
            OutputLevel=align.OutputLevel())

        combmu = mualign.selectCombinedMuons()

        muonAlignRefitTool.MuonRefitTool = muonRefitTool

        muonAlignRefitTool.RemoveBIS8Hits = False
        muonAlignRefitTool.RemoveTGCHits = False
        muonAlignRefitTool.RemoveTGCEtaHits = True
        muonAlignRefitTool.RemoveRPCEtaHits = True
        muonAlignRefitTool.RemoveCSCPhiHits = True
        muonAlignRefitTool.DeclusterTGCHits = False
        muonAlignRefitTool.RemoveSmallBarrelHits = False

        muonAlignRefitTool.RemoveCSCHits = mualign.removeCSCHits()
        muonAlignRefitTool.RemoveBEEHits = not mualign.alignEE()
        muonAlignRefitTool.RemoveEEHits = not mualign.alignEE()

        muonAlignRefitTool.RemoveBarrelHits = not mualign.alignBarrel()
        muonAlignRefitTool.RemoveEndcapHits = not mualign.alignEndcap()
        muonAlignRefitTool.RemoveTRTHits = mualign.removeTRTHits()
        muonAlignRefitTool.RemoveScattering = not align.includeScatterers()

        muonAlignRefitTool.RecreateStartingParameters = not mualign.selectCombinedMuons(
        )
        muonAlignRefitTool.ExtrapolateToMuonEntry = not mualign.selectCombinedMuons(
        )

        self._MuonAlignRefitToolHandle = muonAlignRefitTool

        mlog.info(" now adding to ToolSvc")
        from __main__ import ToolSvc
        ToolSvc += self.MuonAlignRefitToolHandle()

        mlog.info(" leaving configure")

        return True
Exemple #8
0
 def doMultiLevelAlignment(self):
     doMultiLevelAlignment = False
     if align.alignmentLevel() != 3:
         if align.iteration() > 0 or mualign.jobType() == 'misal':
             doMultiLevelAlignment = True
     mualign.doMultiLevelAlignment = doMultiLevelAlignment
     return doMultiLevelAlignment
Exemple #9
0
    def configureReco(self):
        from AthenaCommon.DetFlags import DetFlags
        DetFlags.Muon_setOn()
        DetFlags.Calo_setOff()

        recAlgsFlags.doMuonIDStandAlone = False
        recAlgsFlags.doMuonIDCombined = False

        # add some more flags available for standalone running
        import MuonRecExample.MuonRecStandaloneFlags

        # configure flags so that only Muon Standalone reco is run
        import MuonRecExample.MuonRecStandaloneOnlySetup

        muonRecFlags.useAlignmentCorrections = mualign.useOpticalAlignment()

        # cosmics setup
        #if align.dataType()=='cosmic' or align.dataType()=='simCosmic':

        ##### no more flags after this line #####
        print "align.dataType()=", align.dataType()
        if align.dataType() == 'data' or align.dataType() == 'cosmic':
            muonRecTopOptions = "MuonAlignGenTools/MuonDataRec_myTopOptions.py"
        else:
            muonRecTopOptions = "MuonRecExample/MuonRec_topOptions.py"
        try:
            include(muonRecTopOptions)

        ###### put any user finetuning before this line #####
        except:
            # always write config so far for debugging
            from AthenaCommon.ConfigurationShelve import saveToAscii
            saveToAscii("config.txt")
            # but still exit with error
            raise
Exemple #10
0
    def setL1(self):
        #align.derivativeType = 'Numerical'
        align.alignmentLevel = 1
        align.requireOverlap = False
        #self.setFullReco(True)

        level1modules = []
        if mualign.doEndcap():

            if mualign.endcapsToAlign == 'A' or mualign.endcapsToAlign == 'BOTH':
                level1modules.append('ECA')
            if mualign.endcapsToAlign == 'C' or mualign.endcapsToAlign == 'BOTH':
                level1modules.append('ECC')

        if mualign.doBarrel():
            level1modules.append('Bar')
    def configure ( self ) :
        mlog = logging.getLogger( self._name+'::configure :' )

        # create tool instance
        from MuonAlignGenTools.MuonAlignGenToolsConf import Muon__MuonGeometryManagerTool, Muon__MdtGeometryManagerTool, Muon__CscGeometryManagerTool, Muon__TgcGeometryManagerTool

        # MDT
        mdtGeometryManagerTool =  Muon__MdtGeometryManagerTool(OutputLevel = align.OutputLevel(),
                                                               AlignLevel = align.alignmentLevel(),
                                                               AlignTraX=mualign.mdtAlignTraX(),
                                                               AlignTraY=mualign.mdtAlignTraY(),
                                                               AlignTraZ=mualign.mdtAlignTraZ(),
                                                               AlignRotX=mualign.mdtAlignRotX(),
                                                               AlignRotY=mualign.mdtAlignRotY(),
                                                               AlignRotZ=mualign.mdtAlignRotZ())
        self._MdtGeometryManagerToolHandle = mdtGeometryManagerTool

        # CSC
        cscGeometryManagerTool =  Muon__CscGeometryManagerTool(OutputLevel = align.OutputLevel(),
                                                               AlignLevel = align.alignmentLevel())
        self._CscGeometryManagerToolHandle = cscGeometryManagerTool

        # TGC
        tgcGeometryManagerTool =  Muon__TgcGeometryManagerTool(OutputLevel = align.OutputLevel(),
                                                               AlignLevel = align.alignmentLevel())
        self._TgcGeometryManagerToolHandle = tgcGeometryManagerTool
        
        mlog.info(" now adding geometryManagerTools to ToolSvc" )
        from __main__ import ToolSvc
        ToolSvc += self.MdtGeometryManagerToolHandle()
        ToolSvc += self.CscGeometryManagerToolHandle()
        ToolSvc += self.TgcGeometryManagerToolHandle()

        muonGeometryManagerTool = Muon__MuonGeometryManagerTool(OutputLevel = align.OutputLevel(),
                                                                AlignLevel = align.alignmentLevel(),
                                                                MdtGeometryManager = mdtGeometryManagerTool,
                                                                CscGeometryManager = cscGeometryManagerTool,
                                                                TgcGeometryManager = tgcGeometryManagerTool,
                                                                doModuleSelection = mualign.doModuleSelection(),
                                                                AlignMdt = mualign.alignMDT(),
                                                                AlignTgc = False, #mualign.alignTGC(),
                                                                AlignCsc = False, #mualign.alignCSC(),
                                                                ModuleSelection = mualign.modulesToAlign())
        self._MuonGeometryManagerToolHandle = muonGeometryManagerTool
        
        mlog.info(" now adding MuonGeometryManagerTool to ToolSvc" )
        ToolSvc += self.MuonGeometryManagerToolHandle()

        mlog.info(" leaving configure" )

        return True
Exemple #12
0
    def addRegionSelectionSvc(self):
        from MuonCalibStandAloneBase.MuonCalibStandAloneBaseConf import RegionSelectionSvc
        RegionSelectionSvc = RegionSelectionSvc(PrintList=True)
        RegionSelectionSvc.Region = mualign.moduleSelectionString()

        from AthenaCommon.AppMgr import ServiceMgr as svcMgr
        svcMgr += RegionSelectionSvc
        print RegionSelectionSvc
Exemple #13
0
    def setL1(self):
        align.derivativeType = 'Numerical'
        align.alignmentLevel = 1
        align.requireOverlap = False
        self.setFullReco(True)

        mualign.alignMDT = True
        level1modules = []
        if mualign.doEndcap():

            if mualign.endcapsToAlign == 'A' or mualign.endcapsToAlign == 'BOTH':
                level1modules.append(0)
            if mualign.endcapsToAlign == 'C' or mualign.endcapsToAlign == 'BOTH':
                level1modules.append(1)

        if mualign.doBarrel():
            level1modules.append(2)
            mlog.warning("this isn't really implemented yet!!!")
Exemple #14
0
    def configure(self):
        mlog = logging.getLogger(self._name + '::configure :')

        # create tool instance
        from TrkAlignGenTools.AlignResidualCalculatorGetter import AlignResidualCalculatorGetter
        resCalc = AlignResidualCalculatorGetter(
        ).AlignResidualCalculatorHandle()

        from TrkAlignGenTools.AlignmentTrackFitter import AlignmentTrackFitter
        from TrkAlignGenTools.TrkAlignGenToolsConf import Trk__ShiftingDerivCalcTool
        shiftingDerivCalcTool = Trk__ShiftingDerivCalcTool(
            "ShiftingDerivCalcTool",
            OutputLevel=AlignmentFlags.OutputLevel(),
            TrackFitterTool=AlignmentTrackFitter().fitter(),
            ResidualCalculator=resCalc,
            TranslationSize=mualign.shiftSizeTranslations(),
            RotationSize=mualign.shiftSizeRotations(),
            NumberOfShifts=mualign.numberOfShifts(),
            doChi2VChamberShiftsMeasType=mualign.doChi2VChamberShiftsMeasType(
            ))
        if AlignmentFlags.useSLFitter():
            shiftingDerivCalcTool.SLTrackFitterTool = AlignmentTrackFitter(
            ).slfitter()

        # configure other jobOptions
        shiftingDerivCalcTool.RunOutlierRemoval = AlignmentFlags.runOutlierRemoval(
        )
        shiftingDerivCalcTool.ParticleNumber = AlignmentFlags.particleNumber()
        shiftingDerivCalcTool.TrackAlignParamCut = AlignmentFlags.trackAlignParamCut(
        )
        shiftingDerivCalcTool.SetMinIterations = AlignmentFlags.setMinIterations(
        )

        self._ShiftingDerivCalcToolHandle = shiftingDerivCalcTool

        mlog.info(" now adding to ToolSvc")
        from __main__ import ToolSvc
        ToolSvc += self.ShiftingDerivCalcToolHandle()

        mlog.info(" leaving configure")

        return True
Exemple #15
0
    def setAlignmentDbTool(self, useAlternateAscii):

        from AtlasGeoModel.MuonGM import GeoModelSvc
        MuonDetectorTool = GeoModelSvc.DetectorTools["MuonDetectorTool"]
        MuonDetectorTool.OutputLevel = align.OutputLevel()
        altASZTFile = ""
        if mualign.doMultiLevelAlignment():
            MuonDetectorTool.UseAsciiConditionData = 1
            MuonDetectorTool.UseConditionDb = 1
        else:
            print "doMultiLevelAlignment=False"
        from MuonAlignGenTools.MuonAlignmentIOFiles import MuonAlignmentIOFiles
        if useAlternateAscii:
            altASZTFile = self.muonIO.asztInputFile()
            MuonDetectorTool.AlternateASZTFile = altASZTFile
        print MuonDetectorTool

        from MuonCondTool.MuonCondToolConf import MuonAlignmentDbTool
        MuonAlignmentDbTool = MuonAlignmentDbTool("MGM_AlignmentDbTool")
        MuonAlignmentDbTool.ParlineFolders = [
            "/MUONALIGN/MDT/BARREL", "/MUONALIGN/MDT/ENDCAP/SIDEA",
            "/MUONALIGN/MDT/ENDCAP/SIDEC", "/MUONALIGN/TGC/SIDEA",
            "/MUONALIGN/TGC/SIDEC"
        ]
        MuonAlignmentDbTool.OutputLevel = align.OutputLevel()

        from __main__ import ToolSvc
        ToolSvc += MuonAlignmentDbTool

        if mualign.doMultiLevelAlignment():
            from MuonCondTool.MuonCondToolConf import MultiLevelAlignmentDbTool
            MultiLevelAlignmentDbTool = MultiLevelAlignmentDbTool(
                "MultiLevelAlignmentDbTool")
            MultiLevelAlignmentDbTool.ABLineDbTool = ToolSvc.MGM_AlignmentDbTool
            MultiLevelAlignmentDbTool.L1AsciiFile = self.muonIO.inputLevel1File(
            )
            MultiLevelAlignmentDbTool.OutputLevel = align.OutputLevel()
            ToolSvc += MultiLevelAlignmentDbTool

            MuonDetectorTool.TheMuonAlignmentTool = MultiLevelAlignmentDbTool
        else:
            MuonDetectorTool.TheMuonAlignmentTool = MuonAlignmentDbTool
Exemple #16
0
    def configure(self):
        mlog = logging.getLogger(self._name + '::configure :')

        # create tool instance
        from MuonAlignGenTools.MuonAlignGenToolsConf import Muon__MdtGeometryManagerTool
        mdtGeometryManagerTool = Muon__MdtGeometryManagerTool(
            OutputLevel=align.OutputLevel(),
            MdtAlignParameters=mualign.mdtAlignParams())
        self._MdtGeometryManagerToolHandle = mdtGeometryManagerTool

        mlog.info(" now adding to ToolSvc")
        from __main__ import ToolSvc
        ToolSvc += self.MdtGeometryManagerToolHandle()

        mlog.info(" leaving configure")

        return True
    def configure(self):
        mlog = logging.getLogger(self._name + '::configure :')

        # create tool instance
        from MuonAlignGenTools.MuonAlignGenToolsConf import Muon__MuonAlignModuleTool
        muonAlignModuleTool = Muon__MuonAlignModuleTool(
            OutputLevel=align.OutputLevel(),
            AlignModuleListType=mualign.alignModuleListType())

        self._MuonAlignModuleToolHandle = muonAlignModuleTool

        mlog.info(" now adding to ToolSvc")
        from __main__ import ToolSvc
        ToolSvc += self.MuonAlignModuleToolHandle()

        mlog.info(" leaving configure")

        return True
Exemple #18
0
    def configureAlignment(self, useAlternateAscii=False, isMC=True):

        print "in configureAlignment"

        self.setAlignmentDbTool(useAlternateAscii, isMC)

        # get AlignAlg without muon-specific tools
        from TrkAlignGenAlgs.AlignAlgGetter import AlignAlgGetter
        alignAlg = AlignAlgGetter().AlignAlgHandle()

        # add muon-specific tools using current MuonAlignment flags

        # MuonTrackCollectionProvider
        if mualign.trackCollectionProvider() == 'MuonTrackCollectionProvider':
            from MuonAlignGenTools.MuonTrackCollectionProviderGetter import MuonTrackCollectionProviderGetter
            alignAlg.TrackCollectionProvider = MuonTrackCollectionProviderGetter(
            ).MuonTrackCollectionProviderHandle()

            # create instance of MuonMatchQuality
            #from MuonTrackThroughCalo.ConfMuonTrackThroughCalo import ConfMuonTrackThroughCalo
            #MuonTTC = ConfMuonTrackThroughCalo("MuonTrackThroughCalo")

            from AthenaCommon.AppMgr import ToolSvc
            #ToolSvc += MuonTTC

            from MuonRecExample import MuonRecTools
            muonCombiTrackMaker = MuonRecTools.getPublicTool(
                'MooTrackSteering')
            #muonCombiTrackMaker.OutputLevel = DEBUG
            muonCombiTrackMaker.OutputLevel = align.OutputLevel()

            atlasExtrapolator = MuonRecTools.getPublicTool('AtlasExtrapolator')
            from MuonCombinedTestTools.MuonCombinedTestToolsConf import MuonCombined__MuonTrackTagTestTool
            combinedMuonTag = MuonCombined__MuonTrackTagTestTool(
                name="CombinedMuonTag",
                ExtrapolatorTool=atlasExtrapolator,
                #TTCTool          = MuonTTC,
                Chi2Cut=2500.)
            ToolSvc += combinedMuonTag

            alignAlg.TrackCollectionProvider.TagTool = combinedMuonTag

        # create tool instance
        elif mualign.trackCollectionProvider() == 'TrackCollectionProvider':
            from TrkAlignGenTools.TrackCollectionProviderGetter import TrackCollectionProviderGetter
            alignAlg.TrackCollectionProvider = TrackCollectionProviderGetter(
            ).TrackCollectionProviderGetterHandle()
        else:
            print "Using default TrackCollectionProvider!"

# MuonTrackPreProcessor
        from MuonAlignGenTools.MuonTrackPreProcessorGetter import MuonTrackPreProcessorGetter
        alignAlg.AlignTrackPreProcessor = MuonTrackPreProcessorGetter(
        ).MuonTrackPreProcessorHandle()

        # MuonGeometryManagerTool
        from MuonAlignGenTools.MuonGeometryManagerToolGetter import MuonGeometryManagerToolGetter
        alignAlg.GeometryManagerTool = MuonGeometryManagerToolGetter(
        ).MuonGeometryManagerToolHandle()

        # MuonFillNtupleTool
        from MuonAlignGenTools.MuonFillNtupleToolGetter import MuonFillNtupleToolGetter
        alignAlg.FillNtupleTool = MuonFillNtupleToolGetter(
        ).MuonFillNtupleToolHandle()

        # MdtAlignDBTool
        if mualign.alignMDT():
            from MuonAlignGenTools.MdtAlignDBToolGetter import MdtAlignDBToolGetter
            alignAlg.AlignDBTool = MdtAlignDBToolGetter().MdtAlignDBToolHandle(
            )
        elif mualign.alignCSC():
            from MuonAlignGenTools.CscAlignDBToolGetter import CscAlignDBToolGetter
            alignAlg.AlignDBTool = CscAlignDBToolGetter().CscAlignDBToolHandle(
            )
        else:
            print '************ At the moment set to MdtAlignDBTool  *************'
            print '*********** but please make sure what you are doing ***********'
            from MuonAlignGenTools.MdtAlignDBToolGetter import MdtAlignDBToolGetter
            alignAlg.AlignDBTool = MdtAlignDBToolGetter().MdtAlignDBToolHandle(
            )

# create MuonAlignModuleTool and configure tools
        from MuonAlignGenTools.MuonAlignModuleToolGetter import MuonAlignModuleToolGetter
        alignModTool = MuonAlignModuleToolGetter().MuonAlignModuleToolHandle()
        alignAlg.AlignTool.AlignModuleTool = alignModTool
        alignAlg.AlignTool.MatrixTool.AlignModuleTool = alignModTool
        alignAlg.AlignTrackCreator.AlignModuleTool = alignModTool
        alignAlg.AlignTrackDresser.DerivCalcTool.AlignModuleTool = alignModTool

        # set matrix tool output to DEBUG
        alignAlg.AlignTool.MatrixTool.OutputLevel = 2

        # configure GlobalChi2AlignTool's output tree
        globalChi2AlignTool = alignAlg.AlignTool

        # add RegionSelectionSvc
        self.addRegionSelectionSvc()
Exemple #19
0
    def setAlignmentDbTool(self, useAlternateAscii, isMC):

        from AtlasGeoModel.MuonGM import GeoModelSvc
        MuonDetectorTool = GeoModelSvc.DetectorTools["MuonDetectorTool"]
        MuonDetectorTool.OutputLevel = align.OutputLevel()
        #MuonDetectorTool.OutputLevel = INFO

        print "in setAlignmentDbTool, useAlternateAscii=", useAlternateAscii
        if isMC:

            #altASZTFile = ""
            if mualign.doMultiLevelAlignment():
                MuonDetectorTool.UseAsciiConditionData = 1
                MuonDetectorTool.UseConditionDb = 0
            from MuonAlignGenTools.MuonAlignmentIOFiles import MuonAlignmentIOFiles
            if useAlternateAscii:
                #altASZTFile = self.muonIO.asztInputFile()
                MuonDetectorTool.AlternateASZTFile = "asztInput.txt"
                MuonDetectorTool.UseAsciiConditionData = 1

        # get MuonAlignmentDbTool if already configured, create one if not
        from __main__ import ToolSvc
        try:
            muonAlignmentDbTool = ToolSvc.MGM_AlignmentDbTool
        except:
            from MuonCondTool.MuonCondToolConf import MuonAlignmentDbTool
            muonAlignmentDbTool = MuonAlignmentDbTool("MGM_AlignmentDbTool")
            ToolSvc += muonAlignmentDbTool
            MuonDetectorTool.TheMuonAlignmentTool = muonAlignmentDbTool

        muonAlignmentDbTool.OutputLevel = align.OutputLevel()
        #muonAlignmentDbTool.OutputLevel = DEBUG
        muonAlignmentDbTool.DumpALines = False
        if isMC and useAlternateAscii and align.alignmentLevel == 3:
            muonAlignmentDbTool.ALinesFile = "asztInput.txt"
        if not isMC:
            muonAlignmentDbTool.ParlineFolders = [
                "/MUONALIGN/MDT/BARREL", "/MUONALIGN/MDT/ENDCAP/SIDEA",
                "/MUONALIGN/MDT/ENDCAP/SIDEC", "/MUONALIGN/TGC/SIDEA",
                "/MUONALIGN/TGC/SIDEC"
            ]
        print "doMultiLevelAlignment: ", mualign.doMultiLevelAlignment()

        if mualign.doMultiLevelAlignment():
            from MuonCondTool.MuonCondToolConf import MultiLevelAlignmentDbTool
            MultiLevelAlignmentDbTool = MultiLevelAlignmentDbTool(
                "MultiLevelAlignmentDbTool")
            MultiLevelAlignmentDbTool.ABLineDbTool = muonAlignmentDbTool
            if align.alignmentLevel == 1:
                MultiLevelAlignmentDbTool.L1AsciiFile = "level1input.txt"
            elif align.alignmentLevel == 23:
                MultiLevelAlignmentDbTool.L23AsciiFile = "level23input.txt"
            elif align.alignmentLevel == 3:
                MultiLevelAlignmentDbTool.L3AsciiFile = "asztInput.txt"
            else:
                print "*** Alignment level: ", align.alignmentLevel,\
                      "not yet implemented in MultiLevelAlignmentDbTool ***"
            MultiLevelAlignmentDbTool.OutputLevel = align.OutputLevel()
            #MultiLevelAlignmentDbTool.OutputLevel = INFO

            #MultiLevelAlignmentDbTool.MuonIdHelperTool = ToolSvc.MuonIdHelperTool
            ToolSvc += MultiLevelAlignmentDbTool

            MuonDetectorTool.TheMuonAlignmentTool = MultiLevelAlignmentDbTool

        #from IOVDbSvc.CondDB import conddb
        #conddb.addOverride("/MUONALIGN/MDT/ENDCAP/SIDEA","MuonAlignMDTEndCapAAlign-2010-01-02")
        #conddb.addOverride("/MUONALIGN/MDT/ENDCAP/SIDEC","MuonAlignMDTEndCapCAlign-2010-01-02")

        print ToolSvc
Exemple #20
0
from MuonRecExample.MuonRecFlags import muonRecFlags, mooreFlags, muonboyFlags
from MuonCalibAlgs.MuonCalibFlags import muonCalibFlags
from RecExConfig.RecFlags import rec as recFlags
from RecExConfig.RecAlgsFlags import recAlgs as recAlgsFlags
from AthenaCommon.AthenaCommonFlags import athenaCommonFlags

from AthenaCommon.DetFlags import DetFlags
DetFlags.Muon_setOn()
DetFlags.Calo_setOff()
DetFlags.ID_setOff()

recAlgsFlags.doMuonIDStandAlone = False
recAlgsFlags.doMuonIDCombined = False

# in Standalone mode, don't allow any configuration errors
athenaCommonFlags.AllowIgnoreConfigError = False

# add some more flags available for standalone running
import MuonRecExample.MuonRecStandaloneFlags

# configure flags so that only Muon Standalone reco is run
import MuonRecExample.MuonRecStandaloneOnlySetup

from MuonAlignGenTools.MuonAlignmentFlags import MuonAlignmentFlags as mualign
muonRecFlags.useAlignmentCorrections = mualign.useOpticalAlignment()
    def configure(self):
        mlog = logging.getLogger(self._name + '::configure :')

        # create tool instance
        from TrkAlignGenTools.AlignmentTrackFitter import AlignmentTrackFitter
        from MuonAlignGenTools.MuonAlignGenToolsConf import Muon__MuonAlignHelperTool, Muon__MuonTrackPreProcessor

        from MuonAlignGenTools.MuonAlignRefitToolGetter import MuonAlignRefitToolGetter
        muonAlignRefitTool = MuonAlignRefitToolGetter(
        ).MuonAlignRefitToolHandle()

        muonAlignHelperTool = Muon__MuonAlignHelperTool(
            OutputLevel=align.OutputLevel())

        from __main__ import ToolSvc
        ToolSvc += muonAlignHelperTool

        muonTrackPreProcessor = Muon__MuonTrackPreProcessor(
            OutputLevel=align.OutputLevel(),
            TrackFitterTool=AlignmentTrackFitter().fitter(),
            MuonAlignRefitTool=muonAlignRefitTool)

        if align.useSLFitter():
            muonTrackPreProcessor.SLTrackFitterTool = AlignmentTrackFitter(
            ).slfitter()

        muonTrackPreProcessor.RefitTracks = align.refitTracks()
        muonTrackPreProcessor.ParticleNumber = align.particleNumber()
        muonTrackPreProcessor.RunOutlierRemoval = align.runOutlierRemoval()
        muonTrackPreProcessor.RedoErrorScaling = mualign.redoErrorScaling()
        muonTrackPreProcessor.pTCorrectTrack = mualign.pTCorrectTrack()
        muonTrackPreProcessor.RemovePerigeeBeforeRefit = mualign.removePerigeeBeforeRefit(
        )

        muonTrackPreProcessor.ResetScatteringAngles = mualign.resetScatteringAngles(
        )

        muonTrackPreProcessor.ApplyStandardSelectionCuts = mualign.applyStandardSelectionCuts(
        )
        muonTrackPreProcessor.ApplySelectionCuts = mualign.applySelectionCuts()
        muonTrackPreProcessor.RequireOneHitPerTubeLayerEC = mualign.requireOneHitPerTubeLayerEC(
        )
        muonTrackPreProcessor.RequireInnerLayerEndcapMdt = mualign.requireInnerLayerECTracks(
        )
        muonTrackPreProcessor.RequireOuterLayerEndcapMdt = mualign.requireOuterLayerECTracks(
        )
        muonTrackPreProcessor.RequireBarrelECOverlap = mualign.requireBarrelECOverlap(
        )
        muonTrackPreProcessor.CutOnBarrel = mualign.cutOnBarrelTracks()
        muonTrackPreProcessor.RequireRPCPhiHit = mualign.requireRPCPhiHit()
        muonTrackPreProcessor.RequireSmallLargeOverlap = mualign.requireSmallLargeOverlap(
        )

        muonTrackPreProcessor.MuonContainer = mualign.MuonContainerName()
        muonTrackPreProcessor.SelectCombinedMuons = mualign.selectCombinedMuons(
        )

        muonTrackPreProcessor.MSID_ptDiffCut = mualign.msidPtDiffCut()
        muonTrackPreProcessor.chiSqCut = mualign.cutOnTrackChisquare()
        muonTrackPreProcessor.nAllowedHoles = mualign.cutOnNumHolesOnTrack()
        muonTrackPreProcessor.nAllowedOutliers = mualign.cutOnNumOutlierOnTrack(
        )
        muonTrackPreProcessor.MaxDriftSignSum = mualign.cutOnMaxDriftSignSum()

        self._MuonTrackPreProcessorHandle = muonTrackPreProcessor

        mlog.info(" adding MuonTrackPreProcessor to ToolSvc")
        ToolSvc += muonAlignHelperTool

        mlog.info(" leaving configure")

        return True
import os

from TrkAlignGenTools.AlignmentFlags import AlignmentFlags as align
from MuonAlignGenTools.MuonAlignmentFlags import MuonAlignmentFlags as mualign
from AthenaCommon.Constants import *
from AthenaCommon.AppMgr import ToolSvc

# configure muon alignment
from MuonAlignGenTools.ConfigureMuonAlignment import ConfigureMuonAlignment
config = ConfigureMuonAlignment()
config.configureAlignment(mualign.useAlternateASZT(), align.isMC())

if align.readEventList():

    from TrkAlignGenAlgs.SelectEventNumberGetter import SelectEventNumberGetter
    selectEvtNumber = SelectEventNumberGetter().SelectEventNumberHandle()
    #selectEvtNumber.EventList = "goodEvts_"+align.fileRootName()+"_iter0.txt"
    #selectEvtNumber.EventList = "goodEvts_iter0.txt"
    selectEvtNumber.EventList = align.eventList()
    #selectEvtNumber.EventList = "goodEvts.txt"

#if mualign.doLocalErrorScaling:
if 'errorScaleDb' in dir() and errorScaleDb != '':

    errScaleDbName = errorScaleDb
    errScaleDbNameSplit = errScaleDbName.rsplit("/", 1)
    if len(errScaleDbNameSplit) > 1:
        errScaleDbName = errScaleDbNameSplit[1]
    from IOVDbSvc.CondDB import conddb
    IOVDbSvc.dbConnection = "sqlite://X;schema=mycool.db;dbname=OFLP200"
    conddb.addFolder(
Exemple #23
0
mualign.trackCollectionProvider = "MuonTrackCollectionProvider"
mualign.MuonContainerName       = "MuidMuonCollection"
mualign.useStandaloneTracks     = False

mualign.asztFilePath          = './'

mualign.modulesToAlign  = ['ECA']
mualign.jobType               = 'ECmisal'
mualign.endcapsToAlign        = 'A' # A-side only 
mualign.doMultiLevelAlignment = True
mualign.requireOneHitPerTubeLayerEC = True 
#mualign.declusterTGCHits      = False

readESD=rec.readESD
mualign.setDefaultRecoFlags(readESD)
mualign.setDefaultL1Flags()
if align.derivativeType=='Analytical':
  mualign.setDefaultAnalyticalDerivativeFlags()
else:
  mualign.setDefaultShiftingDerivativeFlags()
mualign.setDefaultMatrixSolvingFlags()

mualign.useFullReco = True
#mualign.mdtAlignParams=[0,1,2,3,4]
#mualign.xyRotZPosition = 5700.
mualign.xyRotZPosition = 0.

mualign.applySelectionCuts = False 

#mualign.doLocalErrorScaling = doLocalErrorScaling
mualign.jobType = ''
mualign.endcapsToAlign = 'BOTH'
mualign.alignCSC = True

mualign.useAlternateASZT = False
if align.iteration == 0:
    mualign.doMultiLevelAlignment = False
else:
    mualign.doMultiLevelAlignment = True

#from RecExConfig.RecFlags import rec
#readESD=rec.readESD
#print "readESD=",readESD
#mualign.setDefaultRecoFlags(readESD)
mualign.setDefaultRecoFlags()
#mualign.setDefaultShiftingDerivativeFlags()
mualign.setDefaultL3Flags()
if align.derivativeType == 'Analytical':
    mualign.setDefaultAnalyticalDerivativeFlags()
mualign.setDefaultMatrixSolvingFlags()

if 'doBarrelOnly' in dir() and doBarrelOnly:
    mualign.chamberSelectionString = "[BIL]"
else:
    #mualign.chamberSelectionString = "[EML,2,3]"
    #mualign.chamberSelectionString = "[E?L,2,1-99]"
    #mualign.chamberSelectionString = "[E??]"
    mualign.redoErrorScaling = False
    #mualign.removeBEEHits = False
    #mualign.removeEEHits = False
Exemple #25
0
 def setFileRootName(self):
     fileroot = str(align.alignmentLevel()) + "_" + align.dataType()
     if mualign.jobType() != "":
         fileroot = fileroot + "_" + mualign.jobType()
     align.fileRootName = fileroot
     print "in ConfigMuonAlignment, fileroot=", fileroot