def checkInput(self): self.checkFileMetaData() log = logging.getLogger( "TriggerConfigGetter.py" ) if "ReadPool" in self._environment or "WritePool" in self._environment: log.info("Flags are ignored, since 'ReadPool' or 'WritePool' is specified") return True if rec.readESD() or rec.readAOD(): # and globalflags.DataSource()=='data': # need this for MC as well protectedInclude("TriggerJobOpts/TriggerConfigCheckMetadata.py") if rec.readRDO() and globalflags.InputFormat()=='bytestream' and globalflags.DataSource()=='data' and TriggerFlags.configForStartup()!='HLToffline': protectedInclude("TriggerJobOpts/TriggerConfigCheckHLTpsk.py") log.info("The following flags are set:") log.info("globalflags.InputFormat : %s", globalflags.InputFormat()) log.info("rec.read.* : RDO: %s, ESD: %s, AOD: %s, TAG: %s", rec.readRDO(), rec.readESD(), rec.readAOD(), rec.readTAG()) log.info("rec.doWrite.* : ESD: %s, AOD: %s, TAG: %s", rec.doWriteESD(), rec.doWriteAOD(), rec.doWriteTAG()) log.info("globalflags.DataSource : %s", globalflags.DataSource()) log.info("TriggerFlags.configForStartup : %s", TriggerFlags.configForStartup()) log.info("TriggerFlags.dataTakingConditions : %s", TriggerFlags.dataTakingConditions()) log.info("TriggerFlags.configurationSourceList: %s", TriggerFlags.configurationSourceList()) count = len([1 for x in [rec.readRDO(),rec.readESD(),rec.readAOD()] if x ]) #readTAG is only set with another input if count == 0: log.warning("Don't know what the input format is.") return False if count >= 2: log.warning("More than one input format specified, please set only the appropriate one.") return False return True
def MdtCalibrationSvc(name="MdtCalibrationSvc", **kwargs): # call dependent tools. TODO: fix in C++ (move to ServiceHandle + declareProperty) from AthenaCommon.CfgGetter import getService getService("MdtCalibrationDbSvc") kwargs.setdefault("DoSlewingCorrection", mdtCalibFlags.correctMdtRtForTimeSlewing()) # Hack to use DoTemperatureCorrection for applyRtScaling; but applyRtScaling should not be used anyway, since MLRT can be used kwargs.setdefault("DoTemperatureCorrection", mdtCalibFlags.applyRtScaling()) kwargs.setdefault("DoWireSagCorrection", mdtCalibFlags.correctMdtRtWireSag()) if beamFlags.beamType() == 'collisions': kwargs.setdefault("DoTofCorrection", True) if globalflags.DataSource() == 'geant4': # for collisions cut away hits that are far outside of the MDT time window kwargs.setdefault("TimeWindowSetting", mdtCalibWindowNumber('Collision_G4')) elif globalflags.DataSource() == 'data': # for collisions cut away hits that are far outside of the MDT time window kwargs.setdefault("TimeWindowSetting", mdtCalibWindowNumber('Collision_G4')) else: # cosmics or single beam kwargs.setdefault("DoTofCorrection", False) return CfgMgr.MdtCalibrationSvc(name, **kwargs)
def CaloBCIDLumiCondAlgDefault(): from AthenaCommon.GlobalFlags import globalflags name = 'CaloBCIDLumiCondAlg' condSeq = AthSequencer('AthCondSeq') if hasattr(condSeq, name): return getattr(condSeq, name) from CaloRec.CaloBCIDCoeffsCondAlgDefault import CaloBCIDCoeffsCondAlgDefault CaloBCIDCoeffsCondAlgDefault() if globalflags.DataSource() == 'data': from LumiBlockComps.LuminosityCondAlgDefault import LuminosityCondAlgDefault LuminosityCondAlgDefault() else: #MC case from LumiBlockComps.BunchCrossingCondAlgDefault import BunchCrossingCondAlgDefault BunchCrossingCondAlgDefault() CaloBCIDLumiCondAlg = CompFactory.CaloBCIDLumiCondAlg # CaloRec alg = CaloBCIDLumiCondAlg(name, CoeffsKey='CaloBCIDCoeffs', BunchCrossingCondDataKey='BunchCrossingData', LuminosityCondDataKey='LuminosityCondData', isMC=globalflags.DataSource() != 'data', OutputLumiKey='CaloBCIDLumi') condSeq += alg return alg
def MdtDriftCircleOnTrackCreator(name="MdtDriftCircleOnTrackCreator",**kwargs): # setup dependencies missing in C++. TODO: fix in C++ getService("MdtCalibrationSvc") getService("MdtCalibrationDbSvc") kwargs.setdefault("DoMagneticFieldCorrection", mdtCalibFlags.correctMdtRtForBField()) kwargs.setdefault("DoWireSag", muonRecFlags.useWireSagCorrections()) kwargs.setdefault("DoSlewingCorrection", mdtCalibFlags.correctMdtRtForTimeSlewing()) if beamFlags.beamType() == 'cosmics' or beamFlags.beamType() == 'singlebeam' : kwargs.setdefault("DoTofCorrection", False) kwargs.setdefault("DoFixedError", True) kwargs.setdefault("TimingMode", 1) kwargs.setdefault("UseParametrisedError", True) else: # collisions simulation/data settings kwargs.setdefault("DoTofCorrection", True) kwargs.setdefault("DoFixedError", False) kwargs.setdefault("DoErrorScaling", False) kwargs.setdefault("MuonTofTool", None) kwargs.setdefault("TimeWindowSetting", mdtCalibWindowNumber('Collision_data')) # MJW: should this be Collision_G4 ??? kwargs.setdefault("UseParametrisedError", False) if globalflags.DataSource() == 'data': # collisions real data or simulated first data kwargs.setdefault("CreateTubeHit", True) # BroadErrors kwargs.setdefault("UseLooseErrors", muonRecFlags.useLooseErrorTuning()) # LooseErrors on data if globalflags.DataSource() == 'data': kwargs.setdefault("IsMC", False) else: kwargs.setdefault("IsMC", True) return CfgMgr.Muon__MdtDriftCircleOnTrackCreator(name,**kwargs)
def CaloCellPedestalCorrDefault(name='CaloCellPedestalCorr'): import traceback from AthenaCommon.Logging import logging mlog = logging.getLogger('CaloCellPedestalCorrDefault') from AthenaCommon.AppMgr import ToolSvc from AthenaCommon.GlobalFlags import globalflags try: from CaloCellCorrection.CaloCellCorrectionConf import CaloCellPedestalCorr theCaloCellPedestalCorr = CaloCellPedestalCorr("CaloCellPedestalCorr") except: mlog.error("could not get handle to CaloCellPedestalCorr Quit") print traceback.format_exc() ToolSvc += theCaloCellPedestalCorr try: from CaloRec.CaloRecConf import CaloCellContainerCorrectorTool from CaloIdentifier import SUBCALO thePedestalTool = CaloCellContainerCorrectorTool( "PedestalTool", CaloNums=[SUBCALO.NSUBCALO], CellCorrectionToolNames=[theCaloCellPedestalCorr]) except: mlog.error( "could not get handle to CaloCellContainerCorrectorTool Quit") print traceback.format_exc() return False if globalflags.DataSource() == 'data': from IOVDbSvc.CondDB import conddb if conddb.isOnline: folder = '/CALO/Pedestal/CellPedestal' conddb.addFolder('CALO_ONL', folder) else: folder = '/CALO/Ofl/Pedestal/CellPedestal' conddb.addFolder('CALO_OFL', folder) theCaloCellPedestalCorr.FolderName = folder theCaloCellPedestalCorr.isMC = False else: theCaloCellPedestalCorr.isMC = True from AthenaCommon.AthenaCommonFlags import athenaCommonFlags from CaloRec.CaloCellFlags import jobproperties if globalflags.DataSource() == 'data' and ( not jobproperties.CaloCellFlags.doPileupOffsetBCIDCorr()) and ( not athenaCommonFlags.isOnline()): lumiFolder = '/TRIGGER/LUMI/LBLESTONL' conddb.addFolder('TRIGGER_ONL', lumiFolder) theCaloCellPedestalCorr.Luminosity = -1 theCaloCellPedestalCorr.LumiFolderName = lumiFolder if jobproperties.CaloCellFlags.doPileupOffsetBCIDCorr() and ( not athenaCommonFlags.isOnline()): from CaloTools.CaloLumiBCIDToolDefault import CaloLumiBCIDToolDefault theCaloLumiBCIDTool = CaloLumiBCIDToolDefault() ToolSvc += theCaloLumiBCIDTool theCaloCellPedestalCorr.LumiBCIDTool = theCaloLumiBCIDTool return thePedestalTool
def setupCOOLReading(self,TrigCoolDbConnection): log = logging.getLogger( "TriggerConfigGetter.py" ) log.info( 'DSConfigSvc enabled, will setup IOVDbSvc to access configuration meta data') #usePresetConnection = (TrigCoolDbConnection != "") ## if we process MC from an XML file the dbConnection needs to ## be set to a local SQlite file # when reading from the COOL database (either form # ORACLE/SQlite) we need an algorithm that triggers the # copying # # In addition for MC the IOV has to be adjusted since in COOL the config data is written with IOV=infinity if TrigCoolDbConnection=='': log.info("COOL DBConnection: not set, will use default conditions database" ) TrigCoolDbConnection = 'TRIGGER' addNewFolders = TriggerFlags.configForStartup()=="HLTonline" and self.readRDO else: # for sqlite COOL: temp (usually /tmp/hltMenu.xxx.db) or predefined (e.g. trigconf.db) log.info("COOL DBConnection: " + TrigCoolDbConnection ) addNewFolders = ( ( TriggerFlags.configForStartup()=="HLToffline" or TriggerFlags.configForStartup()=="HLTonline" or globalflags.DataSource()!='data') and self.readRDO ) # bytestream or MC RDO # add folders for reading from IOVDbSvc.CondDB import conddb folders = [] if self.hltFolders: folders += [ "HLT/Menu", "HLT/HltConfigKeys" ] if self.l1Folders: folders += [ "LVL1/Lvl1ConfigKey", "LVL1/Menu", "LVL1/Prescales" ] if globalflags.DataSource() == 'data': if self.l1Folders: folders += [ "LVL1/BunchGroupKey", "LVL1/BunchGroupDescription", "LVL1/BunchGroupContent" ] if self.hasLBwiseHLTPrescalesAndL1ItemDef: if self.hltFolders: folders += [ "HLT/Prescales", "HLT/PrescaleKey" ] if self.l1Folders: folders += [ "LVL1/ItemDef" ] log.info("Adding folders to IOVDbSvc") if addNewFolders: # Need thresholds folders but only for Tier0 BS->ESD log.info("Also adding new folders to IOVDbSvc") if self.hltFolders: folders += [ "HLT/Groups" ] if self.l1Folders: folders += [ "LVL1/Thresholds" ] for f in folders: log.info(" /TRIGGER/%s", f) conddb.addFolderWithTag(TrigCoolDbConnection, "/TRIGGER/%s" % f, "HEAD")
def MdtMathSegmentFinder(name="MdtMathSegmentFinder", extraFlags=None, **kwargs): beamType = getattr(extraFlags, "beamType", beamFlags.beamType()) doSegmentT0Fit = getattr(extraFlags, "doSegmentT0Fit", muonRecFlags.doSegmentT0Fit()) enableCurvedSegmentFinding = getattr( extraFlags, "enableCurvedSegmentFinding", muonStandaloneFlags.enableCurvedSegmentFinding()) if doSegmentT0Fit: kwargs.setdefault("AssociationRoadWidth", 3.) kwargs.setdefault("MDTAssocationPullcut", 3.) kwargs.setdefault("RecoverMdtOutliers", False) kwargs.setdefault("DCFitProvider", "MdtSegmentT0Fitter") if beamType == 'singlebeam' or beamType == 'cosmics' or globalflags.DataSource( ) == 'data': kwargs.setdefault("AssociationRoadWidth", 2.) kwargs.setdefault("MDTAssocationPullcut", 4.) kwargs.setdefault("RecoverMdtOutliers", True) if enableCurvedSegmentFinding: kwargs.setdefault("DoCurvedSegmentFinder", True) return CfgMgr.Muon__MdtMathSegmentFinder(name, **kwargs)
def getCellWeightTool(finder="Cone", mainparam=0.4, input="Topo", onlyCellWeight=False): """ Returns a fully configured H1-style cell weighting calibration tool. This tool only uses cell weights! Parameters/type: finder/str : name of jet finder input/str : input objects triggers calibration weights mainparam/float: size parameter for jet """ from CaloClusterCorrection.CaloClusterCorrectionConf import H1WeightToolCSC12Generic if globalflags.DataSource() == 'data': isMC = False else: isMC = True #-- DB access (key, folder, tag) = H1Calibration.getCalibDBParams(finder, mainparam, input, onlyCellWeight, isMC) H1Calibration.loadCaloFolder(folder, tag, isMC) #-- configure tool toolName = finder + editParm(mainparam) + input cellcalibtool = H1WeightToolCSC12Generic("H1Weight" + toolName) cellcalibtool.DBHandleKey = key # -- return cellcalibtool
def addDistanceInTrain(sequence=DerivationFrameworkJob): # simple set up -- either the alg exists and contains the tool, in which case we exit if hasattr(sequence, "DistanceInTrainAugmentation"): dfjetlog.warning( "DistanceInTrainAugmentation: DistanceInTrainAugmentation already scheduled on sequence" + sequence.name) return else: isMC = False if globalflags.DataSource() == 'geant4': isMC = True distanceintrainaug = CfgMgr.DerivationFramework__CommonAugmentation( "DistanceInTrainAugmentation") sequence += distanceintrainaug distanceintrainaugtool = None from AthenaCommon.AppMgr import ToolSvc # create and add the tool to the alg if needed if hasattr(ToolSvc, "DistanceInTrainAugmentationTool"): distanceintrainaugtool = getattr( ToolSvc, "DistanceInTrainAugmentationTool") else: distanceintrainaugtool = CfgMgr.DerivationFramework__DistanceInTrainAugmentationTool( "DistanceInTrainAugmentationTool") from TrigBunchCrossingTool.BunchCrossingTool import BunchCrossingTool if isMC: ToolSvc += BunchCrossingTool("MC") distanceintrainaugtool.BCTool = "Trig::MCBunchCrossingTool/BunchCrossingTool" else: ToolSvc += BunchCrossingTool("LHC") distanceintrainaugtool.BCTool = "Trig::LHCBunchCrossingTool/BunchCrossingTool" ToolSvc += distanceintrainaugtool if not distanceintrainaugtool in distanceintrainaug.AugmentationTools: distanceintrainaug.AugmentationTools.append(distanceintrainaugtool)
def isMC(): ''' Test whether the input is monte carlo. @return true if this is simulation and should have truth information ''' from AthenaCommon.GlobalFlags import globalflags return globalflags.DataSource() != 'data'
def MuonPatternSegmentMaker(name="MuonPatternSegmentMaker", extraFlags=None, **kwargs): if extraFlags is None: extraFlags = ExtraFlags() beamType = extraFlags.setFlagDefault(beamFlags.beamType) doSegmentT0Fit = extraFlags.setFlagDefault(muonRecFlags.doSegmentT0Fit) if "MdtCreator" not in kwargs: # on data configure a MdtDriftCircleOnTrackCreator for the segment finding with reduced errors # when using the t0 refit enlarge the time window if globalflags.DataSource() == 'data' and beamFlags.beamType( ) == 'collisions': if doSegmentT0Fit: mdtCreator = getPublicToolClone( "MdtDriftCircleOnTrackCreatorSegmentFinding", "MdtDriftCircleOnTrackCreator", CreateTubeHit=False, TimeWindowSetting=mdtCalibWindowNumber('Collision_t0fit')) else: mdtCreator = getPublicToolClone( "MdtDriftCircleOnTrackCreatorSegmentFinding", "MdtDriftCircleOnTrackCreator", CreateTubeHit=False, TimeWindowSetting=mdtCalibWindowNumber('Collision_data')) kwargs["MdtCreator"] = mdtCreator if beamType == 'cosmics': kwargs.setdefault("AngleCutPhi", 1e9) kwargs.setdefault("DropDistance", 100000000.) return CfgMgr.Muon__MuonPatternSegmentMaker(name, **kwargs)
def MuonChamberHoleRecoveryTool(name="MuonChamberHoleRecoveryTool", extraFlags=None, **kwargs): doSegmentT0Fit = getattr(extraFlags, "doSegmentT0Fit", muonRecFlags.doSegmentT0Fit()) kwargs.setdefault("Extrapolator", "MuonExtrapolator") if doSegmentT0Fit: kwargs.setdefault("AddMeasurements", False) if muonRecFlags.doCSCs(): if muonRecFlags.enableErrorTuning() or globalflags.DataSource( ) == 'data': kwargs.setdefault("CscRotCreator", "CscBroadClusterOnTrackCreator") else: kwargs.setdefault("CscRotCreator", "CscClusterOnTrackCreator") else: # no CSCs # switch off whatever is set kwargs["CscRotCreator"] = "" kwargs["CscPrepDataContainer"] = "" # add in missing C++ dependency. TODO: fix in C++ getPublicTool("ResidualPullCalculator") if not MuonGeometryFlags.hasSTGC(): kwargs.setdefault("sTgcPrepDataContainer", "") if not MuonGeometryFlags.hasMM(): kwargs.setdefault("MMPrepDataContainer", "") #MDT conditions information not available online if (athenaCommonFlags.isOnline): kwargs.setdefault("MdtCondKey", "") return CfgMgr.Muon__MuonChamberHoleRecoveryTool(name, **kwargs)
def __init__(self, name="MuonSegmentSelectionTool", **kwargs): self.applyUserDefaults(kwargs, name) if globalflags.DataSource( ) == 'data': #collisions-data or simulation first data kwargs.setdefault("GoodADCFractionCut", 0.5) kwargs.setdefault("MinADCPerSegmentCut", 100) super(MuonSegmentSelectionTool, self).__init__(name, **kwargs)
def DCMathSegmentMaker(name='DCMathSegmentMaker', extraFlags=None, **kwargs): beamType = getattr(extraFlags, "beamType", beamFlags.beamType()) doSegmentT0Fit = getattr(extraFlags, "doSegmentT0Fit", muonRecFlags.doSegmentT0Fit()) updateSegmentSecondCoordinate = getattr( extraFlags, "updateSegmentSecondCoordinate", muonStandaloneFlags.updateSegmentSecondCoordinate()) enableCurvedSegmentFinding = getattr( extraFlags, "enableCurvedSegmentFinding", muonStandaloneFlags.enableCurvedSegmentFinding()) kwargs.setdefault("RefitSegment", True) kwargs.setdefault("AssumePointingPhi", beamType != 'cosmics') kwargs.setdefault("OutputFittedT0", True) kwargs.setdefault("DCFitProvider", "MdtSegmentT0Fitter") #kwargs.setdefault("CurvedErrorScaling", False) kwargs.setdefault("UsePreciseError", True) kwargs.setdefault("SinAngleCut", 0.4) #MDT conditions information not available online if (athenaCommonFlags.isOnline): kwargs.setdefault("MdtCondKey", "") # MuonCompetingClustersCreator apparently just takes default kwargs.setdefault("MuonClusterCreator", getPrivateTool("MuonClusterOnTrackCreator")) if (beamType == 'singlebeam' or beamType == 'cosmics'): kwargs.setdefault("SinAngleCut", 0.9) kwargs.setdefault("AddUnassociatedPhiHits", True) kwargs.setdefault("RecoverBadRpcCabling", True) kwargs.setdefault("CurvedErrorScaling", False) elif globalflags.DataSource( ) == 'data': # collisions real data or simulation first data kwargs.setdefault("AddUnassociatedPhiHits", True) kwargs.setdefault("RecoverBadRpcCabling", True) if doSegmentT0Fit: kwargs.setdefault( "MdtCreatorT0", getPrivateTool("MdtDriftCircleOnTrackCreatorAdjustableT0")) kwargs.setdefault("MdtSegmentFinder", getPrivateTool("MdtMathT0FitSegmentFinder")) else: kwargs.setdefault("MdtSegmentFinder", getPrivateTool("MdtMathSegmentFinder")) kwargs.setdefault("SegmentFitter", getPrivateTool("MuonSegmentFittingTool")) kwargs.setdefault("SegmentSelector", getPrivateTool("MuonSegmentSelectionTool")) if updateSegmentSecondCoordinate: kwargs.setdefault("UpdatePhiUsingPhiHits", True) if enableCurvedSegmentFinding: kwargs.setdefault("CurvedErrorScaling", False) kwargs.setdefault("PreciseErrorScale", 1) kwargs.setdefault("UsePreciseError", True) return CfgMgr.Muon__DCMathSegmentMaker(name, **kwargs)
def setDefaults(self): # check on problematic global tags with no association of cabling map folders exist; in this case we use the old cabling logMuon.debug("in setDefaults") problematic_tags = ['COMCOND-HLT[A-C]-00[01]-00', 'COMCOND-ES1C-00[01]-00', 'COMCOND-REPC-001', 'COMCOND-SIM-01-00'] if any(re.match(tag,globalflags.ConditionsTag()) for tag in problematic_tags): # setting the values (not just the defaults) self.UseAlines = 'none' self.UseBlines = 'none' self.UseIlines = False self.UseAsBuilt = False logMuon.info("No good alignment constants associated to Conditions Tag %r: UseAlines=%r UseBlines=%r UseIlines=%r UseAsBuilt=%r", globalflags.ConditionsTag(),self.UseAlines(), self.UseBlines(), self.UseIlines(), self.UseAsBuilt() ) # # simulation, digitization and reconstruction # # MDT elif globalflags.DataSource() == 'geant4': # MC reconstruction or digitization setDefault(self.UseAlines, 'none') setDefault(self.UseBlines, 'none') setDefault(self.UseIlines, False) setDefault(self.UseAsBuilt, False) logMuon.info("Running a reconstruction job on geant4 or a digitization job: UseAlines=%r UseBlines=%r UseIlines=%r UseAsBuilt=%r", self.UseAlines(), self.UseBlines(), self.UseIlines(), self.UseAsBuilt()) else: # here reconstruction or real data setDefault(self.UseAlines, 'all') setDefault(self.UseBlines, 'all') setDefault(self.UseIlines, True) setDefault(self.UseAsBuilt, True) logMuon.info("Running a reconstruction job on data: UseAlines=%r UseBlines=%r UseIlines=%r UseAsBuilt=%r", self.UseAlines(), self.UseBlines(), self.UseIlines(), self.UseAsBuilt())
def configure(self): mlog = logging.getLogger( 'Py:LArRawChannelGetter_DigiHSTruth::configure %s:' % self.__class__) from AthenaCommon.AlgSequence import AlgSequence topSequence = AlgSequence() from AthenaCommon.AppMgr import ToolSvc from LArROD.LArRODFlags import larRODFlags from AthenaCommon.GlobalFlags import globalflags # This should never be run in data if globalflags.DataSource() == 'data' or larRODFlags.forceIter(): return True else: # MC Case try: from AthenaCommon import CfgGetter from LArRODConfig import getLArRawChannelBuilder_DigiHSTruth theLArRawChannelBuilder_DigiHSTruth = getLArRawChannelBuilder_DigiHSTruth( ) topSequence += theLArRawChannelBuilder_DigiHSTruth except Exception as cfgException: print cfgException mlog.error( "Failed to retrieve LArRawChannelBuilder_DigiHSTruth. Quit" ) return False return True
def DontReduceInfo(Rel20=True): global DontReduceInfoRun if (DontReduceInfoRun): return DontReduceInfoRun = True if globalflags.DataSource()!='geant4': return from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__TrackParametersForTruthParticles TTPName = "TruthParticle" if Rel20: TTPName = "TruthParticles" TruthDecor = DerivationFramework__TrackParametersForTruthParticles( name = "TruthTPDecor", OutputLevel = Lvl.INFO, DecorationPrefix ="", TruthParticleContainerName=TTPName) global ToolSvc ToolSvc +=TruthDecor augmentationTools = [TruthDecor] from DerivationFrameworkCore.DerivationFrameworkCoreConf import DerivationFramework__CommonAugmentation global DerivationFrameworkJob DerivationFrameworkJob += CfgMgr.DerivationFramework__CommonAugmentation("MyDFTSOS_KERN", AugmentationTools = augmentationTools, OutputLevel = Lvl.INFO )
def LArHVScaleRetrieverDefault(name="LArHVScaleRetrieverDefault", **kw): from AthenaCommon.AppMgr import ToolSvc mlog = logging.getLogger( 'LArHVScaleRetrieverDefault' ) #Check if the tool exits already in ToolSvc if hasattr(ToolSvc,name): mlog.info("LArHVScaleRetriever with name "+ name+" already known to ToolSvc") return getattr(ToolSvc,name) tool=LArHVScaleRetriever(name) from AthenaCommon.GlobalFlags import globalflags from AthenaCommon import CfgMgr if (globalflags.DataSource()!='data'): tool.IsMC=True mlog.info("%s configured for MC" % name) else: #Data case, need also LArHVCorrTool tool.IsMC=False mlog.info("%s configured for real data" % name) if 'LArHVCorrTool' in kw: tool.LArHVCorrTool= kw['LArHVCorrTool'] else: from LArRecUtils.LArHVCorrToolDefault import LArHVCorrToolDefault theLArHVCorrTool=LArHVCorrToolDefault() tool.LArHVCorrTool=theLArHVCorrTool pass ToolSvc += tool return tool
def __init__(self, name = 'LArDigitThinner', addToAlgSeq = True) : super( DefaultLArDigitThinner, self ).__init__( name ) from AthenaCommon.BeamFlags import jobproperties if jobproperties.Beam.beamType() == "cosmics" : self.EnergyCuts_Barrel = [ 1000, 500, 1000, 1000 ] # values for [presampler, strips, mid, back ] self.EnergyCuts_Endcap = [ 1000, 500, 1000, 1000 ] # values for [presampler, strips, mid, back ] self.EnergyCut_HEC = 2000 self.EnergyCut_FCAL = 3000 else : self.EnergyCuts_Barrel = [ 1000, 1000, 1000, 1000 ] # values for [presampler, strips, mid, back ] self.EnergyCuts_Endcap = [ 2000, 2000, 2000, 2000 ] # values for [presampler, strips, mid, back ] self.EnergyCut_HEC = 5000 self.EnergyCut_FCAL = 20000 from AthenaCommon.AlgSequence import AlgSequence topSequence = AlgSequence() from AthenaCommon.GlobalFlags import globalflags if globalflags.DataSource()=='data': if globalflags.InputFormat() == 'bytestream': from LArByteStream.LArByteStreamConf import LArRawDataReadingAlg if LArRawDataReadingAlg() not in topSequence: topSequence+=LArRawDataReadingAlg() self.InputContainerName="FREE" LArOnOffIdMapping() if addToAlgSeq : topSequence += self
def MuonClusterOnTrackCreator(name="MuonClusterOnTrackCreator",**kwargs): if globalflags.DataSource() == 'data': # collisions real data or simulated first data # scale TGC eta hit errors as long as TGC eta are not well aligned kwargs.setdefault("DoFixedErrorTgcEta", True) kwargs.setdefault("FixedErrorTgcEta", 15.) return CfgMgr.Muon__MuonClusterOnTrackCreator(name,**kwargs)
def __init__(self, printConfigurables=False): self._print = printConfigurables #printConfigurables self._lock = False self.config(useDCS=True, onlineMode=False, prefix='') self._isMC = False from AthenaCommon.GlobalFlags import globalflags if globalflags.DataSource() == 'geant4': self._isMC = True
def initCalibSvc(self, instanceName): "Init Calibration Data service" from AthenaCommon.GlobalFlags import globalflags if (globalflags.DataSource() == 'data'): if hasattr(self.svcMgr, instanceName): calibSvc = getattr(self.svcMgr, instanceName) else: from SCT_ConditionsServices.SCT_ConditionsServicesConf import SCT_ReadCalibDataSvc calibSvc = SCT_ReadCalibDataSvc(name=instanceName) self.svcMgr += calibSvc self.summarySvc.ConditionsServices += [instanceName] if not self.condDB.folderRequested( '/SCT/DAQ/Calibration/NPtGainDefects'): self.condDB.addFolderSplitMC( "SCT", "/SCT/DAQ/Calibration/NPtGainDefects", "/SCT/DAQ/Calibration/NPtGainDefects") if not self.condDB.folderRequested( '/SCT/DAQ/Calibration/NoiseOccupancyDefects'): self.condDB.addFolderSplitMC( "SCT", "/SCT/DAQ/Calibration/NoiseOccupancyDefects", "/SCT/DAQ/Calibration/NoiseOccupancyDefects") return calibSvc else: return None
def MdtDriftCircleOnTrackCreator(name="MdtDriftCircleOnTrackCreator", **kwargs): # setup dependencies missing in C++. TODO: fix in C++ from MuonRecExample import MuonAlignConfig from MuonCnvExample import MuonCalibConfig MuonCalibConfig.setupMdtCondDB() from MuonCnvExample.MuonCalibFlags import mdtCalibFlags mdtCalibFlags.setDefaults() kwargs.setdefault("DoMagneticFieldCorrection", mdtCalibFlags.correctMdtRtForBField()) kwargs.setdefault("DoWireSag", muonRecFlags.useWireSagCorrections()) kwargs.setdefault("DoSlewingCorrection", mdtCalibFlags.correctMdtRtForTimeSlewing()) if beamFlags.beamType() == 'cosmics' or beamFlags.beamType( ) == 'singlebeam': kwargs.setdefault("DoTofCorrection", False) kwargs.setdefault("DoFixedError", True) kwargs.setdefault("TimingMode", 1) kwargs.setdefault("UseParametrisedError", True) else: # collisions simulation/data settings kwargs.setdefault("DoTofCorrection", True) kwargs.setdefault("DoFixedError", False) kwargs.setdefault("DoErrorScaling", False) kwargs.setdefault( "TimeWindowSetting", mdtCalibWindowNumber( 'Collision_data')) # MJW: should this be Collision_G4 ??? kwargs.setdefault("UseParametrisedError", False) if globalflags.DataSource( ) == 'data': # collisions real data or simulated first data kwargs.setdefault("CreateTubeHit", True) # BroadErrors kwargs.setdefault( "UseLooseErrors", muonRecFlags.useLooseErrorTuning()) # LooseErrors on data if globalflags.DataSource() == 'data': kwargs.setdefault("IsMC", False) else: kwargs.setdefault("IsMC", True) if TriggerFlags.MuonSlice.doTrigMuonConfig: kwargs.setdefault("doMDT", True) return CfgMgr.Muon__MdtDriftCircleOnTrackCreator(name, **kwargs)
def DQTDataFlowMonAlgConfigOld(flags): from AthenaMonitoring import AthMonitorCfgHelperOld from .DataQualityToolsConf import DQTDataFlowMonAlg from AthenaCommon.GlobalFlags import globalflags helper = AthMonitorCfgHelperOld(flags, 'DQTDataFlowMonAlgCfg') _DQTDataFlowMonAlgConfigCore(helper, DQTDataFlowMonAlg, globalflags.DataSource() == 'geant4') return helper.result()
def CaloCellPedestalCorrDefault(name='CaloCellPedestalCorr'): import traceback from AthenaCommon.Logging import logging mlog = logging.getLogger( 'CaloCellPedestalCorrDefault' ) from AthenaCommon.AppMgr import ToolSvc from AthenaCommon.GlobalFlags import globalflags try: from CaloCellCorrection.CaloCellCorrectionConf import CaloCellPedestalCorr theCaloCellPedestalCorr = CaloCellPedestalCorr("CaloCellPedestalCorr") except: mlog.error("could not get handle to CaloCellPedestalCorr Quit") traceback.print_exc() #ToolSvc += theCaloCellPedestalCorr if globalflags.DataSource()=='data' : from IOVDbSvc.CondDB import conddb if conddb.isOnline: folder = '/CALO/Pedestal/CellPedestal' conddb.addFolder('CALO_ONL',folder,className="CondAttrListCollection") else: folder= '/CALO/Ofl/Pedestal/CellPedestal' conddb.addFolder('CALO_OFL',folder,className="CondAttrListCollection") theCaloCellPedestalCorr.PedestalShiftFolder = folder theCaloCellPedestalCorr.isMC=False else: theCaloCellPedestalCorr.isMC=True from AthenaCommon.AthenaCommonFlags import athenaCommonFlags from CaloRec.CaloCellFlags import jobproperties if globalflags.DataSource()=='data' and (not jobproperties.CaloCellFlags.doPileupOffsetBCIDCorr()) and (not athenaCommonFlags.isOnline()): lumiFolder = '/TRIGGER/LUMI/LBLESTONL' conddb.addFolder('TRIGGER_ONL',lumiFolder,className="CondAttrListCollection"); theCaloCellPedestalCorr.Luminosity = -1 theCaloCellPedestalCorr.LumiFolderName = lumiFolder if jobproperties.CaloCellFlags.doPileupOffsetBCIDCorr() and (not athenaCommonFlags.isOnline()): from CaloRec.CaloBCIDAvgAlgDefault import CaloBCIDAvgAlgDefault CaloBCIDAvgAlgDefault() theCaloCellPedestalCorr.CaloBCIDAverageKey="CaloBCIDAverage" else: theCaloCellPedestalCorr.CaloBCIDAverageKey="" return theCaloCellPedestalCorr
def getTileCondToolOfcCool(source='FILE', runType='PHY', ofcType='OF2', name='TileCondToolOfcCool', **kwargs): if source not in validSources: raise (Exception("Invalid source: %s" % source)) if runType not in validRunTypes: raise (Exception("Invalid run type %s" % runType)) from TileConditions.TileConditionsConf import TileCondToolOfcCool from AthenaCommon.AlgSequence import AthSequencer condSequence = AthSequencer("AthCondSeq") #do some check for global flag here: if source='' and flag set, adopt flag from AthenaCommon.GlobalFlags import globalflags isMC = (globalflags.DataSource() != 'data') tool = None if source == 'COOL': # There are OFC for OF1 only in DB used in Run2 if ofcType == 'OF1' and not (isUsedDataBaseRun2 or isMC): return None from TileConditions.TileCoolMgr import GetTileOfcCoolSource, AddTileOfcCoolSource, tileCoolMgr ofc = 'TileOfc' + ofcType.capitalize() ofcCondAlg = ofc + 'CondAlg' if not hasattr(condSequence, ofcCondAlg): proxySource = GetTileOfcCoolSource(ofcType, runType) if not tileCoolMgr.isSourceAvailable(proxySource): splitOnline = isUsedDataBaseRun2 and (runType == 'PHY') AddTileOfcCoolSource(ofcType, runType, splitOnline) proxyName = 'TileCondProxyCool_' + proxySource ofcCoolProxy = getTileCondProxy('COOL', 'Ofc', proxySource, proxyName) from TileConditions.TileConditionsConf import TileCalibCondAlg_TileCalibDrawerOfc_ as TileCalibOfcCondAlg condSequence += TileCalibOfcCondAlg(name=ofcCondAlg, ConditionsProxy=ofcCoolProxy, TileCalibData=ofc) tool = TileCondToolOfcCool(name, TileOfc=ofc) else: raise (Exception("Invalid source %s" % source)) #=== set the arguments passed and return tool for n, v in kwargs.items(): setattr(tool, n, v) return tool
def LArAutoCorrTotalToolDefault(name="LArAutoCorrTotalToolDefault", **kw): # call base class constructor from AthenaCommon import CfgMgr kw['name'] = name tool = CfgMgr.LArAutoCorrTotalTool(**kw) mlog = logging.getLogger('LArAutoCorrTotalToolDefault::__init__ ') mlog.info("entering") # do the configuration if globalflags.DataSource() == 'data': tool.MCSym = False tool.IsMC = False tool.keyPedestal = "Pedestal" else: tool.MCSym = True tool.IsMC = True from AthenaCommon.BeamFlags import jobproperties tool.deltaBunch = int(jobproperties.Beam.bunchSpacing() / (25. * ns) + 0.5) from LArROD.LArRODFlags import larRODFlags if larRODFlags.doOFCMixedOptimization(): tool.UseMixedOFCOpt = True tool.NMinBias = jobproperties.Beam.numberOfCollisions() mlog.info( " setup for Ncollisions %f deltaBunch %f and OFC *MIXED* optimization" % (jobproperties.Beam.numberOfCollisions(), jobproperties.Beam.bunchSpacing())) else: if larRODFlags.doOFCPileupOptimization(): if larRODFlags.NumberOfCollisions(): tool.NMinBias = larRODFlags.NumberOfCollisions() mlog.info(" setup for Ncollisions %f deltaBunch %f" % (larRODFlags.NumberOfCollisions(), jobproperties.Beam.bunchSpacing())) else: tool.NMinBias = jobproperties.Beam.numberOfCollisions() mlog.info(" setup for Ncollisions %f deltaBunch %f" % (jobproperties.Beam.numberOfCollisions(), jobproperties.Beam.bunchSpacing())) else: tool.NMinBias = 0 mlog.info( " setup for computing total noise autocorrelation without pileup" ) tool.NSamples = larRODFlags.nSamples() tool.firstSample = larRODFlags.firstSample() from LArRecUtils.LArADC2MeVToolDefault import LArADC2MeVToolDefault theADC2MeVTool = LArADC2MeVToolDefault() from AthenaCommon.AppMgr import ToolSvc ToolSvc += theADC2MeVTool tool.ADC2MeVTool = theADC2MeVTool return tool
def __init__(self, name='TrigCaloDataAccessSvc'): super(TrigCaloDataAccessSvc, self).__init__(name) from AthenaCommon.AppMgr import ServiceMgr as svcMgr from TriggerJobOpts.TriggerFlags import TriggerFlags from AthenaCommon.GlobalFlags import globalflags from AthenaCommon.AthenaCommonFlags import athenaCommonFlags from AthenaCommon.Logging import logging log = logging.getLogger(name) if ( globalflags.DatabaseInstance == "COMP200" and TriggerFlags.doCaloOffsetCorrection() ) : log.warning("Not possible to run BCID offset correction with COMP200") else: if TriggerFlags.doCaloOffsetCorrection(): if globalflags.DataSource()=='data' and athenaCommonFlags.isOnline(): log.info('Enable HLT calo offset correction for data') from IOVDbSvc.CondDB import conddb conddb.addFolder("LAR_ONL","/LAR/ElecCalibFlat/OFC") from LArRecUtils.LArRecUtilsConf import LArFlatConditionSvc svcMgr += LArFlatConditionSvc() svcMgr.LArFlatConditionSvc.OFCInput="/LAR/ElecCalibFlat/OFC" svcMgr.ProxyProviderSvc.ProviderNames += [ "LArFlatConditionSvc" ] from IOVDbSvc.CondDB import conddb conddb.addFolder("LAR_ONL","/LAR/ElecCalibFlat/OFC",className = 'CondAttrListCollection') from AthenaCommon.AlgSequence import AthSequencer condSequence = AthSequencer("AthCondSeq") from LArRecUtils.LArRecUtilsConf import LArFlatConditionsAlg_LArOFCFlat_ as LArOFCCondAlg condSequence += LArOFCCondAlg (ReadKey="/LAR/ElecCalibFlat/OFC", WriteKey='LArOFC') from LumiBlockComps.LuminosityCondAlgDefault import LuminosityCondAlgOnlineDefault LuminosityCondAlgOnlineDefault() from CaloRec.CaloBCIDAvgAlgDefault import CaloBCIDAvgAlgDefault CaloBCIDAvgAlgDefault() else: log.info('Enable HLT calo offset correction for MC') from CaloRec.CaloBCIDAvgAlgDefault import CaloBCIDAvgAlgDefault CaloBCIDAvgAlgDefault() from AthenaCommon.AlgSequence import AlgSequence topSequence = AlgSequence() if not hasattr(topSequence,"CaloBCIDAvgAlg"): log.info('Cannot use timer for CaloBCIDAvgAlg') else: from AthenaMonitoringKernel.GenericMonitoringTool import GenericMonitoringTool monTool = GenericMonitoringTool('MonTool') monTool.defineHistogram('TIME_exec', path='EXPERT', type='TH1F', title="CaloBCIDAvgAlg execution time; time [ us ] ; Nruns", xbins=80, xmin=0.0, xmax=4000) topSequence.CaloBCIDAvgAlg.MonTool = monTool log.info('using timer for CaloBCIDAvgAlg') else: log.info('Disable HLT calo offset correction') return
def CscClusterOnTrackCreator(name="CscClusterOnTrackCreator",**kwargs): kwargs.setdefault("CscStripFitter", getPublicTool("CalibCscStripFitter") ) kwargs.setdefault("CscClusterFitter", getPublicTool("QratCscClusterFitter") ) kwargs.setdefault("CscClusterUtilTool", getPublicTool("CscClusterUtilTool") ) if globalflags.DataSource() == 'data': # collisions real data or simulated first data # scale CSC and hit errors kwargs.setdefault("ErrorScalerBeta", 0.070 ) return CfgMgr.Muon__CscClusterOnTrackCreator(name,**kwargs)
def LArOFCSCToolDefault(name="LArOFCSCToolDefault", **kw): # call base class constructor from AthenaCommon import CfgMgr kw['name'] = name tool = CfgMgr.LArOFCTool(**kw) mlog = logging.getLogger('LArOFCSCToolDefault::__init__ ') mlog.info("entering") # do the configuration if globalflags.DataSource() == 'data': return False else: tool.MCSym = False tool.IsMC = True tool.IsSuperCell = True tool.FromDatabase = False tool.keyShape = "LArShapeSC" tool.keyNoise = "LArNoiseSC" tool.keyPedestal = "LArPedestalSC" tool.UseDelta = 0 ### avoid unforseed options ### #tool.Dump = True from LArRecUtils.LArAutoCorrTotalSCToolDefault import LArAutoCorrTotalSCToolDefault theAutoCorrTool = LArAutoCorrTotalSCToolDefault() from AthenaCommon.AppMgr import ToolSvc ToolSvc += theAutoCorrTool tool.AutoCorrTool = theAutoCorrTool from IOVDbSvc.CondDB import conddb if (conddb.isMC and not conddb.folderRequested('/LAR/IdentifierOfl/OnOffIdMap_SC')): conddb.addFolder( "LAR_OFL", "<tag>LARIdentifierOflOnOffIdMap_SC-000</tag>/LAR/IdentifierOfl/OnOffIdMap_SC" ) if (conddb.isMC and not conddb.folderRequested('/LAR/ElecCalibMCSC/Pedestal')): conddb.addFolder( "LAR_OFL", "<tag>LARElecCalibMCSCPedestal-000</tag>/LAR/ElecCalibMCSC/Pedestal" ) if (conddb.isMC and not conddb.folderRequested('/LAR/ElecCalibMCSC/Noise')): conddb.addFolder( "LAR_OFL", "<tag>LARElecCalibMCSCNoise-000</tag>/LAR/ElecCalibMCSC/Noise") if (conddb.isMC and not conddb.folderRequested('/LAR/ElecCalibMCSC/Shape')): conddb.addFolder( "LAR_OFL", "<tag>LARElecCalibMCSCShape-000</tag>/LAR/ElecCalibMCSC/Shape") return tool