Skip to content
Snippets Groups Projects
Commit b51fdfb3 authored by Charles Burton's avatar Charles Burton
Browse files

resolve MR comments

1. Cleanup boilerplate code
2. Change property declaration to new method
3. Change function names in AthMonitorCfgHelper
4. Add AOD to TestDefaults.py
5. Add override keyword to functions
parent 204dcb50
Branches
No related tags found
No related merge requests found
......@@ -52,7 +52,7 @@ public:
*
* @return StatusCode
*/
virtual StatusCode initialize();
virtual StatusCode initialize() override;
/**
......@@ -61,7 +61,7 @@ public:
* @param ctx event context for reentrant Athena call
* @return StatusCode
*/
virtual StatusCode execute(const EventContext& ctx) const;
virtual StatusCode execute(const EventContext& ctx) const override;
/**
......@@ -125,7 +125,7 @@ public:
*
* @return a value in the Environment_t enumeration which matches the input string.
*/
Environment_t envStringToEnum( const std::string& str );
Environment_t envStringToEnum( const std::string& str ) const;
/**
......@@ -141,7 +141,7 @@ public:
*
* @return a value in the DataType_t enumeration which matches the input string.
*/
DataType_t dataTypeStringToEnum( const std::string& str );
DataType_t dataTypeStringToEnum( const std::string& str ) const;
/**
......@@ -261,27 +261,30 @@ public:
protected:
ToolHandleArray<GenericMonitoringTool> m_tools; ///< Array of Generic Monitoring Tools
ToolHandle<Trig::ITrigDecisionTool> m_trigDecTool; ///< Tool to tell whether a specific trigger is passed
ToolHandle<ITriggerTranslatorTool> m_trigTranslator; ///< Tool to unpack trigger categories into a trigger list
ToolHandleArray<IDQFilterTool> m_DQFilterTools; ///< Array of Data Quality filter tools
ToolHandle<ILuminosityTool> m_lumiTool; ///< Tool for calculating various luminosity quantities
ToolHandle<ITrigLivefractionTool> m_liveTool; ///< Tool for calculating various live luminosity quantities
// Using the new way to declare JO properties: Gaudi::Property<int> m_myProperty {this,"MyProperty",0};
ToolHandleArray<GenericMonitoringTool> m_tools {this,"GMTools",{}}; ///< Array of Generic Monitoring Tools
ToolHandle<Trig::ITrigDecisionTool> m_trigDecTool {this,"TrigDecisionTool",""}; ///< Tool to tell whether a specific trigger is passed
ToolHandle<ITriggerTranslatorTool> m_trigTranslator {this,"TriggerTranslatorTool",""}; ///< Tool to unpack trigger categories into a trigger list
ToolHandleArray<IDQFilterTool> m_DQFilterTools {this,"FilterTools",{}}; ///< Array of Data Quality filter tools
ToolHandle<ILuminosityTool> m_lumiTool {this,"lumiTool","LuminosityTool"}; ///< Tool for calculating various luminosity quantities
ToolHandle<ITrigLivefractionTool> m_liveTool {this,"liveTool","TrigLivefractionTool"}; ///< Tool for calculating various live luminosity quantities
AthMonitorAlgorithm::Environment_t m_environment; ///< Instance of the Environment_t enum
AthMonitorAlgorithm::DataType_t m_dataType; ///< Instance of the DataType_t enum
std::string m_environmentStr; ///< Environment string pulled from the job option and converted to enum
std::string m_dataTypeStr; ///< DataType string pulled from the job option and converted to enum
Gaudi::Property<std::string> m_environmentStr {this,"Environment","user"}; ///< Environment string pulled from the job option and converted to enum
Gaudi::Property<std::string> m_dataTypeStr {this,"DataType","userDefined"}; ///< DataType string pulled from the job option and converted to enum
std::string m_triggerChainString; ///< Trigger chain string pulled from the job option and parsed into a vector
Gaudi::Property<std::string> m_triggerChainString {this,"TriggerChain",""}; ///< Trigger chain string pulled from the job option and parsed into a vector
std::vector<std::string> m_vTrigChainNames; ///< Vector of trigger chain names parsed from trigger chain string
std::string m_fileKey;
Gaudi::Property<std::string> m_fileKey {this,"FileKey",""}; ///< Internal Athena name for file
bool m_hasRetrievedLumiTool; ///< Allows use of various luminosity functions
bool m_useLumi; ///< Allows use of various luminosity functions
float m_defaultLBDuration; ///< Default duration of one lumi block
int m_detailLevel; ///< Sets the level of detail used in the monitoring
SG::ReadHandleKey<xAOD::EventInfo> m_EventInfoKey; // key for retrieving EventInfo from StoreGate
Gaudi::Property<bool> m_useLumi {this,"EnableLumi",false}; ///< Allows use of various luminosity functions
Gaudi::Property<float> m_defaultLBDuration {this,"DefaultLBDuration",60.}; ///< Default duration of one lumi block
Gaudi::Property<int> m_detailLevel {this,"DetailLevel",0}; ///< Sets the level of detail used in the monitoring
SG::ReadHandleKey<xAOD::EventInfo> m_EventInfoKey {this,"EventInfoKey","EventInfo"}; ///< Key for retrieving EventInfo from StoreGate
};
#endif
......@@ -20,6 +20,6 @@ public:
StatusCode initialize();
virtual StatusCode fillHistograms( const EventContext& ctx ) const override;
private:
bool m_doRandom;
Gaudi::Property<bool> m_doRandom {this,"RandomHist",false};
};
#endif
\ No newline at end of file
......@@ -11,7 +11,7 @@ class AthMonitorCfgHelper(object):
self.monSeq = AthSequencer('AthMonSeq_' + monName)
self.resobj = ComponentAccumulator()
def AddAlgorithm(self,algClassOrObj, *args, **kwargs):
def addAlgorithm(self,algClassOrObj, *args, **kwargs):
from AthenaCommon.Configurable import Configurable
if issubclass(algClassOrObj, Configurable):
algObj = algClassOrObj(*args, **kwargs)
......@@ -25,7 +25,7 @@ class AthMonitorCfgHelper(object):
self.monSeq += algObj
return algObj
def AddGroup(self, alg, name, topPath=''):
def addGroup(self, alg, name, topPath=''):
from AthenaMonitoring.GenericMonitoringTool import GenericMonitoringTool
tool = GenericMonitoringTool(name)
acc, histsvc = GetDQTHistSvc(self.inputFlags)
......
......@@ -21,7 +21,7 @@ def ExampleMonitoringConfig(inputFlags):
# The following class will make a sequence, configure algorithms, and link
# them to GenericMonitoringTools
from AthenaMonitoring import AthMonitorCfgHelper
helper = AthMonitorCfgHelper(inputFlags,"ExampleMonitor")
helper = AthMonitorCfgHelper(inputFlags,'ExampleAthMonitorCfg')
### STEP 2 ###
......@@ -31,11 +31,11 @@ def ExampleMonitoringConfig(inputFlags):
# base class configuration following the inputFlags. The returned object
# is the algorithm.
from AthenaMonitoring.AthenaMonitoringConf import ExampleMonitorAlgorithm
exampleMonAlg = helper.AddAlgorithm(ExampleMonitorAlgorithm)
exampleMonAlg = helper.addAlgorithm(ExampleMonitorAlgorithm,'ExampleMonAlg')
# You can actually make multiple instances of the same algorithm and give
# them different configurations
anotherExampleMonAlg = helper.AddAlgorithm(ExampleMonitorAlgorithm)
anotherExampleMonAlg = helper.addAlgorithm(ExampleMonitorAlgorithm,'AnotherExampleMonAlg')
# # If for some really obscure reason you need to instantiate an algorithm
# # yourself, the AddAlgorithm method will still configure the base
......@@ -44,14 +44,8 @@ def ExampleMonitoringConfig(inputFlags):
### STEP 3 ###
# Edit properties of a algorithm, using inputFlags.
exampleMonAlg.FileKey = inputFlags.DQ.FileKey
exampleMonAlg.Environment = inputFlags.DQ.Environment
exampleMonAlg.DataType = inputFlags.DQ.DataType
# Edit properties of a algorithm
exampleMonAlg.TriggerChain = ''
exampleMonAlg.EnableLumi = True
### STEP 4 ###
# Add some tools. N.B. Do not use your own trigger decion tool. Use the
......@@ -72,21 +66,29 @@ def ExampleMonitoringConfig(inputFlags):
# Add a generic monitoring tool (a "group" in old language). The returned
# object here is the standard GenericMonitoringTool.
myGroup = helper.AddGroup(
myGroup = helper.addGroup(
exampleMonAlg,
"ExampleMonitor",
"OneRing/"
'ExampleMonitor',
'OneRing/'
)
# Add a GMT for the other example monitor algorithm
anotherGroup = helper.addGroup(anotherExampleMonAlg,'ExampleMonitor')
### STEP 5 ###
# Configure histograms
myGroup.defineHistogram("lumiPerBCID;lumiPerBCID", title="Luminosity;L/BCID;Events",
myGroup.defineHistogram('lumiPerBCID;lumiPerBCID', title='Luminosity;L/BCID;Events',
path='ToRuleThemAll',xbins=10,xmin=0.0,xmax=10.0)
myGroup.defineHistogram("lb;lb", title="Luminosity Block;lb;Events",
myGroup.defineHistogram('lb;lb', title='Luminosity Block;lb;Events',
path='ToFindThem',xbins=1000,xmin=-0.5,xmax=999.5)
myGroup.defineHistogram("random;random", title="LB;x;Events",
myGroup.defineHistogram('random;random', title='LB;x;Events',
path='ToBringThemAll',xbins=30,xmin=0,xmax=1)
anotherGroup.defineHistogram('lbWithFilter;lbWithFilter',title='Lumi;lb;Events',
path='top',xbins=1000,xmin=-0.5,xmax=999.5)
### STEP 6 ###
# Finalize. The return value should be a tuple of the ComponentAccumulator
# and the sequence containing the created algorithms. If we haven't called
......@@ -116,7 +118,7 @@ if __name__=='__main__':
file = 'data16_13TeV.00311321.physics_Main.recon.AOD.r9264/AOD.11038520._000001.pool.root.1'
ConfigFlags.Input.Files = [nightly+file]
ConfigFlags.Input.isMC = False
ConfigFlags.Output.HISTFileName = 'ExampleMonitor.root'
ConfigFlags.Output.HISTFileName = 'ExampleMonitorOutput.root'
ConfigFlags.lock()
# Initialize configuration object, add accumulator, merge, and run.
......
......@@ -3,5 +3,4 @@
#
from AthMonitorCfgHelper import AthMonitorCfgHelper
from AtlasReadyFilterTool import GetAtlasReadyFilterTool
import DQConfigFlags
from AtlasReadyFilterTool import GetAtlasReadyFilterTool
\ No newline at end of file
......@@ -6,41 +6,11 @@
AthMonitorAlgorithm::AthMonitorAlgorithm( const std::string& name, ISvcLocator* pSvcLocator )
:AthReentrantAlgorithm(name,pSvcLocator)
,m_tools(this)
,m_trigDecTool("")
,m_trigTranslator("")
,m_DQFilterTools(this)
,m_lumiTool("LuminosityTool")
,m_liveTool("TrigLivefractionTool")
,m_environment(Environment_t::user)
,m_dataType(DataType_t::userDefined)
,m_environmentStr("user")
,m_dataTypeStr("userDefined")
,m_triggerChainString("")
,m_vTrigChainNames({})
,m_fileKey("")
,m_hasRetrievedLumiTool(false)
,m_useLumi(false)
,m_defaultLBDuration(60.)
,m_detailLevel(1)
,m_EventInfoKey("EventInfo")
{
// The following properties are set in the python configuration and
// picked up here to be converted into the method variables. For an
// explanation of each variable, see the header.
declareProperty("GMTools",m_tools);
declareProperty("TrigDecisionTool",m_trigDecTool);
declareProperty("TriggerTranslatorTool",m_trigTranslator);
declareProperty("FilterTools",m_DQFilterTools);
declareProperty("Environment",m_environmentStr);
declareProperty("DataType",m_dataTypeStr);
declareProperty("TriggerChain",m_triggerChainString);
declareProperty("FileKey",m_fileKey);
declareProperty("EnableLumi",m_useLumi);
declareProperty("DefaultLBDuration",m_defaultLBDuration);
declareProperty("DetailLevel",m_detailLevel);
declareProperty("EventInfoKey",m_EventInfoKey);
}
{}
AthMonitorAlgorithm::~AthMonitorAlgorithm() {}
......@@ -51,19 +21,12 @@ StatusCode AthMonitorAlgorithm::initialize() {
// Retrieve the generic monitoring tools (a ToolHandleArray)
if ( !m_tools.empty() ) {
sc = m_tools.retrieve();
if ( !sc.isSuccess() ) {
ATH_MSG_ERROR("Unable to retrieve the generic monitoring tools." << endmsg);
}
ATH_CHECK( m_tools.retrieve() );
}
// Retrieve the trigger decision tool if requested
if ( !m_trigDecTool.empty() ) {
sc = m_trigDecTool.retrieve();
if( !sc.isSuccess() ) {
ATH_MSG_ERROR("Unable to retrieve the TrigDecisionTool." << endmsg);
return sc;
}
ATH_CHECK( m_trigDecTool.retrieve() );
// If the trigger chain is specified, parse it into a list.
if ( m_triggerChainString!="" ) {
......@@ -76,11 +39,7 @@ StatusCode AthMonitorAlgorithm::initialize() {
// Then, retrieve the trigger translator if requested. Finally, convert
// into a usable format using the unpackTriggerCategories function.
if (!m_trigTranslator.empty()) {
sc = m_trigTranslator.retrieve();
if ( !sc.isSuccess() ) {
ATH_MSG_ERROR("Unable to retrieve the TrigTranslatorTool." << endmsg);
return sc;
}
ATH_CHECK( m_trigTranslator.retrieve() );
unpackTriggerCategories(m_vTrigChainNames);
}
}
......@@ -144,7 +103,7 @@ AthMonitorAlgorithm::Environment_t AthMonitorAlgorithm::environment() const {
}
AthMonitorAlgorithm::Environment_t AthMonitorAlgorithm::envStringToEnum( const std::string& str ) {
AthMonitorAlgorithm::Environment_t AthMonitorAlgorithm::envStringToEnum( const std::string& str ) const {
// convert the string to all lowercase
std::string lowerCaseStr = str;
std::transform(lowerCaseStr.begin(), lowerCaseStr.end(), lowerCaseStr.begin(), ::tolower);
......@@ -177,7 +136,7 @@ AthMonitorAlgorithm::DataType_t AthMonitorAlgorithm::dataType() const {
}
AthMonitorAlgorithm::DataType_t AthMonitorAlgorithm::dataTypeStringToEnum( const std::string& str ) {
AthMonitorAlgorithm::DataType_t AthMonitorAlgorithm::dataTypeStringToEnum( const std::string& str ) const {
// convert the string to all lowercase
std::string lowerCaseStr = str;
std::transform(lowerCaseStr.begin(), lowerCaseStr.end(), lowerCaseStr.begin(), ::tolower);
......
......@@ -7,9 +7,7 @@
ExampleMonitorAlgorithm::ExampleMonitorAlgorithm( const std::string& name, ISvcLocator* pSvcLocator )
:AthMonitorAlgorithm(name,pSvcLocator)
,m_doRandom(false)
{
declareProperty("RandomHist",m_doRandom);
}
{}
ExampleMonitorAlgorithm::~ExampleMonitorAlgorithm() {}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment