Skip to content

Commit

Permalink
Fixes for misc. threading problems found by static analysis and helgrind
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Riley authored and Dan Riley committed Feb 2, 2016
1 parent b8b7866 commit 2dca225
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion SimCalorimetry/HcalSimAlgos/src/HPDIonFeedbackSim.cc
Expand Up @@ -27,7 +27,7 @@ using namespace edm;
using namespace std;

// constants for simulation/parameterization
double pe2Charge = 0.333333; // fC/p.e.
const double pe2Charge = 0.333333; // fC/p.e.

HPDIonFeedbackSim::HPDIonFeedbackSim(const edm::ParameterSet & iConfig, const CaloShapes * shapes)
: theDbService(0), theShapes(shapes)
Expand Down
Expand Up @@ -24,8 +24,6 @@
//
#include "DataMixingHcalDigiWorker.h"

std::vector<size_t> ids;

using namespace std;

namespace {
Expand Down Expand Up @@ -191,7 +189,6 @@ namespace edm

void DataMixingHcalDigiWorker::addHcalSignals(const edm::Event &e,const edm::EventSetup& ES) {
// Calibration stuff will look like this:
ids.clear();
// get conditions
edm::ESHandle<HcalDbService> conditions;
ES.get<HcalDbRecord>().get(conditions);
Expand Down
Expand Up @@ -225,10 +225,10 @@ void DataMixingSiPixelMCDigiWorker::init_DynIneffDB(const edm::EventSetup& es, c
void DataMixingSiPixelMCDigiWorker::PixelEfficiencies::init_from_db(const edm::ESHandle<TrackerGeometry>& geom, const edm::ESHandle<SiPixelDynamicInefficiency>& SiPixelDynamicInefficiency) {

theInstLumiScaleFactor = SiPixelDynamicInefficiency->gettheInstLumiScaleFactor();
std::map<uint32_t, double> PixelGeomFactorsDB = SiPixelDynamicInefficiency->getPixelGeomFactors();
std::map<uint32_t, double> ColGeomFactorsDB = SiPixelDynamicInefficiency->getColGeomFactors();
std::map<uint32_t, double> ChipGeomFactorsDB = SiPixelDynamicInefficiency->getChipGeomFactors();
std::map<uint32_t, std::vector<double> > PUFactors = SiPixelDynamicInefficiency->getPUFactors();
const std::map<uint32_t, double>& PixelGeomFactorsDB = SiPixelDynamicInefficiency->getPixelGeomFactors();
const std::map<uint32_t, double>& ColGeomFactorsDB = SiPixelDynamicInefficiency->getColGeomFactors();
const std::map<uint32_t, double>& ChipGeomFactorsDB = SiPixelDynamicInefficiency->getChipGeomFactors();
const std::map<uint32_t, std::vector<double> >& PUFactors = SiPixelDynamicInefficiency->getPUFactors();
std::vector<uint32_t > DetIdmasks = SiPixelDynamicInefficiency->getDetIdmasks();

// Loop on all modules, calculate geometrical scale factors and store in map for easy access
Expand Down
Expand Up @@ -491,10 +491,10 @@ void SiPixelDigitizerAlgorithm::init_DynIneffDB(const edm::EventSetup& es, const
void SiPixelDigitizerAlgorithm::PixelEfficiencies::init_from_db(const edm::ESHandle<TrackerGeometry>& geom, const edm::ESHandle<SiPixelDynamicInefficiency>& SiPixelDynamicInefficiency) {

theInstLumiScaleFactor = SiPixelDynamicInefficiency->gettheInstLumiScaleFactor();
std::map<uint32_t, double> PixelGeomFactorsDB = SiPixelDynamicInefficiency->getPixelGeomFactors();
std::map<uint32_t, double> ColGeomFactorsDB = SiPixelDynamicInefficiency->getColGeomFactors();
std::map<uint32_t, double> ChipGeomFactorsDB = SiPixelDynamicInefficiency->getChipGeomFactors();
std::map<uint32_t, std::vector<double> > PUFactors = SiPixelDynamicInefficiency->getPUFactors();
const std::map<uint32_t, double>& PixelGeomFactorsDB = SiPixelDynamicInefficiency->getPixelGeomFactors();
const std::map<uint32_t, double>& ColGeomFactorsDB = SiPixelDynamicInefficiency->getColGeomFactors();
const std::map<uint32_t, double>& ChipGeomFactorsDB = SiPixelDynamicInefficiency->getChipGeomFactors();
const std::map<uint32_t, std::vector<double> >& PUFactors = SiPixelDynamicInefficiency->getPUFactors();
std::vector<uint32_t > DetIdmasks = SiPixelDynamicInefficiency->getDetIdmasks();

// Loop on all modules, calculate geometrical scale factors and store in map for easy access
Expand Down
Expand Up @@ -13,6 +13,8 @@

namespace {
struct Count {
#ifdef SISTRIP_COUNT
// note: this code is not thread safe, counts will be inaccurate if run with multiple threads
double ncall=0;
double ndep=0, ndep2=0, maxdep=0;
double nstr=0, nstr2=0;
Expand All @@ -23,13 +25,17 @@ namespace {
void val(double d) { ncv++; nval+=d; nval2+=d*d; maxv=std::max(d,maxv);}
void zero() { dzero++;}
~Count() {
#ifdef SISTRIP_COUNT
std::cout << "deposits " << ncall << " " << maxdep << " " << ndep/ncall << " " << std::sqrt(ndep2*ncall -ndep*ndep)/ncall << std::endl;
std::cout << "zeros " << dzero << std::endl;
std::cout << "strips " << nstr/ndep << " " << std::sqrt(nstr2*ndep -nstr*nstr)/ndep << std::endl;
std::cout << "vaules " << ncv << " " << maxv << " " << nval/ncv << " " << std::sqrt(nval2*ncv -nval*nval)/ncv << std::endl;
#endif
}
#else
void dep(double) {}
void str(double) {}
void val(double) {}
void zero() {}
#endif
};

Count count;
Expand Down

0 comments on commit 2dca225

Please sign in to comment.