Beispiel #1
0
    def __init__(self,doOldStyleConfig=False):
        "Setup conditions DB - IOVDbSvc and connections according to GlobalFlags"
        from AthenaCommon.AppMgr import ServiceMgr as svcMgr
        from AthenaCommon.Logging import logging
        self.msg = logging.getLogger( 'IOVDbSvc.CondDB' )
        self.msg.debug("Loading basic services for CondDBSetup...")
    
        # AthenaPool and IOVDbSvc configuration
        from AthenaPoolCnvSvc import AthenaPool  # noqa: F401
        from IOVDbSvc import IOVDb               # noqa: F401
        # local access to IOVDbSvc parameters
        self.iovdbsvc=svcMgr.IOVDbSvc

        # initialise list of allowed DBs
        self.dblist={}
        # and list of blocked folders
        self.blocklist=[]
        
        # decide which instance to setup
        # default database
        self.dbname=''
        # names for MC and data database in case forceMC/forceData are used
        self.dbmc=''
        self.dbdata=''
        self.poolcats=[]
        from AthenaCommon.GlobalFlags import globalflags
        from AthenaCommon.AthenaCommonFlags import athenaCommonFlags
        self.isOnline=athenaCommonFlags.isOnline()
        self.isMC=not globalflags.DataSource()=='data'
        if (globalflags.DetGeo() in ['atlas','commis']):
            # ATLAS full or commissioning geometry
            self.dbmc='OFLP200'
            self.dbdata=globalflags.DatabaseInstance() #could be 'auto'
            if self.isMC:
                # Monte Carlo
                self.dbname=self.dbmc
                self.poolcats=['oflcond']
            else:
                # real data
                if (self.dbdata=='auto'):
                    from RecExConfig.RecFlags import rec
                    self.dbdata=self._InstanceFromProjectName(rec.projectName())
                    self.msg.info("Configuring database instance %s based on project tag %s", self.dbdata, rec.projectName())
                self.dbname=self.dbdata
                self.poolcats=['comcond','oflcond']
        elif (globalflags.DetGeo() in ['ctbh8','ctbh6']):
            self.dbmc='TMCP200'
            self.dbdata='TBDP200'
            if self.isMC:
                # 2004 combined testbeam, Monte Carlo
                self.dbname=self.dbmc
                self.poolcats=['tbcond','oflcond']
            else:
                # 2004 combined testbeam, real data
                self.dbname=self.dbdata
                self.poolcats=['tbcond','oflcond']
        else:
            raise RuntimeError("Unknown globalflags.DetGeo: %s" % globalflags.DetGeo())
        if (self.dbname!=''):
            self.msg.info('Setting up conditions DB access to instance %s', self.dbname)
            # set up all access options - online schemas
            self._SetAcc('INDET','COOLONL_INDET')
            self._SetAcc('INDET_ONL','COOLONL_INDET')
            self._SetAcc('PIXEL','COOLONL_PIXEL')
            self._SetAcc('PIXEL_ONL','COOLONL_PIXEL')
            self._SetAcc('SCT','COOLONL_SCT')
            self._SetAcc('SCT_ONL','COOLONL_SCT')
            self._SetAcc('TRT','COOLONL_TRT')
            self._SetAcc('TRT_ONL','COOLONL_TRT')
            self._SetAcc('LAR','COOLONL_LAR')
            self._SetAcc('LAR_ONL','COOLONL_LAR')
            self._SetAcc('TILE','COOLONL_TILE')
            self._SetAcc('TILE_ONL','COOLONL_TILE')
            self._SetAcc('MUON','COOLONL_MUON')
            self._SetAcc('MUON_ONL','COOLONL_MUON')
            self._SetAcc('MUONALIGN','COOLONL_MUONALIGN')
            self._SetAcc('MUONALIGN_ONL','COOLONL_MUONALIGN')
            self._SetAcc('MDT','COOLONL_MDT')
            self._SetAcc('MDT_ONL','COOLONL_MDT')
            self._SetAcc('RPC','COOLONL_RPC')
            self._SetAcc('RPC_ONL','COOLONL_RPC')
            self._SetAcc('TGC','COOLONL_TGC')
            self._SetAcc('TGC_ONL','COOLONL_TGC')
            self._SetAcc('CSC','COOLONL_CSC')
            self._SetAcc('CSC_ONL','COOLONL_CSC')
            self._SetAcc('TDAQ','COOLONL_TDAQ')
            self._SetAcc('TDAQ_ONL','COOLONL_TDAQ')
            self._SetAcc('GLOBAL','COOLONL_GLOBAL')
            self._SetAcc('GLOBAL_ONL','COOLONL_GLOBAL')
            self._SetAcc('TRIGGER','COOLONL_TRIGGER')
            self._SetAcc('TRIGGER_ONL','COOLONL_TRIGGER')
            self._SetAcc('CALO','COOLONL_CALO')
            self._SetAcc('CALO_ONL','COOLONL_CALO')
            self._SetAcc('FWD','COOLONL_FWD')
            self._SetAcc('FWD_ONL','COOLONL_FWD')            
            # set up all access options - offline schemas
            # only do this if isOnline flag is NOT set
            # or MC flag is set, to allow HLT testing using MC database
            if (self.isMC or not self.isOnline):
                self._SetAcc('INDET_OFL','COOLOFL_INDET')
                self._SetAcc('PIXEL_OFL','COOLOFL_PIXEL')
                self._SetAcc('SCT_OFL','COOLOFL_SCT')
                self._SetAcc('TRT_OFL','COOLOFL_TRT')
                self._SetAcc('LAR_OFL','COOLOFL_LAR')
                self._SetAcc('TILE_OFL','COOLOFL_TILE')
                self._SetAcc('MUON_OFL','COOLOFL_MUON')
                self._SetAcc('MUONALIGN_OFL','COOLOFL_MUONALIGN')
                self._SetAcc('MDT_OFL','COOLOFL_MDT')
                self._SetAcc('RPC_OFL','COOLOFL_RPC')
                self._SetAcc('TGC_OFL','COOLOFL_TGC')
                self._SetAcc('CSC_OFL','COOLOFL_CSC')
                self._SetAcc('TDAQ_OFL','COOLOFL_TDAQ')
                self._SetAcc('DCS_OFL','COOLOFL_DCS')
                self._SetAcc('GLOBAL_OFL','COOLOFL_GLOBAL')
                self._SetAcc('TRIGGER_OFL','COOLOFL_TRIGGER')
                self._SetAcc('CALO_OFL','COOLOFL_CALO')
                self._SetAcc('FWD_OFL','COOLOFL_FWD')
            else:
                self.msg.info('Running in online mode - no access to COOLOFL schemas')
                self.iovdbsvc.OnlineMode=True
                
            # setup default connection to localfile, and put in LOCAL symbol
            localfile="sqlite://;schema=mycool.db;dbname="
            self.dblist['LOCAL']=localfile
            self.iovdbsvc.dbConnection=localfile+self.dbname

            # setup knowledge of dbinstance in IOVDbSvc, for global tag x-check
            self.iovdbsvc.DBInstance=self.dbname


            # setup DBReplicaSvc to veto DBRelease SQLite files if real data
            if not self.isMC:
                from DBReplicaSvc.DBReplicaSvcConf import DBReplicaSvc
                svcMgr+=DBReplicaSvc(COOLSQLiteVetoPattern="/DBRelease/")

            # enable Frontier cache alignment if it looks like Frontier will
            # be used (via FRONTIER_SERVER variable)
            if 'FRONTIER_SERVER' in os.environ.keys() and os.environ['FRONTIER_SERVER']!="":
                self.iovdbsvc.CacheAlign=3
            # setup PoolSvc catalogues
            from PoolSvc.PoolSvcConf import PoolSvc
            if not hasattr (svcMgr, 'PoolSvc'):
                svcMgr+=PoolSvc()
            # add the standard catalogues
            for i in self.poolcats:
                svcMgr.PoolSvc.ReadCatalog+=["prfile:poolcond/PoolCat_%s.xml" % i]
            # also add entries which will be resolved using ATLAS_POOLCOND_PATH
            # (if set) - the actual resolution is done inside PoolSvc C++
            for i in self.poolcats:
                svcMgr.PoolSvc.ReadCatalog+=["apcfile:poolcond/PoolCat_%s.xml" % i]
            svcMgr.PoolSvc.ReadCatalog+=["apcfile:poolcond/PoolFileCatalog.xml"]
        else:
            raise RuntimeError('Not enough configuration information to setup ConditionsDB access (are GlobalFlags being used?)')
        self.msg.debug("Loading basic services for CondDBSetup... [DONE]")
Beispiel #2
0
    def configure(self):
        mlog = logging.getLogger( 'Py:LArRawChannelGetter::configure %s:' % self.__class__ )

        from AthenaCommon.AlgSequence import AlgSequence
        topSequence = AlgSequence()
        from AthenaCommon.AppMgr import ToolSvc


        # get LArDigitGetter in MC case
        from AthenaCommon.DetFlags import DetFlags
        if DetFlags.digitize.LAr_on() :
            try:
                from LArDigitization.LArDigitGetter import LArDigitGetter
                theLArDigitGetter = LArDigitGetter()
            except Exception as configException:
                mlog.error("could not get handle to LArDigitGetter Quit")
                import traceback
                mlog.error(traceback.format_exc())
                return False
            if not theLArDigitGetter.usable():
                mlog.error("LArDigitGetter unusable. Quite")
                return False

        from LArROD.LArRODFlags import larRODFlags

        from AthenaCommon.GlobalFlags import globalflags
        if globalflags.DataSource()=='data' or larRODFlags.forceIter() :

            # ADC2MeV tool
            from LArRecUtils.LArADC2MeVToolDefault import LArADC2MeVToolDefault
            theADC2MeVTool = LArADC2MeVToolDefault()
            ToolSvc += theADC2MeVTool


            from AthenaCommon.AppMgr import ServiceMgr as svcMgr

# Data case

            if larRODFlags.readDigits():

                from AthenaCommon.GlobalFlags import globalflags
                if globalflags.InputFormat() == 'bytestream':
                    if not larRODFlags.keepDSPRaw():
                        topSequence.LArRawDataReaderAlg.LArRawChannelKey=""

                if globalflags.DetGeo() == 'ctbh6' or globalflags.DetGeo() == 'ctbh8':        
                    from LArROD.LArRODConf import LArRawChannelBuilder
                    theLArRawChannelBuilder=LArRawChannelBuilder()
                    topSequence += theLArRawChannelBuilder
                    return True

                from LArROD.LArRODConf import LArRawChannelBuilderDriver

                theLArRawChannelBuilder=LArRawChannelBuilderDriver("LArRawChannelBuilder")
                topSequence += theLArRawChannelBuilder

                if larRODFlags.keepDSPRaw():
                    theLArRawChannelBuilder.LArRawChannelContainerName=larRODFlags.RawChannelFromDigitsContainerName()

                # bad channel masking if required
                if not larRODFlags.doBuildBadChannel():
                    # The first tool filters out bad channels
                    from LArROD.LArRODConf import LArRawChannelBuilderToolBadChannelTool
                    theLArRawChannelBuilderToolBadChannel=LArRawChannelBuilderToolBadChannelTool()
                    from LArBadChannelTool.LArBadChannelToolConf import LArBadChannelMasker
                    theLArRCBMasker=LArBadChannelMasker("LArRCBMasker")
                    theLArRCBMasker.DoMasking=True
                    theLArRCBMasker.ProblemsToMask=[
                       "deadReadout","deadPhys","almostDead","short",
                       "lowNoiseHG","highNoiseHG","unstableNoiseHG",
                       "lowNoiseMG","highNoiseMG","unstableNoiseMG",
                       "lowNoiseLG","highNoiseLG","unstableNoiseLG"
                      ]
                    theLArRawChannelBuilderToolBadChannel.BadChannelMask=theLArRCBMasker
                    theLArRawChannelBuilder.BuilderTools += [theLArRawChannelBuilderToolBadChannel]
                    ToolSvc+=theLArRawChannelBuilderToolBadChannel

               
                # Pulse reconstruction
                # main method: OFC iteration
                from LArROD.LArRODConf import LArRawChannelBuilderToolOFCIter
                theLArRawChannelBuilderToolOFCIter=LArRawChannelBuilderToolOFCIter()
                theLArRawChannelBuilderToolOFCIter.minSample = 2
                theLArRawChannelBuilderToolOFCIter.maxSample = 12
                theLArRawChannelBuilderToolOFCIter.minADCforIterInSigma=4 # ADCmax at least 4 sigma above noise for iteration
                theLArRawChannelBuilderToolOFCIter.minADCforIter=15 # min adc for iteration (only if no pedestalRMS found)
                theLArRawChannelBuilderToolOFCIter.defaultPhase=0    # starting delay, also the fixed delay for ADC below min.
                theLArRawChannelBuilderToolOFCIter.ECut=250.         # Energy to save quality
                theLArRawChannelBuilder.BuilderTools += [theLArRawChannelBuilderToolOFCIter]
                theLArRawChannelBuilder+=theLArRawChannelBuilderToolOFCIter 

                # no fallback when emulating exactly DSP computation
                if not larRODFlags.doDSP():
                    # fallback(1): cubic method
                    from LArROD.LArRODConf import LArRawChannelBuilderToolCubic
                    theLArRawChannelBuilderToolCubic=LArRawChannelBuilderToolCubic()
                    theLArRawChannelBuilderToolCubic.minADCforCubic=30 
                    theLArRawChannelBuilder.BuilderTools  += [theLArRawChannelBuilderToolCubic]
                    theLArRawChannelBuilder += theLArRawChannelBuilderToolCubic 

                    # fallback(2) averageing
                    from LArROD.LArRODConf import LArRawChannelBuilderToolAverage
                    theLArRawChannelBuilderToolAverage=LArRawChannelBuilderToolAverage()
                    theLArRawChannelBuilderToolAverage.NScan=0
                    theLArRawChannelBuilder.BuilderTools  += [theLArRawChannelBuilderToolAverage]
                    theLArRawChannelBuilder += theLArRawChannelBuilderToolAverage 


                # Pedestal
                # main method from database
                from LArROD.LArRODConf import LArRawChannelBuilderPedestalDataBase
                theLArRawChannelBuilderPedestalDataBase=LArRawChannelBuilderPedestalDataBase()
                theLArRawChannelBuilderPedestalDataBase.LArPedestalKey = "LArPedestal"
                theLArRawChannelBuilder.PedestalTools  = [theLArRawChannelBuilderPedestalDataBase]
                theLArRawChannelBuilder += theLArRawChannelBuilderPedestalDataBase 
                
                # no fallback when emulating exactly DSP computation
                if not larRODFlags.doDSP():
                    # fallback. sample 0
                    from LArROD.LArRODConf import LArRawChannelBuilderPedestalSampleZero
                    theLArRawChannelBuilderPedestalSampleZero=LArRawChannelBuilderPedestalSampleZero()
                    theLArRawChannelBuilder.PedestalTools  += [theLArRawChannelBuilderPedestalSampleZero]
                    theLArRawChannelBuilder += theLArRawChannelBuilderPedestalSampleZero

                # ADC to energy
                # main method from database
                from LArROD.LArRODConf import LArRawChannelBuilderADC2EDataBase
                theLArRawChannelBuilderADC2EDataBase=LArRawChannelBuilderADC2EDataBase()
                theLArRawChannelBuilder.ADCtoEnergyTools  = [theLArRawChannelBuilderADC2EDataBase]
                theLArRawChannelBuilderADC2EDataBase.ADC2MeVTool = theADC2MeVTool
                theLArRawChannelBuilder += theLArRawChannelBuilderADC2EDataBase 

                # no fallback when emulating exactly DSP computation
                if not larRODFlags.doDSP():
                    # fallback, constant conversion factors
                    from LArROD.LArRODConf import LArRawChannelBuilderADC2EConstants
                    theLArRawChannelBuilderADC2EConstants=LArRawChannelBuilderADC2EConstants()
                    theLArRawChannelBuilder.ADCtoEnergyTools += [theLArRawChannelBuilderADC2EConstants]
                    theLArRawChannelBuilder += theLArRawChannelBuilderADC2EConstants

                #more tools to be configured
                from LArRecUtils.LArRecUtilsConf import LArOFPeakRecoTool
                theLArOFPeakRecoTool=LArOFPeakRecoTool()
                from LArConditionsCommon.LArCondFlags import larCondFlags
                theLArOFPeakRecoTool.UseShape=larCondFlags.useShape()
                if larCondFlags.LArCoolChannelSelection.statusOn:
                    if len(larCondFlags.LArCoolChannelSelection())>0:
                        theLArOFPeakRecoTool.forceHighGain=larCondFlags.useOFCOnlyCoolChannelSelection()
                ToolSvc += theLArOFPeakRecoTool

                #
                # adjust default timing to match first sample information written in cool from Lar online configuration
                #
                nominalPeakSample=2
                if globalflags.DataSource()=='data':
                    from LArConditionsCommon.LArCool import larcool
                    if (larcool is not None):
                        nominalPeakSample = larcool.firstSample()
                        # don't use ramp intercept in calibration if gain type is not auto
                        if larcool.gainType() > 0 :
                            mlog.info(" Gain Type: %d  don't use intercept in ADC to Energy ramp calibration",larcool.gainType())
                            theLArRawChannelBuilderADC2EDataBase.UseHighGainRampIntercept = False
                            theLArRawChannelBuilderADC2EDataBase.UseMedGainRampIntercept = False
                            theLArRawChannelBuilderADC2EDataBase.UseLowGainRampIntercept = False
                        else :
                             mlog.info(" Gain Type: %d   use intercept in ADC to energy ramp calibraion ",larcool.gainType())
                if (nominalPeakSample > 1) :
                    theLArRawChannelBuilder.DefaultShiftTimeSample=nominalPeakSample-2
                else :
                    theLArRawChannelBuilder.DefaultShiftTimeSample=0
                theLArRawChannelBuilder.DataLocation    = "FREE"

            else:

                from AthenaCommon.GlobalFlags import globalflags
                if globalflags.InputFormat() == 'bytestream':
                    if not "LArRawChannelContainer/LArRawChannels" in svcMgr.ByteStreamAddressProviderSvc.TypeNames:
                        svcMgr.ByteStreamAddressProviderSvc.TypeNames+=["LArRawChannelContainer/LArRawChannels"]

            # In the case of DSP monitoring and reading rawchannels, need to give a different name to the LArRawChannels container
            # read from the bytestream ...
            # This name has to be coherent with the name in LArMonTools/LArRODMonTool_jobOptions.py
            if larRODFlags.doDSP() and larRODFlags.readRawChannels():  #Reading LArRawChannel
                print ("Reading RawChannels in DSP physics mode")
                # !!! The name of the LArRawChannels container read from the Bytestream is LArRawChannels_fB !!!
                if not "LArRawChannelContainer/LArRawChannels_fB" in svcMgr.ByteStreamAddressProviderSvc.TypeNames:
                    svcMgr.ByteStreamAddressProviderSvc.TypeNames+=["LArRawChannelContainer/LArRawChannels_fB"]
                print (svcMgr.ByteStreamAddressProviderSvc.TypeNames)
      
        else:

            # MC Case
            try:
                from AthenaCommon import CfgGetter
                topSequence += CfgGetter.getAlgorithm("LArRawChannelBuilder", tryDefaultConfigurable=True)
            except Exception as cfgException:
                mlog.error("Failed to retrieve LArRawChannelBuilder. Quit")
                import traceback
                mlog.error(traceback.format_exc())
                return False

        return True
# IOVRecExTB.py - setup IOVDbSvc for RecExTB
# combined testbeam analysis with data or Monte Carlo

log.warning("IOVDbSvc/IOVRecExTB.py - This file is obselete; conditions DB access should automatically be configured from detector geometry")

from AthenaCommon.GlobalFlags import globalflags
if (globalflags.DetGeo() in ['ctbh8','ctbh6']):
    from IOVDbSvc.CondDB import conddb
else:
    raise RuntimeError,'IOVRecExTB.py included but geometry is not CTB'
Beispiel #4
0
# IOVRecExCommon.py - setup IOVDbSvc for RecExCommon
# Full ATLAS Monte Carlo setup

log.warning(
    "IOVDbSvc/IOVRecExCommon.py - This file is obselete; conditions DB access should automatically be configured from detector geometry"
)

from AthenaCommon.GlobalFlags import globalflags
if (globalflags.DetGeo() == 'atlas'):
    from IOVDbSvc.CondDB import conddb
else:
    raise RuntimeError, 'IOVRecExCommon.py included but geometry is not atlas'
Beispiel #5
0
    )

CaloCellMakerFlags.doCompactCellInstead = doCompactCellInstead
CaloCellMakerFlags.doCompactCellInAddition = doCompactCellInAddition

# set sensible defaults according to global tags

CaloCellMakerFlags.makeCellFromRawChannel = False
CaloCellMakerFlags.makeCellFromDigit = False
CaloCellMakerFlags.doLArHitToCellDirect = False
CaloCellMakerFlags.doTileHitToRawChannelDirect = False

from AthenaCommon.GlobalFlags import globalflags

if globalflags.DataSource() == 'data':
    if globalflags.DetGeo() == 'ctb':
        CaloCellMakerFlags.makeCellFromDigit = True
if globalflags.DataSource() == 'geant3' and globalflags.InputFormat(
) == 'zebra':
    # for geant3 digitisation of all calo is needed
    DetFlags.digitize.Calo_setOn()
    # usually use fast digitisation for lar
    CaloCellMakerFlags.doLArHitToCellDirect = True
    # usually use slow digitisation for tile
    CaloCellMakerFlags.doTileHitToRawChannelDirect = False
    CaloCellMakerFlags.makeCellFromDigit = True
elif globalflags.DataSource() == 'geant3' or globalflags.DataSource(
) == 'geant4':
    # on geant4 usually run on raw channel file
    CaloCellMakerFlags.makeCellFromRawChannel = True
Beispiel #6
0
# IOVRecExCommission.py - setup IOVDbSvc for RecExCommissionMC
# commissioning with Monte Carlo

log.warning(
    "IOVDbSvc/IOVRecExCommissionMC.py - This file is obselete; conditions DB access should automatically be configured from detector geometry"
)

from AthenaCommon.GlobalFlags import globalflags
if (globalflags.DetGeo() == 'commis' and globalflags.DataSource() != 'data'):
    from IOVDbSvc.CondDB import conddb
else:
    raise RuntimeError, 'IOVRecExCommissionMC.py included but geometry is not commis / Monte Carlo'
Beispiel #7
0
def CaloNoiseToolDefault(flag='',name='CaloNoiseToolDefault'):

    # check if tool already exists
    from AthenaCommon.AppMgr import ServiceMgr as svcMgr
    if hasattr(svcMgr.ToolSvc, name):
        # re-use previously configured (public) tool
        return getattr(svcMgr.ToolSvc, name)

    mlog = logging.getLogger( 'CaloNoiseToolDefault' )

    if flag=='db' :
       _useDB = True
    elif flag=='tool' :
       _useDB = False
    else :
       # will put here logic to select according to global flag
       from AthenaCommon.GlobalFlags import globalflags
       from AthenaCommon.BeamFlags import jobproperties
       if globalflags.DataSource()=='data' and globalflags.DetGeo()!='ctbh6' and globalflags.DetGeo()!='ctbh8':
           _useDB = True
       elif globalflags.DataSource()=='geant4' and jobproperties.Beam.zeroLuminosity():
           _useDB = True
       else:
          # now uses also calonoisetoolDB for MC with pileup.. requires a new global tag for pileup reco to have the noise properly read
           _useDB = True

    if _useDB :
        mlog.info(" Using CaloNoiseToolDB" )
        from AthenaCommon.GlobalFlags import globalflags
        if globalflags.DataSource()=='data':
            from CaloTools.CaloNoiseToolDBData import CaloNoiseToolDBData
            theTool = CaloNoiseToolDBData(name)
        else:
            from CaloTools.CaloNoiseToolDBMC import CaloNoiseToolDBMC
            theTool = CaloNoiseToolDBMC(name)
        return theTool
    else :
        mlog.info("Using CaloNoiseTool")
        from CaloTools.CaloToolsConf import CaloNoiseTool
        # Tile configuration
        from AthenaCommon.DetFlags      import DetFlags
        if DetFlags.Tile_on():
            from TileConditions.TileInfoConfigurator import TileInfoConfigurator
            tileInfoConfigurator = TileInfoConfigurator()
            tileInfoConfigurator.setupCOOL()
            UseTile = True
        else:
            UseTile = False
        
        # CaloNoiseTool configuration
        WorkMode=1
        WithOF=True
        TileInfoName="TileInfo"
        # get public tool LArADC2MeVTool
        from LArRecUtils.LArADC2MeVToolDefault import LArADC2MeVToolDefault
        theADC2MeVTool = LArADC2MeVToolDefault()
        from AthenaCommon.AppMgr import ToolSvc
        ToolSvc += theADC2MeVTool
        # get public tool LArOFCTool
        from LArRecUtils.LArOFCToolDefault import LArOFCToolDefault
        theOFCTool = LArOFCToolDefault()
        from AthenaCommon.AppMgr import ToolSvc
        ToolSvc += theOFCTool
        from AthenaCommon.BeamFlags import jobproperties
        if jobproperties.Beam.zeroLuminosity(): 
            ReturnNoise="electronicNoise"
            NMinBias=0
            deltaBunch=1
        else:
            ReturnNoise="totalNoise"
            NMinBias=jobproperties.Beam.numberOfCollisions()
            deltaBunch=int(jobproperties.Beam.bunchSpacing()/( 25.*ns)+0.5)
        from AthenaCommon.GlobalFlags import globalflags
        if globalflags.DataSource()=='data':
            IsMC = False
            UseSymmetry= False
        else:
            IsMC = True
            UseSymmetry= True

        from LArROD.LArRODFlags import larRODFlags
        theTool = CaloNoiseTool(name,
                          WorkMode = WorkMode,
                          WithOF = WithOF,
                          UseTile = UseTile,
                          TileInfoName = TileInfoName,
                          LArADC2MeVTool = theADC2MeVTool,
                          LArOFCTool = theOFCTool,
                          ReturnNoise = ReturnNoise,
                          NMinBias = NMinBias,
                          deltaBunch = deltaBunch,
                          IsMC = IsMC,
                          UseSymmetry = UseSymmetry,
                          firstSample=larRODFlags.firstSample())
        return theTool
Beispiel #8
0
    def configure(self):
        log = logging.getLogger("TriggerConfigGetter.py")

        # first check the input
        if "HIT2RDO" in self._environment:
            TriggerFlags.doLVL2 = False
            TriggerFlags.doEF = False
            log.info("For simulation jobs the following flags are set:")
            log.info("globalflags.InputFormat             : %s" %
                     globalflags.InputFormat())
            log.info("globalflags.DataSource              : %s" %
                     globalflags.DataSource())
            log.info("TriggerFlags.configForStartup       : %s" %
                     TriggerFlags.configForStartup())
            log.info("TriggerFlags.dataTakingConditions   : %s" %
                     TriggerFlags.dataTakingConditions())
            log.info("TriggerFlags.doLVL2                 : %s" %
                     TriggerFlags.doLVL2())
            log.info("TriggerFlags.doEF                   : %s" %
                     TriggerFlags.doEF())
        else:
            if not self.checkInput():
                log.error(
                    "Could not determine job input. Can't setup trigger configuration and will return!"
                )
                return

        self.readPool = globalflags.InputFormat() == 'pool'
        self.readRDO = rec.readRDO()
        self.writeESDAOD = rec.doWriteESD() or rec.doWriteAOD(
        ) or rec.doWriteDPD()
        self.ConfigSrcList = TriggerFlags.configurationSourceList()
        self.readMC = globalflags.DataSource(
        ) == 'geant3' or globalflags.DataSource() == 'geant4'
        self.readTriggerDB = TriggerFlags.readMenuFromTriggerDb(
        ) and self.readRDO
        self.isCommisioning = globalflags.DataSource(
        ) == 'data' and globalflags.DetGeo() == 'commis'
        self.l1Folders = TriggerFlags.dataTakingConditions(
        ) == 'FullTrigger' or TriggerFlags.dataTakingConditions() == 'Lvl1Only'
        self.hltFolders = TriggerFlags.dataTakingConditions(
        ) == 'FullTrigger' or TriggerFlags.dataTakingConditions() == 'HltOnly'
        self.isRun1Data = False
        if globalflags.DataSource() == 'data':
            from RecExConfig.AutoConfiguration import GetRunNumber
            runNumber = GetRunNumber()
            if runNumber > 0 and runNumber < 230000:
                self.isRun1Data = True
        self.isTriggerReprocessing = False

        # the TriggerFlags.readMenuFromTriggerDb() tells us that we read the trigger menu from the database
        # the connection itself is defined in TriggerFlags.triggerDbConnection()

        # reading from the TriggerDB can mean different things:

        # a) TriggerFlags doLVL2() and doEF() are both False:
        #    - create a tmp sqlite file with the conditions (menu)
        #    - use DSConfigSvc

        # b) TriggerFlags doLVL2() or doEF() is True:
        #    - use HLTConfigSvc
        if self.readTriggerDB and (TriggerFlags.doLVL2()
                                   or TriggerFlags.doEF()
                                   or TriggerFlags.doHLT()):

            self.ConfigSrcList = [
                'xml'
            ]  # to use L1/HLTConfigSvc and not DSConfigSvc, but only if we are running the HLT

        if self._environment:  # I don't think anyone calls TriggerConfigGetter with an argument
            self.readPool = False
            self.writeESDAOD = False
            self.readHits = False
            if "ReadPoolRDO" in self._environment:
                self.readPool = True
                self.readRDO = True
            elif "ReadPool" in self._environment:
                self.readPool = True
                self.readRDO = False
            if "WritePool" in self._environment:
                self.writeESDAOD = True
            if "HIT2RDO" in self._environment:
                self.readRDO = False
                self.readHits = True

        # define ConfigSvc
        if not self.ConfigSrcList:
            if (self.readPool and not self.readRDO) or (
                    self.readRDO
                    and not self.readPool):  # (ESD, AOD, DPD) or (RDO-BS)
                self.ConfigSrcList = ['ds']
            elif (self.readRDO and self.readPool
                  ) or rec.readTAG() or self.readHits:  # (RDO-MC) or TAG
                self.ConfigSrcList = ['xml']
            else:  # should not get here: should be found by checkInput
                log.fatal('no reading of BS, RDO, AOD, ESD, or TAG specified')

        # we need the temporary COOL database, if we read the configuration from XML and write ESD/AOD (or have 'ds' set for some reason)
        self.makeTempCool   = self.readRDO and \
                              ( self.writeESDAOD or 'ds' in self.ConfigSrcList ) and \
                              ( self.readMC \
                                or (self.isCommisioning and (TriggerFlags.readLVL1configFromXML() and TriggerFlags.readHLTconfigFromXML())) \
                                or TriggerFlags.readMenuFromTriggerDb() )

        log.info("Need to create temporary cool file? : %r" %
                 self.makeTempCool)

        log.info('Creating the Trigger Configuration Services')
        self.svc = SetupTrigConfigSvc()

        #set the merged system
        #self.svc.doMergedHLT = TriggerFlags.doHLT()

        if 'xml' in self.ConfigSrcList or self.makeTempCool:
            # sets them if plain XML reading is to be used
            self.svc.l1topoXmlFile = TriggerFlags.outputL1TopoConfigFile(
            )  # generated in python
            self.svc.l1XmlFile = TriggerFlags.outputLVL1configFile(
            )  # generated in python
            self.svc.hltXmlFile = TriggerFlags.outputHLTconfigFile(
            )  # generated in python
            if TriggerFlags.readL1TopoConfigFromXML():
                self.svc.l1topoXmlFile = TriggerFlags.inputL1TopoConfigFile(
                )  # given XML
            if TriggerFlags.readLVL1configFromXML():
                self.svc.l1XmlFile = TriggerFlags.inputLVL1configFile(
                )  # given XML
            if TriggerFlags.readHLTconfigFromXML():
                self.svc.hltXmlFile = TriggerFlags.inputHLTconfigFile(
                )  # given XML

        ### preparations are done!
        try:
            self.svc.SetStates(self.ConfigSrcList)
        except:
            log.error('Failed to set state of TrigConfigSvc to %r' %
                      self.ConfigSrcList)
        else:
            log.info('The following configuration services will be tried: %r' %
                     self.ConfigSrcList)

        try:
            self.svc.InitialiseSvc()
        except Exception, ex:
            log.error('Failed to activate TrigConfigSvc: %r' % ex)
Beispiel #9
0
    def configure(self):
        log = logging.getLogger( "TriggerConfigGetter.py" )
        from PyUtils.MetaReaderPeekerFull import metadata

        # first check the input
        if "HIT2RDO" in self._environment:
            TriggerFlags.doLVL2 = False
            TriggerFlags.doEF = False
            log.info("For simulation jobs the following flags are set:")
            log.info("globalflags.InputFormat             : %s", globalflags.InputFormat())
            log.info("globalflags.DataSource              : %s", globalflags.DataSource())
            log.info("TriggerFlags.configForStartup       : %s", TriggerFlags.configForStartup())
            log.info("TriggerFlags.dataTakingConditions   : %s", TriggerFlags.dataTakingConditions())
            log.info("TriggerFlags.doLVL2                 : %s", TriggerFlags.doLVL2())
            log.info("TriggerFlags.doEF                   : %s", TriggerFlags.doEF())
        else:
            if not self.checkInput():
                log.error("Could not determine job input. Can't setup trigger configuration and will return!")
                return
            # self.checkInput() may call TriggerConfigCheckMetadata, this can in turn set "rec.doTrigger.set_Value_and_Lock(False)"
            # but TriggerConfigGetter might have only been called in the first place due to this flag having been true, 
            # so re-check that we're still OK to be executing here
            if not (recAlgs.doTrigger() or rec.doTrigger() or TriggerFlags.doTriggerConfigOnly()):
                log.info("Aborting TriggerConfigGetter as the trigger flags were switched to false in checkInput()")
                return True

        self.readPool       = globalflags.InputFormat() == 'pool'
        self.readRDO        = rec.readRDO()
        self.writeESDAOD    = rec.doWriteESD() or rec.doWriteAOD() or rec.doWriteDPD()
        self.writeAOD       = rec.doWriteAOD() or rec.doWriteDPD()
        self.ConfigSrcList  = TriggerFlags.configurationSourceList()
        self.readMC         = globalflags.DataSource()=='geant3' or globalflags.DataSource()=='geant4'
        self.readTriggerDB  = TriggerFlags.readMenuFromTriggerDb() and self.readRDO
        self.isCommisioning = globalflags.DataSource()=='data' and globalflags.DetGeo()=='commis' 
        self.l1Folders      = TriggerFlags.dataTakingConditions()=='FullTrigger' or TriggerFlags.dataTakingConditions()=='Lvl1Only'
        self.hltFolders     = TriggerFlags.dataTakingConditions()=='FullTrigger' or TriggerFlags.dataTakingConditions()=='HltOnly'
        self.isRun1Data     = False 
        self.hasxAODMeta    = ("metadata_items" in metadata and any(('TriggerMenu' in key) for key in metadata["metadata_items"].keys()))
        if globalflags.DataSource()=='data':
            from RecExConfig.AutoConfiguration  import GetRunNumber
            runNumber = GetRunNumber()
            if runNumber is not None and runNumber > 0 and runNumber < 230000 :
                self.isRun1Data = True
        self.isTriggerReprocessing = False

        # the TriggerFlags.readMenuFromTriggerDb() tells us that we read the trigger menu from the database
        # the connection itself is defined in TriggerFlags.triggerDbConnection()

        # reading from the TriggerDB can mean different things:

        # a) TriggerFlags doLVL2() and doEF() are both False:
        #    - create a tmp sqlite file with the conditions (menu)
        #    - use DSConfigSvc


        # b) TriggerFlags doLVL2() or doEF() is True:
        #    - use HLTConfigSvc
        if self.readTriggerDB and (TriggerFlags.doLVL2() or TriggerFlags.doEF() or TriggerFlags.doHLT()):

            self.ConfigSrcList = ['xml'] # to use L1/HLTConfigSvc and not DSConfigSvc, but only if we are running the HLT


        if self._environment: # I don't think anyone calls TriggerConfigGetter with an argument
            self.readPool  = False
            self.writeESDAOD = False
            self.readHits = False
            if "ReadPoolRDO" in self._environment:
                self.readPool = True
                self.readRDO = True
            elif "ReadPool" in self._environment:
                self.readPool = True
                self.readRDO = False
            if "WritePool" in self._environment:
                self.writeESDAOD = True
            if "HIT2RDO" in self._environment:
                self.readRDO = False
                self.readHits = True


        # define ConfigSvc
        if not self.ConfigSrcList:
            if (self.readPool and not self.readRDO) or (self.readRDO and not self.readPool): # (ESD, AOD, DPD) or (RDO-BS)
                self.ConfigSrcList = ['ds']
            elif (self.readRDO and self.readPool) or rec.readTAG() or self.readHits:           # (RDO-MC) or TAG
                self.ConfigSrcList = ['xml']
            else: # should not get here: should be found by checkInput
                log.fatal('no reading of BS, RDO, AOD, ESD, or TAG specified')

        # we need the temporary COOL database, if we read the configuration from XML and write ESD/AOD (or have 'ds' set for some reason)
        self.makeTempCool   = self.readRDO and \
                              ( self.writeESDAOD or 'ds' in self.ConfigSrcList ) and \
                              ( self.readMC \
                                or (self.isCommisioning and (TriggerFlags.readLVL1configFromXML() and TriggerFlags.readHLTconfigFromXML())) \
                                or TriggerFlags.readMenuFromTriggerDb() )

        log.info("Need to create temporary cool file? : %r", self.makeTempCool)

        log.info('Creating the Trigger Configuration Services')

        from AthenaCommon.AppMgr import ServiceMgr as svcMgr

        ########################################################################
        # START OF TEMPORARY SOLUTION FOR RUN-3 TRIGGER DEVELOPMENT
        ########################################################################
        from TriggerJobOpts.HLTTriggerResultGetter import EDMDecodingVersion
        EDMDecodingVersion()  # In most use cases this needs to be called much earlier than in HLTTriggerResultGetter

        if TriggerFlags.EDMDecodingVersion() >= 3:
            if self.hasxAODMeta:
                if not hasattr(svcMgr, 'xAODConfigSvc'):
                    from TrigConfxAOD.TrigConfxAODConf import TrigConf__xAODConfigSvc
                    svcMgr += TrigConf__xAODConfigSvc('xAODConfigSvc')
            else: # Does not have xAODMeta
                # Run-3 Trigger Configuration Services
                from TrigConfigSvc.TrigConfigSvcCfg import getL1ConfigSvc, getHLTConfigSvc
                from AthenaConfiguration.AllConfigFlags import ConfigFlags
                svcMgr += getL1ConfigSvc(ConfigFlags)
                svcMgr += getHLTConfigSvc(ConfigFlags)

                # Needed for TrigConf::xAODMenuWriterMT
                from TrigConfigSvc.TrigConfigSvcConfig import TrigConfigSvc
                svcMgr += TrigConfigSvc("TrigConfigSvc")
                svcMgr.TrigConfigSvc.PriorityList = ["none", "ds", "xml"]

        else:
            # non-MT (Run-2) Trigger Configuration
            self.svc = SetupTrigConfigSvc()

            if 'xml' in self.ConfigSrcList or self.makeTempCool:
                # sets them if plain XML reading is to be used
                self.svc.l1topoXmlFile = TriggerFlags.outputL1TopoConfigFile()  # generated in python
                self.svc.l1XmlFile     = TriggerFlags.outputLVL1configFile()    # generated in python
                self.svc.hltXmlFile    = TriggerFlags.outputHLTconfigFile()     # generated in python
                if TriggerFlags.readL1TopoConfigFromXML():
                    self.svc.l1topoXmlFile  = TriggerFlags.inputL1TopoConfigFile() # given XML
                if TriggerFlags.readLVL1configFromXML():
                    self.svc.l1XmlFile  = TriggerFlags.inputLVL1configFile() # given XML
                if TriggerFlags.readHLTconfigFromXML():
                    self.svc.hltXmlFile  = TriggerFlags.inputHLTconfigFile()   # given XML

            try:
                self.svc.SetStates( self.ConfigSrcList )
            except Exception:
                log.error( 'Failed to set state of TrigConfigSvc to %r', self.ConfigSrcList )
            else:
                log.info('The following configuration services will be tried: %r', self.ConfigSrcList )

            try:
                self.svc.InitialiseSvc()
            except Exception as ex:
                log.error( 'Failed to activate TrigConfigSvc: %r', ex )
        ########################################################################
        # END OF TEMPORARY SOLUTION FOR RUN-3 TRIGGER DEVELOPMENT
        ########################################################################

        if self.readTriggerDB:
            log.info( "Using TriggerDB connection '%s'", TriggerFlags.triggerDbConnection() )
            self.trigDbConnectionParameters = interpretConnection(TriggerFlags.triggerDbConnection(), resolveAlias=False)
            self.setConfigSvcConnParams(self.trigDbConnectionParameters)

        log.info("TriggerFlags.triggerCoolDbConnection is '%s' [default: '']", TriggerFlags.triggerCoolDbConnection())
        TrigCoolDbConnection = TriggerFlags.triggerCoolDbConnection()

        if self.makeTempCool:
            TrigCoolDbConnection = self.setupTempCOOLWriting(TrigCoolDbConnection)

        if ('ds' in self.ConfigSrcList) and not self.hasxAODMeta:
            self.setupCOOLReading(TrigCoolDbConnection)

        if hasattr(svcMgr, 'DSConfigSvc'):
            db = 'TRIGGERDB'
            if self.isRun1Data:
                db = 'TRIGGERDB_RUN1'
            elif self.readMC:
                db = 'TRIGGERDBMC'
            elif self.isTriggerReprocessing:
                db = 'TRIGGERDBREPR'
            svcMgr.DSConfigSvc.ConfigSource = 'dblookup'
            svcMgr.DSConfigSvc.DBServer = db
            log.info("DSConfigSvc trigger database is '%s'", db)
        
        if not self.hasxAODMeta:
            self.setupxAODWriting()


        # all went fine we are configured
        return True