예제 #1
0
def fullReco() :
    from Configurables import ( ProcessPhase, GaudiSequencer, RecSysConf )
    brunelSeq = GaudiSequencer("BrunelSequencer")
    # analysis and Phys init are not run with MDF
    GaudiSequencer("DaVinciInitSeq").Members += [ brunelSeq ] 
    brunelSeq.Members += [ "ProcessPhase/Init", "ProcessPhase/Reco", "ProcessPhase/Moni"]
    ProcessPhase("Init").DetectorList += [ "Brunel", "Calo"]
    GaudiSequencer("InitCaloSeq").Members += ["GaudiSequencer/CaloBanksHandler"]
    importOptions("$CALODAQROOT/options/CaloBankHandler.opts")
    configureMoni(False,False)
예제 #2
0
 def _setupPhase(self, name, knownDets):
     seq = self.getProp("%sSequence" % name)
     if len(seq) == 0:
         seq = knownDets
         self.setProp("%sSequence" % name, seq)
     else:
         for det in seq:
             if det not in knownDets:
                 log.warning("Unknown subdet '%s' in %sSequence" %
                             (det, seq))
     ProcessPhase(name).DetectorList += seq
     return seq
예제 #3
0
 def daqOutput(self):
     from Configurables import DstConf, Serialisation, ProcessPhase
     ###print '[WARN]  Running GaudiSerialize!'
     self.app.WriteLumi = False
     self.app.Histograms = 'Online'
     print '[WARN] Running brunel with histogram settings:Online'
     sys.stdout.flush()
     Brunel.Configuration.Brunel.configureOutput = dummy
     ProcessPhase("Output").DetectorList += ['DST']
     self.app.setProp('DatasetName', 'GaudiSerialize')
     DstConf().Writer = 'DstWriter'
     DstConf().DstType = 'DST'
     DstConf().PackType = 'NONE'
     Serialisation().Writer = 'Writer'
     Serialisation()._ConfigurableUser__addPassiveUseOf(DstConf())
예제 #4
0
    def configureFilter(self):
        """
        Set up the filter sequence to selectively write out events
        """
        filterDets = self.getProp("FilterSequence")
        for det in filterDets:
            if det not in self.KnownFilterSubdets:
                log.warning("Unknown subdet '%s' in FilterSequence" % det)

        filterSeq = ProcessPhase("Filter", ModeOR=True)
        filterSeq.DetectorList += filterDets

        if "L0" in filterDets:
            from Configurables import L0Conf
            L0Conf().FilterSequencer = GaudiSequencer("FilterL0Seq")

        if "ODIN" in filterDets:
            from Configurables import OdinTypesFilter
            odinFilter = OdinTypesFilter()
            GaudiSequencer("FilterODINSeq").Members += [odinFilter]
예제 #5
0
def configureMoni(expert,withMC):
    # Set up monitoring (i.e. not using MC truth)
    moniSeq = ["CALO","RICH","MUON","VELO","Tr","ST"]
    ProcessPhase("Moni").DetectorList += moniSeq

    # Histograms filled both in real and simulated data cases
    if "CALO" in moniSeq :
        importOptions('$CALOMONIDSTOPTS/CaloMonitor.opts')
    else :
        # Hack for units options, normally included by CaloMonitor.opts
        importOptions('$STDOPTS/PreloadUnits.opts')

    if "VELO" in moniSeq :
        importOptions('$VELORECMONITORSROOT/options/BrunelMoni_Velo.py')

    if "Tr" in moniSeq :
        from TrackMonitors.ConfiguredTrackMonitors import ConfiguredTrackMonitorSequence
        ConfiguredTrackMonitorSequence(Name='MoniTrSeq')

    if "MUON" in moniSeq :
        importOptions("$MUONPIDCHECKERROOT/options/MuonPIDMonitor.py")

    if "ST" in moniSeq :
        from Configurables import ST__STClusterMonitor, GaudiSequencer
        GaudiSequencer( "MoniSTSeq" ).Members += [ ST__STClusterMonitor("TTClusterMonitor"),
                                                   ST__STClusterMonitor("ITClusterMonitor")]
        ST__STClusterMonitor("TTClusterMonitor").DetType = "TT" ## default anyway 
        ST__STClusterMonitor("ITClusterMonitor").DetType = "IT" 

    # Histograms filled only in real data case
    if not withMC:
        from Configurables import RichRecQCConf
        if "RICH" in moniSeq :
            from Configurables import GaudiSequencer
            RichRecQCConf().DataType = "MDF"
            RichRecQCConf().setProp("MoniSequencer", GaudiSequencer("MoniRICHSeq"))
예제 #6
0
    def configureInit(self, inputType):
        # Init sequence
        if not self.isPropertySet("InitSequence"):
            if self._isReprocessing(inputType):
                self.setProp( "InitSequence", self.DefaultReproInitSequence )
            else:
                self.setProp( "InitSequence", self.DefaultInitSequence )
        from Configurables import ProcessPhase
        ProcessPhase("Init").DetectorList += self.getProp("InitSequence")

        from Configurables import RecInit, MemoryTool
        recInit = RecInit( "BrunelInit",
                           PrintFreq = self.getProp("PrintFreq"))
        GaudiSequencer("InitBrunelSeq").Members += [ recInit ]
        recInit.addTool( MemoryTool(), name = "BrunelMemory" )
        recInit.BrunelMemory.HistoTopDir = "Brunel/"
        recInit.BrunelMemory.HistoDir    = "MemoryTool"
        if not recInit.isPropertySet( "MemoryPurgeLimit" ): recInit.MemoryPurgeLimit = 2000 * 1000 # 2GB

        # count events
        from Configurables import EventCountHisto
        evtC = EventCountHisto("BrunelEventCount")
        evtC.HistoTopDir = "Brunel/"
        GaudiSequencer("InitBrunelSeq").Members += [ evtC ]

        # kill some RAW banks
        banksToKill = []
        if self.isPropertySet( "RawBanksToKill" ):
            banksToKill  = self.getProp( "RawBanksToKill" )
        if ("2009" == self.getProp("DataType")) and (inputType in ["MDF"]) and not self.getProp("Simulation") :
            banksToKill += ["VeloFull", "L0PUFull"]
        if len(banksToKill) > 0 :
            from Configurables import bankKiller
            bkKill = bankKiller("BrunelBankKiller")
            bkKill.BankTypes = banksToKill
            GaudiSequencer("InitBrunelSeq").Members += [ bkKill ]

        # Do not print event number at every event (done already by BrunelInit)
        EventSelector().PrintFreq = -1

        # OutputLevel
        self.setOtherProp(LHCbApp(),"OutputLevel")
        if self.isPropertySet( "OutputLevel" ) :
            level = self.getProp("OutputLevel")
            if level == ERROR or level == WARNING :
                # Suppress known warnings
                importOptions( "$BRUNELOPTS/SuppressWarnings.opts" )
                if not recInit.isPropertySet( "OutputLevel" ): recInit.OutputLevel = INFO
        self.setOtherProps(RecSysConf(), ["OutputLevel","Detectors"])
        self.setOtherProps(RecMoniConf(),["OutputLevel","Detectors"])

        # New NoSPDPRS switches
        noSPDPRS = False
        if [det for det in ['Spd', 'Prs'] if det not in self.getProp("Detectors")]:
            noSPDPRS = True
        # only set properties if no use RecoSequence is defined or if it contains 'PROTO'
        # not that 'PROTO' alone is not sufficient to run the Calo reconstruction, but a requirement
        if ( not self.isPropertySet("RecoSequence") or "PROTO" in self.getProp("RecoSequence") ):
            CaloProcessor().setProp("NoSpdPrs", noSPDPRS)
            GlobalRecoConf().setProp("NoSpdPrs", noSPDPRS)


        # Always print Magnetic Field used
        from Configurables import MagneticFieldSvc
        magSvc = MagneticFieldSvc()
        if not magSvc.isPropertySet("OutputLevel") :
            magSvc.setProp("OutputLevel", INFO)

        # Switch off LoKi banner
        from Configurables import LoKiSvc
        LoKiSvc().Welcome = False
예제 #7
0
    def defineOptions(self):

        # Kept for Dirac backward compatibility
        if self.getProp( "NoWarnings" ) :
            log.warning("Brunel().NoWarnings=True property is obsolete and maintained for Dirac compatibility. Please use Brunel().ProductionMode=True instead")
            self.setProp( "ProductionMode", True )

        # Special settings for production
        if self.getProp( "ProductionMode" ) :
            if not self.isPropertySet( "OutputLevel" ) :
                self.setProp("OutputLevel", ERROR)
            if not LHCbApp().isPropertySet( "TimeStamp" ) :
                LHCbApp().setProp( "TimeStamp", True )
            if not self.isPropertySet( "PrintFreq" ) :
                self.setProp("PrintFreq", 1000)

        # HC does not exist in Run 1, so use appropriate split output
        if self.getProp( "DataType" ) in self.Run1DataTypes :
            if not self.isPropertySet( "SplitRawEventOutput" ) :
                self.setProp( "SplitRawEventOutput", 4.0 )

        # Online mode
        if self.getProp( "OnlineMode" ) :
            if not self.isPropertySet("Histograms") :
                self.setProp("Histograms","Online")
            if not CondDB().isPropertySet("Online") :
                CondDB().setProp("Online", True)

        inputType = self.getProp( "InputType" ).upper()
        if inputType not in self.KnownInputTypes:
            raise TypeError( "Invalid inputType '%s'"%inputType )

        outputType = self.getProp( "OutputType" ).upper()

        histOpt = self.getProp("Histograms")
        if histOpt not in self.KnownHistograms:
            raise RuntimeError("Unknown Histograms option '%s'"%histOpt)

        withMC = self.getProp("WithMC")
        if withMC:
            if inputType in [ "MDF" ]:
                log.warning( "WithMC = True, but InputType = '%s'. Forcing WithMC = False"%inputType )
                withMC = False # Force it, MDF never contains MC truth
            if outputType in [ "RDST" ]:
                log.warning( "WithMC = True, but OutputType = '%s'. Forcing WithMC = False"%inputType )
                withMC = False # Force it, RDST never contains MC truth

        if self.getProp("WriteFSR") and self.getProp("PackType").upper() in ["MDF"]:
            if hasattr( self, "WriteFSR" ): log.warning("Don't know how to write FSR to MDF output file")
            self.setProp("WriteFSR", False)

        if self.getProp( "MergeGenFSR") and not self.getProp( "Simulation" ):
            if hasattr( self, "MergeGenFSR" ): log.warning("Cannot MergeGenFSR on real data")
            self.setProp( "MergeGenFSR", False )
                
        # Do not look for Hlt errors in data without HltDecReports bank
        if self.getProp( "DataType" ) in [ "2008", "2009" ]:
            self.setProp( "VetoHltErrorEvents", False )
        # For simulation, change the default but allow to override
        if self.getProp( "Simulation" ) and not hasattr( self, "VetoHltErrorEvents" ):
            self.setProp( "VetoHltErrorEvents", False )


        # Flag to handle or not LumiEvents
        handleLumi = inputType in ["MDF"] and not withMC and not self.getProp('UseDBSnapshot')

        # Top level configuration for skipping tracking
        if self.getProp("SkipTracking"):
            if inputType in ["MDF", "DIGI" ]:
                raise RuntimeError( "Cannot skip tracking if tracks not present on the input file" )
            if withMC:
                raise RuntimeError( "SkipTracking not (yet) supported for simulation input" )
            if( self.getProp("DataType") is "Upgrade"):
                raise RuntimeError( "SkipTracking not (yet) supported for Upgrade configurations" )
            ApplicationMgr().ExtSvc += [ "DataOnDemandSvc" ] # to decode the tracks from the DST
            DstConf().setProp("EnableUnpack", ["Tracking"] )

        # veto Hlt Error Events
        vetoHltErrorEvents = self.getProp("VetoHltErrorEvents")

        self.configureSequences( withMC, handleLumi, vetoHltErrorEvents )

        self.configureInit( inputType )

        self.configureInput( inputType )

        self.configureOutput( outputType, withMC, handleLumi )

        if withMC:
            # Create associators for checking and for DST
            from Configurables import ProcessPhase
            ProcessPhase("MCLinks").DetectorList += self.getProp("MCLinksSequence")
            # Unpack Sim data
            GaudiSequencer("MCLinksUnpackSeq").Members += [ "UnpackMCParticle"]

            # particle gun uses MCVertex to fake a reconstructed one
            # unpacking again would lead to crash
            if "pGun" not in self.getProp("SpecialData"):
                GaudiSequencer("MCLinksUnpackSeq").Members += [ "UnpackMCVertex" ]
            else:
                # Cannot run trigger on pGun events...
                L0Conf().EnsureKnownTCK=False
            
            GaudiSequencer("MCLinksTrSeq").Members += [ "TrackAssociator" ]
            GaudiSequencer("MCLinksCaloSeq").Members += [ "CaloDigit2MCLinks2Table", "CaloClusterMCTruth", "CaloHypoMCTruth" ]

            # activate all configured checking (uses MC truth)
            self.configureCheck( histOpt == "Expert" )

            # data on demand needed to pack RichDigitSummary for DST, when reading unpacked DIGI
            # Also needed to unpack MCHit containers when expert checking enabled
            ApplicationMgr().ExtSvc += [ "DataOnDemandSvc" ]

        # ROOT persistency for histograms
        ApplicationMgr().HistogramPersistency = "ROOT"
        from Configurables import RootHistCnv__PersSvc
        RootHistCnv__PersSvc('RootHistCnv').ForceAlphaIds = True

        if histOpt == "None" or histOpt == "":
            # HistogramPersistency still needed to read in CaloPID DLLs.
            # so do not set ApplicationMgr().HistogramPersistency = "NONE"
            return

        # Pass expert checking option to RecSys and RecMoni
        if histOpt == "Expert":
            DstConf().EnablePackingChecks = True

        # Use a default histogram file name if not already set
        if not HistogramPersistencySvc().isPropertySet( "OutputFile" ):
            histosName   = self.getProp("DatasetName")
            if histosName == "": histosName = "Brunel"
            if self.getProp( "RecL0Only" ): histosName += '-L0Yes'
            if (self.evtMax() > 0): histosName += '-' + str(self.evtMax()) + 'ev'
            if histOpt == "Expert": histosName += '-expert'
            histosName += '-histos.root'
            HistogramPersistencySvc().OutputFile = histosName
            
        #reconfigure decoders to point to default location, if required!
        if DecodeRawEvent().isPropertySet("OverrideInputs") and DecodeRawEvent().getProp("OverrideInputs") is not None:
            #do nothing, it's been configured by someone else!
            pass
        elif self.isPropertySet("SplitRawEventInput") and self.getProp("SplitRawEventInput") is not None:
            #print "WAAAAH Overriding RawEvent Locations"
            DecodeRawEvent().setProp("OverrideInputs",self.getProp("SplitRawEventInput"))
        elif inputType in [ "MDF", "DIGI", "XDIGI" ]:
            #set to the default of what comes out of Moore
            DecodeRawEvent().setProp("OverrideInputs","Moore")
        #remember that the default is a long list of locations,
        #starting with places which only exist _after_ brunel has run!

        # Following needed to build RecSummary, even if tracking is skipped.
        if self.getProp("SkipTracking"):
            from TrackSys import RecoTracking
            RecoTracking.DecodeTracking(["FastVelo"])
예제 #8
0
    def configureSequences(self, withMC, handleLumi, vetoHltErrorEvents):
        brunelSeq = GaudiSequencer("BrunelSequencer")
        brunelSeq.Context = self.getProp("Context")
        ApplicationMgr().TopAlg += [ brunelSeq ]
        brunelSeq.Members += [ "ProcessPhase/Init" ]
        physicsSeq = GaudiSequencer( "PhysicsSeq" )

        # Treatment of luminosity events
        if handleLumi:
            lumiSeq = GaudiSequencer("LumiSeq")

            # Prepare the FSR
            if self.getProp("WriteFSR"):
                self.setOtherProps(LumiAlgsConf(),["Context","DataType","InputType","Simulation"])
                lumiCounters = GaudiSequencer("LumiCounters")
                lumiSeq.Members += [ lumiCounters ]
                LumiAlgsConf().LumiSequencer = lumiCounters

            # Trigger masks changed in 2016, see LHCBPS-1486
            if self.getProp( "DataType" ) in self.Run1DataTypes or self.getProp( "DataType" ) in [ "2015" ]:
                physFilterRequireMask = [ 0x0, 0x4, 0x0 ]
                lumiFilterRequireMask = [ 0x0, 0x2, 0x0 ]
            else:
                physFilterRequireMask = [ 0x0, 0x0, 0x80000000 ]
                lumiFilterRequireMask = [ 0x0, 0x0, 0x40000000 ]

            # Filter out Lumi only triggers from further processing, but still write to output
            from Configurables import HltRoutingBitsFilter
            physFilter = HltRoutingBitsFilter( "PhysFilter", RequireMask = physFilterRequireMask )
            physicsSeq.Members += [ physFilter ]
            lumiFilter = HltRoutingBitsFilter( "LumiFilter", RequireMask = lumiFilterRequireMask )
            lumiSeq.Members += [ lumiFilter, physFilter ]
            lumiSeq.ModeOR = True

            # Sequence to be executed if physics sequence not called (nano events)
            notPhysSeq = GaudiSequencer("NotPhysicsSeq")
            notPhysSeq.ModeOR = True
            notPhysSeq.Members = [ physFilter ]

            brunelSeq.Members += [ lumiSeq, notPhysSeq ]
            
        # Hlt decreports decoders
        from DAQSys.Decoders import DecoderDB
        from Configurables import LoKi__HDRFilter, AddToProcStatus
        hltStages = ('Hlt1',) if self.getProp('OnlineMode') else ('Hlt1', 'Hlt2')
        hltDecoders = []
        hltErrorFilters = []
        hltFilters = []
        for stage in hltStages:
            decoder = DecoderDB["HltDecReportsDecoder/%sDecReportsDecoder" % stage].setup()
            hltDecoders += [decoder]            # decode DecReports
            # identifies events that are not of type ErrorEvent
            errorFilterCode = "HLT_PASS_RE('%s(?!ErrorEvent).*Decision')" % stage
            hltErrorFilter = LoKi__HDRFilter('%sErrorFilter' % stage, Code = errorFilterCode, Location = decoder.OutputHltDecReportsLocation)
            hltErrorFilters += [decoder, hltErrorFilter] # and apply filter
            
            filterCode = self.getProp(stage + "FilterCode")
            if filterCode:
                hltFilter = LoKi__HDRFilter('%sFilter' % stage, Code = filterCode, Location = decoder.OutputHltDecReportsLocation)
                hltFilters += [decoder, hltFilter]

        # Do not process events flagged as error in Hlt, but still write procstatus
        if vetoHltErrorEvents:
            """
            By Patrick Koppenburg, 16/6/2011
            """
            # Make a sequence that selects HltErrorEvents
            hltErrorFilterSeq = GaudiSequencer("HltErrorFilterSeq")
            if handleLumi: hltErrorFilterSeq.Members = [ physFilter ]       # protect against lumi (that doesn't have decreports)
            hltErrorFilterSeq.Members += hltErrorFilters

            # Sequence to be executed if HltErrorFilter is failing to set ProcStatus
            hltErrorSeq = GaudiSequencer("HltErrorSeq", ModeOR = True, ShortCircuit = True) # anti-logic
            addToProc = AddToProcStatus("HltErrorProc", Reason = "HltError", Subsystem = "Hlt") # write a procstatus
            hltErrorSeq.Members += [hltErrorFilterSeq, addToProc]      # only run if hltErrorFilterSeq fails
            brunelSeq.Members   += [hltErrorSeq]                       # add this sequece to Brunel _before_ physseq
            physicsSeq.Members  += [hltErrorFilterSeq]                 # take good events in physics seq

        # Filter events based on HLT decisions if filters were specified
        if hltFilters:
            hltFilterSeq = GaudiSequencer("HltFilterSeq")
            hltFilterSeq.Members = hltFilters
            physicsSeq.Members += [hltFilterSeq]

        # Convert Calo ReadoutStatus to ProcStatus
        caloBanks=GaudiSequencer("CaloBanksHandler")
        caloDetectors = [det for det in ['Spd','Prs','Ecal','Hcal'] if det in self.getProp("Detectors")]
        CaloDigitConf(ReadoutStatusConvert=True,Sequence=caloBanks,Detectors=caloDetectors)
        physicsSeq.Members += [caloBanks]
        
        # Decode L0 (and HLT if not already done)
        trgSeq = GaudiSequencer("DecodeTriggerSeq")
        l0TrgSeq = GaudiSequencer("L0TriggerSeq")
        if self.getProp( "DataType" ) not in [ "2008", "2009" ]:
            trgSeq.Members += hltDecoders
        trgSeq.Members += [ l0TrgSeq ]
        physicsSeq.Members += [ trgSeq ]
        L0Conf().L0Sequencer = l0TrgSeq
        if self.getProp("RecL0Only"):
            # Setup L0 filtering if requested, runs L0 before Reco
            L0Conf().FilterL0FromRaw = True
            self.setOtherProps( L0Conf(), ["DataType"] )
        else:
            L0Conf().DecodeL0DU = True

        if not self.isPropertySet("MainSequence"):
            if withMC:
                mainSeq = self.DefaultMCSequence
            else:
                mainSeq = self.DefaultSequence
            self.MainSequence = mainSeq
        physicsSeq.Members += self.getProp("MainSequence")
        from Configurables import ProcessPhase
        outputPhase = ProcessPhase("Output")
        brunelSeq.Members  += [ physicsSeq ]
        brunelSeq.Members  += [ outputPhase ]
예제 #9
0
    def enableTAE(self):
        """
        switch to generate Time Alignment events (only Prev1 for now).
        """
        from GaudiKernel.SystemOfUnits import ns

        taeSlots = []
        mainSeq = GaudiSequencer("BooleSequencer").Members

        taePrev = self.getProp("TAEPrev")
        while taePrev > 0:
            digi = mainSeq.index("ProcessPhase/Digi")
            taePhase = ProcessPhase("DigiPrev%s" % taePrev)
            taePhase.RootInTES = "Prev%s/" % taePrev
            mainSeq.insert(digi, taePhase)
            taeSlots.append("Prev%s" % taePrev)
            taePrev -= 1

        taeNext = self.getProp("TAENext")
        while taeNext > 0:
            digi = mainSeq.index("ProcessPhase/Digi")
            taePhase = ProcessPhase("DigiNext%s" % taeNext)
            taePhase.RootInTES = "Next%s/" % taeNext
            mainSeq.insert(digi + 1, taePhase)
            taeSlots.append("Next%s" % taeNext)
            taeNext -= 1
        GaudiSequencer("BooleSequencer").Members = mainSeq

        for taeSlot in taeSlots:
            taePhase = ProcessPhase("Digi%s" % taeSlot)
            taeDets = self.getProp("TAESubdets")
            taePhase.DetectorList = ["Init"] + taeDets
            from Configurables import BooleInit
            slotInit = BooleInit("Init%s" % taeSlot, RootInTES="%s/" % taeSlot)
            GaudiSequencer("Digi%sInitSeq" % taeSlot).Members = [slotInit]
            if "Velo" in taeDets:
                self.configureDigiVelo(
                    GaudiSequencer("Digi%sVeloSeq" % taeSlot), taeSlot)
            if "VeloPix" in taeDets:
                self.configureDigiVeloPix(
                    GaudiSequencer("Digi%sVeloPixSeq" % taeSlot), taeSlot)
            if "TT" in taeDets:
                self.configureDigiST(GaudiSequencer("Digi%sTTSeq" % taeSlot),
                                     "TT", taeSlot)
            if "IT" in taeDets:
                self.configureDigiST(GaudiSequencer("Digi%sITSeq" % taeSlot),
                                     "IT", taeSlot)
            if "OT" in taeDets:
                self.configureDigiOT(GaudiSequencer("Digi%sOTSeq" % taeSlot),
                                     taeSlot)
            if "Rich" in taeDets:
                self.configureDigiRich(
                    GaudiSequencer("Digi%sRichSeq" % taeSlot), taeSlot)
            if "Calo" in taeDets:
                self.configureDigiCalo(
                    GaudiSequencer("Digi%sCaloSeq" % taeSlot), taeSlot)
            if "Muon" in taeDets:
                self.configureDigiMuon(
                    GaudiSequencer("Digi%sMuonSeq" % taeSlot), taeSlot)
            if "L0" in taeDets:
                self.configureDigiL0(GaudiSequencer("Digi%sL0Seq" % taeSlot),
                                     taeSlot)
예제 #10
0
STOfflineConf.DefaultConf().configureTools()

# Create the top level Conf object and set some general options from DV
rConf = RecSysConf("RecSysConf")
DaVinci().setOtherProps(rConf, ["Simulation", "DataType"])

# Only run PID + Protoparticles
rConf.RecoSequence = ["CALO", "PROTO"]
rConf.SkipTracking = True
PhysConf().CaloReProcessing = True

# list of algs to prepend to DV
palgs = []

# Create the Reco process phase
reco = ProcessPhase("Reco")
palgs += [reco]

# Re-pack the new CALO output
from Configurables import CaloDstPackConf
caloPackSeq = GaudiSequencer("CaloPacking")
caloPack = CaloDstPackConf(Enable=True)
caloPack.Sequence = caloPackSeq
caloPack.AlwaysCreate = True
caloPack.EnableChecks = False
caloPack.ClearRegistry = False
palgs += [caloPackSeq]

# Pack the new ProtoParticles
from Configurables import PackProtoParticle
packChargedPs = PackProtoParticle(name="PackChargedProtos",
예제 #11
0
def RecoTrackingHLT2(exclude=[],
                     simplifiedGeometryFit=True,
                     liteClustersFit=True):
    '''Function that defines the pattern recognition algorithms for the HLT2 sequence of the Run 2 offline tracking'''

    ## Tracking sequence
    from Configurables import ProcessPhase
    track = ProcessPhase("TrackHLT2")
    GaudiSequencer("RecoTrHLT2Seq").Members += [track]

    tracklists = []

    # Which algs to run ?
    trackAlgs = TrackSys().getProp("TrackPatRecAlgorithms")

    # Which data type is it?
    dataType = TrackSys().getProp("DataType")

    ## Forward pattern
    if "ForwardHLT2" in trackAlgs:
        track.DetectorList += ["ForwardPatHLT2"]
        # Need to filter out the Velo tracks of the fitted HLT1 tracks
        #from Configurables import TrackListRefiner, TrackSelector
        #refiner = TrackListRefiner("FilterForwardHLT1Tracks")
        #refiner.inputLocation = "Rec/Track/FittedHLT1Tracks"
        #refiner.outputLocation = "Rec/Track/FittedHLT1ForwardTracks"
        #refiner.Selector = "TrackSelector"
        #refiner.addTool(TrackSelector("TrackSelector"))
        #refiner.TrackSelector.TrackTypes = [ "Long" ]
        #GaudiSequencer("TrackHLT2ForwardPatHLT2Seq").Members +=  [ refiner ]

        from Configurables import PatForward
        GaudiSequencer("TrackHLT2ForwardPatHLT2Seq").Members += [
            PatForward("PatForwardHLT2")
        ]
        from PatAlgorithms import PatAlgConf
        PatAlgConf.ForwardConf().configureAlgRun2HLT2()
        if TrackSys().timing():
            PatForward("PatForwardHLT2").TimingMeasurement = True
            #tracklists += ["Rec/Track/ForwardHLT2"]

        #merge forward from HLT1 and HLT2
        from Configurables import TrackContainerCopy
        merger = TrackContainerCopy("MergeForwardHLT1HLT2")
        merger.inputLocations = [
            "Rec/Track/FittedHLT1ForwardTracks", "Rec/Track/ForwardHLT2"
        ]
        merger.outputLocation = "Rec/Track/Forward"
        merger.copyFailures = True
        GaudiSequencer("TrackHLT2ForwardPatHLT2Seq").Members += [merger]
        tracklists += ["Rec/Track/Forward"]

    ## Seed pattern
    if "PatSeed" in trackAlgs:
        track.DetectorList += ["SeedPat"]
        from Configurables import PatSeeding
        GaudiSequencer("TrackHLT2SeedPatSeq").Members += [
            PatSeeding("PatSeeding")
        ]
        # should be replaced by more 'global' tracking configuration
        from PatAlgorithms import PatAlgConf
        PatAlgConf.SeedingConf().configureAlg()

        if TrackSys().timing():
            PatSeeding("PatSeeding").TimingMeasurement = True

        if TrackSys().cosmics():
            from PatAlgorithms import PatAlgConf
            PatAlgConf.CosmicConf().configureAlg()

        tracklists += ["Rec/Track/Seed"]

    ## Matching
    if "PatMatch" in trackAlgs:
        track.DetectorList += ["MatchPat"]
        from Configurables import PatMatch
        GaudiSequencer("TrackHLT2MatchPatSeq").Members += [
            PatMatch("PatMatch")
        ]
        # timing?
        # global conf?
        tracklists += ["Rec/Track/Match"]

    ## avoid running both downstream algos
    if "Downstream" in trackAlgs and "PatLongLivedTracking" in trackAlgs:
        raise RuntimeError(
            "Cannot run both PatDownstream and PatLongLivedTracking at once")

    ## Downstream
    if "Downstream" in trackAlgs:
        track.DetectorList += ["DownstreamPat"]
        from Configurables import PatDownstream
        GaudiSequencer("TrackHLT2DownstreamPatSeq").Members += [
            PatDownstream("PatDownstream")
        ]
        from PatAlgorithms import PatAlgConf
        # global conf?
        #PatAlgConf.DownstreamConf().configureAlg()
        if TrackSys().timing():
            PatDownstream("PatDownstream").TimingMeasurement = True
        tracklists += ["Rec/Track/Downstream"]

    ## PatLongLivedTracking (aka improved Downstream)
    if "PatLongLivedTracking" in trackAlgs:
        track.DetectorList += ["DownstreamPat"]
        from Configurables import PatLongLivedTracking
        GaudiSequencer("TrackHLT2DownstreamPatSeq").Members += [
            PatLongLivedTracking("PatLongLivedTracking")
        ]
        if TrackSys().timing():
            PatLongLivedTracking(
                "PatLongLivedTracking").TimingMeasurement = True
        tracklists += ["Rec/Track/Downstream"]

    fit = ProcessPhase("FitHLT2")
    GaudiSequencer("RecoTrHLT2Seq").Members += [fit]
    ### Clean clone and fit
    fit.DetectorList += ["Best"]

    # complete the list of track lists
    if "FastVelo" in trackAlgs:
        tracklists += ["Rec/Track/Velo"]

    if "VeloTT" in trackAlgs:
        tracklists += ["Rec/Track/VeloTT"]

    # create the best track creator
    # note the comment for the HLT1 forward fitter about configurations
    from TrackFitter.ConfiguredFitters import ConfiguredMasterFitter
    from Configurables import TrackBestTrackCreator, TrackMasterFitter, TrackStateInitTool

    # add and cut on the GP in the TrackBestTrackCreator
    # the variable is needed later
    addGhostProbTBTC = True

    bestTrackCreator = TrackBestTrackCreator(TracksInContainers=tracklists)
    bestTrackCreator.MaxChi2DoF = 4.0
    bestTrackCreator.addTool(TrackMasterFitter, name="Fitter")
    bestTrackCreator.DoNotRefit = True
    bestTrackCreator.addTool(TrackStateInitTool, name="StateInitTool")
    bestTrackCreator.StateInitTool.UseFastMomentumEstimate = True
    # cut on ghost prob
    bestTrackCreator.AddGhostProb = addGhostProbTBTC
    bestTrackCreator.GhostIdTool = "Run2GhostId"
    bestTrackCreator.MaxGhostProb = 0.4
    # configure its fitter and stateinittool
    ConfiguredMasterFitter(getattr(bestTrackCreator, "Fitter"),
                           SimplifiedGeometry=simplifiedGeometryFit,
                           LiteClusters=liteClustersFit,
                           MSRossiAndGreisen=True)
    if "FastVelo" in trackAlgs:
        bestTrackCreator.StateInitTool.VeloFitterName = "FastVeloFitLHCbIDs"
    # add to the sequence
    GaudiSequencer("FitHLT2BestSeq").Members += [bestTrackCreator]

    ### Change dEdx correction for simulated data
    #if TrackSys().getProp("Simulation"):
    #   from Configurables import StateDetailedBetheBlochEnergyCorrectionTool,DetailedMaterialLocator
    #   from Configurables import TrackBestTrackCreator
    #   fitter = TrackBestTrackCreator().Fitter
    #   fitter.MaterialLocator.addTool(StateDetailedBetheBlochEnergyCorrectionTool("GeneralDedxTool"))
    #   fitter.MaterialLocator.GeneralDedxTool.EnergyLossFactor = 0.76

    # Make V0
    # needs to be done after fitting, but before the extra infos
    from Configurables import TrackV0Finder
    V0 = ProcessPhase("RecV0")
    GaudiSequencer("RecoTrHLT2Seq").Members += [V0]
    V0.DetectorList += ["MakeV0"]
    ### Clean clone and fit
    trackV0Finder = TrackV0Finder("TrackV0Finder")
    GaudiSequencer("RecV0MakeV0Seq").Members += [trackV0Finder]

    #########################################################
    ##########################################################

    addExtraInfo = ProcessPhase("AddExtraInfo")
    GaudiSequencer("RecoTrHLT2Seq").Members += [addExtraInfo]

    ## Extra track information sequence
    extraInfos = TrackSys().getProp("TrackExtraInfoAlgorithms")
    if len(extraInfos) > 0:

        ## Clone finding and flagging
        if "CloneFlagging" in extraInfos:

            addExtraInfo.DetectorList += ["Clones"]

            from Configurables import TrackBuildCloneTable, TrackCloneCleaner
            #trackClones = GaudiSequencer("TrackClonesSeq")
            if TrackSys().timing():
                trackClones.MeasureTime = True
            cloneTable = TrackBuildCloneTable("FindTrackClones")
            cloneTable.maxDz = 500 * mm
            cloneTable.zStates = [0 * mm, 990 * mm, 9450 * mm]
            cloneTable.klCut = 5e3
            cloneCleaner = TrackCloneCleaner("FlagTrackClones")
            cloneCleaner.CloneCut = 5e3
            #trackClones.Members += [ cloneTable, cloneCleaner ]
            GaudiSequencer("AddExtraInfoClonesSeq").Members += [
                cloneTable, cloneCleaner
            ]

        ## Add the likelihood information
        if "TrackLikelihood" in extraInfos and ('TrackLikelihood'
                                                not in exclude):

            addExtraInfo.DetectorList += ["TrackLikelihood"]

            from Configurables import TrackAddLikelihood, TrackLikelihood
            trackAddLikelihood = TrackAddLikelihood()
            trackAddLikelihood.addTool(TrackLikelihood,
                                       name="TrackMatching_likTool")
            trackAddLikelihood.TrackMatching_likTool.otEff = 0.9
            GaudiSequencer("AddExtraInfoTrackLikelihoodSeq").Members += [
                trackAddLikelihood
            ]

        ## ghost probability using a Neural Net
        if "GhostProbability" in extraInfos and addGhostProbTBTC is False:

            addExtraInfo.DetectorList += ["GhostProb"]

            from Configurables import TrackAddNNGhostId
            nn = TrackAddNNGhostId("TrackAddNNGhostdId")
            nn.GhostIdTool = "Run2GhostId"  # to be decided
            GaudiSequencer("AddExtraInfoGhostProbSeq").Members += [nn]

    # this is very misleading (naming wise), but it will erase extra info that is put on the track by some algorithms
    # (not of the ones beforehand).
    addExtraInfo.DetectorList += ["EraseExtraInfo"]
    from Configurables import TrackEraseExtraInfo

    # erase extra info on Best tracks and on fitted Velo tracks (i.e. on everything that is saved on a DST)
    eraseExtraInfoBest = TrackEraseExtraInfo("TrackEraseExtraInfoBest")
    eraseExtraInfoFittedVelo = TrackEraseExtraInfo(
        "TrackEraseExtraInfoFittedVelo")
    eraseExtraInfoFittedVelo.InputLocation = "Rec/Track/FittedHLT1VeloTracks"

    GaudiSequencer("AddExtraInfoEraseExtraInfoSeq").Members += [
        eraseExtraInfoBest, eraseExtraInfoFittedVelo
    ]

    ## Muon alignment tracks
    ## is this still needed? Looks rather old
    if "MuonAlign" in trackAlgs:
        from Configurables import TrackEventFitter, AlignMuonRec
        track.DetectorList += ["MuonRec"]
        GaudiSequencer("TrackMuonRecSeq").Members += [
            AlignMuonRec("AlignMuonRec"),
            TrackEventFitter("MuonTrackFitter")
        ]
        importOptions("$TRACKSYSROOT/options/AlignMuonRec.opts")
        if TrackSys().fieldOff():
            AlignMuonRec("AlignMuonRec").BField = False
            importOptions("$STDOPTS/DstContentMuonAlign.opts")
예제 #12
0
def RecoTrackingHLT1(exclude=[],
                     simplifiedGeometryFit=True,
                     liteClustersFit=True):
    '''Function that defines the pattern recognition algorithms for the HLT1 sequence of the Run 2 offline tracking'''
    ## Start TransportSvc, needed by track fit
    ApplicationMgr().ExtSvc.append("TransportSvc")

    ## --------------------------------------------------------------------
    ## Pattern Recognition and Fitting
    ## --------------------------------------------------------------------

    # Which algs to run ?
    trackAlgs = TrackSys().getProp("TrackPatRecAlgorithms")

    # Which data type is it?
    dataType = TrackSys().getProp("DataType")

    # Decode the RAW banks
    ExcludedLayers = TrackSys().getProp("ExcludedLayers")
    DecodeTracking(trackAlgs, ExcludedLayers)

    from Configurables import STOfflinePosition
    IT = STOfflinePosition('ITClusterPosition')
    IT.DetType = "IT"
    TT = STOfflinePosition('TTClusterPosition')
    TT.DetType = "TT"

    from STTools import STOfflineConf
    STOfflineConf.DefaultConf().configureTools()

    ## Make sure the default extrapolator and interpolator use simplified material
    from Configurables import TrackMasterExtrapolator, TrackInterpolator, SimplifiedMaterialLocator, DetailedMaterialLocator
    if TrackSys().simplifiedGeometry() and ('SimpleGeom' not in exclude):
        TrackMasterExtrapolator().MaterialLocator = 'SimplifiedMaterialLocator'
        TrackInterpolator().addTool(TrackMasterExtrapolator(
            MaterialLocator='SimplifiedMaterialLocator'),
                                    name='Extrapolator')

    ### This configures public tools to use the new multiple scattering description without the log term
    from Configurables import StateThickMSCorrectionTool
    me = TrackMasterExtrapolator()
    me.addTool(DetailedMaterialLocator(), name="MaterialLocator")
    me.MaterialLocator.addTool(StateThickMSCorrectionTool,
                               name="StateMSCorrectionTool")
    me.MaterialLocator.StateMSCorrectionTool.UseRossiAndGreisen = True

    ti = TrackInterpolator()
    ti.addTool(me)

    from Configurables import TrackStateProvider
    tsp = TrackStateProvider()
    tsp.addTool(TrackInterpolator, name="Interpolator")
    tsp.addTool(TrackMasterExtrapolator, name="Extrapolator")
    tsp.Interpolator.addTool(TrackMasterExtrapolator, name='Extrapolator')
    if simplifiedGeometryFit or (TrackSys().simplifiedGeometry() and
                                 ('SimpleGeom' not in exclude)):
        tsp.Extrapolator.addTool(SimplifiedMaterialLocator,
                                 name="MaterialLocator")
        tsp.Interpolator.Extrapolator.addTool(SimplifiedMaterialLocator,
                                              name="MaterialLocator")
    else:
        tsp.Extrapolator.addTool(DetailedMaterialLocator,
                                 name="MaterialLocator")
        tsp.Interpolator.Extrapolator.addTool(DetailedMaterialLocator,
                                              name="MaterialLocator")
    tsp.Extrapolator.MaterialLocator.addTool(StateThickMSCorrectionTool,
                                             name="StateMSCorrectionTool")
    tsp.Extrapolator.MaterialLocator.StateMSCorrectionTool.UseRossiAndGreisen = True
    tsp.Interpolator.Extrapolator.MaterialLocator.addTool(
        StateThickMSCorrectionTool, name="StateMSCorrectionTool")
    tsp.Interpolator.Extrapolator.MaterialLocator.StateMSCorrectionTool.UseRossiAndGreisen = True
    ###

    ## Velo tracking
    ## Why is Velo not in the tracking sequence?
    if "FastVelo" in trackAlgs:
        from Configurables import FastVeloTracking
        GaudiSequencer("RecoVELOSeq").Members += [
            FastVeloTracking("FastVeloTracking")
        ]
        if TrackSys().timing():
            FastVeloTracking().TimingMeasurement = True

    ## Tracking sequence
    from Configurables import ProcessPhase
    track = ProcessPhase("TrackHLT1")
    GaudiSequencer("RecoTrHLT1Seq").Members += [track]

    from Configurables import MagneticFieldSvc
    if TrackSys().fieldOff():
        MagneticFieldSvc().ForcedSignedCurrentScaling = 0.

    if "noDrifttimes" in TrackSys().getProp("ExpertTracking"):
        from Configurables import (Tf__OTHitCreator)
        Tf__OTHitCreator("OTHitCreator").NoDriftTimes = True

    # Get the fitters
    from TrackFitter.ConfiguredFitters import ConfiguredFit, ConfiguredFitSeed, ConfiguredMasterFitter

    # Clone killer
    tracklists = []

    # Is this standard sequence?
    stdSeq = "fastSequence" not in TrackSys().getProp("ExpertTracking")

    ## Velo-TT pattern
    if "VeloTT" in trackAlgs:
        track.DetectorList += ["VeloTTPat"]
        from Configurables import PatVeloTTHybrid
        GaudiSequencer("TrackHLT1VeloTTPatSeq").Members += [
            PatVeloTTHybrid("PatVeloTTHybrid")
        ]
        from PatVeloTT import PatVeloTTAlgConf
        PatVeloTTAlgConf.PatVeloTTConf().configureAlgRun2HLT1()
        if TrackSys().timing():
            PatVeloTTHybrid("PatVeloTTHybrid").TimingMeasurement = True
        tracklists += ["Rec/Track/VeloTT"]

    ## Forward pattern
    if "ForwardHLT1" in trackAlgs:
        if "VeloTT" not in trackAlgs:
            raise RuntimeError("Cannot run HLT1 forward without VeloTT")

        track.DetectorList += ["ForwardPatHLT1"]
        from Configurables import PatForward, PatForwardTool
        GaudiSequencer("TrackHLT1ForwardPatHLT1Seq").Members += [
            PatForward("PatForwardHLT1")
        ]

        # should be replaced by more 'global' tracking configuration
        from PatAlgorithms import PatAlgConf
        PatAlgConf.ForwardConf().configureAlgRun2HLT1()
        if TrackSys().timing():
            PatForward("PatForwardHLT1").TimingMeasurement = True
        tracklists += ["Rec/Track/ForwardHLT1"]

    ## Fitting all HLT1 tracks
    track.DetectorList += ["FitHLT1"]

    from Configurables import TrackEventFitter, TrackInitFit, TrackStateInitTool, TrackStateInitAlg, TrackMasterExtrapolator, TrackMasterFitter
    from Configurables import SimplifiedMaterialLocator, DetailedMaterialLocator
    from Configurables import TrackContainerCopy

    ######
    ### Fitter for Velo tracks
    ######
    if "FastVelo" in trackAlgs:
        if "VeloForwardKalmanHLT1" in TrackSys().getProp("ExpertTracking"):
            # This is the option for the 2015 early measurements
            veloFitter = TrackEventFitter('VeloOnlyFitterAlg')
            veloFitter.TracksInContainer = "Rec/Track/Velo"
            veloFitter.TracksOutContainer = "Rec/Track/FittedHLT1VeloTracks"
            veloFitter.Fitter = "TrackInitFit/Fit"
            veloFitter.addTool(TrackInitFit, "Fit")
            veloFitter.Fit.Init = "TrackStateInitTool/VeloOnlyStateInit"
            veloFitter.Fit.addTool(TrackStateInitTool, "VeloOnlyStateInit")
            veloFitter.Fit.VeloOnlyStateInit.VeloFitterName = "FastVeloFitLHCbIDs"
            veloFitter.Fit.VeloOnlyStateInit.addTool(TrackMasterExtrapolator,
                                                     "Extrapolator")
            if (simplifiedGeometryFit):
                veloFitter.Fit.VeloOnlyStateInit.Extrapolator.addTool(
                    SimplifiedMaterialLocator, name="MaterialLocator")
            else:
                veloFitter.Fit.VeloOnlyStateInit.Extrapolator.addTool(
                    DetailedMaterialLocator, name="MaterialLocator")

            veloFitter.Fit.Fit = "TrackMasterFitter/Fit"
            veloFitter.Fit.addTool(TrackMasterFitter, name="Fit")

            from TrackFitter.ConfiguredFitters import ConfiguredForwardFitter
            ConfiguredForwardFitter(veloFitter.Fit.Fit,
                                    LiteClusters=liteClustersFit)

            GaudiSequencer("TrackHLT1FitHLT1Seq").Members += [veloFitter]

        else:
            # and this is the option for after the early measurements
            # copy tracks from pat reco output container to a new one
            copyVeloTracks = TrackContainerCopy("CopyVeloTracks")
            copyVeloTracks.inputLocations = ["Rec/Track/Velo"]
            copyVeloTracks.outputLocation = "Rec/Track/FittedHLT1VeloTracks"

            from FastVelo import FastVeloAlgConf
            stateInit = TrackStateInitAlg('VeloOnlyInitAlg')
            FastVeloAlgConf.FastVeloKalmanConf().configureFastKalmanFit(
                init=stateInit)
            GaudiSequencer("TrackHLT1FitHLT1Seq").Members += [
                copyVeloTracks, stateInit
            ]

    ######
    ### Fitter for Forward tracks
    ### Need to be careful: This is all a little fragile, so if you plan to change something, check that everything configures the way you expect
    ### The Extrapolator for the StateInitTool does not use material corrections, so don't need to explicitely add the StateThickMSCorrectionTool
    ######
    if "ForwardHLT1" in trackAlgs:
        fwdFitter = TrackEventFitter('ForwardHLT1FitterAlg')
        fwdFitter.TracksInContainer = "Rec/Track/ForwardHLT1"
        fwdFitter.TracksOutContainer = "Rec/Track/FittedHLT1ForwardTracks"
        # Keep only good tracks, this cut should be aligned with the one in the TrackBestTrackCreator
        fwdFitter.MaxChi2DoF = 4.0
        fwdFitter.Fitter = "TrackInitFit/Fit"
        fwdFitter.addTool(TrackInitFit, "Fit")
        fwdFitter.Fit.Init = "TrackStateInitTool/FwdStateInit"
        fwdFitter.Fit.addTool(TrackStateInitTool, "FwdStateInit")
        fwdFitter.Fit.FwdStateInit.addTool(TrackMasterExtrapolator,
                                           "Extrapolator")
        fwdFitter.Fit.FwdStateInit.UseFastMomentumEstimate = True
        fwdFitter.Fit.FwdStateInit.VeloFitterName = "FastVeloFitLHCbIDs"
        if (simplifiedGeometryFit):
            fwdFitter.Fit.FwdStateInit.Extrapolator.addTool(
                SimplifiedMaterialLocator, name="MaterialLocator")
        else:
            fwdFitter.Fit.FwdStateInit.Extrapolator.addTool(
                DetailedMaterialLocator, name="MaterialLocator")

        fwdFitter.Fit.Fit = "TrackMasterFitter/Fit"
        fwdFitter.Fit.addTool(TrackMasterFitter, name="Fit")

        from TrackFitter.ConfiguredFitters import ConfiguredMasterFitter
        ConfiguredMasterFitter(fwdFitter.Fit.Fit,
                               SimplifiedGeometry=simplifiedGeometryFit,
                               LiteClusters=liteClustersFit,
                               MSRossiAndGreisen=True)

        GaudiSequencer("TrackHLT1FitHLT1Seq").Members += [fwdFitter]
예제 #13
0
    def configureInit(self, tae, initDets):
        """
        Set up the initialization sequence
        """
        # Start the DataOnDemandSvc ahead of ToolSvc
        ApplicationMgr().ExtSvc += ["DataOnDemandSvc"]
        ApplicationMgr().ExtSvc += ["ToolSvc"]

        ProcessPhase("Init").DetectorList.insert(
            0, "Boole")  # Always run Boole initialisation first!
        initBoole = GaudiSequencer("InitBooleSeq")
        initBoole.Members += ["BooleInit"]

        # Kept for Dirac backward compatibility
        if self.getProp("NoWarnings"):
            log.warning(
                "Boole().NoWarnings=True property is obsolete and maintained for Dirac compatibility. Please use Boole().ProductionMode=True instead"
            )
            self.setProp("ProductionMode", True)

        # Special settings for production
        if self.getProp("ProductionMode"):
            self.setProp("OutputLevel", ERROR)
            if not LHCbApp().isPropertySet("TimeStamp"):
                LHCbApp().setProp("TimeStamp", True)

        # OutputLevel
        self.setOtherProp(LHCbApp(), "OutputLevel")
        if self.isPropertySet("OutputLevel"):
            level = self.getProp("OutputLevel")
            if level == ERROR or level == WARNING:
                # Suppress known warnings
                importOptions("$BOOLEOPTS/SuppressWarnings.opts")
                # Additional information to be kept
                getConfigurable("BooleInit").OutputLevel = INFO

        # Do not print event number at every event (done already by BooleInit)
        EventSelector().PrintFreq = -1

        # Load the spillover branches, then kill those not required to prevent further access
        spillPaths = self.getProp("SpilloverPaths")
        killPaths = []
        if len(spillPaths) == 0:
            spillPaths = self.KnownSpillPaths
            self.setProp("SpilloverPaths", spillPaths)

        if self.getProp("UseSpillover"):
            if tae:
                killPaths = self.KnownSpillPaths
            else:
                self.setOtherProp(SimConf(), "SpilloverPaths")
                # Kill any spillover paths not required
                for spill in self.KnownSpillPaths:
                    if spill not in spillPaths:
                        killPaths.append(spill)
        else:
            # Kill all spillover paths
            killPaths = self.KnownSpillPaths

        from Configurables import EventNodeKiller, TESCheck
        spillLoader = TESCheck("SpilloverLoader")
        spillLoader.Inputs = spillPaths
        spillLoader.Stop = False  # In case no spillover on input file
        spillLoader.OutputLevel = ERROR
        spillKiller = EventNodeKiller("SpilloverKiller")
        spillKiller.Nodes = killPaths
        spillHandler = GaudiSequencer("SpilloverHandler")
        spillHandler.Members += [spillLoader, spillKiller]
        spillHandler.IgnoreFilterPassed = True  # In case no spillover on input file
        initBoole.Members += [spillHandler]

        if "Muon" in initDets:
            # Muon Background
            from Configurables import MuonBackground
            GaudiSequencer("InitMuonSeq").Members += [
                MuonBackground("MuonLowEnergy")
            ]
            importOptions("$MUONBACKGROUNDROOT/options/MuonLowEnergy-G4.opts")
            if not tae:
                flatSpillover = MuonBackground("MuonFlatSpillover")
                GaudiSequencer("InitMuonSeq").Members += [flatSpillover]
                if self.getProp("DataType") == "2010":
                    flatSpillover.NBXFullFull = 344
                if self.getProp("DataType") == "2009":
                    flatSpillover.NBXFullFull = 4
                importOptions(
                    "$MUONBACKGROUNDROOT/options/MuonFlatSpillover-G4.opts")
예제 #14
0
    def applyConf(self):

        # Check the special data options
        for option in self.getProp("SpecialData"):
            if option not in self.KnownSpecialData:
                raise RuntimeError("Unknown SpecialData option '%s'"%option)
        
        # Phases
        if not self.isPropertySet("RecoSequence"):
            self.setProp("RecoSequence",self.DefaultSubDetsFieldOn)
            if self.getProp("DataType") in self.Run2DataTypes:
                self.setProp("RecoSequence",self.DefaultSubDetsFieldOnRun2)
        
        recoSeq = self.getProp("RecoSequence")
        if self.getProp("SkipTracking"):
            for det in self.DefaultTrackingSubdets:
                if det in recoSeq:
                    recoSeq.remove(det)
        from Configurables import ProcessPhase
        ProcessPhase("Reco").DetectorList += recoSeq

        # Primary Vertex and V0 finding
        if "Vertex" in recoSeq  and self.getProp("DataType") not in self.Run2DataTypes:
            from Configurables import PatPVOffline, TrackV0Finder
            pvAlg = PatPVOffline()
            if "2009" == self.getProp("DataType"):
                from PatPV import PVConf 
                PVConf.VLoosePV().configureAlg()
            elif ( "veloOpen" in self.getProp("SpecialData") or
                    "microBiasTrigger" in self.getProp("SpecialData") ):
                from PatPV import PVConf
                PVConf.LoosePV().configureAlg()
            elif ( not ( self.getProp("Simulation") and
                         self.getProp("DataType") in ["2008","2009","2010","MC09"] ) ):
                # Default setting uses beam spot constraint from DB, available from 2011. Prior to 2011 stability of beam spot is not certain
                from PatPV import PVConf
                PVConf.StandardPV().configureAlg()
                
            # MC with particle gun cannot reconstruct PV, hence need to introduce one by hand
            if "pGun" in self.getProp("SpecialData"):
                from Configurables import PGPrimaryVertex
                pgPV = PGPrimaryVertex()
                GaudiSequencer("RecoVertexSeq").Members += [ pgPV ]
            else:
                GaudiSequencer("RecoVertexSeq").Members += [ pvAlg ];
                
            trackV0Finder = TrackV0Finder()
            GaudiSequencer("RecoVertexSeq").Members += [ trackV0Finder ]

        # for Run 2, we run a different algorithm and don't want to have
        # the V0 finder in the vertex sequence (which is now after HLT1)
        if "Vertex" in recoSeq and self.getProp("DataType") in self.Run2DataTypes:
            from Configurables import PatPV3D, PVOfflineTool, LSAdaptPV3DFitter
            pvAlg = PatPV3D("PatPV3D")
            ## this should go in a configuration file when we know what to use
            pvAlg.addTool(PVOfflineTool,"PVOfflineTool")
            pvAlg.PVOfflineTool.addTool(LSAdaptPV3DFitter, "LSAdaptPV3DFitter")
            pvAlg.PVOfflineTool.PVFitterName = "LSAdaptPV3DFitter"
            pvAlg.PVOfflineTool.LSAdaptPV3DFitter.UseFittedTracks = True
            pvAlg.PVOfflineTool.LSAdaptPV3DFitter.AddMultipleScattering = False
            pvAlg.PVOfflineTool.LSAdaptPV3DFitter.TrackErrorScaleFactor = 1.0
            pvAlg.PVOfflineTool.LSAdaptPV3DFitter.MinTracks = 4
            pvAlg.PVOfflineTool.LSAdaptPV3DFitter.trackMaxChi2 = 12.0
            pvAlg.PVOfflineTool.UseBeamSpotRCut = True
            pvAlg.PVOfflineTool.BeamSpotRCut = 0.2
            pvAlg.PVOfflineTool.BeamSpotRHighMultiplicityCut = 0.4
            pvAlg.PVOfflineTool.BeamSpotRMultiplicityTreshold = 10
            pvAlg.PVOfflineTool.InputTracks = [ "Rec/Track/FittedHLT1VeloTracks" ]
            pvAlg.OutputVerticesName = "Rec/Vertex/Primary"
            pvAlg.PrimaryVertexLocation = "Rec/Vertex/PrimaryVertices"

            # Remove all tracks that don't belong to a PV (to save space on a DST)
            from Configurables import TrackContainerCleaner, SelectTrackInVertex
            pvVeloTracksCleaner = TrackContainerCleaner("PVVeloTracksCleaner")
            pvVeloTracksCleaner.inputLocation = "Rec/Track/FittedHLT1VeloTracks" 
            pvVeloTracksCleaner.selectorName = "SelectTrackInVertex"

            GaudiSequencer("RecoVertexSeq").Members += [ pvAlg, pvVeloTracksCleaner ];
            GaudiSequencer("RecoVertexSeq").IgnoreFilterPassed = True

        ## Upgrade type?
        if self.getProp("DataType") == 'Upgrade' :
             specialDataList = self.getProp("SpecialData")
             specialDataList.append("upgrade")
             self.setProp("SpecialData",specialDataList)


        # Tracking (Should make it more fine grained ??)
        DoTracking = False
        for seq in self.DefaultTrackingSubdets :
            if seq in recoSeq: DoTracking = True
        if DoTracking:
            trackConf = TrackSys()
            self.setOtherProps(trackConf,["SpecialData","OutputType"])
            trackConf.ExpertHistos = self.expertHistos()

        # RICH
        if "RICH" in recoSeq:

            # The main sequence
            seq = GaudiSequencer("RecoRICHSeq")
            
            # Create the top level Conf object 
            richConf = RichRecSysConf(self.richRecConfName)
            
            # set some general options
            self.setOtherProps(richConf,["SpecialData","Context","OutputLevel",
                                         "Simulation","DataType","OnlineMode"])
            
            # Set the sequencer the RICH reco algs should be added to
            richConf.RecoSequencer = seq

            # Input Tracks (would be better to not hard code this. Get from TrackSys() or DstConf())
            # Only set if not previously set, to allow for custom studies using non standard locations
            # set at the top level options file level
            if not richConf.trackConfig().isPropertySet("InputTracksLocation") :
                richConf.trackConfig().setProp("InputTracksLocation","Rec/Track/Best")
                
            # Output PID Location. Again allow for pre-defined custom locations.
            if not richConf.isPropertySet("RichPIDLocation") :
                richConf.setProp("RichPIDLocation","Rec/Rich/PIDs")
            
            # Printout
            import GaudiKernel.ProcessJobOptions
            GaudiKernel.ProcessJobOptions.PrintOn()
            log.debug(richConf)
            GaudiKernel.ProcessJobOptions.PrintOff()
            
        # CALO
        if "CALO" in recoSeq:
            import GaudiKernel.ProcessJobOptions            
            seq  = GaudiSequencer ( 'RecoCALOSeq' )
            caloConf=CaloProcessor(
                Context            = self.getProp('Context')       ,
                OutputLevel        = self.getProp('OutputLevel')    ,
                UseTracks          = True                           ,
                EnableOnDemand     = False                          ,
                DataType           = self.getProp ('DataType')      
                )
            GaudiKernel.ProcessJobOptions.PrintOn()
            seq.Members = [caloConf.caloSequence()]
            GaudiKernel.ProcessJobOptions.PrintOff()
            


        # MUON
        if "MUON" in recoSeq:
            from MuonID import ConfiguredMuonIDs
            from Configurables import RawBankReadoutStatusConverter,RawBankReadoutStatusFilter
            cm=ConfiguredMuonIDs.ConfiguredMuonIDs(data=self.getProp("DataType"),
                                                   specialData=self.getProp("SpecialData"))
            MuonIDSeq=cm.getMuonIDSeq()
            RawBankReadoutStatusConverter("MuonProcStatus").System="Muon"
            RawBankReadoutStatusConverter("MuonProcStatus").BankTypes=["Muon"]
            RawBankReadoutStatusFilter("MuonROFilter").BankType=13
            RawBankReadoutStatusFilter("MuonROFilter").RejectionMask=2067            
            GaudiSequencer("RecoMUONSeq").Members += [ "MuonRec",
                                                       "RawBankReadoutStatusConverter/MuonProcStatus", 
                                                       "RawBankReadoutStatusFilter/MuonROFilter",  MuonIDSeq ]
           
      
        # PROTO
        if "PROTO" in recoSeq:
            self.setOtherProps(GlobalRecoConf(),["DataType","SpecialData",
                                                 "Context","OutputLevel"])
            GlobalRecoConf().RecoSequencer = GaudiSequencer("RecoPROTOSeq")
            

        # SUMMARY
        if "SUMMARY" in recoSeq:
            from Configurables import RecSummaryAlg
            summary = RecSummaryAlg("RecSummary")
            # make a new list of uppered detectors
            dets = []
            for det in self.getProp("Detectors"):
                dets.append(det.upper())
            summary.Detectors = dets 
            GaudiSequencer("RecoSUMMARYSeq").Members += [summary]
예제 #15
0
    def configureOutput(self, dstType, withMC, handleLumi):
        """
        Set up output stream
        """

        # Merge genFSRs
        if self.getProp("WriteFSR"):
            if self.getProp("MergeGenFSR"):
                GaudiSequencer("OutputDSTSeq").Members += ["GenFSRMerge"]
                                                                                                                                              
        if dstType in [ "XDST", "DST", "LDST", "RDST" ]:
            writerName = "DstWriter"
            packType  = self.getProp( "PackType" )

            # event output
            dstWriter = OutputStream( writerName )
            dstWriter.AcceptAlgs += ["Reco"] # Write only if Rec phase completed
            if handleLumi and self.getProp( "WriteLumi" ):
                dstWriter.AcceptAlgs += ["LumiSeq"] # Write also if Lumi sequence completed
            # set verbosity
            if self.getProp( "ProductionMode" ):
                if not dstWriter.isPropertySet( "OutputLevel" ):
                    dstWriter.OutputLevel = INFO
                if self.getProp("WriteFSR"):
                    FSRWriter = RecordStream( "FSROutputStreamDstWriter")
                    if not FSRWriter.isPropertySet( "OutputLevel" ):
                        FSRWriter.OutputLevel = INFO
            # Suppress spurious error when reading POOL files without run records
            if self.getProp("WriteFSR"):
                if self.getProp( "InputType" ).upper() not in [ "MDF" ]:
                    from Configurables import FileRecordDataSvc
                    FileRecordDataSvc().OutputLevel = FATAL

            if dstType == "XDST":
                # Allow multiple files open at once (SIM,DST,DIGI etc.)
                IODataManager().AgeLimit += 1

            if dstType in ["DST","XDST","LDST"] and packType not in ["MDF"]:
                jseq=GaudiSequencer("RawEventSplitSeq")
                #################################
                # Split the Raw Event for the DST
                # Use the RawEventJuggler.
                # Not delegated to DSTConf.
                # Some information must be shared with DSTConf
                #################################
                juggler=RawEventJuggler()
                juggler.Sequencer=jseq
                dstseq=GaudiSequencer("OutputDSTSeq")
                dstseq.Members.append(jseq)
                # Set the output version if not already overwritten
                if juggler.isPropertySet("Output") and juggler.getProp("Output") is not None:
                    #it's already set
                    pass
                else:
                    juggler.setProp("Output",self.getProp("SplitRawEventOutput"))
                #set the input version, could come from several places
                if self.isPropertySet("SplitRawEventInput") and self.getProp("SplitRawEventInput") is not None:
                    #if set, take it from Brunel()
                    juggler.setProp("Input",self.getProp("SplitRawEventInput"))
                    #otherwise use the setting of the juggler if it is set
                elif juggler.isPropertySet("Input") and juggler.getProp("Input") is not None:
                    pass
                    #else find it from DecodeRawEvent
                elif DecodeRawEvent().isPropertySet("OverrideInputs") and DecodeRawEvent().getProp("OverrideInputs") is not None:
                    juggler.setProp("Input",DecodeRawEvent().getProp("OverrideInputs"))
                    #else if I'm input with a DST, assume it is a Stripping20 type
                elif self._isReprocessing(self.getProp("InputType")):
                    juggler.setProp("Input",2.0)
                else:
                    #or set the default to whatever comes out of Moore by default
                    juggler.setProp("Input","Moore")
                
                #share information from the Juggler with DSTConf
                #always write out to where the Juggler asked!    
                DstConf().setProp("SplitRawEventOutput", juggler.getProp("Output"))
                #or else the default in the juggler is used, should be 0.0
                #TODO, handle the turned off Calo, shouldn't actually be a problem...
                from RawEventCompat.Configuration import _checkv
                from Configurables import RawEventFormatConf
                RawEventFormatConf().loadIfRequired()
                if juggler.getProp("Input")!=juggler.getProp("Output"):
                    if (juggler.getProp("Input") is None or juggler.getProp("Output")) is None or (_checkv(juggler.getProp("Input")))!=(_checkv(juggler.getProp("Output"))):
                        juggler.KillExtraBanks=True
                        juggler.KillExtraNodes=True
                        #really kill /Event/DAQ to prevent it re-appearing!
                        juggler.KillExtraDirectories=True
            
            from Configurables import TrackToDST

            # Filter Best Track States to be written
            trackFilter = TrackToDST("FilterBestTrackStates")
            from Configurables import ProcessPhase
            ProcessPhase("Output").DetectorList += [ "DST" ]
            GaudiSequencer("OutputDSTSeq").Members += [ trackFilter ]
            
            ### For Run 2, filter the fitted Velo tracks for PV
            if( self.getProp("DataType") in self.Run2DataTypes ):
                fittedVeloTracksFilter = TrackToDST("FilterFittedVeloTrackStates", veloStates = ["ClosestToBeam"])
                fittedVeloTracksFilter.TracksInContainer = "Rec/Track/FittedHLT1VeloTracks"
                GaudiSequencer("OutputDSTSeq").Members += [ fittedVeloTracksFilter ]
           
            if "Muon" in self.getProp("Detectors"):
                # Filter Muon Track States            
                muonTrackFilter = TrackToDST("FilterMuonTrackStates")
                muonTrackFilter.TracksInContainer = "/Event/Rec/Track/Muon"
                GaudiSequencer("OutputDSTSeq").Members += [ muonTrackFilter ]


            if packType != "NONE":
                # Add the sequence to pack the DST containers
                packSeq = GaudiSequencer("PackDST")
                DstConf().PackSequencer = packSeq
                DstConf().AlwaysCreate  = True
                GaudiSequencer("OutputDSTSeq").Members += [ packSeq ]
                # Run the packers also on Lumi only events to write empty containers
                if handleLumi and self.getProp( "WriteLumi" ):
                    notPhysSeq = GaudiSequencer("NotPhysicsSeq")
                    notPhysSeq.Members += [ packSeq ]

            # Define the file content
            DstConf().Writer     = writerName
            DstConf().DstType    = dstType
            DstConf().PackType   = packType
            #In case we didn't juggle the raw event,
            #We should write out the same as the input type!
            if not DstConf().isPropertySet("SplitRawEventOutput"):
                if self.isPropertySet("SplitRawEventInput") and self.getProp("SplitRawEventInput") is not None:
                    DstConf().setProp("SplitRawEventOutput",self.getProp("SplitRawEventInput"))
                elif DecodeRawEvent().isPropertySet("OverrideInputs") and DecodeRawEvent().getProp("OverrideInputs") is not None:
                    DstConf().setProp("SplitRawEventOutput",DecodeRawEvent().getProp("SplitRawEventInput"))
            
            if withMC:
                DstConf().SimType = "Full"
            elif self.getProp("DigiType").capitalize() == "Minimal":
                from Configurables import PackMCVertex
                GaudiSequencer("OutputDSTSeq").Members += [PackMCVertex()]
                DstConf().SimType = "Minimal"
            DstConf().OutputName = self.outputName()
            self.setOtherProps(DstConf(),["DataType","WriteFSR"])
예제 #16
0
from Configurables import (ProcessPhase, GaudiSequencer, RecSysConf)

RecSysConf()

appConf = ApplicationMgr()
# Set main sequence
brunelSeq = GaudiSequencer("BrunelSequencer")
appConf.TopAlg = [brunelSeq]
brunelSeq.Members += ["ProcessPhase/Init", "ProcessPhase/Reco"]
ProcessPhase("Init").DetectorList += ["Brunel", "Calo"]
예제 #17
0
def RecoTracking(exclude=[]):
    '''What used to be in the options file, moved here'''
    ## Start TransportSvc, needed by track fit
    ApplicationMgr().ExtSvc.append("TransportSvc")

    ## --------------------------------------------------------------------
    ## Pattern Recognition and Fitting
    ## --------------------------------------------------------------------

    # Which algs to run ?
    trackAlgs = TrackSys().getProp("TrackPatRecAlgorithms")

    # Which data type is it?
    dataType = TrackSys().getProp("DataType")

    # Decode the RAW banks
    DecodeTracking(trackAlgs)

    from Configurables import STOfflinePosition
    IT = STOfflinePosition('ITClusterPosition')
    IT.DetType = "IT"
    TT = STOfflinePosition('TTClusterPosition')
    TT.DetType = "TT"

    from STTools import STOfflineConf
    STOfflineConf.DefaultConf().configureTools()

    #importOptions( "$STTOOLSROOT/options/Brunel.opts" )

    ## Velo tracking
    if "FastVelo" in trackAlgs:
        from Configurables import FastVeloTracking
        GaudiSequencer("RecoVELOSeq").Members += [FastVeloTracking()]
        if TrackSys().timing():
            FastVeloTracking().TimingMeasurement = True

    if "Velo" in trackAlgs:
        from Configurables import Tf__PatVeloGeneralTracking
        if TrackSys().veloOpen():
            if TrackSys().beamGas():
                from Configurables import Tf__PatVeloGeneric
                GaudiSequencer("RecoVELOSeq").Members += [
                    Tf__PatVeloGeneric("PatVeloGeneric"),
                    Tf__PatVeloGeneralTracking("PatVeloGeneralTracking")
                ]
            else:
                from Configurables import Tf__PatVeloTrackTool
                GaudiSequencer("RecoVELOSeq").Members += [
                    Tf__PatVeloGeneralTracking("PatVeloGeneralTracking")
                ]
                Tf__PatVeloGeneralTracking(
                    "PatVeloGeneralTracking").PointErrorMin = 2 * mm
                Tf__PatVeloGeneralTracking("PatVeloGeneralTracking").addTool(
                    Tf__PatVeloTrackTool("PatVeloTrackTool"))
                Tf__PatVeloTrackTool("PatVeloTrackTool").highChargeFract = 0.5
                if TrackSys().timing():
                    Tf__PatVeloGeneralTracking(
                        "PatVeloGeneralTracking").TimingMeasurement = True
        else:
            from Configurables import (Tf__PatVeloRTracking,
                                       Tf__PatVeloSpaceTool,
                                       Tf__PatVeloSpaceTracking)
            GaudiSequencer("RecoVELOSeq").Members += [
                Tf__PatVeloRTracking("PatVeloRTracking"),
                Tf__PatVeloSpaceTracking("PatVeloSpaceTracking"),
                Tf__PatVeloGeneralTracking("PatVeloGeneralTracking")
            ]
            Tf__PatVeloSpaceTracking("PatVeloSpaceTracking").addTool(
                Tf__PatVeloSpaceTool(), name="PatVeloSpaceTool")
            Tf__PatVeloSpaceTracking("PatVeloSpaceTracking"
                                     ).PatVeloSpaceTool.MarkClustersUsed = True
            if TrackSys().timing():
                Tf__PatVeloSpaceTracking(
                    "PatVeloSpaceTracking").TimingMeasurement = True
                Tf__PatVeloRTracking(
                    "PatVeloRTracking").TimingMeasurement = True
                Tf__PatVeloGeneralTracking(
                    "PatVeloGeneralTracking").TimingMeasurement = True

    ## Make sure the default extrapolator and interpolator use simplified material
    if TrackSys().simplifiedGeometry() and ('SimpleGeom' not in exclude):
        from Configurables import TrackMasterExtrapolator, TrackInterpolator
        TrackMasterExtrapolator().MaterialLocator = 'SimplifiedMaterialLocator'
        TrackInterpolator().addTool(TrackMasterExtrapolator(
            MaterialLocator='SimplifiedMaterialLocator'),
                                    name='Extrapolator')

    ## Tracking sequence
    from Configurables import ProcessPhase
    track = ProcessPhase("Track")
    GaudiSequencer("RecoTrSeq").Members += [track]

    from Configurables import MagneticFieldSvc
    if TrackSys().fieldOff():
        MagneticFieldSvc().ForcedSignedCurrentScaling = 0.

    if "noDrifttimes" in TrackSys().getProp("ExpertTracking"):
        from Configurables import (Tf__OTHitCreator)
        Tf__OTHitCreator("OTHitCreator").NoDriftTimes = True

    # Get the fitters
    from TrackFitter.ConfiguredFitters import ConfiguredFit, ConfiguredFitSeed, ConfiguredMasterFitter

    # Clone killer
    tracklists = []

    # Is this standard sequence?
    stdSeq = "fastSequence" not in TrackSys().getProp("ExpertTracking")

    # TrackMatching not supported anymore, raise error
    if "Match" in trackAlgs:
        raise RuntimeError(
            "TrackMatching not supported anymore. If you think this is wrong, report to [email protected]"
        )

    ## Forward pattern
    if "Forward" in trackAlgs:
        track.DetectorList += ["ForwardPat"]
        from Configurables import PatForward
        GaudiSequencer("TrackForwardPatSeq").Members += [
            PatForward("PatForward")
        ]
        from PatAlgorithms import PatAlgConf
        PatAlgConf.ForwardConf().configureAlg()
        if TrackSys().timing():
            PatForward("PatForward").TimingMeasurement = True
        tracklists += ["Rec/Track/Forward"]

    ## Seed pattern
    if "TsaSeed" in trackAlgs and "PatSeed" in trackAlgs:
        raise RuntimeError("Cannot run both Tsa and Pat Seeding at once")

    if "TsaSeed" in trackAlgs:
        track.DetectorList += ["SeedPat"]
        from Configurables import Tf__Tsa__Seed, Tf__Tsa__SeedTrackCnv
        GaudiSequencer("TrackSeedPatSeq").Members += [
            Tf__Tsa__Seed("TsaSeed"),
            Tf__Tsa__SeedTrackCnv("TsaSeedTrackCnv")
        ]
        from TsaAlgorithms import TsaAlgConf
        TsaAlgConf.TsaSeedConf().configureAlg()
        if TrackSys().timing():
            Tf__Tsa__Seed("TsaSeed").TimingMeasurement = True

    if "PatSeed" in trackAlgs:
        track.DetectorList += ["SeedPat"]
        from Configurables import PatSeeding
        GaudiSequencer("TrackSeedPatSeq").Members += [PatSeeding("PatSeeding")]
        from PatAlgorithms import PatAlgConf
        PatAlgConf.SeedingConf().configureAlg()

        if TrackSys().timing():
            PatSeeding("PatSeeding").TimingMeasurement = True

        if TrackSys().cosmics():
            from PatAlgorithms import PatAlgConf
            PatAlgConf.CosmicConf().configureAlg()

    if "TsaSeed" in trackAlgs or "PatSeed" in trackAlgs:
        tracklists += ["Rec/Track/Seed"]
        # TrackMatching not supported anymore, comment for the moment in case anything breaks
        #if "Match" in trackAlgs :
        # Fit now
        #track.DetectorList += [ "SeedFit" ]
        ## Seed fit initialization
        #from Configurables import TrackStateInitAlg, TrackStateInitTool
        #initSeedFit = TrackStateInitAlg("InitSeedFit",
        #                                TrackLocation = "Rec/Track/Seed")
        #GaudiSequencer("TrackSeedFitSeq").Members += [initSeedFit]
        #if "FastVelo" in trackAlgs :
        #   initSeedFit.StateInitTool.VeloFitterName = "FastVeloFitLHCbIDs"
        # Use small ErrorQoP fitter, needed for Match
        #GaudiSequencer("TrackSeedFitSeq").Members += [ConfiguredFitSeed()]

    # TrackMatching not supported anymore, comment for the moment in case anything breaks
    ## Match
    #if "Match" in trackAlgs and "PatMatch" in trackAlgs :
    #   raise RuntimeError("Cannot run both TrackMatching and PatMatch at once")
    #if "Match" in trackAlgs :
    #   track.DetectorList += [ "MatchPat" ]
    #   from Configurables import TrackMatchVeloSeed
    #   GaudiSequencer("TrackMatchPatSeq").Members += [ TrackMatchVeloSeed("TrackMatch") ]
    #   from TrackMatching import TrackMatchConf
    #   TrackMatchConf.MatchingConf().configureAlg()
    #   TrackMatchVeloSeed("TrackMatch").LikCut = -99999.
    #   if TrackSys().timing() :
    #      TrackMatchVeloSeed("TrackMatch").TimingMeasurement = True;

    if "PatMatch" in trackAlgs:
        track.DetectorList += ["MatchPat"]
        from Configurables import PatMatch
        GaudiSequencer("TrackMatchPatSeq").Members += [PatMatch("PatMatch")]
    if "Match" in trackAlgs or "PatMatch" in trackAlgs:
        tracklists += ["Rec/Track/Match"]

    ## Downstream
    if "Downstream" in trackAlgs:
        track.DetectorList += ["DownstreamPat"]
        from Configurables import PatDownstream
        GaudiSequencer("TrackDownstreamPatSeq").Members += [PatDownstream()]
        tracklists += ["Rec/Track/Downstream"]
        from PatAlgorithms import PatAlgConf
        #PatAlgConf.DownstreamConf().configureAlg()
        if TrackSys().timing():
            PatDownstream("PatDownstream").TimingMeasurement = True

    ## Velo-TT pattern
    if "VeloTT" in trackAlgs:
        track.DetectorList += ["VeloTTPat"]
        # from 2015 on, 'VeloTTHybrid' is used (as in the HLT)
        # on python configuration is used
        if dataType is "2015":
            from Configurables import PatVeloTTHybrid
            GaudiSequencer("TrackVeloTTPatSeq").Members += [
                PatVeloTTHybrid("PatVeloTTHybrid")
            ]
            if TrackSys().timing():
                PatVeloTTHybrid("PatVeloTTHybrid").TimingMeasurement = True
        # for everything older, the old 'PatVeloTT' is run
        else:
            from Configurables import PatVeloTT
            GaudiSequencer("TrackVeloTTPatSeq").Members += [
                PatVeloTT("PatVeloTT")
            ]
            from PatVeloTT.PatVeloTTAlgConf import PatVeloTTConf
            PatVeloTTConf().configureAlg()
            if TrackSys().timing():
                PatVeloTT("PatVeloTT").TimingMeasurement = True
        tracklists += ["Rec/Track/VeloTT"]

    ### Clean clone and fit
    track.DetectorList += ["Fit"]
    if TrackSys().getProp("OldCloneKiller"):
        from Configurables import TrackEventCloneKiller, TrackStateInitAlg, TrackContainerCopy
        cloneKiller = TrackEventCloneKiller()
        cloneKiller.TracksInContainers = tracklists
        cloneKiller.TracksOutContainer = "Rec/Track/AllBest"
        GaudiSequencer("TrackFitSeq").Members += [cloneKiller]
        stateInitAlg = TrackStateInitAlg("InitBestFit")
        stateInitAlg.TrackLocation = "Rec/Track/AllBest"
        if "FastVelo" in trackAlgs:
            stateInitAlg.StateInitTool.VeloFitterName = "FastVeloFitLHCbIDs"
        GaudiSequencer("TrackFitSeq").Members += [stateInitAlg]

        GaudiSequencer("TrackFitSeq").Members += [
            ConfiguredFit("FitBest", "Rec/Track/AllBest")
        ]
        copyBest = TrackContainerCopy("CopyBest")
        copyBest.inputLocations = ["Rec/Track/AllBest"]
        GaudiSequencer("TrackFitSeq").Members += [copyBest]

        ## Velo fitting
        if "Velo" in trackAlgs or "FastVelo" in trackAlgs:
            ## Prepare the velo tracks for the fit
            track.DetectorList += ["VeloFit"]
            from Configurables import TrackPrepareVelo
            GaudiSequencer("TrackVeloFitSeq").Members += [TrackPrepareVelo()]
            ## Fit the velo tracks
            GaudiSequencer("TrackVeloFitSeq").Members += [
                ConfiguredFit("FitVelo", "Rec/Track/PreparedVelo")
            ]
            ## copy the velo tracks to the "best" container
            copyVelo = TrackContainerCopy("CopyVelo")
            copyVelo.inputLocations = ["Rec/Track/PreparedVelo"]
            GaudiSequencer("TrackVeloFitSeq").Members += [copyVelo]
    else:
        # complete the list of track lists
        if "Velo" in trackAlgs or "FastVelo" in trackAlgs:
            tracklists += ["Rec/Track/Velo"]
        # create the best track creator
        from Configurables import TrackBestTrackCreator
        bestTrackCreator = TrackBestTrackCreator(TracksInContainers=tracklists)
        # configure its fitter and stateinittool
        ConfiguredMasterFitter(bestTrackCreator.Fitter)
        if "FastVelo" in trackAlgs:
            bestTrackCreator.StateInitTool.VeloFitterName = "FastVeloFitLHCbIDs"
        # add to the sequence
        GaudiSequencer("TrackFitSeq").Members.append(bestTrackCreator)

    ### Change dEdx correction for simulated data
    if TrackSys().getProp("Simulation"):
        from Configurables import StateDetailedBetheBlochEnergyCorrectionTool, DetailedMaterialLocator
        if TrackSys().getProp("OldCloneKiller"):
            from Configurables import TrackEventFitter, TrackMasterFitter
            fitBest = TrackEventFitter("FitBest")
            fitBest.Fitter.MaterialLocator.addTool(
                StateDetailedBetheBlochEnergyCorrectionTool("GeneralDedxTool"))
            fitBest.Fitter.MaterialLocator.GeneralDedxTool.EnergyLossFactor = 0.76
        else:
            from Configurables import TrackBestTrackCreator
            fitter = TrackBestTrackCreator().Fitter
            fitter.MaterialLocator.addTool(
                StateDetailedBetheBlochEnergyCorrectionTool("GeneralDedxTool"))
            fitter.MaterialLocator.GeneralDedxTool.EnergyLossFactor = 0.76

    ## Extra track information sequence
    extraInfos = TrackSys().getProp("TrackExtraInfoAlgorithms")
    if len(extraInfos) > 0:

        track.DetectorList += ["AddExtraInfo"]

        ## Clone finding and flagging
        if "CloneFlagging" in extraInfos:
            from Configurables import TrackBuildCloneTable, TrackCloneCleaner
            trackClones = GaudiSequencer("TrackClonesSeq")
            GaudiSequencer("TrackAddExtraInfoSeq").Members += [trackClones]
            if TrackSys().timing():
                trackClones.MeasureTime = True
            cloneTable = TrackBuildCloneTable("FindTrackClones")
            cloneTable.maxDz = 500 * mm
            cloneTable.zStates = [0 * mm, 990 * mm, 9450 * mm]
            cloneTable.klCut = 5e3
            cloneCleaner = TrackCloneCleaner("FlagTrackClones")
            cloneCleaner.CloneCut = 5e3
            trackClones.Members += [cloneTable, cloneCleaner]

        ## Add expected hit information
        #if "ExpectedHits" in extraInfos :
        #   GaudiSequencer("TrackAddExtraInfoSeq").Members += [ TrackComputeExpectedHits() ]

        ## Add the likelihood information
        if "TrackLikelihood" in extraInfos and ('TrackLikelihood'
                                                not in exclude):
            from Configurables import TrackAddLikelihood, TrackLikelihood
            trackAddLikelihood = TrackAddLikelihood()
            trackAddLikelihood.addTool(TrackLikelihood,
                                       name="TrackMatching_likTool")
            trackAddLikelihood.TrackMatching_likTool.otEff = 0.9
            GaudiSequencer("TrackAddExtraInfoSeq").Members += [
                trackAddLikelihood
            ]

        ## ghost probability using a Neural Net
        if "GhostProbability" in extraInfos:
            from Configurables import TrackAddNNGhostId, TrackNNGhostId
            nn = TrackAddNNGhostId()
            GaudiSequencer("TrackAddExtraInfoSeq").Members += [nn]

    track.DetectorList += ["EraseExtraInformation"]
    from Configurables import TrackEraseExtraInfo
    GaudiSequencer("TrackEraseExtraInformationSeq").Members += [
        TrackEraseExtraInfo()
    ]

    ## Muon alignment tracks
    if "MuonAlign" in trackAlgs:
        from Configurables import TrackEventFitter, AlignMuonRec
        track.DetectorList += ["MuonRec"]
        GaudiSequencer("TrackMuonRecSeq").Members += [
            AlignMuonRec("AlignMuonRec"),
            TrackEventFitter("MuonTrackFitter")
        ]
        importOptions("$TRACKSYSROOT/options/AlignMuonRec.opts")
        if TrackSys().fieldOff():
            AlignMuonRec("AlignMuonRec").BField = False
            importOptions("$STDOPTS/DstContentMuonAlign.opts")
예제 #18
0
    def configureOutput(self, dstType):
        """
        Set up output stream
        """
        if dstType in ["DST", "RDST"]:
            if hasattr(self, "Persistency"):
                if self.getProp("Persistency") is not None:
                    DstConf().Persistency = self.getProp("Persistency")

            writerName = "DstWriter"
            packType = self.getProp("PackType")
            # Do not pack DC06 DSTs, for consistency with existing productions
            if self.getProp("DataType") == "DC06": packType = "NONE"

            dstWriter = OutputStream(writerName)
            dstWriter.RequireAlgs += ["Reco"
                                      ]  # Write only if Rec phase completed

            # Set a default output file name if not already defined in the user job options
            if not hasattr(dstWriter, "Output"):
                DstConf().OutputName = self.outputName()

            # Define the file content
            DstConf().Writer = writerName
            DstConf().DstType = dstType
            DstConf().PackType = packType
            DstConf().setProp("WriteFSR", self.getProp("WriteFSR"))

            if hasattr(self, "Persistency"):
                if self.getProp("Persistency") is not None:
                    DstConf().setProp("Persistency",
                                      self.getProp("Persistency"))

            from Configurables import TrackToDST
            if dstType == "DST":
                # Sequence for altering DST content
                ProcessPhase("Output").DetectorList += ["DST"]
                # Filter Track States to be written
                trackFilter = TrackToDST()
            else:
                # Sequence for altering content of rDST compared to DST
                ProcessPhase("Output").DetectorList += ["L0", "DST"]
                # Filter Track States to be written
                trackFilter = TrackToDST("TrackToRDST")
                trackFilter.veloStates = ["ClosestToBeam"]
                trackFilter.longStates = ["ClosestToBeam"]
                trackFilter.TTrackStates = ["FirstMeasurement"]
                trackFilter.downstreamStates = ["FirstMeasurement"]
                trackFilter.upstreamStates = ["ClosestToBeam"]

            GaudiSequencer("OutputDSTSeq").Members += [trackFilter]

            if packType != "NONE":
                # Add the sequence to pack the DST containers
                packSeq = GaudiSequencer("PackDST")
                DstConf().PackSequencer = packSeq
                DstConf().AlwaysCreate = True
                GaudiSequencer("OutputDSTSeq").Members += [packSeq]

        # Always write an ETC if ETC input
        if self.getProp("InputType").upper() == "ETC":
            raise DeprecationWarning, "ETC are no longer supported by LHCb"
            etcWriter = TagCollectionSvc("EvtTupleSvc")
            ApplicationMgr().ExtSvc.append(etcWriter)
            ApplicationMgr().OutStream.append("GaudiSequencer/SeqTagWriter")
            importOptions("$ESCHEROPTS/DefineETC.opts")
            if not hasattr(etcWriter, "Output"):
                etcWriter.Output = [
                    "EVTTAGS2 DATAFILE='" + self.getProp("DatasetName") +
                    "-etc.root' TYP='POOL_ROOTTREE' OPT='RECREATE' "
                ]

        # Do not print event number at every event (done already by Brunel)
        EventSelector().PrintFreq = -1
        CountingPrescaler("EscherPrescaler").PrintFreq = self.getProp(
            "PrintFreq")
        # Modify printout defaults
        if self.getProp("NoWarnings"):
            importOptions("$ESCHEROPTS/SuppressWarnings.opts")
예제 #19
0
    def configureSequences(self):

        # Check for special data options
        for option in self.getProp('SpecialData'):
            if option not in self.KnownSpecialData:
                raise RunTimeError("Unknown SpecialData option '%s'" % option)

        escherSeq = GaudiSequencer("EscherSequencer")
        #escherSeq.Context = self.getProp("Context")
        ApplicationMgr().TopAlg = [escherSeq]
        mainSeq = self.getProp("MainSequence")
        if len(mainSeq) == 0:
            self.MainSequence = self.DefaultSequence
        mainSeq = self.MainSequence
        escherSeq.Members += mainSeq
        ProcessPhase("Init").DetectorList += self.getProp("InitSequence")
        ProcessPhase("Init").Context = self.getProp("Context")

        from Configurables import RecInit, TrackSys
        log.info("Setting up alignment sequence")
        recInit = RecInit(name="EscherInit",
                          PrintFreq=self.getProp("PrintFreq"))
        GaudiSequencer("InitEscherSeq").Members += [recInit]

        # set up the HltFilterSeq
        from Configurables import HltCompositionMonitor
        from Configurables import LoKi__HDRFilter as HDRFilter
        hltFilterSeq = GaudiSequencer("HltFilterSeq")

        from DAQSys.Decoders import DecoderDB
        from DAQSys.DecoderClass import decodersForBank
        from itertools import chain
        hltdecs = [DecoderDB.get("HltDecReportsDecoder/Hlt1DecReportsDecoder")]
        if not self.getProp("OnlineMode"):
            ## HLT2 decreports are only used offline.
            hltdecs += [
                DecoderDB.get("HltDecReportsDecoder/Hlt2DecReportsDecoder")
            ]
        hltFilterSeq.Members = [d.setup() for d in hltdecs]

        ## FIXME: These lines should go back in as soon as an easy to use filter
        ## FIXME: is available that works for HLT1 and HLT2 decreports at the same time.
        ## identifies events that are not of type Hlt1ErrorEvent or Hlt2ErrorEvent
        ## hltErrCode = "HLT_PASS_RE('Hlt1(?!ErrorEvent).*Decision') & HLT_PASS_RE('Hlt2(?!ErrorEvent).*Decision')"
        ## hltErrorFilter = HDRFilter('HltErrorFilter', Code = hltErrCode )   # the filter
        ## hltFilterSeq.Members += [ HltCompositionMonitor(), hltErrorFilter ]
        ## add more hlt filters, if requested
        ## if hasattr(self,"HltFilterCode") and len(self.getProp("HltFilterCode"))>0:
        ##     hltfilter = HDRFilter ( 'HLTFilter',
        ##                             Code = self.getProp("HltFilterCode"))
        ##     hltfilter.Preambulo += [ "from LoKiCore.functions import *" ]
        ##     hltFilterSeq.Members += [ hltfilter ]

        # in Escher we'll always use the DOD
        ApplicationMgr().ExtSvc += ["DataOnDemandSvc"]

        alignSeq = GaudiSequencer("AlignSequence")

        # if the patter reco is not run, we need the DataOnDemand svc
        # so that e.g. the track container(s) is unpacked:
        if not GaudiSequencer("RecoTrSeq").getProp("Enable"):
            DstConf(EnableUnpack=True)

        # Setup tracking sequence
        trackConf = TrackSys()
        self.setOtherProps(trackConf, [
            "SpecialData", "OutputType", "DataType", "Simulation", "GlobalCuts"
        ])
        trackConf.ExpertTracking = self.getProp("ExpertTracking")

        ta = TAlignment()
        ta.Upgrade = self.getProp("Upgrade")
        self.setOtherProps(ta,
                           ["DatasetName", "OnlineMode", "OnlineAligWorkDir"])
        ta.Sequencer = alignSeq
        if self.getProp("Millepede"):
            log.info("Using Millepede type alignment!")
            self.setProp("Incident", "GlobalMPedeFit")
            ta.Method = "Millepede"
            ta.Sequencer = GaudiSequencer("MpedeAlignSeq")
예제 #20
0
    def configureCheck(self,expert):
        # "Check" histograms filled only with simulated data

        KnownCheckSubdets = ["Pat"]

        # CheckSubdets
        if [det for det in ['Rich1', 'Rich2', 'Rich1Pmt', 'Rich2Pmt'] if det in self.getProp("Detectors")]:
            KnownCheckSubdets.append("RICH")
        if [det for det in ['Muon', 'MuonNoM1'] if det in self.getProp("Detectors")]:
            KnownCheckSubdets.append("MUON")

        # Expert Check Subdets
        KnownExpertCheckSubdets = [] + KnownCheckSubdets
        
        if [det for det in ['TT'] if det in self.getProp("Detectors")]:
            KnownExpertCheckSubdets.append("TT")

        tmpExpertSubdets = [det for det in ['IT', 'OT'] if det in self.getProp("Detectors")]
        if tmpExpertSubdets:
            for det in tmpExpertSubdets:
                KnownExpertCheckSubdets.append(det)
        if [det for det in ['Tr'] if det in self.getProp("Detectors")]:
            KnownExpertCheckSubdets.append('Tr')
        if [det for det in ['Spd', 'Prs', 'Ecal', 'Hcal'] if det in self.getProp("Detectors")]:
            KnownExpertCheckSubdets.append("CALO")

        KnownExpertCheckSubdets.append("PROTO")


        RecMoniConf().setProp( "CheckEnabled", True )

        if not self.isPropertySet("MCCheckSequence"):
            if expert:
                checkSeq = KnownExpertCheckSubdets
            else:
                checkSeq = KnownCheckSubdets
            self.MCCheckSequence = checkSeq
        else:
            for seq in self.getProp("MCCheckSequence"):
                if expert:
                    if seq not in KnownExpertCheckSubdets:
                        log.warning("Unknown subdet '%s' in MCCheckSequence"%seq)
                else:
                    if seq not in KnownCheckSubdets:
                        log.warning("Unknown subdet '%s' in MCCheckSequence"%seq)

        checkSeq = self.getProp("MCCheckSequence")
        from Configurables import ProcessPhase
        ProcessPhase("Check").DetectorList += checkSeq

        # Tracking handled inside TrackSys configurable
        TrackSys().setProp( "WithMC", True )

        if ("MUON" in checkSeq) and ("Muon" in self.getProp("Detectors")):
            from MuonPIDChecker import ConfigureMuonPIDChecker as cmuon
            mydata =  self.getProp("DataType")
            mycheckconf = cmuon.ConfigureMuonPIDChecker(data = mydata)
            mycheckconf.configure(UseMC = True, HistosLevel = self.getProp("Histograms"))

        if ("RICH" in checkSeq) and [det for det in ['Rich1', 'Rich2', 'Rich1Pmt', 'Rich2Pmt'] if det in self.getProp("Detectors")] :
            from Configurables import GaudiSequencer
            richMoniConf = RichRecQCConf(self.richMoniConfName)
            self.setOtherProps(richMoniConf, ["Histograms","Context","OutputLevel","OnlineMode",
                                              "DataType","WithMC","Simulation"] )
            richMoniConf.setProp("MoniSequencer", GaudiSequencer("CheckRICHSeq"))

        if expert:
            # Data on Demand for MCParticle to MCHit association, needed by ST, IT, OT, Tr, Muon
            # Different for upgrade and non-upgrade
            if( self.getProp("DataType") is "Upgrade" ):
                importOptions( "$ASSOCIATORSROOT/options/MCParticleToMCHitUpgrade.py" )
            else:
                importOptions( "$ASSOCIATORSROOT/options/MCParticleToMCHit.py" )
                
            # Allow multiple files open at once (SIM,DST,DIGI etc.)
            IODataManager().AgeLimit += 1

            if (
                ("TT" in checkSeq) and
                (hasattr(self, "Detectors")) and
                ("TT" in self.getProp("Detectors"))
                ):
                from Configurables import ( STEffChecker, MCParticleSelector )
                from GaudiKernel.SystemOfUnits import GeV
                effCheck = STEffChecker("TTEffChecker")
                effCheck.FullDetail = True
                effCheck.addTool(MCParticleSelector)
                effCheck.MCParticleSelector.zOrigin = 50.0
                effCheck.MCParticleSelector.pMin = 1.0*GeV
                effCheck.MCParticleSelector.betaGammaMin = 1.0
                from Configurables import GaudiSequencer
                GaudiSequencer("CheckTTSeq").Members += [effCheck]

            if (
                ("IT" in checkSeq) and
                (hasattr(self, "Detectors")) and
                ("IT" in self.getProp("Detectors"))
                ):
                from Configurables import ( STEffChecker, MCParticleSelector )
                from GaudiKernel.SystemOfUnits import GeV
                effCheck = STEffChecker("ITEffChecker")
                effCheck.FullDetail = True
                effCheck.addTool(MCParticleSelector)
                effCheck.MCParticleSelector.zOrigin = 50.0
                effCheck.MCParticleSelector.pMin = 1.0*GeV
                effCheck.MCParticleSelector.betaGammaMin = 1.0
                effCheck.DetType = "IT"
                from Configurables import GaudiSequencer
                GaudiSequencer("CheckITSeq").Members += [effCheck]

            if (
                ("OT" in checkSeq) and
                (hasattr(self, "Detectors")) and
                ("OT" in self.getProp("Detectors"))
                ):
                GaudiSequencer("CheckOTSeq").Members += ["OTTimeChecker"] # needs MCHits

            if "Tr" in  checkSeq :
                # Checking on the tracks in the "best" container - needs MCHits
                # not active for upgrade for the moment
                if( self.getProp("DataType") is "Upgrade" ):
                    pass
                else:
                    importOptions( "$TRACKSYSROOT/options/TrackChecking.opts" )

            if "CALO" in  checkSeq :
                import GaudiKernel.ProcessJobOptions
                GaudiKernel.ProcessJobOptions.PrintOn()
                from Configurables import GaudiSequencer
                ccseq=GaudiSequencer("CaloCheckers")
                noSPDPRS = False
                if [det for det in ['Spd', 'Prs'] if det in self.getProp("Detectors")]:
                    noSPDPRS = True
                caloMoni = CaloMoniDstConf( CheckerSequence  = ccseq,
                                            OutputLevel = self.getProp('OutputLevel'),
                                            Context = 'Offline',
                                            NoSpdPrs = noSPDPRS)
                caloMoni.printConf()

                GaudiKernel.ProcessJobOptions.PrintOff()
                GaudiSequencer("CheckCALOSeq").Members = [ "CaloDigit2MCLinks2Table", "CaloClusterMCTruth" ,ccseq] 

            if "PROTO" in checkSeq :
                from Configurables import GaudiSequencer
                self.setOtherProps(GlobalRecoChecks(),["OutputLevel"])
                exSeq = GaudiSequencer("ExpertProtoMoni")
                GaudiSequencer("CheckPROTOSeq").Members += [exSeq]
                GlobalRecoChecks().Sequencer = exSeq
예제 #21
0
    def applyConf(self):
        # Build list of existing detectors
        dets = []
        for det in self.getProp("Detectors"):
            dets.append(det.upper())
        # general monitoring
        for det in self.KnownMoniGeneral:
            dets.append(det)
        # For compatibility reasons
        if [det for det in ['IT', 'TT'] if det in dets]:
            dets.append("ST")
        if [det for det in ['SPD', 'PRS', 'ECAL', 'HCAL'] if det in dets]:
            dets.append("CALO")
        if [det for det in ['RICH1', 'RICH2'] if det in dets]:
            dets.append("RICH")
            
        # Set up monitoring (i.e. not using MC truth)
        moniSeq = []
        if not self.isPropertySet("MoniSequence"):
            # Build default monitoring
            if self.expertHistos():
                moniDets = self.KnownExpertMoniSubdets
            else:
                moniDets = self.KnownMoniSubdets
            # create overlap
            for det in moniDets:
                if det in dets:
                    moniSeq.append(det)
            self.MoniSequence = moniSeq
        else:
            for seq in self.getProp("MoniSequence"):
                if self.expertHistos():
                    if seq not in self.KnownExpertMoniSubdets:
                        log.warning("Unknown subdet '%s' in MoniSequence"%seq)
                    if seq not in dets:
                        log.warning("Detector unknown '%s'"%seq)    
                else:
                    if seq not in self.KnownMoniSubdets:
                        log.warning("Unknown subdet '%s' in MoniSequence"%seq)
                    if seq not in dets:
                        log.warning("Detector unknown '%s'"%seq)    
            moniSeq = self.getProp("MoniSequence")

        if self.getProp("SkipTracking"):
            for det in ['VELO','IT','TT','ST','OT']:
                if det in moniSeq:
                    moniSeq.remove(det)        
        from Configurables import ProcessPhase
        ProcessPhase("Moni").DetectorList += moniSeq

        # Histograms filled both in real and simulated data cases
        if "GENERAL" in moniSeq :

            # Enable ChronoAuditor
            chronoAuditor = "ChronoAuditor"
            if chronoAuditor not in AuditorSvc().Auditors :
                AuditorSvc().Auditors += [ chronoAuditor ]
            ChronoAuditor().Enable = True
            # Turn off most output
            ChronoStatSvc().ChronoPrintOutTable = False
            ChronoStatSvc().PrintUserTime       = False
            ChronoStatSvc().PrintSystemTime     = False
            
            from Configurables import GaudiSequencer, RecProcessingTimeMoni
            seq = GaudiSequencer( "MoniGENERALSeq")

            # Overall time
            overallTime = RecProcessingTimeMoni("OverallEventProcTime")
            overallTime.Algorithms = ["PhysicsSeq"]
            seq.Members += [overallTime]

            # Tracking
            trackTime = RecProcessingTimeMoni("TrackEventProcTime")
            trackTime.Algorithms = ["RecoTrSeq","RecoVELOSeq","RecoDecodingSeq"]
            seq.Members += [trackTime]

            # Vertex
            vertTime = RecProcessingTimeMoni("VertexEventProcTime")
            vertTime.Algorithms = ["RecoVertexSeq"]
            seq.Members += [vertTime]

            # RICH
            richTime = RecProcessingTimeMoni("RichEventProcTime")
            richTime.Algorithms = ["RecoRICHSeq"]
            seq.Members += [richTime]

            # CALO
            caloTime = RecProcessingTimeMoni("CaloEventProcTime")
            caloTime.Algorithms = ["RecoCALOSeq"]
            seq.Members += [caloTime]

            # MUON
            muonTime = RecProcessingTimeMoni("MuonEventProcTime")
            muonTime.Algorithms = ["RecoMUONSeq"]
            seq.Members += [muonTime]

            # PROTO
            protoTime = RecProcessingTimeMoni("ProtoEventProcTime")
            protoTime.Algorithms = ["RecoPROTOSeq"]
            seq.Members += [protoTime]

            # ProcStat Abort rates
            from Configurables import ProcStatAbortMoni
            seq.Members += [ProcStatAbortMoni()]
        
        if "CALO" in moniSeq :
            import GaudiKernel.ProcessJobOptions
            GaudiKernel.ProcessJobOptions.PrintOn()
            from Configurables import GaudiSequencer
            seq = GaudiSequencer( "MoniCALOSeq")
            noSPDPRS = True
            if [det for det in ['SPD','PRS'] if det in dets]:
                noSPDPRS = False
            caloMoni = CaloMoniDstConf( MonitorSequence    = seq,
                                        OutputLevel = self.getProp('OutputLevel'),
                                        Context = 'Offline',
                                        NoSpdPrs = noSPDPRS)
            caloMoni.printConf()
            self.setOtherProps(caloMoni,["Histograms"])
            GaudiKernel.ProcessJobOptions.PrintOff()

        if "VELO" in moniSeq :
            from Configurables import GaudiSequencer
            self.setOtherProps(VeloRecMonitors(),["Histograms","OutputLevel"])
            VeloRecMonitors().setProp("MoniSequence", GaudiSequencer("MoniVELOSeq"))
            #importOptions('$VELORECMONITORSROOT/options/BrunelMoni_Velo.py')   
        if "OT" in moniSeq :
            from TrackMonitors.ConfiguredTrackMonitors import ConfiguredOTMonitorSequence
            ConfiguredOTMonitorSequence(Name='MoniOTSeq')

        if "MUON" in moniSeq :
            from MuonPIDChecker import ConfigureMuonPIDChecker as mmuon
            mydata =  self.getProp("DataType")
            mymonitconf = mmuon.ConfigureMuonPIDChecker(data = mydata)
            mymonitconf.configure(UseMC = False, HistosLevel = self.getProp("Histograms")) 

            mymtmconf = MuonTrackMonitorConf()
            self.setOtherProps(mymtmconf,["Histograms","OutputLevel","DataType"])
            mymtmconf.setProp("Sequencer", GaudiSequencer("MoniMUONSeq"))

        if "ST" in moniSeq :
            from Configurables import ST__STClusterMonitor, GaudiSequencer
            GaudiSequencer( "MoniSTSeq" ).Members += [ ST__STClusterMonitor("TTClusterMonitor")]
            ST__STClusterMonitor("TTClusterMonitor").DetType = "TT" ## default anyway 
            GaudiSequencer( "MoniSTSeq" ).Members += [ ST__STClusterMonitor("ITClusterMonitor")]
            ST__STClusterMonitor("ITClusterMonitor").DetType = "IT"

        if "Tr" in moniSeq :
            from TrackMonitors.ConfiguredTrackMonitors import ConfiguredTrackMonitorSequence
            ConfiguredTrackMonitorSequence(Name='MoniTrSeq')


        if "PROTO" in moniSeq :
            from Configurables import ( ChargedProtoParticleMoni, GaudiSequencer,
                                        ANNGlobalPID__ChargedProtoANNPIDMoni )
            seq = GaudiSequencer( "MoniPROTOSeq" )
            seq.Members += [ ChargedProtoParticleMoni("ChargedProtoPMoni"),
                             ANNGlobalPID__ChargedProtoANNPIDMoni("ChargedProtoANNPIDMoni") ]
            if self.expertHistos() and not self.getProp("CheckEnabled") :
                exSeq = GaudiSequencer("ExpertProtoMoni")
                seq.Members += [exSeq]
                GlobalRecoChecks().Sequencer = exSeq

        # If checking is enabled, all Rich histograms are booked in check sequence
        if "RICH" in moniSeq and not self.getProp("CheckEnabled"):
            from Configurables import GaudiSequencer
            conf = RichRecQCConf(self.richMoniConfName)
            self.setOtherProps(conf,["Histograms","Context","OutputLevel",
                                     "DataType","Simulation","OnlineMode"])
            conf.setProp("MoniSequencer", GaudiSequencer("MoniRICHSeq"))
            conf.setProp("WithMC", False)
            conf.RichPIDLocation = "Rec/Rich/PIDs"
            import GaudiKernel.ProcessJobOptions
            GaudiKernel.ProcessJobOptions.PrintOn()
            log.debug(conf)
            GaudiKernel.ProcessJobOptions.PrintOff()
        
        if "Hlt" in moniSeq :
            # Do not run Hlt monitoring on DataTypes without HltDecReports 
            if self.getProp("DataType") not in ["2008","DC06","MC09"] and not self.getProp("Simulation") :
                from HltMonitors.ConfiguredHltMonitors import ConfiguredHltMonitorSequence
                ConfiguredHltMonitorSequence(Name='MoniHltSeq')

        # Expert histograms
        if self.expertHistos():
            if "TT" in moniSeq :
                from Configurables import ST__STClusterMonitor
                clusMoni = ST__STClusterMonitor("TTClusterMonitor")
                clusMoni.FullDetail = True
                GaudiSequencer("MoniTTSeq").Members += [clusMoni]
            if "IT" in moniSeq :
                from Configurables import ST__STClusterMonitor
                clusMoni = ST__STClusterMonitor("ITClusterMonitor")
                clusMoni.FullDetail = True
                clusMoni.DetType = "IT"
                GaudiSequencer("MoniITSeq").Members += [clusMoni]