예제 #1
0
    def applyConf(self):
        """
        Calorimeter PID Configuration
        """

        self.printConf()

        pids = self.caloPIDs()

        setTheProperty(pids, 'Context', self.getProp('Context'))
        setTheProperty(pids, 'MeasureTime', self.getProp('MeasureTime'))
        if self.isPropertySet("OutputLevel"):
            setTheProperty(pids, 'OutputLevel', self.getProp('OutputLevel'))

        if self.getProp('Sequence'):
            addAlgs(self.Sequence, pids)
            _log.info('Configure main Calo PIDs Sequence  : %s ' %
                      self.Sequence.name())
            if self.getProp('Verbose'):
                _log.info(prntCmp(self.Sequence))
        else:
            _log.info('Configure Calorimeter PIDs blocks ')
            if self.getProp('Verbose'):
                _log.info(prntCmp(pids))

        if self.getProp('EnablePIDsOnDemand'):
            _log.info(printOnDemand())
예제 #2
0
def mergedPi0Reco(context,
                  enableRecoOnDemand,
                  clusterOnly=False,
                  neutralID=True,
                  useTracks=True,
                  mergedPi0Pt=2 * GeV,
                  fastReco=False,
                  external='',
                  noSpdPrs=False,
                  masksE=[],
                  masksP=[]):
    """
    Define the recontruction of Merged Pi0s
    """

    from Configurables import CaloMergedPi0  # CaloMergedPi0Alg is obsolete (replaced by CaloMergedPi0)
    from Configurables import CaloHypoAlg

    from Configurables import (CaloExtraDigits, CaloECorrection,
                               CaloSCorrection, CaloLCorrection)

    # build the sequences
    seq = getAlgo(GaudiSequencer, 'MergedPi0Reco', context)
    sseq = getAlgo(GaudiSequencer, 'SplitClusterReco', context)

    ## Merged Pi0
    if clusterOnly:
        pi0 = getAlgo(CaloMergedPi0, 'SplitClustersRec', context)
        pi0.CreateSplitClustersOnly = True
        sseq.Members = [pi0]
    else:
        pi0 = getAlgo(CaloMergedPi0, 'MergedPi0Rec', context)

    if masksE != []:
        pi0.EnergyTags = masksE
    if masksP != []:
        pi0.PositionTags = masksP

    if external != '':
        pi0.InputData = external

    pi0.PropertiesPrint = False

    pi0.EtCut = mergedPi0Pt

    if clusterOnly:
        setTheProperty(sseq, 'Context', context)
        return sseq

    ## MergedPi0 sequence

    ## 2/ SplitPhotons
    #    splitg = getAlgo ( CaloHypoAlg , 'PhotonFromMergedRec' , context )
    #    splitg.HypoType = "SplitPhotons";
    #    splitg.PropertiesPrint = False

    ## Add Prs/Spd digits
    if not noSpdPrs:
        pi0.addTool(CaloExtraDigits, 'SpdPrsExtraS')
        pi0.addTool(CaloExtraDigits, 'SpdPrsExtraM')
    ## Pi0 correction tools
    pi0.addTool(CaloECorrection, 'ECorrection')
    pi0.addTool(CaloSCorrection, 'SCorrection')
    pi0.addTool(CaloLCorrection, 'LCorrection')

    # tool configuration via condDB only (remove default configuration)
    if not noSpdPrs:
        pi0.PhotonTools = [
            pi0.SpdPrsExtraS, pi0.ECorrection, pi0.SCorrection, pi0.LCorrection
        ]
        pi0.Pi0Tools = [pi0.SpdPrsExtraM]
    else:
        pi0.PhotonTools = [pi0.ECorrection, pi0.SCorrection, pi0.LCorrection]

    seq.Members = [pi0]

    ## 3/ (PhotonFrom)MergedID
    if neutralID:
        from CaloPIDs.PIDs import (MergedID, PhotonFromMergedID)
        idSeq = getAlgo(GaudiSequencer, "MergedIDSeq", context)
        mID = MergedID(context, enableRecoOnDemand, useTracks)
        pmID = PhotonFromMergedID(context, enableRecoOnDemand, useTracks)
        idSeq.Members = [mID, pmID]
        addAlgs(seq, idSeq)

    # propagate the context
    setTheProperty(seq, 'Context', context)

    ## onDemand
    if enableRecoOnDemand:
        onDemand('Rec/Calo/SplitPhotons', seq, context)
        onDemand('Rec/Calo/MergedPi0s', seq, context)
        #onDemand ( 'Rec/Calo/EcalSplitClusters' , seq , context )  ## ??

    ## printout
    _log.debug('Configure MergedPi0 Reco Seq : %s  for : %s' %
               (seq.name(), context))
    if enableRecoOnDemand:
        _log.info('MergedPi0Reco onDemand')

    return seq
예제 #3
0
def electronReco(context,
                 enableRecoOnDemand,
                 useTracksE=True,
                 useSpdE=True,
                 usePrsE=True,
                 trackLocations=[],
                 electronPt=50. * MeV,
                 fastReco=False,
                 external='',
                 noSpdPrs=False,
                 matchTrTypes=[]):
    """
    Define the reconstruction of
    """

    from Configurables import CaloElectronAlg
    from Configurables import CaloHypoAlg

    from Configurables import (CaloSelectCluster, CaloSelectClusterWithPrs,
                               CaloSelectNeutralClusterWithTracks,
                               CaloSelectNeutralClusterWithSpd,
                               CaloSelectChargedClusterWithSpd,
                               CaloSelectorNOT)

    from Configurables import (CaloExtraDigits, CaloECorrection,
                               CaloSCorrection, CaloLCorrection)

    ## build the context-dependent sequence (  TrackMatch + SingleElectronRec )
    seq = getAlgo(GaudiSequencer, "ElectronReco", context,
                  'Rec/Calo/Electrons', enableRecoOnDemand)
    seq.Members = []

    # 1/ ElectronMatch from CaloPIDs (if useTracks)
    if useTracksE:
        from CaloPIDs.PIDs import trackMatch
        tm = trackMatch(context, enableRecoOnDemand, trackLocations,
                        matchTrTypes, fastReco, external)
        addAlgs(seq, tm)

    ## 2/ Electron Rec alg
    alg = getAlgo(CaloElectronAlg, 'SingleElectronRec', context)
    alg.PropertiesPrint = False
    if external != '':
        alg.InputData = external

    # cluster selection tools:

    ## 1/ generic selection (energy/multiplicity)
    alg.addTool(CaloSelectCluster, "ElectronCluster")
    alg.SelectionTools = [alg.ElectronCluster]
    alg.ElectronCluster.MinEt = electronPt
    alg.ElectronCluster.MinDigits = 2  # skip single-cell clusters

    ## 2/  hits in Spd
    if useSpdE:
        alg.addTool(CaloSelectChargedClusterWithSpd, "ChargedClusterWithSpd")
        alg.SelectionTools += [alg.ChargedClusterWithSpd]
        _log.debug(
            'CaloReco/ElectronReco: Configure Charged Cluster Selector with Spd     : %s'
            % alg.ChargedClusterWithSpd.getFullName())

    ## 3/ energy in Prs
    if usePrsE:
        alg.addTool(CaloSelectClusterWithPrs, "ClusterWithPrs")
        alg.ClusterWithPrs.MinEnergy = 10 * MeV
        alg.SelectionTools += [alg.ClusterWithPrs]
        _log.debug(
            'CaloReco/ElectronReco: Configure Cluster Selector with Prs    : %s'
            % alg.ClusterWithPrs.getFullName())

    ## 4/  match with tracks
    if useTracksE:
        alg.addTool(CaloSelectorNOT, "ChargedCluster")
        clnot = alg.ChargedCluster
        clnot.addTool(CaloSelectNeutralClusterWithTracks, "NotNeutralCluster")
        clnot.NotNeutralCluster.MinChi2 = 25
        clnot.SelectorTools = [clnot.NotNeutralCluster]
        alg.SelectionTools += [alg.ChargedCluster]
        _log.debug(
            'CaloReco/ElectronReco: Configure Charged Cluster Selector with Tracks     : %s'
            % alg.ChargedCluster.getFullName())

    ## hypo tools : add Spd/Prs digits
    if not noSpdPrs:
        alg.addTool(CaloExtraDigits, 'SpdPrsExtraE')
        alg.HypoTools = [alg.SpdPrsExtraE]
    else:
        alg.HypoTools = []

    ## correction tools : E/S/L
    alg.addTool(CaloECorrection, 'ECorrection')
    alg.addTool(CaloSCorrection, 'SCorrection')
    alg.addTool(CaloLCorrection, 'LCorrection')

    ecorr = alg.ECorrection
    scorr = alg.SCorrection
    lcorr = alg.LCorrection

    # tool configuration via condDB (remove default configuration)
    alg.CorrectionTools2 = [ecorr, scorr, lcorr]

    ## update the sequence
    addAlgs(seq, alg)

    # global context
    setTheProperty(seq, 'Context', context)

    ## printout
    _log.debug('Configure Electron Reco Seq : %s  for : %s' %
               (seq.name(), context))
    if enableRecoOnDemand:
        _log.info('ElectronReco onDemand')

    return seq
예제 #4
0
def photonReco(context,
               enableRecoOnDemand,
               useTracks=True,
               useSpd=False,
               usePrs=False,
               trackLocations=[],
               neutralID=True,
               photonPt=50. * MeV,
               fastReco=False,
               external='',
               noSpdPrs=False,
               matchTrTypes=[]):
    """
    Define the recontruction of Single Photon Hypo
    """

    from Configurables import CaloSinglePhotonAlg
    from Configurables import CaloHypoAlg
    from Configurables import (CaloSelectCluster, CaloSelectClusterWithPrs,
                               CaloSelectNeutralClusterWithTracks,
                               CaloSelectNeutralClusterWithSpd,
                               CaloSelectChargedClusterWithSpd,
                               CaloSelectorNOT, CaloSelectorOR)

    from Configurables import (CaloExtraDigits, CaloECorrection,
                               CaloSCorrection, CaloLCorrection)

    ## build the context-dependent sequence (  TrackMatch + SinglePhotonRec )
    seq = getAlgo(GaudiSequencer, "PhotonReco", context, "Rec/Calo/Photons",
                  enableRecoOnDemand)
    seq.Members = []

    # 1/ PhotonMatch from CaloPIDs (if tracking is requested)
    if useTracks:
        from CaloPIDs.PIDs import trackMatch
        tm = trackMatch(context, enableRecoOnDemand, trackLocations,
                        matchTrTypes, fastReco, external)
        addAlgs(seq, tm)

    ##2/ SinglePhotonRec alg
    alg = getAlgo(CaloSinglePhotonAlg, "SinglePhotonRec", context)
    alg.PropertiesPrint = False
    if external != '':
        alg.InputData = external

    # cluster selection tools:
    ### a/ generic selection (energy/multiplicity)
    alg.addTool(CaloSelectCluster, "PhotonCluster")
    alg.SelectionTools = [alg.PhotonCluster]
    alg.PhotonCluster.MinEt = photonPt
    alg.PhotonCluster.MinDigits = 2  # skip single-cell clusters

    ### b/ Neutral cluster (track-based and/or Spd/Prs-based)
    if useTracks:
        alg.addTool(CaloSelectNeutralClusterWithTracks, "NeutralCluster")
        alg.NeutralCluster.MinChi2 = 4
        alg.SelectionTools += [alg.NeutralCluster]
        _log.debug(
            'CaloReco/PhotonReco: Configure Neutral Cluster Selector with Tracks     : %s'
            % alg.NeutralCluster.getFullName())

    if usePrs:
        alg.addTool(CaloSelectClusterWithPrs, "ClusterWithPrs")
        alg.ClusterWithPrs.MinEnergy = 10. * MeV
        alg.SelectionTools += [alg.ClusterWithPrs]
        _log.debug(
            'CaloReco/PhotonReco: Configure Cluster Selector with  Prs       : %s'
            % alg.ClusterWithPrs.getFullName())

    if useSpd:
        alg.addTool(CaloSelectNeutralClusterWithSpd, "NeutralClusterWithSpd")
        alg.SelectionTools += [alg.NeutralClusterWithSpd]
        _log.debug(
            'CaloReco/PhotonReco: Configure Neutral Cluster Selector with !Spd : %s '
            % alg.NeutralClusterWithSpd.getFullName())

    ## hypo tools : add Spd/Prs digits

    if not noSpdPrs:
        alg.addTool(CaloExtraDigits, 'SpdPrsExtraG')
        alg.HypoTools = [alg.SpdPrsExtraG]
    else:
        alg.HypoTools = []

    ## correction tools : E/S/L
    alg.addTool(CaloECorrection, 'ECorrection')
    alg.addTool(CaloSCorrection, 'SCorrection')
    alg.addTool(CaloLCorrection, 'LCorrection')

    ecorr = alg.ECorrection
    scorr = alg.SCorrection
    lcorr = alg.LCorrection

    # tool configuration via condDB only (remove default configuration)
    alg.CorrectionTools2 = [ecorr, scorr, lcorr]

    # update the sequence
    addAlgs(seq, alg)

    ## 3/ PhotonID
    from CaloPIDs.PIDs import PhotonID
    if neutralID:
        pID = PhotonID(context, enableRecoOnDemand, useTracks)
        addAlgs(seq, pID)

    ## global context
    setTheProperty(seq, 'Context', context)

    ## printout
    _log.debug('Configure Photon Reco Seq : %s  for : %s' %
               (seq.name(), context))
    if enableRecoOnDemand:
        _log.info('PhotonReco onDemand')

    return seq
예제 #5
0
    def applyConf(self):
        """
        Calorimeter Monitor Configuration
        """
        log.info('CaloMoniConf: Apply Calo Monitoring Configuration ')

        self.printConf()

        self.checkConfiguration()

        #----- MONITORS
        monList = self.MoniList
        seq = []
        if 'Digits' in monList: addAlgs(seq, self.digits())
        if 'EFlow' in monList: addAlgs(seq, self.eflow())
        if 'Clusters' in monList: addAlgs(seq, self.clusters())
        if 'Hypos' in monList: addAlgs(seq, self.hypos())
        if 'Pi0s' in monList: addAlgs(seq, self.pi0s())
        if 'Protos' in monList: addAlgs(seq, self.protos())
        if 'PIDs' in monList: addAlgs(seq, self.pids())
        setTheProperty(seq, 'Context', self.getProp('Context'))
        if self.isPropertySet("OutputLevel"):
            setTheProperty(seq, 'OutputLevel', self.getProp('OutputLevel'))
        setTheProperty(seq, 'MeasureTime', self.getProp('MeasureTime'))
        if self.isPropertySet('MonitorSequence'):
            moniSeq = self.getProp('MonitorSequence')
            addAlgs(moniSeq, seq)
            log.info('Configure main Calo Moni MonitorSequence  : %s ' %
                     moniSeq.name())
            if self.getProp('Verbose'):
                log.info(prntCmp(moniSeq))

        #----- CHECKERS
        checkList = self.CheckList
        cseq = []
        if 'Reco' in checkList: addAlgs(cseq, self.recoChecker())
        if 'PIDs' in checkList: addAlgs(cseq, self.pidChecker())
        setTheProperty(cseq, 'Context', self.getProp('Context'))
        if self.isPropertySet("OutputLevel"):
            setTheProperty(cseq, 'OutputLevel', self.getProp('OutputLevel'))
        setTheProperty(cseq, 'MeasureTime', self.getProp('MeasureTime'))

        if self.isPropertySet('CheckerSequence'):
            checkSeq = self.getProp('CheckerSequence')
            addAlgs(checkSeq, cseq)
            log.info('Configure  CheckerSequence  : %s ' % checkSeq.name())
            if self.getProp('Verbose'):
                log.info(prntCmp(checkSeq))
예제 #6
0
    def applyConf(self):

        from Configurables import (GaudiSequencer, HltL0CaloCandidates)

        if self.getName() == 'CaloLines' and (self.getProp('Context') == ''
                                              or self.getProp('Context')
                                              == 'CaloLines'):
            self.setProp(
                'Context', 'Offline'
            )  # default is Offline is neither context nor name is specified

        # overwrite Reco & PID onDemand
        dod = self.getProp('EnableOnDemand')
        pdod = self.getProp('ProtoOnDemand')
        if dod:
            pdod = dod

        tracks = self.getProp('TrackLocations')

        ###
        caloLines = GaudiSequencer('CaloLinesSeq' + self.getName())
        caloLines.Members[:] = []

        if self.getProp('L0Calo2Calo'):
            l0calo2calo = HltL0CaloCandidates('L0Calo2Calo')
            if self.getProp('ClusterizationLevel') > 0:
                level = self.getProp('ClusterizationLevel')
                l0calo2calo.ClusterizationLevel = level
            addAlgs(caloLines, l0calo2calo)
            tagHighP = ''
            tagLowP = ''
            tagLowE = ''
        else:
            tagHighP = 'HighPhoton'
            tagLowP = 'LowPhoton'
            tagLowE = 'LowElectron'

        name = self.getName()
        fac = self.getProp('ClusterEtFactor')

        if self.getProp('HighPhoton'):
            context = self.getProp('Context')
            if context != '':
                context = context + 'HighPhoton'
            hp = CaloProcessor(
                name + 'HighPhoton',
                TrackLocations=tracks,
                Context=context,
                RecList=['Digits', 'Clusters', 'Photons'],
                CaloPIDs=False,
                ExternalClusters="/Event/Rec/Calo/HighEtPhotons",
                ClusterPt=self.getProp('HighEt') * fac,
                PhotonPt=self.getProp('HighEt'),
                MakeExternalClustersWithTag=tagHighP,
                NoSpdPrs=self.getProp('NoSpdPrs'))

            addAlgs(caloLines, hp.caloSequence(tracks=tracks))

            if self.getProp('HighEtProtoPPrefix') == '':
                hploc = name + 'HighPhoton/ProtoP'
            else:
                hploc = self.getProp('HighEtProtoPPrefix')
            addAlgs(caloLines,
                    hp.neutralProtoSequence(protoPrefix=hploc, tracks=tracks))

        if self.getProp('LowPhoton'):
            context = self.getProp('Context')
            if context != '':
                context = context + 'LowPhoton'
            lp = CaloProcessor(name + 'LowPhoton',
                               TrackLocations=tracks,
                               Context=context,
                               RecList=[
                                   'Digits', 'Clusters', 'Photons',
                                   'MergedPi0s', 'SplitPhotons'
                               ],
                               ExternalClusters="/Event/Rec/Calo/LowEtPhotons",
                               CaloPIDs=False,
                               ClusterPt=self.getProp('LowEt') * fac,
                               PhotonPt=self.getProp('LowEt'),
                               MakeExternalClustersWithTag=tagLowP,
                               NoSpdPrs=self.getProp('NoSpdPrs'))
            addAlgs(caloLines, lp.caloSequence(tracks=tracks))
            if self.getProp('LowEtProtoPPrefix') == '':
                lploc = name + 'LowPhoton/ProtoP'
            else:
                lploc = self.getProp('LowEtProtoPPrefix')
            addAlgs(caloLines,
                    lp.neutralProtoSequence(protoPrefix=lploc, tracks=tracks))

        if self.getProp('LowElectron'):
            context = self.getProp('Context')
            if context != '':
                context = context + 'LowElectron'
            le = CaloProcessor(
                name + 'LowElectron',
                TrackLocations=tracks,
                Context=context,
                RecList=['Digits', 'Clusters', 'Electrons'],
                ExternalClusters="/Event/Rec/Calo/LowEtElectrons",
                ClusterPt=self.getProp('LowEt') * fac,
                ElectronPt=self.getProp('LowEt'),
                SkipNeutrals=True,
                ProtoOnDemand=pdod,
                MakeExternalClustersWithTag=tagLowE,
                NoSpdPrs=self.getProp('NoSpdPrs'))
            addAlgs(caloLines, le.caloSequence(tracks=tracks))
            if self.getProp('LowEtProtoPPrefix') == '':
                leloc = name + 'LowElectron/ProtoP'
            else:
                leloc = self.getProp('LowEtProtoPPrefix')
            addAlgs(caloLines,
                    le.chargedProtoSequence(protoPrefix=leloc, tracks=tracks))

        caloLines.IgnoreFilterPassed = True
        ## propagate the global properties
        if self.isPropertySet("OutputLevel"):
            setTheProperty(caloLines, 'OutputLevel',
                           self.getProp('OutputLevel'))

        ## define the sequencers
        if self.isPropertySet('Sequencer'):
            main = self.getProp('Sequencer')
            addAlgs(main, caloLines)
예제 #7
0
    def applyConf(self):
        _log.info('Apply CaloProcessor configuration for %s and %s',
                  self.getProp('RecList'), self.getProp('PIDList'))

        self.printConf()

        knownMasks = ['3x3', '2x2', 'SwissCross']

        for tag in self.getProp('ClusterEnergyMasks'):
            if tag not in knownMasks:
                raise AttributeError, 'ClusterEnergyMasks contains unknown tag' + tag + ' -should be in' + knownMasks
        for tag in self.getProp('ClusterPositionMasks'):
            if tag not in knownMasks:
                raise AttributeError, 'PositionEnergyMasks contains unknown tag ' + tag + ' -should be in' + knownMasks

        from Configurables import (
            GaudiSequencer, ChargedProtoParticleAddEcalInfo,
            ChargedProtoParticleAddBremInfo, ChargedProtoParticleAddHcalInfo,
            ChargedProtoParticleAddPrsInfo, ChargedProtoParticleAddSpdInfo,
            ChargedProtoParticleMaker, ChargedProtoCombineDLLsAlg)

        fullSeq = []

        if self.getName() == 'CaloProcessor' and (self.getProp('Context') == ''
                                                  or self.getProp('Context')
                                                  == 'CaloProcessor'):
            self.setProp(
                'Context', 'Offline'
            )  # default is Offline is neither context nor name is specified

        # prepare the NoSpdPrs configuration
        if self.getProp('NoSpdPrs'):
            self.setProp('UseSpd', False)
            self.setProp('UsePrs', False)
            self.setProp('UseSpdE', False)
            self.setProp('UsePrsE', False)
            # configure the public getter tool
            from Configurables import ToolSvc, CaloGetterTool
            tsvc = ToolSvc()
            tsvc.addTool(CaloGetterTool, name="CaloGetter")
            tsvc.CaloGetter.DetectorMask = 12

        # overwrite Reco & PID onDemand
        dod = self.getProp('EnableOnDemand')
        pdod = self.getProp('ProtoOnDemand')

        if dod:
            pdod = dod
        self.setProp('EnableRecoOnDemand', dod)

        ## define the calo sequence
        caloSeq = []

        doReco = self.getProp('CaloReco')
        doPIDs = self.getProp('CaloPIDs')
        skipNeutrals = self.getProp('SkipNeutrals')
        skipCharged = self.getProp('SkipCharged')
        context = self.getProp('Context')

        # CaloReco sequence
        recoSeq = getAlgo(GaudiSequencer, "CaloRecoFor" + self.getName(),
                          context)
        recoSeq.Members[:] = []
        recList = self.getProp('RecList')

        # configure all components by default (DoD)
        forceOnDemand = self.getProp('ForceOnDemand')
        if forceOnDemand:
            self.setProp('EnableOnDemand', 'True')
            self.setProp('EnableRecoOnDemand', 'True')
            dig = self.digits()
            clu = self.clusters()
            pho = self.photons()
            mer = self.mergedPi0s()
            ele = self.electrons()

        #  add only the requested components to the sequence
        if 'Digits' in recList:
            addAlgs(recoSeq, self.digits())
            CaloDigitConf().printConf()
        if 'Clusters' in recList:
            addAlgs(recoSeq, self.clusters())
            if 'Digits' not in recList:
                CaloDigitConf().printConf()

        if not skipNeutrals:
            if 'Photons' in recList: addAlgs(recoSeq, self.photons())
            if 'MergedPi0s' in recList or 'SplitPhotons' in recList:
                addAlgs(recoSeq, self.mergedPi0s())
        if not skipCharged:
            if 'Electrons' in recList: addAlgs(recoSeq, self.electrons())

        # CaloPIDs sequence
        #        pidSeq = getAlgo( GaudiSequencer , "CaloPIDsSeq" , context )
        #        addAlgs ( pidSeq , self.caloPIDs  () )

        pidSeq = self.caloPIDs()

        # update CaloSequence
        if doReco:
            addAlgs(caloSeq, recoSeq)
        if doPIDs:
            addAlgs(caloSeq, pidSeq)

        ## propagate the global properties
        setTheProperty(caloSeq, 'Context', self.getProp('Context'))
        setTheProperty(caloSeq, 'MeasureTime', self.getProp('MeasureTime'))
        if self.isPropertySet("OutputLevel"):
            setTheProperty(caloSeq, 'OutputLevel', self.getProp('OutputLevel'))

        ######## ProtoParticle update ##########
        protoSeq = []
        cProtoSeq = []
        nProtoSeq = []
        #  ProtoParticle locations
        nloc = self.getProp('NeutralProtoLocation')
        cloc = self.getProp('ChargedProtoLocation')
        # try automatic location if not explicit for HLT's sequence
        if hltContext(self.getProp('Context')):
            if nloc == '':
                if nloc.find('/') == -1:
                    nloc = context + '/ProtoP/Neutrals'
                else:
                    nloc = context.replace('/', '/ProtoP/', 1) + '/Neutrals'
            if cloc == '':
                if cloc.find('/') == -1:
                    cloc = context + '/ProtoP/Charged'
                else:
                    cloc = context.replace('/', '/ProtoP/', 1) + '/Charged'

        # Confuse Configurable
        if cloc != '':
            if cloc.find('/Event/') != 0:
                cloc = '/Event/' + cloc

        if nloc != '':
            if nloc.find('/Event/') != 0:
                nloc = '/Event/' + nloc

        # ChargedProtoParticle
        if not self.getProp('SkipCharged'):
            suffix = "For" + self.getName()
            ecal = getAlgo(ChargedProtoParticleAddEcalInfo,
                           "ChargedProtoPAddEcal" + suffix, context)
            brem = getAlgo(ChargedProtoParticleAddBremInfo,
                           "ChargedProtoPAddBrem" + suffix, context)
            hcal = getAlgo(ChargedProtoParticleAddHcalInfo,
                           "ChargedProtoPAddHcal" + suffix, context)
            if not self.getProp('NoSpdPrs'):
                prs = getAlgo(ChargedProtoParticleAddPrsInfo,
                              "ChargedProtoPAddPrs" + suffix, context)
                spd = getAlgo(ChargedProtoParticleAddSpdInfo,
                              "ChargedProtoPAddSpd" + suffix, context)
            comb = getAlgo(ChargedProtoCombineDLLsAlg,
                           "ChargedProtoPCombineDLLs" + suffix, context)

            # ChargedProtoP Maker on demand (not in any sequencer)  ####
            maker = getAlgo(ChargedProtoParticleMaker, "ChargedProtoMaker",
                            context, cloc, pdod)
            # protoPMaker settings (from GlobalRecoConf)
            from Configurables import DelegatingTrackSelector, GaudiSequencer
            ## ppConf = GlobalRecoConf('DummyConf',RecoSequencer=GaudiSequencer('DummySeq'))
            ##ttypes = ppConf.getProp('TrackTypes')
            ##tcuts  = ppConf.getProp('TrackCuts')

            ttypes = self.getProp('TrackTypes')
            tcuts = self.getProp('TrackCuts')

            maker.addTool(DelegatingTrackSelector, name="TrackSelector")
            maker.TrackSelector.TrackTypes = ttypes
            from Configurables import TrackSelector
            for type in ttypes:
                maker.TrackSelector.addTool(TrackSelector, name=type)
                ts = getattr(maker.TrackSelector, type)
                ts.TrackTypes = [type]
                if type in tcuts:
                    for name, cut in tcuts[type].iteritems():
                        ts.setProp("Min" + name, cut[0])
                        ts.setProp("Max" + name, cut[1])
            #########################################
            if cloc != '':
                maker.Output = cloc

        ## confuse configurable on purpose
            _locs = self.getProp('TrackLocations')
            _elocs = []
            for l in _locs:
                if l.find('/Event/') != 0:
                    l = '/Event/' + l
                _elocs.append(l)

            if not hltContext(self.getProp('Context')) and _elocs:
                maker.Inputs = _elocs

            # location
            if cloc != '':
                ecal.ProtoParticleLocation = cloc
                brem.ProtoParticleLocation = cloc
                hcal.ProtoParticleLocation = cloc
                if not self.getProp('NoSpdPrs'):
                    prs.ProtoParticleLocation = cloc
                    spd.ProtoParticleLocation = cloc
                comb.ProtoParticleLocation = cloc
            # Fill the sequence
            cpSeq = getAlgo(GaudiSequencer,
                            self.getName() + "ChargedProtoPCaloUpdateSeq",
                            context)
            cpSeq.Members = [ecal, brem, hcal]
            if not self.getProp('NoSpdPrs'):
                cpSeq.Members += [prs, spd]
            cpSeq.Members += [comb]
            addAlgs(protoSeq, cpSeq)
            addAlgs(cProtoSeq, cpSeq.Members)

        # NeutralProtoParticleProtoP components
        if not self.getProp('SkipNeutrals'):
            from Configurables import NeutralProtoPAlg
            suffix = "For" + self.getName()
            neutral = getAlgo(NeutralProtoPAlg, "NeutralProtoPMaker" + suffix,
                              context)
            # location
            if nloc != '':
                neutral.ProtoParticleLocation = nloc
            # fill the sequence
            addAlgs(protoSeq, neutral)
            addAlgs(nProtoSeq, neutral)

        ## propagate the global properties
        setTheProperty(protoSeq, 'Context', self.getProp('Context'))
        setTheProperty(protoSeq, 'MeasureTime', self.getProp('MeasureTime'))
        if self.isPropertySet("OutputLevel"):
            setTheProperty(protoSeq, 'OutputLevel',
                           self.getProp('OutputLevel'))

        setTheProperty(nProtoSeq, 'Context', self.getProp('Context'))
        setTheProperty(nProtoSeq, 'MeasureTime', self.getProp('MeasureTime'))
        if self.isPropertySet("OutputLevel"):
            setTheProperty(nProtoSeq, 'OutputLevel',
                           self.getProp('OutputLevel'))

        setTheProperty(cProtoSeq, 'Context', self.getProp('Context'))
        setTheProperty(cProtoSeq, 'MeasureTime', self.getProp('MeasureTime'))
        if self.isPropertySet("OutputLevel"):
            setTheProperty(cProtoSeq, 'OutputLevel',
                           self.getProp('OutputLevel'))

        # Full sequence
        addAlgs(fullSeq, caloSeq)
        addAlgs(fullSeq, protoSeq)

        ## define the sequencers
        if self.isPropertySet('Sequence'):
            main = self.getProp('Sequence')
            main.Members[:] = []
            addAlgs(main, fullSeq)
            _log.info('Configure full sequence %s with ' % main.name())
            _log.info('    Reco : %s ' % self.getProp('RecList'))
            _log.info('    PIDs : %s ' % self.getProp('PIDList'))
            _log.info('    and ProtoParticle update')
            if self.getProp('Verbose'):
                _log.info(prntCmp(main))

        if self.isPropertySet('CaloSequencer'):
            calo = self.getProp('CaloSequencer')
            calo.Members[:] = []
            addAlgs(calo, caloSeq)
            _log.info('Configure caloSequencer  : %s ' % calo.name())
            if self.getProp('Verbose'):
                _log.info(prntCmp(calo))

        if self.isPropertySet('ProtoSequencer'):
            proto = self.getProp('ProtoSequencer')
            proto.Members[:] = []
            addAlgs(proto, protoSeq)
            _log.info('Configure protoSequencer  : %s ' % proto.name())
            if self.getProp('Verbose'):
                _log.info(prntCmp(proto))

        if self.isPropertySet('ChargedProtoSequencer'):
            cproto = self.getProp('ChargedProtoSequencer')
            cproto.Members[:] = []
            addAlgs(cproto, cProtoSeq)
            _log.info('Configure chargedProtoSequencer  : %s ' % cproto.name())
            if self.getProp('Verbose'):
                _log.info(prntCmp(cproto))

        if self.isPropertySet('NeutralProtoSequencer'):
            nproto = self.getProp('NeutralProtoSequencer')
            nproto.Members[:] = []
            addAlgs(nproto, nProtoSeq)
            _log.info('Configure neutralProtoSequencer  : %s ' % nproto.name())
            if self.getProp('Verbose'):
                _log.info(prntCmp(nproto))

        if self.getProp('EnableOnDemand'):
            _log.info("CaloProcessor onDemand enabled")
            if self.getProp('Verbose'):
                _log.info(printOnDemand())
예제 #8
0
    def applyConf(self):
        """
        Calorimeter Reconstruction Configuration
        """

        self.printConf()

        _log.info('Apply CaloRecoConf configuration for %s ',
                  self.getProp('RecList'))

        recList = self.getProp('RecList')
        skipNeutrals = self.getProp('SkipNeutrals')
        skipCharged = self.getProp('SkipCharged')
        forceOnDemand = self.getProp('ForceOnDemand')

        seq = []

        # configure all components for DoD
        if forceOnDemand:
            _log.info('Force Data-On-Demand for all components')
            self.setProp('EnableRecoOnDemand', 'True')
            self.digits()
            self.clusters()
            self.photons()
            self.mergedPi0s()
            self.electrons()

        if self.getProp('NoSpdPrs'):
            self.setProp('UseSpd', False)
            self.setProp('UsePrs', False)
            self.setProp('UseSpdE', False)
            self.setProp('UsePrsE', False)
            # configure the public getter tool
            from Configurables import ToolSvc, CaloGetterTool
            tsvc = ToolSvc()
            tsvc.addTool(CaloGetterTool, name="CaloGetter")
            tsvc.CaloGetter.DetectorMask = 12

        # add only the requested components to the sequence
        if 'Digits' in recList:
            addAlgs(seq, self.digits())
            CaloDigitConf().printConf()
        if 'Clusters' in recList:
            addAlgs(seq, self.clusters())
            if 'Digits' not in recList:
                CaloDigitConf().printConf()
        if not skipNeutrals:
            if 'Photons' in recList: addAlgs(seq, self.photons())
            if 'MergedPi0s' in recList or 'SplitPhotons' in recList:
                addAlgs(seq, self.mergedPi0s())
        if not skipCharged:
            if 'Electrons' in recList: addAlgs(seq, self.electrons())

        setTheProperty(seq, 'Context', self.getProp('Context'))
        setTheProperty(seq, 'MeasureTime', self.getProp('MeasureTime'))
        if self.isPropertySet("OutputLevel"):
            setTheProperty(seq, 'OutputLevel', self.getProp('OutputLevel'))

        if self.isPropertySet('Sequence'):
            main = self.getProp('Sequence')
            addAlgs(main, seq)
            _log.info('Configure main Calo Reco Sequence  : %s ' % main.name())
            if self.getProp('Verbose'):
                _log.info(prntCmp(main))
        else:
            _log.info('Configure Calorimeter Reco blocks ')
            if self.getProp('Verbose'):
                _log.info(prntCmp(seq))

        if self.getProp('EnableRecoOnDemand'):
            _log.info("CaloReco onDemand enabled")
            if self.getProp('Verbose'):
                _log.info(printOnDemand())
예제 #9
0
def caloPIDs(context,
             enableRecoOnDemand,
             list,
             trackLocations=[],
             matchTrTypes=[],
             caloTrTypes=[],
             bremTrTypes=[],
             skipNeutrals=False,
             skipCharged=False,
             fastPID=False,
             external='',
             name='',
             noSpdPrs=False):
    """
    Define various Calo PIDs evaluation
    """

    from Configurables import (InSpdAcceptance, InSpdAcceptanceAlg,
                               InPrsAcceptance, InPrsAcceptanceAlg,
                               InEcalAcceptance, InEcalAcceptanceAlg,
                               InBremAcceptance, InBremAcceptanceAlg,
                               InHcalAcceptance, InHcalAcceptanceAlg)

    from Configurables import (ElectronMatchAlg, BremMatchAlg)

    from Configurables import (Track2SpdEAlg, Track2PrsEAlg, Track2EcalEAlg,
                               Track2HcalEAlg)

    from Configurables import (EcalChi22ID, BremChi22ID, ClusChi22ID,
                               PrsPIDeAlg, EcalPIDeAlg, BremPIDeAlg,
                               HcalPIDeAlg, EcalPIDmuAlg, HcalPIDmuAlg,
                               CaloPhotonIdAlg)

    ##  SANITY CHECK FOR TRACK TYPES (caloTrTypes must be included  in matchTrTypes)
    defMatchTrTypes = [3, 5, 6]  # Long / Downstream / TTracks
    if matchTrTypes != []:
        defMatchTrTypes = matchTrTypes
    for item in caloTrTypes:
        if item not in defMatchTrTypes:
            raise AttributeError, 'TrackTypes for ClusterMatching must include CaloPID TrackTypes'

    if matchTrTypes != []:
        log.info(" ! Will use track types = % s for matching" % matchTrTypes)
    if caloTrTypes != []:
        log.info(" ! Will use track types = % s for caloPID" % caloTrTypes)
    if bremTrTypes != []:
        log.info(" ! Will use track types = % s for bremPID" % bremTrTypes)

    ## global PID sequence
    _name = 'CaloPIDs'
    if name != context or context.upper() == 'OFFLINE': _name = _name + name
    seq = getAlgo(GaudiSequencer, _name, context)
    seq.Members = []

    ## add Charged
    if not skipCharged:
        _name = 'ChargedPIDs'
        if name != context or context.upper() == 'OFFLINE':
            _name = _name + name

        charged = getAlgo(GaudiSequencer, _name, context)

        # inAcceptance
        inAcc = getAlgo(GaudiSequencer, 'InCaloAcceptance', context)

        inECAL = inEcalAcc(context, enableRecoOnDemand, trackLocations,
                           matchTrTypes)
        inHCAL = getAlgo(InHcalAcceptanceAlg, 'InHCAL', context,
                         "Rec/Calo/InAccHcal", enableRecoOnDemand)
        inBREM = getAlgo(InBremAcceptanceAlg, 'InBREM', context,
                         "Rec/Calo/InAccBrem", enableRecoOnDemand)
        inAcc.Members = [inECAL, inHCAL, inBREM]

        if not noSpdPrs:
            inSPD = getAlgo(InSpdAcceptanceAlg, 'InSPD', context,
                            "Rec/Calo/InAccSpd", enableRecoOnDemand)
            inPRS = getAlgo(InPrsAcceptanceAlg, 'InPRS', context,
                            "Rec/Calo/InAccPrs", enableRecoOnDemand)
            inAcc.Members += [inSPD, inPRS]
        else:
            log.info('remove Spd/Prs from acceptance')

        # matching
        match = getAlgo(GaudiSequencer, 'CaloMatch', context)
        cluster = trackMatch(context, enableRecoOnDemand, trackLocations,
                             matchTrTypes, fastPID, external)

        electron = getAlgo(ElectronMatchAlg, "ElectronMatch", context,
                           'Rec/Calo/ElectronMatch', enableRecoOnDemand)
        brem = getAlgo(BremMatchAlg, "BremMatch", context,
                       'Rec/Calo/BremMatch', enableRecoOnDemand)

        match.Members = [cluster, electron, brem]

        # energy
        energy = getAlgo(GaudiSequencer, 'CaloEnergy', context)
        ecalE = getAlgo(Track2EcalEAlg, 'EcalE', context, 'Rec/Calo/EcalE',
                        enableRecoOnDemand)
        hcalE = getAlgo(Track2HcalEAlg, 'HcalE', context, 'Rec/Calo/HcalE',
                        enableRecoOnDemand)

        energy.Members = [ecalE, hcalE]
        if not noSpdPrs:
            spdE = getAlgo(Track2SpdEAlg, 'SpdE', context, 'Rec/Calo/SpdE',
                           enableRecoOnDemand)
            prsE = getAlgo(Track2PrsEAlg, 'PrsE', context, 'Rec/Calo/PrsE',
                           enableRecoOnDemand)

            energy.Members += [spdE, prsE]
        else:
            log.info('remove Spd/Prs from energy estimators')

        # Chi2's
        chi2 = getAlgo(GaudiSequencer, 'CaloChi2', context)
        eChi2 = getAlgo(EcalChi22ID, 'EcalChi22ID', context,
                        'Rec/Calo/EcalChi2', enableRecoOnDemand)
        bChi2 = getAlgo(BremChi22ID, 'BremChi22ID', context,
                        'Rec/Calo/BremChi2', enableRecoOnDemand)
        cChi2 = getAlgo(ClusChi22ID, 'ClusChi22ID', context,
                        'Rec/Calo/ClusChi2', enableRecoOnDemand)
        chi2.Members = [eChi2, bChi2, cChi2]

        # DLL
        dlle = getAlgo(GaudiSequencer, 'CaloDLLe', context)
        dllmu = getAlgo(GaudiSequencer, 'CaloDLLmu', context)
        ecale = getAlgo(EcalPIDeAlg, 'EcalPIDe', context, 'Rec/Calo/EcalPIDe',
                        enableRecoOnDemand)
        breme = getAlgo(BremPIDeAlg, 'BremPIDe', context, 'Rec/Calo/BremPIDe',
                        enableRecoOnDemand)
        hcale = getAlgo(HcalPIDeAlg, 'HcalPIDe', context, 'Rec/Calo/HcalPIDe',
                        enableRecoOnDemand)
        ecalmu = getAlgo(EcalPIDmuAlg, 'EcalPIDmu', context,
                         'Rec/Calo/EcalPIDmu', enableRecoOnDemand)
        hcalmu = getAlgo(HcalPIDmuAlg, 'HcalPIDmu', context,
                         'Rec/Calo/HcalPIDmu', enableRecoOnDemand)

        dllmu.Members = [ecalmu, hcalmu]
        dlle.Members = [ecale, breme, hcale]
        if not noSpdPrs:
            prse = getAlgo(PrsPIDeAlg, 'PrsPIDe', context, 'Rec/Calo/PrsPIDe',
                           enableRecoOnDemand)

            dlle.Members += [prse]
        else:
            log.info('remove Spd/Prs from dlle')

        # alternative sequence (per caloPID technique)
        ecalT = getAlgo(GaudiSequencer, 'EcalPID', context)
        ecalT.Members = [
            inECAL, cluster, electron, ecalE, eChi2, cChi2, ecale, ecalmu
        ]

        hcalT = getAlgo(GaudiSequencer, 'HcalPID', context)
        hcalT.Members = [inHCAL, hcalE, hcale, hcalmu]

        if not noSpdPrs:
            prsT = getAlgo(GaudiSequencer, 'PrsPID', context)
            prsT.Members = [inPRS, prsE, prse]

            spdT = getAlgo(GaudiSequencer, 'SpdPID', context)
            spdT.Members = [inSPD, spdE]

        bremT = getAlgo(GaudiSequencer, 'BremPID', context)
        bremT.Members = [inBREM, brem, bChi2, breme]

        # === Redefine accepted track types ===
        # matchTrTypes propagated to the relevant modules (inEcalAcc & clusterMatch)
        if caloTrTypes != []:
            electron.AcceptedType = caloTrTypes
            cChi2.AcceptedType = caloTrTypes
            eChi2.AcceptedType = caloTrTypes
            ecalE.AcceptedType = caloTrTypes
            ecale.AcceptedType = caloTrTypes
            ecalmu.AcceptedType = caloTrTypes
            inHCAL.AcceptedType = caloTrTypes
            hcalE.AcceptedType = caloTrTypes
            hcale.AcceptedType = caloTrTypes
            hcalmu.AcceptedType = caloTrTypes
            if not noSpdPrs:
                inSPD.AcceptedType = caloTrTypes
                spdE.AcceptedType = caloTrTypes
                inPRS.AcceptedType = caloTrTypes
                prsE.AcceptedType = caloTrTypes
                prse.AcceptedType = caloTrTypes
        if bremTrTypes != []:
            inBREM.AcceptedType = bremTrTypes
            brem.AcceptedType = bremTrTypes
            bChi2.AcceptedType = bremTrTypes
            breme.AcceptedType = bremTrTypes

        # === Override CaloAlgUtils default track location ===
        if trackLocations:
            electron.Tracks = trackLocations
            brem.Tracks = trackLocations
            inBREM.Inputs = trackLocations
            inHCAL.Inputs = trackLocations
            eChi2.Tracks = trackLocations
            bChi2.Tracks = trackLocations
            cChi2.Tracks = trackLocations
            ecalE.Inputs = trackLocations
            hcalE.Inputs = trackLocations
            if not noSpdPrs:
                inPRS.Inputs = trackLocations
                inSPD.Inputs = trackLocations
                spdE.Inputs = trackLocations
                prsE.Inputs = trackLocations

        charged.Members = []
        # updatXe global sequence with charged
        if 'InAcceptance' in list: charged.Members += [inAcc]
        if 'Match' in list: charged.Members += [match]
        if 'Energy' in list: charged.Members += [energy]
        if 'Chi2' in list: charged.Members += [chi2]
        if 'DLL' in list or 'DLLe' in list: charged.Members += [dlle]
        if 'DLL' in list or 'DLLmu' in list: charged.Members += [dllmu]

        # alternative full sequence per technique
        if 'EcalPID' in list: charged.Members += [ecalT]
        if 'BremPID' in list: charged.Members += [bremT]
        if 'HcalPID' in list: charged.Members += [hcalT]
        if 'PrsPID' in list and not noSpdPrs: charged.Members += [prsT]
        if 'SpdPID' in list and not noSpdPrs: charged.Members += [spdT]
        if charged.Members: addAlgs(seq, charged)

    ## Add Neutrals (! No neutralID so far for the noSpdPrs configuration )
    if not skipNeutrals and not noSpdPrs:
        _name = 'NeutralPIDs'
        if name != context or context.upper() == 'OFFLINE':
            _name = _name + name
        neutrals = getAlgo(GaudiSequencer, _name, context)
        photonID = PhotonID(context, enableRecoOnDemand)
        mergedID = MergedID(context, enableRecoOnDemand)
        photonFromMergedID = PhotonFromMergedID(context, enableRecoOnDemand)
        # update global sequence with neutrals
        neutrals.Members = []
        if 'PhotonID' in list or 'NeutralPID' in list:
            neutrals.Members += [photonID]
        if 'MergedID' in list or 'NeutralPID' in list:
            neutrals.Members += [mergedID]
        if 'PhotonFromMergedID' in list or 'NeutralPID' in list:
            neutrals.Members += [photonFromMergedID]
        if neutrals.Members: addAlgs(seq, neutrals)

    setTheProperty(seq, 'Context', context)

    log.debug('Configure Calo PIDs  Reco : %s    for context : %s' %
              (seq.name(), context))

    return seq