Skip to content
Snippets Groups Projects
Commit ff9b39a8 authored by Vakhtang Tsulaia's avatar Vakhtang Tsulaia
Browse files

Merge branch 'fwinkl_20200325T150052' into 'master'

AthenaMonitoringKernel: Fix string filling with generator

See merge request !31492
parents 5d2457fa 728bbbc8
No related branches found
No related tags found
6 merge requests!58791DataQualityConfigurations: Modify L1Calo config for web display,!46784MuonCondInterface: Enable thread-safety checking.,!46776Updated LArMonitoring config file for WD to match new files produced using MT,!45405updated ART test cron job,!42417Draft: DIRE and VINCIA Base Fragments for Pythia 8.3,!31492AthenaMonitoringKernel: Fix string filling with generator
......@@ -49,8 +49,7 @@ namespace Monitored {
*/
Scalar(std::string name, const T& defaultValue = {}) :
IMonitoredVariable(std::move(name)),
m_value(defaultValue),
m_valueTransform()
m_value(defaultValue)
{}
/**
......@@ -80,8 +79,6 @@ namespace Monitored {
*/
Scalar(std::string name, std::function<T()> generator) :
IMonitoredVariable(std::move(name)),
m_value(0),
m_valueTransform(),
m_valueGenerator( generator )
{}
......@@ -111,7 +108,7 @@ namespace Monitored {
}
std::vector<std::string> getStringVectorRepresentation() const override{
return { convertToString( m_value ) };
return { convertToString( m_value, m_valueGenerator ) };
}
virtual bool hasStringRepresentation() const override {
......@@ -123,17 +120,19 @@ namespace Monitored {
}
private:
T m_value;
T m_value{};
std::function<double(const T&)> m_valueTransform;
std::function<T()> m_valueGenerator;
template< typename U, typename = typename std::enable_if< std::is_constructible<std::string, U>::value >::type >
std::string convertToString( const U& value ) const {
return std::string{value};
template< typename U, typename Generator,
typename = typename std::enable_if< std::is_constructible<std::string, U>::value >::type >
std::string convertToString( const U& value, Generator g ) const {
return ( g ? g() : value );
}
template< typename U, typename = typename std::enable_if< ! std::is_constructible<std::string, U>::value >::type, typename = void >
std::string convertToString( const U& ) const {
template< typename U, typename Generator,
typename = typename std::enable_if< ! std::is_constructible<std::string, U>::value >::type, typename = void >
std::string convertToString( const U&, Generator ) const {
return "";
}
......
......@@ -52,6 +52,10 @@ TTree* getTree( ITHistSvc* histSvc, const std::string& treeName ) {
void resetHist( ITHistSvc* histSvc, const std::string& histName ) {
TH1* h ATLAS_THREAD_SAFE = const_cast<TH1*>(getHist( histSvc, histName ));
h->Reset();
THashList* labels = h->GetXaxis()->GetLabels();
if (labels) labels->Clear();
labels = h->GetYaxis()->GetLabels();
if (labels) labels->Clear();
}
void resetHists( ITHistSvc* histSvc ) {
......@@ -572,6 +576,26 @@ bool stringFilling(ToolHandle<GenericMonitoringTool>& monTool, ITHistSvc* histSv
return true;
}
bool stringFillingGen(ToolHandle<GenericMonitoringTool>& monTool, ITHistSvc* histSvc) {
auto fill = [&]() {
auto det = Monitored::Scalar<std::string>( "DetID", [&](){return "SCT";} );
Monitored::Group(monTool, det);
return 1;
};
auto check = [&](size_t N) {
const TH1* h = getHist( histSvc, "/EXPERT/TestGroup/DetID" );
VALUE( h->GetEntries() ) EXPECTED( N );
VALUE( h->GetXaxis()->FindFixBin("SCT") ) EXPECTED( 1 );
};
resetHists( histSvc ); check(fill());
resetHists( histSvc ); check(fill_mt(fill));
return true;
}
bool stringFromCollection(ToolHandle<GenericMonitoringTool>& monTool, ITHistSvc* histSvc) {
auto fill = [&]() {
......@@ -716,6 +740,8 @@ int main() {
assert( timerFilling( validMon, histSvc ) );
log << MSG::DEBUG << "stringFilling" << endmsg;
assert( stringFilling( validMon, histSvc ) );
log << MSG::DEBUG << "stringFillingGen" << endmsg;
assert( stringFillingGen( validMon, histSvc ) );
log << MSG::DEBUG << "string2DFilling" << endmsg;
assert( string2DFilling( validMon, histSvc ) );
log << MSG::DEBUG << "stringFromCollection" << endmsg;
......
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