Ejemplo n.º 1
0
def eflowMoni(context):
    """
    Define Energy flow omnitoring 
    """

    from Configurables import CaloEFlowAlg

    seq = getAlgo(GaudiSequencer, 'CaloEFlowMoni', context)

    alg = getAlgo(CaloEFlowAlg, 'EcalEFlowMon', context)

    if not alg.isPropertySet('histoList'):
        alg.histoList = ['all']
    if not alg.isPropertySet('SplitAreas'):
        alg.SplitAreas = False
    if not alg.isPropertySet('OneDimension'):
        alg.OneDimension = True
    if not alg.isPropertySet('EtFilterMax'):
        alg.EtFilterMax = 1 * GeV
    if not alg.isPropertySet('EnergyFilterMax'):
        alg.EnergyFilterMax = 10 * GeV

    seq.Members = [alg]

    setTheProperty(alg, 'Context', context)

    return seq
Ejemplo n.º 2
0
def clustersMoni(context):
    """    
    Prepare clusters monitoring
    
    """

    from Configurables import CaloClusterMonitor

    alg = getAlgo(GaudiSequencer, "CaloClustersMoni", context)

    alg1 = getAlgo(CaloClusterMonitor, 'EcalClusterMon', context)

    alg2 = getAlgo(CaloClusterMonitor, 'EcalSplitClusterMon', context)

    if not alg1.isPropertySet('histoList'):
        alg1.histoList = ["1", "2", "3", "4", "7", "8", "9"]

#    delegate to CaloAlgUtils
#    alg1.Input = 'Rec/Calo/EcalClusters'
#    alg2.Input = 'Rec/Calo/EcalSplitClusters'

#    alg.Members = [ alg1 , alg2 ]
    alg.Members = [alg1]  ## do not monitor splitCluster so far

    setTheProperty(alg, 'Context', context)

    return alg
Ejemplo n.º 3
0
def hyposMoni(context):
    """    
    Prepare hypo monitoring
    
    """

    from Configurables import CaloHypoMonitor

    alg = getAlgo(GaudiSequencer, "CaloHyposMoni", context)

    alg1 = getAlgo(CaloHypoMonitor, 'ElectronMon', context)
    alg2 = getAlgo(CaloHypoMonitor, 'PhotonMon', context)
    alg3 = getAlgo(CaloHypoMonitor, 'SplitPhotonMon', context)
    alg4 = getAlgo(CaloHypoMonitor, 'MergedPi0Mon', context)

    # Delegate I/O to CaloAlgUtils
    #    alg1.Input = 'Rec/Calo/Electrons'
    #    alg2.Input = 'Rec/Calo/Photons'
    #    alg3.Input = 'Rec/Calo/SplitPhotons'
    #    alg4.Input = 'Rec/Calo/MergedPi0s'

    if not alg1.isPropertySet('histoList'):
        alg1.histoList = ["1", "2", "3", "7", "8", "9", "10", "11", "14"]
    if not alg2.isPropertySet('histoList'):
        alg2.histoList = ["1", "2", "3", "7", "8", "9", "10", "11", "14"]
    if not alg3.isPropertySet('histoList'):
        alg3.histoList = ["1", "2", "3", "7", "8", "9", "10", "11"]
    if not alg4.isPropertySet('histoList'):
        alg4.histoList = ["1", "2", "3", "4", "7", "8", "9", "14"]

    alg.Members = [alg1, alg2, alg3, alg4]

    setTheProperty(alg, 'Context', context)

    return alg
Ejemplo n.º 4
0
def pidCheck(context, noSpdPrs=False):

    from Configurables import (CaloPIDsChecker, CaloPhotonChecker)

    alg = getAlgo(GaudiSequencer, 'CaloPIDsCheck', context)
    alg1 = pidCheckerConf('PIDeEcalChecker', context, 11, "Rec/Calo/EcalPIDe",
                          50.0 * GeV, 0.0, "Long", "Rec/Calo/InAccEcal")
    alg2 = pidCheckerConf('PIDeHcalChecker', context, 11, "Rec/Calo/HcalPIDe",
                          50.0 * GeV, 0.0, "Long", "Rec/Calo/InAccHcal")
    alg3 = pidCheckerConf('PIDeBremChecker', context, 11, "Rec/Calo/BremPIDe",
                          50.0 * GeV, 0.0, "Long", "Rec/Calo/InAccBrem")
    alg4 = pidCheckerConf('PIDmEcalChecker', context, 13, "Rec/Calo/EcalPIDmu",
                          25.0 * GeV, 0.0, "Long", "Rec/Calo/InAccEcal")
    alg5 = pidCheckerConf('PIDmHcalChecker', context, 13, "Rec/Calo/HcalPIDmu",
                          25.0 * GeV, 0.0, "Long", "Rec/Calo/InAccHcal")
    alg.Members = [alg1, alg2, alg3, alg4, alg5]
    if not noSpdPrs:
        alg6 = pidCheckerConf('PIDePrsChecker', context, 11,
                              "Rec/Calo/PrsPIDe", 50.0 * GeV, 0.0, "Long",
                              "Rec/Calo/InAccPrs")
        alg.Members += [alg6]
        # caloPhotonChecker
        alg7 = getAlgo(CaloPhotonChecker, 'CaloPhotonChecker', context)
        alg7.Pdf = True
        alg7.EPrsBin = [50., 0., 200.]
        alg7.Chi2Bin = [26., 0., 104.]
        alg7.SeedBin = [50., 0., 1.]


#        alg.Members += [alg7]
    setTheProperty(alg, 'Context', context)
    return alg
Ejemplo n.º 5
0
    def configureMC(self):
        """
        Define DaVinciAssociators. Do MC unpacking.
        """
        from Configurables import CaloAssociatorsConf
        
        CaloAssociatorsConf ( EnableMCOnDemand = True, OutputLevel = self.getProp("OutputLevel") )

        from CaloKernel.ConfUtils import getAlgo
        from Configurables        import NeutralPP2MC

        ## offline neutral protoparticles 
        alg1 = getAlgo (
            NeutralPP2MC                    , ## type 
            'NeutralPP2MC'                  , ## base-name 
            'Offline'                       , ## context 
            'Relations/Rec/ProtoP/Neutrals' , ## base-location
            True                            ) ## on-demand 

        ## hlt neutral protoparticles 
        alg2 = getAlgo (
            NeutralPP2MC                    , ## type 
            'NeutralPP2MC'                  , ## base-name 
            'Hlt'                           , ## context 
            'Relations/Rec/ProtoP/Neutrals' , ## base-location 
            True                            ) ## on-demand
        
        from Configurables import DataOnDemandSvc
        DataOnDemandSvc().AlgMap['/Event/Relations/Rec/ProtoP/Charged' ]  = 'ChargedPP2MC' 
        DataOnDemandSvc().AlgMap['/Event/Relations/Rec/ProtoP/Upstream' ] = 'ChargedPP2MC' 

        self.unpackMC()
Ejemplo n.º 6
0
def recoCheck(context):

    from Configurables import (CaloClusterChecker, CaloPi0Checker)

    alg = getAlgo(GaudiSequencer, 'CaloRecoCheck', context)
    alg1 = getAlgo(CaloClusterChecker, 'CaloClusterChecker', context)
    alg2 = getAlgo(CaloPi0Checker, 'CaloPi0Checker', context)
    alg.Members = [alg1, alg2]
    setTheProperty(alg, 'Context', context)
    return alg
Ejemplo n.º 7
0
def trackMatch(context,
               enableRecoOnDemand,
               trackLocations=[],
               matchTrTypes=[],
               fastReco=False,
               external=''):
    """

    Define the minimal track match sequnce for photon reconstruction

    """

    from Configurables import PhotonMatchAlg

    seq = getAlgo(GaudiSequencer, 'CaloTrackMatch', context)

    ## perform the actual track <-> cluster match
    clmatch = getAlgo(PhotonMatchAlg, 'ClusterMatch', context,
                      'Rec/Calo/ClusterMatch', enableRecoOnDemand)

    if external != '':
        clmatch.Calos = [external]

#    log.info(" ========= trackLocations = " + str(trackLocations) )

## check if the track is in Ecal acceptance
    inEcal = inEcalAcc(context, enableRecoOnDemand, trackLocations,
                       matchTrTypes)

    seq.Members = [inEcal, clmatch]

    setTheProperty(seq, 'Context', context)

    if matchTrTypes != []:
        clmatch.AcceptedType = matchTrTypes

    if trackLocations:
        clmatch.Tracks = trackLocations

    log.debug("Configure Cluster Track Match : '%s' for  '%s'" %
              (seq.name(), context))

    return seq
Ejemplo n.º 8
0
def pidCheckerConf(name, context, particle, input, norm, cut, type, acc):
    from Configurables import (CaloPIDsChecker)
    algo = getAlgo(CaloPIDsChecker, name, context)
    algo.Particle = particle
    algo.Input = input
    algo.Normalization = norm
    algo.Cut = cut
    algo.TrackType = type
    algo.TrackAcceptance = acc
    return algo
Ejemplo n.º 9
0
def digitsMoni(context, noSpdPrs=False):
    """
    
    Prepare digit monitoring
    
    """
    from Configurables import (CaloDigitMonitor, SpdMonitor)

    alg = getAlgo(GaudiSequencer, "CaloDigitsMoni", context)

    alg1 = getAlgo(CaloDigitMonitor, "EcalDigitMon", context)
    alg2 = getAlgo(CaloDigitMonitor, "HcalDigitMon", context)
    if not alg1.isPropertySet('histoList'):
        alg1.histoList = ["1", "2", "3", "6", "7"]
    if not alg2.isPropertySet('histoList'):
        alg2.histoList = ["1", "2", "3", "6", "7"]

    alg.Members = [alg1, alg2]

    if not noSpdPrs:
        alg3 = getAlgo(CaloDigitMonitor, "PrsDigitMon", context)
        alg4 = getAlgo(CaloDigitMonitor, "SpdDigitMon", context)
        alg5 = getAlgo(SpdMonitor, "SpdMon", context)
        if not alg3.isPropertySet('histoList'):
            alg3.histoList = ["1", "2", "3", "6", "7"]
        if not alg4.isPropertySet('histoList'):
            alg4.histoList = ["1", "2", "3", "6"]
        alg.Members += [alg3, alg4, alg5]
    setTheProperty(alg, 'Context', context)
    return alg
Ejemplo n.º 10
0
def PhotonFromMergedID(context, enableRecoOnDemand, useTracks=True):
    """
    define 'PhotonFromMergedID' algorithm
    """

    from Configurables import CaloPhotonIdAlg

    ## photonID
    pmid = getAlgo(CaloPhotonIdAlg, "PhotonFromMergedID", context,
                   "Rec/Calo/PhotonFromMergedID", enableRecoOnDemand)

    pmid.Type = 'PhotonFromMergedID'
    pmid.Tracking = useTracks
    return pmid
Ejemplo n.º 11
0
def MergedID(context, enableRecoOnDemand, useTracks=True):
    """
    define 'MergedID' algorithm
    """

    from Configurables import CaloPhotonIdAlg

    ## photonID
    mid = getAlgo(CaloPhotonIdAlg, "MergedID", context, "Rec/Calo/MergedID",
                  enableRecoOnDemand)

    mid.Type = 'MergedID'
    mid.Tracking = useTracks
    return mid
Ejemplo n.º 12
0
def pi0sMoni(context):
    """    
    Define pi0 monitoring
    
    """

    from Configurables import CaloPi0Monitor

    alg = getAlgo(GaudiSequencer, "DiPhotonMoni", context)

    alg1 = getAlgo(CaloPi0Monitor, 'ResolvedPi0Mon', context)

    alg2 = getAlgo(CaloPi0Monitor, 'EtaMon', context)

    if not alg1.isPropertySet('PhotonPtFilter'):
        alg1.PhotonPtFilter = 500. * MeV

    if not alg1.isPropertySet('histoList'):
        alg1.histoList = ["1", "2", "3", "4", "5", "6", "7"]

    if not alg2.isPropertySet('PhotonMaxPtFilter'):
        alg2.PhotonMaxPtFilter = 1000. * MeV

    if not alg2.isPropertySet('HistoMassMin'):
        alg2.HistoMassMin = 400. * MeV

    if not alg2.isPropertySet('HistoMassMax'):
        alg2.HistoMassMax = 700. * MeV

    if not alg2.isPropertySet('histoList'):
        alg2.histoList = ["1", "2", "3", "4", "5", "6", "7"]

    alg.Members = [alg1, alg2]
    setTheProperty(alg, 'Context', context)

    return alg
Ejemplo n.º 13
0
def protosMoni(context):
    """    
    Define protoElectron monitoring
    
    """

    from Configurables import CaloProtoElectronMonitor

    alg = getAlgo(CaloProtoElectronMonitor, 'ProtoElectronMon', context)

    if not alg.isPropertySet('histoList'):
        alg.histoList = ["All"]

    setTheProperty(alg, 'Context', context)

    return alg
Ejemplo n.º 14
0
def inEcalAcc(context, enableRecoOnDemand, trackLocations=[], matchTrTypes=[]):
    """
    
    define 'inEcalAcceptance' algorithm
    
    """

    from Configurables import (InEcalAcceptance, InEcalAcceptanceAlg)

    ## check if the track is in Ecal acceptance
    inEcal = getAlgo(InEcalAcceptanceAlg, 'InECAL', context,
                     "Rec/Calo/InAccEcal", enableRecoOnDemand)

    if trackLocations:
        inEcal.Inputs = trackLocations

    if matchTrTypes != []:
        inEcal.AcceptedType = matchTrTypes

    return inEcal
Ejemplo n.º 15
0
def pidsMoni(context, Histograms):
    """
    Define CaloPIDs monitoring
    """

    from Configurables import (CaloClusterMatchMonitor, CaloHypoMatchMonitor,
                               CaloEMuPIDMon)

    alg = getAlgo(GaudiSequencer, 'CaloPIDsMoni', context)

    alg1 = getAlgo(CaloClusterMatchMonitor, 'PhotonMatchMon', context)
    alg2 = getAlgo(CaloHypoMatchMonitor, 'ElectronMatchMon', context)
    alg3 = getAlgo(CaloHypoMatchMonitor, 'BremMatchMon', context)

    alg5 = getAlgo(CaloEMuPIDMon, 'CaloEMuPIDMonUncut', context)

    alg6 = getAlgo(CaloEMuPIDMon, 'CaloEMuPIDMonSoft', context)

    alg7 = getAlgo(CaloEMuPIDMon, 'CaloEMuPIDMonHard', context)

    ## Delegate I/O to CaloAlgUtils
    #    alg1.Input  =   'Rec/Calo/ClusterMatch'
    #    alg1.Inputs = [ 'Rec/Calo/EcalClusters' ]
    #    alg2.Input  =   'Rec/Calo/ElectronMatch'
    #    alg2.Inputs = [ 'Rec/Calo/Electrons'    ]
    #    alg3.Input  =   'Rec/Calo/BremMatch'
    #    alg3.Inputs = [ 'Rec/Calo/Photons'      ]

    if not alg5.isPropertySet('uncut'): alg5.uncut = True
    if not alg5.isPropertySet('SplitSides'): alg5.SplitSides = True

    if not alg7.isPropertySet('pTmin'): alg7.pTmin = 500.
    if not alg7.isPropertySet('RichDLLe'): alg7.RichDLLe = 4.
    if not alg7.isPropertySet('maxEHcalE'): alg7.maxEHcalE = 1000.
    if not alg7.isPropertySet('minPrsE'): alg7.minPrsE = -1.e10

    alg.Members = [alg1, alg2, alg3, alg5, alg6, alg7]

    setTheProperty(alg, 'Context', context)

    return alg
Ejemplo n.º 16
0
def clusterReco(context,
                enableRecoOnDemand,
                clusterPt=0.,
                fastReco=False,
                external='',
                makeTag=False,
                noSpdPrs=False,
                masksE=[],
                masksP=[],
                mergedPi0Pt=2 * GeV):
    """
    Define the recontruction of Ecal Clusters
    """

    from Configurables import (
        CaloDigitFilterAlg,
        CellularAutomatonAlg,
        CaloShowerOverlap,
        # CaloSharedCellAlg        , # obsolete
        CaloClusterCovarianceAlg,
        CaloClusterizationTool)

    # cluster TES  is 'almost' context-independent : single HLT TES whatever the HLT-type else 'offline' TES
    ## Warning MUST be synchronous with CaloAlgUtils TES settings
    ### Exception when external clusters location is given

    if external == '':
        _cont = context
        if '' != context and 'OFFLINE' != _cont.upper() and _cont.upper().find(
                'HLT') != -1:
            context = 'Hlt'
        else:
            context = ''
    elif makeTag != '':
        context = makeTag

    ## Define the context-dependent sequencer
    seq = getAlgo(GaudiSequencer, "ClusterReco", context,
                  "Rec/Calo/EcalClusters", enableRecoOnDemand)

    seq.Members[:] = []
    filter = getAlgo(CaloDigitFilterAlg, "CaloDigitFilter", context)
    if noSpdPrs:
        filter.PrsFilter = 0
        filter.SpdFilter = 0

    clust = getAlgo(CellularAutomatonAlg, "EcalClust", context)
    #   share = getAlgo ( CaloSharedCellAlg        , "EcalShare"  , context )   # obsolete
    share = getAlgo(CaloShowerOverlap, "EcalShare", context)
    covar = getAlgo(CaloClusterCovarianceAlg, "EcalCovar", context)

    if masksE != []:
        share.EnergyTags = masksE
        covar.EnergyTags = masksE
    if masksP != []:
        share.PositionTags = masksP
        covar.PositionTags = masksP

    if external != '':  # use non-default clusters
        share.InputData = external
        covar.InputData = external
        if makeTag != '':  # make the non-default clusters
            seq.Members += [filter, clust]
            clust.OutputData = external
    else:
        seq.Members += [filter, clust]  # make default clusters

    if clusterPt > 0:
        from Configurables import CaloClusterizationTool
        clust.addTool(CaloClusterizationTool, 'CaloClusterizationTool')
        clust.CaloClusterizationTool.ETcut = clusterPt
        clust.CaloClusterizationTool.withET = True

    seq.Members += [share, covar]
    setTheProperty(seq, 'Context', context)

    ## setup onDemand for SplitClusters
    if enableRecoOnDemand:
        splitSeq = mergedPi0Reco(context, enableRecoOnDemand, True, False,
                                 False, mergedPi0Pt, False, '', noSpdPrs,
                                 masksE, masksP)
        onDemand('Rec/Calo/EcalSplitClusters', splitSeq, context)

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

    ##
    return seq
Ejemplo n.º 17
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
Ejemplo n.º 18
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
Ejemplo n.º 19
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
Ejemplo n.º 20
0
def caloMCTruth ( context           = 'Offline' ,
                  enableMCOnDemand  = True      ,
                  Digits            = [ 'Ecal'] ) :
    """
    Define the configuration for on-demand association for Calo objects 
    """

    from CaloDAQ.CaloDigits import caloDigits

    ## configure 'digits'
    caloDigits( 'Offline'        , 
                enableMCOnDemand ,
                False,
                Digits)

    from Configurables import GaudiSequencer 
    main = getAlgo (
        GaudiSequencer ,
        'CaloMCTruth'  ,
        context        ,
        ''             ,
        False          ,
        )
    main.Members = []
    
    mc2digits = getAlgo (
        GaudiSequencer               ,
        "CaloDigitMCTruth"           ,
        'Offline'                    , 
        'Relations/Raw/Calo/Digits'  ,
        enableMCOnDemand             , 
        )
    mc2digits.Members = []

    from Configurables import CaloDigit2MCLinks2Table
    links2table = getAlgo (
        CaloDigit2MCLinks2Table      ,
        'CaloDigitMCLinks2Table'     , 
        'Offline'                    ,
        'Relations/Raw/Calo/Digits'  ,
        False 
        )
    links2table.Inputs = [] 
    
    for dig in Digits :
        
        location = 'Raw/' + dig + '/Digits'
        algName  = dig + 'ZSup' 
        if  dig in ( 'Spd' , 'Prs' ) :
            algName = dig + 'FromRaw'
        alg      = getConfigurable( algName )

        mc2digits   .Members += [ alg      ]
        links2table .Inputs  += [ location ] 

    mc2digits.Members += [ links2table ]

    main.Members += [ mc2digits ]
    
    from Configurables import CaloClusterMCTruth
    
    clusters = getAlgo ( CaloClusterMCTruth            ,   
                         'CaloClusterMCTruth'          ,
                         context                       , 
                         'Relations/Rec/Calo/Clusters' ,
                         enableMCOnDemand              )

    main.Members += [ clusters ]

    return main
Ejemplo n.º 21
0
def caloDigits ( context        ,
                 enableOnDemand ,
                 createADCs=False,
                 detectors=['Ecal','Hcal','Prs','Spd'],
                 ReadoutStatusConvert=False) :

    """
    Decoding of Calo-Digits 
    """
    _cntx = 'Offline'
    if context != _cntx :
        _log.warning('CaloDigit: Context is redefined to be Offline')
        
    from Configurables import ( CaloZSupAlg       ,
                                CaloDigitsFromRaw ,
                                RawBankReadoutStatusConverter,
                                GaudiSequencer    ) 
    

 

    conflist=[]
    alglist=[]

    if 'Spd'  in detectors :
        _log.debug('caloDigits : Spd is added to the detector list')
        spd  = getAlgo ( CaloDigitsFromRaw       , 
                         "SpdFromRaw"            ,
                         _cntx                   ,
                         "Raw/Spd/Digits"        ,
                         enableOnDemand          )
        conflist.append(spd)
        alglist.append(spd)


    if 'Prs'  in detectors :
        _log.debug('caloDigits : Prs is added to the detector list')
        prsSeq = GaudiSequencer ('PrsDigitsSeq',Context = _cntx)
        prs  = getAlgo ( CaloDigitsFromRaw       , 
                         "PrsFromRaw"            ,
                         _cntx                   ,
                         "Raw/Prs/Digits"        ,
                         enableOnDemand          )
        conflist.append(prs)
        if ReadoutStatusConvert :
            prsCnv = getAlgo ( RawBankReadoutStatusConverter, "PrsProcStatus",_cntx)
            prsCnv.System='Prs'
            prsCnv.BankTypes=['PrsPacked']
            prsSeq.Members = [prs,prsCnv]
            alglist.append(prsSeq)
        else :
            alglist.append(prs)
        
    if 'Ecal' in detectors :
        _log.debug('caloDigits : Ecal is added to the detector list')
        ecalSeq = GaudiSequencer ('EcalDigitsSeq',Context = _cntx)
        ecal = getAlgo ( CaloZSupAlg             , 
                         "EcalZSup"              ,
                         _cntx                   ,
                         "Raw/Ecal/Digits"       ,
                         enableOnDemand          )
        conflist.append(ecal)
        if ReadoutStatusConvert :
            ecalCnv = getAlgo ( RawBankReadoutStatusConverter, "EcalProcStatus",_cntx)
            ecalCnv.System='Ecal'
            ecalCnv.BankTypes=['EcalPacked']
            ecalSeq.Members = [ecal,ecalCnv]
            alglist.append(ecalSeq)
        else :
            alglist.append(ecal)


    if 'Hcal' in detectors :
        _log.debug('caloDigits : Hcal is added to the detector list')
        hcalSeq = GaudiSequencer ('HcalDigitsSeq',Context = _cntx)
        hcal = getAlgo ( CaloZSupAlg             , 
                         "HcalZSup"              ,
                         _cntx                   ,
                         "Raw/Hcal/Digits"       ,
                         enableOnDemand          )
        conflist.append(hcal)
        if ReadoutStatusConvert :
            hcalCnv = getAlgo ( RawBankReadoutStatusConverter, "HcalProcStatus",_cntx)
            hcalCnv.System='Hcal'
            hcalCnv.BankTypes=['HcalPacked']
            hcalSeq.Members = [hcal,hcalCnv]
            alglist.append(hcalSeq)
        else :
            alglist.append(hcal)



    if createADCs :
        for a in conflist :
            t = a.OutputType.upper()
            if   t in [ 'DIGIT', 'DIGITS' , 'CALODIGIT' , 'CALODIGITS' ] :
                t.OutputType = 'Both'
                _log.warning( 'Change OutputType for %s from %s to %'
                              % ( t.getFullName() , t , t.OutputType ) )
            elif t in [ 'ADC'  , 'ADCS'   , 'CALOADC'   , 'CALOADCS'   ] :
                pass
            elif t is 'BOTH' :
                pass
            else :
                t.OutputType = 'Adc'
                _log.warning( 'Change OutputType for %s from %s to %'
                              % ( t.getFullName() , t , t.OutputType ) )

               
            
    ## combine them into sequence  
    alg = GaudiSequencer ('CaloDigits',Context = context, IgnoreFilterPassed = True, Members=alglist)
    return alg 
Ejemplo n.º 22
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())
Ejemplo n.º 23
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