Skip to content
Snippets Groups Projects

Draft: Allow the Roi default zed width to be modified

Closed Mark Sutton requested to merge sutt/athena:roizw into master
Files
5
@@ -24,6 +24,8 @@
#include "CxxUtils/checker_macros.h"
ATLAS_NO_CHECK_FILE_THREAD_SAFETY;
/**
* @brief Describes the Region of Ineterest geometry
* It has basically 9 parameters
@@ -182,22 +184,47 @@ public:
public:
static double zedWidthDefault() { return s_zedWidthDefault; }
static void (*zedWidthDefault_set)( double d );
private:
static void zedWidthDefault( double d ) {
std::lock_guard<std::mutex> lock(m_mutex);
if ( s_icount==0 ) {
/// does this lock get released when ity goes out of scope ?
s_icount++;
s_zedWidthDefault = d;
}
// else {
/// can't use MsgSvc, don't want to throw an exception - if we want to report
/// warning we woul have to use std::cerr, sop leave this code here pending
/// a decicion of what - if anything - we want to do here
// if ( d != s_zedWidthDefault ) std::cerr << "WARNING: attempting to modify zedWidthDefault a second time: currently: " << s_zedWidthDefault << attempting to set to " << d << std::endl;
// }
static void zedWidthDefault_0( double d ) {
std::lock_guard<std::mutex> lock(s_mutex);
std::cout << "RoiDescriptor::zedWidthDefault_0() setting z width " << d << std::endl;
/// does this lock get released when ity goes out of scope ?
s_zedWidthDefault = d;
increment();
}
static void zedWidthDefault_1( double ) {
std::cout << "RoiDescriptor::zedWidthDefault_1() nope" << std::endl;
}
/// increment checker to ensure that the static method to set the
/// Roi width can only ever be called before the first RoiDescriptor
/// is created - for thread safety the increment is protected by a
/// mutex, but to avoid pointless resource hungry mutex locking to
/// check all subsequent RoiDescriptor calls, the increment mnethod
/// is replaced by an emtpy method for all subsequent calls so there
/// will be no performance overhead
static void increment_0() {
std::cout << "RoiDescriptor::increment_0()" << std::endl;
std::lock_guard<std::mutex> lock(s_mutex_inc);
zedWidthDefault_set = zedWidthDefault_1;
increment = increment_1;
}
static void increment_1() {
std::cout << "RoiDescriptor::increment_1() nope" << std::endl;
}
public:
static void (*increment)(); /// flawed atlas coding convention - a function pointer should not be treated the same as a standard member variable by the cpp checker
protected:
friend class TrigRoiDescriptorCnv_p2;
@@ -217,10 +244,10 @@ protected:
/// default parameters - there may be better ways, but this will do
static double s_zedWidthDefault ATLAS_THREAD_SAFE;
static int s_icount ATLAS_THREAD_SAFE;
/// Mutex to protect setting of the default z width.
static std::mutex m_mutex;
static std::mutex s_mutex;
static std::mutex s_mutex_inc;
protected:
Loading