Skip to content
Snippets Groups Projects
Commit 8a1b8515 authored by Will Buttinger's avatar Will Buttinger Committed by Graeme Stewart
Browse files

'new toString method and dumpProperties' (AthAnalysisBaseComps-00-00-28)

	* AthAnalysisHelper: added toString method, since gaudi's method adds extra quotations around strings of form "['b','a']", and then these will not set correctly. So if a string is given, just pass it straight as a string.
	* Also added dumpProperties method for quickly inspecting services and tools
	* Tagging AthAnalysisBaseComps-00-00-28

2016-08-24 Will Buttinger <will@cern.ch>
	* AthAnalysisHelper: switched initGaudi to use MinimalEventLoopMgr, because it causes creation of fewer services by default, in particular no EventSelector is made, which is good!
	* SuppressLogging.py: had to not suppress ApplicationMgr for now until ATN tests are ok with it
	* Tagging AthAnalysisBaseComps-00-00-27


Former-commit-id: 6d171e7dae301988153619be7e2fa973d7494e03
parent 216454ce
No related branches found
No related tags found
No related merge requests found
......@@ -28,6 +28,9 @@
#include "GaudiKernel/IAppMgrUI.h"
#include "GaudiKernel/ToolHandle.h"
class AthAnalysisHelper { //thought about being a namespace but went for static methods instead, in case I want private data members in future
public:
......@@ -124,10 +127,15 @@ public:
return theAlg->setProperty(property, value);
}
template<typename T> static std::string toString(const T& value) { return Gaudi::Utils::toString( value ); }
static std::string toString(const std::string& value) { return value; } //gaudi's toString puts extra quote marks around things like "['b']" .. should probably stop that..
static std::string toString(const char* value) { return value; } //gaudi's toString puts extra quote marks around things like "['b']" .. should probably stop that..
///setProperty for services ... will allow setProperty on already-existing services
template<typename T, typename W> static StatusCode setProperty(const ServiceHandle<T>& serviceHandle, const std::string& property, const W& value) {
if(serviceHandle.isSet()) {
return dynamic_cast<Service&>(*serviceHandle).setProperty(property,Gaudi::Utils::toString ( value ));
return dynamic_cast<Service&>(*serviceHandle).setProperty(property,toString ( value ));
}
std::string fullName = serviceHandle.name();
std::string thePropertyName(property);
......@@ -141,7 +149,7 @@ public:
//check if the service already exists
if(Gaudi::svcLocator()->existsService(serviceHandle.name())) {
//set property on the service directly
return dynamic_cast<Service&>(*serviceHandle).setProperty(property,Gaudi::Utils::toString ( value ));
return dynamic_cast<Service&>(*serviceHandle).setProperty(property,toString ( value ));
}
//service not existing, ok so add property to catalogue
......@@ -301,6 +309,22 @@ public:
static void printAuxElement(const SG::AuxElement& ae);
///Dump the properties of an IProperty
//these aren't necessarily the same as what is in the JobOptionsSvc
static void dumpProperties(const IProperty& component);
template<typename T> static void dumpProperties(const ServiceHandle<T>& handle) {
if(!handle.isSet()) {std::cout << "Please retrieve service before dumping properties" << std::endl; return;}
return dumpProperties(dynamic_cast<const IProperty&>(*handle));
}
template<typename T> static void dumpProperties(const ToolHandle<T>& handle) {
if(!handle.isSet()) {std::cout << "Please retrieve service before dumping properties" << std::endl; return;}
return dumpProperties(dynamic_cast<const IProperty&>(*handle));
}
///we keep a static handle to the joboptionsvc, since it's very useful
///can e.g. do: AAH::joSvc->readOptions("myJob.opts","$JOBOPTSEARCHPATH")
static ServiceHandle<IJobOptionsSvc> joSvc;
......
MessageSvc.setWarning += {"ClassIDSvc","PoolSvc","AthDictLoaderSvc","AthenaPoolAddressProviderSvc","ProxyProviderSvc","DBReplicaSvc","MetaDataSvc","MetaDataStore","AthenaPoolCnvSvc","TagMetaDataStore","EventSelector","ApplicationMgr","CoreDumpSvc","AthMasterSeq","EventPersistencySvc","ActiveStoreSvc","AthenaEventLoopMgr","AthOutSeq","AthRegSeq"};
MessageSvc.setWarning += {"ClassIDSvc",
"PoolSvc",
"AthDictLoaderSvc",
"AthenaPoolAddressProviderSvc",
"ProxyProviderSvc",
"DBReplicaSvc",
"MetaDataSvc",
"MetaDataStore",
"AthenaPoolCnvSvc",
"TagMetaDataStore",
"EventSelector",
#"ApplicationMgr", can't silence because otherwise ATN tests fail, see ATLINFR-1235
"CoreDumpSvc",
"AthMasterSeq",
"EventPersistencySvc",
"ActiveStoreSvc",
"AthenaEventLoopMgr",
"AthOutSeq",
"AthRegSeq"};
#also silence storegates if not dumping
if not hasattr(StoreGateSvc,"Dump") or StoreGateSvc.Dump: MessageSvc.setWarning += ["StoreGateSvc"]
......
......@@ -24,6 +24,8 @@ IAppMgrUI* AthAnalysisHelper::initGaudi(const char* options) {
} else {
propMgr->setProperty( "JobOptionsType", "NONE" ); //no joboptions given
}
propMgr->setProperty("EventLoop","MinimalEventLoopMgr"); //using this instead of the default EventLoopMgr means some services (e.g. EventSelector) are not created, which is good! :-)
//configure and return
theApp->configure();
propMgr->setProperty("OutputLevel","3"); //INFO
......@@ -70,4 +72,10 @@ if(typeinfo==typeid(TYPE) && ae.isAvailable<TYPE>(name)) std::cout << ae.auxdata
#undef PRINT_AE
}
}
\ No newline at end of file
}
void AthAnalysisHelper::dumpProperties(const IProperty& component) {
for(auto p : component.getProperties()) {
std::cout << p->name() << " = " << p->toString() << std::endl;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment