Beispiel #1
0
    def configure(self):

        mlog = logging.getLogger('CaloClusterTopoFromTowerGetter::configure :')
        mlog.info('scheduled to output %s', self._output)

        if not self._status['Initialize']:
            mlog.error('module is disabled due to initialization problems')
            return False

        # get handle to upstream object
        theCaloCellGetter = self.getInputGetter(
            jp.CaloRecFlags.clusterCellGetterName())
        cellContKey = theCaloCellGetter.outputKey()

        # configure cluster maker
        TopoBuilder = CaloTopoClusterFromTowerMaker(
            jobproperties.CaloTopoClusterFromTowerFlags.towerConverterName.
            get_Value(),
            CaloTowerContainerKey=jobproperties.CaloTopoClusterFromTowerFlags.
            inputTowerContainerKey.get_Value(),
            CaloCellContainerKey=cellContKey,
            OrderClusterByPt=jobproperties.CaloTopoClusterFromTowerFlags.
            orderByPt.get_Value())

        # moment makers
        TopoMoments = CaloClusterMomentsMaker("TopoMoments")
        TopoMoments.MaxAxisAngle = 20 * deg
        TopoMoments.CaloNoiseTool = theCaloNoiseTool
        TopoMoments.UsePileUpNoise = True
        TopoMoments.TwoGaussianNoise = jobproperties.CaloTopoClusterFlags.doTwoGaussianNoise(
        )
        TopoMoments.MinBadLArQuality = 4000
        TopoMoments.MomentsNames = [
            "AVG_LAR_Q", "AVG_TILE_Q", "BAD_CELLS_CORR_E", "BADLARQ_FRAC",
            "CELL_SIGNIFICANCE", "CELL_SIG_SAMPLING", "CENTER_LAMBDA",
            "CENTER_MAG", "CENTER_X", "CENTER_Y", "CENTER_Z", "DELTA_ALPHA",
            "DELTA_PHI", "DELTA_THETA", "ENG_BAD_CELLS", "ENG_FRAC_CORE",
            "ENG_FRAC_EM", "ENG_FRAC_MAX", "ENG_POS", "FIRST_ENG_DENS",
            "FIRST_ETA", "FIRST_PHI", "ISOLATION", "LATERAL", "LONGITUDINAL",
            "MASS", "N_BAD_CELLS", "N_BAD_CELLS_CORR", "PTD",
            "SECOND_ENG_DENS", "SECOND_LAMBDA", "SECOND_R", "SIGNIFICANCE"
        ]

        # only add HV related moments if it is offline.
        from IOVDbSvc.CondDB import conddb
        if not conddb.isOnline:
            from LArRecUtils.LArHVScaleRetrieverDefault import LArHVScaleRetrieverDefault
            TopoMoments.LArHVScaleRetriever = LArHVScaleRetrieverDefault()
            TopoMoments.MomentsNames += ["ENG_BAD_HV_CELLS", "N_BAD_HV_CELLS"]

        # cluster maker
        CaloTopoCluster = CaloClusterMaker(
            jobproperties.CaloTopoClusterFromTowerFlags.clusterMakerName.
            get_Value())
        mlog.info('instantiated CaloClusterMaker "{0}"'.format(
            CaloTopoCluster.name()))
        CaloTopoCluster.ClustersOutputName = self._output[self._outputType]
        CaloTopoCluster.ClusterMakerTools = [TopoBuilder]

        # bad cell corrections
        from CaloClusterCorrection.CaloClusterBadChannelListCorr import CaloClusterBadChannelListCorr
        BadChannelListCorr = CaloClusterBadChannelListCorr()

        # Correction tools
        CaloTopoCluster.ClusterCorrectionTools += [BadChannelListCorr]
        CaloTopoCluster.ClusterCorrectionTools += [TopoMoments]

        # configuring the algorithm
        CaloTopoCluster += TopoBuilder
        CaloTopoCluster += BadChannelListCorr
        CaloTopoCluster += TopoMoments

        objKeyStore.addManyTypesTransient(self.output())
        mlog.info('add output %s', self.output())
        # only write main object in AOD
        # 2014-01-15 W.L. Remove objs from output streams  b/c of xAOD migration
        #objKeyStore.addStreamESD(self.outputType(),self.outputKey())
        #objKeyStore.addStreamESD("CaloShowerContainer",self.outputKey()+"_Data")
        #objKeyStore.addStreamESD("CaloCellLinkContainer",self.outputKey()+"_Link")
        #objKeyStore.addStreamAOD(self.outputType(),self.outputKey())

        from AthenaCommon.AlgSequence import AlgSequence
        topSequence = AlgSequence()
        topSequence += CaloTopoCluster

        self._handle = CaloTopoCluster

        return True
Beispiel #2
0
def MakeClustersFromTowers(clusterMakerName='CaloClusterMaker',clusterContainerKey='TowerTopoCluster',configDict=ClustersFromTowersDict(),applyEnergyThreshold=False,debugOn=False):
    ''' This function generates an instance of a cluster algorithm producting clusters trom towers with or without moments 
    '''
    # collect inputs
    mlog = logging.getLogger('MakeClustersFromTowers.py:: ')
    mlog.info('ClusterMakerName    = "'+clusterMakerName+'"')
    mlog.info('ClusterContainerKey = <'+clusterContainerKey+'>')
    mlog.info('Converter parameters: ',configDict)

    # configure cluster builder
    cnvname  = configDict['ClusterBuilderName']
    twralgo  = configDict['CaloTowerBuilder']
    towerkey = twralgo.CaloTowerContainer
    mlog.info('(input) CaloTowerContainer <'+towerkey+'>')
    cellkey  = 'AllCalo' ### twralgo.InputCellContainer --> this does not work, why?
    mlog.info('(input) CaloCellContainer  <'+cellkey+'>')
    ptorder  = configDict['OrderClusterByPt']
    tcluskey = configDict['CaloTopoClusterContainerKey']
    tcwgtkey = configDict['CellClusterWeightKey'] 
    #### buildtt  = ( tcluskey != 'NONE' and tcwgtkey != 'NONE' )
    buildtt  = configDict['ApplyLCW']
    ''' Configuration module for the tower converter
    '''
    towerConverter = CaloTopoClusterFromTowerMaker(cnvname,CaloTowerContainerKey=towerkey,CaloCellContainerKey=cellkey,OrderClusterByPt=ptorder)
    ''' Refinement of converter configuration
    '''
    mlog.info(' ')
    if buildtt:
        mlog.info('################################################')
        mlog.info('## Produce LCW calibrated topo-tower clusters ##')
        mlog.info('################################################')
        mlog.info('CaloTopoClusterContainerKey .. {0}'.format(tcluskey))
        mlog.info('CellClusterWeightKey ......... {0}'.format(tcwgtkey))
        towerConverter.CaloTopoClusterContainerKey = tcluskey
        towerConverter.CellClusterWeightKey        = tcwgtkey
        towerConverter.ApplyLCW                    = True
    else:
        mlog.info('####################################################')
        mlog.info('## Produce EM calibrated inclusive tower clusters ##')
        mlog.info('####################################################')
    mlog.info(' ')
    if applyEnergyThreshold:
        towerConverter.CellEnergyThreshold = twralgo.CellEnergyThreshold 
    if debugOn:
        towerConverter.OutputLevel = Lvl.DEBUG
    # setting up the moments: external tools
    from CaloTools.CaloNoiseToolDefault import CaloNoiseToolDefault
    caloNoiseTool = CaloNoiseToolDefault()
    from AthenaCommon.AppMgr import ToolSvc
    ToolSvc += caloNoiseTool

    # moment maker
    from CaloRec.CaloTopoClusterFlags import jobproperties
    from AthenaCommon.SystemOfUnits import deg, GeV, MeV
    from CaloRec.CaloRecConf import CaloClusterMomentsMaker
    clusterMoments = CaloClusterMomentsMaker (clusterMakerName+'MomentMaker')
    clusterMoments.MaxAxisAngle = 20*deg
    clusterMoments.CaloNoiseTool = caloNoiseTool
    clusterMoments.UsePileUpNoise = True
    clusterMoments.TwoGaussianNoise = jobproperties.CaloTopoClusterFlags.doTwoGaussianNoise()
    clusterMoments.MinBadLArQuality = 4000
    clusterMoments.MomentsNames = ["FIRST_PHI" 
                                   ,"FIRST_ETA"
                                   ,"SECOND_R" 
                                   ,"SECOND_LAMBDA"
                                   ,"DELTA_PHI"
                                   ,"DELTA_THETA"
                                   ,"DELTA_ALPHA" 
                                   ,"CENTER_X"
                                   ,"CENTER_Y"
                                   ,"CENTER_Z"
                                   ,"CENTER_MAG"
                                   ,"CENTER_LAMBDA"
                                   ,"LATERAL"
                                   ,"LONGITUDINAL"
                                   ,"FIRST_ENG_DENS" 
                                   ,"ENG_FRAC_EM" 
                                   ,"ENG_FRAC_MAX" 
                                   ,"ENG_FRAC_CORE" 
                                   ,"SECOND_ENG_DENS" 
                                   ,"ISOLATION"
                                   ,"ENG_BAD_CELLS"
                                   ,"N_BAD_CELLS"
                                   ,"N_BAD_CELLS_CORR"
                                   ,"BAD_CELLS_CORR_E"
                                   ,"BADLARQ_FRAC"
                                   ,"ENG_POS"
                                   ,"SIGNIFICANCE"
                                   ,"CELL_SIGNIFICANCE"
                                   ,"CELL_SIG_SAMPLING"
                                   ,"AVG_LAR_Q"
                                   ,"AVG_TILE_Q"
                                   ,"PTD"
                                   ,"MASS"
                                   ]

    # only add HV related moments if it is offline.
    from IOVDbSvc.CondDB import conddb
    if not conddb.isOnline:
        from LArRecUtils.LArHVScaleRetrieverDefault import LArHVScaleRetrieverDefault
        clusterMoments.LArHVScaleRetriever=LArHVScaleRetrieverDefault()
        clusterMoments.MomentsNames += ["ENG_BAD_HV_CELLS"
                                        ,"N_BAD_HV_CELLS"
                                        ]

    # cluster maker
    from CaloRec.CaloRecConf import CaloClusterMaker
    clusterMaker = CaloClusterMaker(clusterMakerName)
    clusterMaker.ClustersOutputName = clusterContainerKey
    clusterMaker.ClusterMakerTools  = [ towerConverter ]
    mlog.info('instantiated CaloClusterMaker "{0}"'.format(clusterMaker.name()))

    # bad cell corrections          
##    from CaloClusterCorrection.CaloClusterBadChannelListCorr import CaloClusterBadChannelListCorr
##    badChannelCorr = CaloClusterBadChannelListCorr()

    # Correction tools
##    clusterMaker.ClusterCorrectionTools += [ badChannelCorr ]
    clusterMaker.ClusterCorrectionTools += [ clusterMoments ]

    # configuring the algorithm
    clusterMaker += towerConverter
##    clusterMaker += badChannelCorr
    clusterMaker += clusterMoments

    if buildtt:
        from CaloRec.CaloRecConf import CaloTopoClusterFromTowerCalibrator
        calgname = clusterMakerName+'Calibrator'
        mlog.info('TopoTowers: add LCW calibration tool <'+calgname+'>')
        clusterCalibrator = CaloTopoClusterFromTowerCalibrator(calgname)
        mlog.info('TopoTowers: '+calgname+'.CellClusterWeightKey = "'+tcwgtkey+'"')
        clusterCalibrator.CellClusterWeightKey     = tcwgtkey
        clusterCalibrator.OrderClusterByPt         = ptorder
        clusterMaker.ClusterCorrectionTools       += [ clusterCalibrator ]
        clusterMaker                              += clusterCalibrator

    # done
    return clusterMaker