00001 """
00002 High level configuration tools for LHCb applications
00003 """
00004 __version__ = "$Id: Configuration.py,v 1.19 2009/03/09 07:57:48 cattanem Exp $"
00005 __author__ = "Marco Cattaneo <Marco.Cattaneo@cern.ch>"
00006
00007 from os import environ
00008 from Gaudi.Configuration import *
00009 from LHCbKernel.Configuration import *
00010 from Configurables import ( DDDBConf )
00011
00012 class LHCbApp(LHCbConfigurableUser):
00013 __slots__ = {
00014 "EvtMax" : -1
00015 ,"SkipEvents" : 0
00016 ,"DataType" : "2008"
00017 ,"DDDBtag" : ""
00018 ,"CondDBtag" : ""
00019 ,"Simulation" : False
00020 ,"Monitors" : []
00021 }
00022
00023 _propertyDocDct = {
00024 'EvtMax' : """ Maximum number of events to process """
00025 ,'SkipEvents' : """ Number of events to skip """
00026 ,'DataType' : """ Data type, can be ['DC06','2008']. Default '2008' """
00027 ,'DDDBtag' : """ Tag for DDDB. Default as set in DDDBConf for DataType """
00028 ,'CondDBtag' : """ Tag for CondDB. Default as set in DDDBConf for DataType """
00029 ,'Simulation' : """ Flag to indicate usage of simulation conditions """
00030 ,'Monitors' : """ List of monitors to execute """
00031 }
00032
00033 __used_configurables__ = [ DDDBConf ]
00034
00035 def knownMonitors(self):
00036 return ["SC", "FPE"]
00037
00038 def knownAuditors(self):
00039 return ["NameAuditor","MemoryAuditor","ChronoAuditor"]
00040
00041 def defineDB(self):
00042
00043 self.setOtherProps( DDDBConf(), ["Simulation", "DataType" ] )
00044
00045 from Configurables import CondDB
00046 tagsOK = True
00047 if hasattr( self, "DDDBtag" ):
00048 CondDB().Tags [ "DDDB" ] = self.getProp("DDDBtag")
00049 else:
00050 log.error( "DDDBtag property has not been set in the options" )
00051 tagsOK = False
00052 if hasattr( self, "CondDBtag" ):
00053 CondDB().Tags [ "LHCBCOND" ] = self.getProp("CondDBtag")
00054 CondDB().Tags [ "SIMCOND" ] = self.getProp("CondDBtag")
00055 else:
00056 log.error( "CondDBtag property has not been set in the options" )
00057 tagsOK = False
00058 if not tagsOK : sys.exit(1)
00059
00060 def defineEvents(self):
00061
00062 EventDataSvc( ForceLeaves = True,
00063 RootCLID = 1,
00064 EnableFaultHandler = True )
00065
00066 SkipEvents = self.getProp("SkipEvents")
00067 if SkipEvents > 0 :
00068 if hasattr(EventSelector(),"FirstEvent"):
00069 log.warning( "EventSelector().FirstEvent and LHCBApp().SkipEvents both defined, using LHCbApp().SkipEvents")
00070 EventSelector().FirstEvent = SkipEvents + 1
00071
00072
00073 self.setOtherProps(ApplicationMgr(),["EvtMax"])
00074
00075 def evtMax(self):
00076 if hasattr(ApplicationMgr(),"EvtMax") and not hasattr(self,"EvtMax"):
00077 return ApplicationMgr().getProp("EvtMax")
00078 else:
00079 return self.getProp("EvtMax")
00080
00081 def skipEvents(self):
00082 if hasattr(EventSelector(),"FirstEvent") and not hasattr(self,"SkipEvents"):
00083 return EventSelector().getProp("FirstEvent") - 1
00084 else:
00085 return self.getProp("SkipEvents")
00086
00087 def defineMonitors(self):
00088 for prop in self.getProp("Monitors"):
00089 if prop not in self.knownMonitors():
00090 if prop in self.knownAuditors():
00091 from Configurables import AuditorSvc
00092 AuditorSvc().Auditors.append( prop )
00093 theConf = getConfigurable(prop)
00094 theConf.Enable = True
00095 else:
00096 raise RuntimeError("Unknown monitor '%s'"%prop)
00097 if "SC" in self.getProp("Monitors"):
00098 ApplicationMgr().StatusCodeCheck = True
00099 if "FPE" in self.getProp("Monitors"):
00100 importOptions( "$STDOPTS/FPEAudit.opts" )
00101
00102 def __apply_configuration__(self):
00103 self.defineDB()
00104 self.defineEvents()
00105 self.defineMonitors()