Skip to content

Commit 498f9dc

Browse files
committed
Merge pull request cms-sw#1189 from wmtan/MakeMixingModuleDataMemberNonStatic
Multithreading fixes -- Make a static data member non-static and declare another static const.
2 parents 21891f3 + 402362e commit 498f9dc

File tree

5 files changed

+13
-15
lines changed

5 files changed

+13
-15
lines changed

Mixing/Base/interface/BMixingModule.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ namespace edm {
7777
virtual void endJob() override;
7878
// std::string type_;
7979
int bunchSpace_;
80-
static int vertexoffset;
80+
int vertexOffset_;
8181
bool checktof_;
8282
int minBunch_;
8383
int maxBunch_;

Mixing/Base/src/BMixingModule.cc

+7-9
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717
#include "TFile.h"
1818
#include "TH1F.h"
1919

20-
using namespace std;
21-
22-
int edm::BMixingModule::vertexoffset = 0;
2320
const unsigned int edm::BMixingModule::maxNbSources_ =4;
2421

2522
namespace
@@ -37,8 +34,8 @@ namespace
3734
std::string histoFileName=" ";
3835
std::string histoName =" ";
3936
TH1F * h = new TH1F("h","h",10,0,10);
40-
vector<int> dataProbFunctionVar;
41-
vector<double> dataProb;
37+
std::vector<int> dataProbFunctionVar;
38+
std::vector<double> dataProb;
4239

4340

4441
const edm::ParameterSet & psin=ps.getParameter<edm::ParameterSet>(sourceName);
@@ -91,15 +88,15 @@ namespace
9188
type_="probFunction";
9289
}
9390

94-
dataProbFunctionVar = psin_average.getParameter<vector<int> >("probFunctionVariable");
95-
dataProb = psin_average.getParameter<vector<double> >("probValue");
91+
dataProbFunctionVar = psin_average.getParameter<std::vector<int> >("probFunctionVariable");
92+
dataProb = psin_average.getParameter<std::vector<double> >("probValue");
9693
histoFileName = psin_average.getUntrackedParameter<std::string>("histoFileName");
9794

9895
int varSize = (int) dataProbFunctionVar.size();
9996
int probSize = (int) dataProb.size();
10097

10198
if ((dataProbFunctionVar[0] != 0) || (dataProbFunctionVar[varSize - 1] != (varSize - 1)))
102-
throw cms::Exception("BadProbFunction") << "Please, check the variables of the probability function! The first variable should be 0 and the difference between two variables should be 1." << endl;
99+
throw cms::Exception("BadProbFunction") << "Please, check the variables of the probability function! The first variable should be 0 and the difference between two variables should be 1." << std::endl;
103100

104101
// Complete the vector containing the probability function data
105102
// with the values "0"
@@ -130,7 +127,7 @@ namespace
130127

131128
// Check if the histogram is normalized
132129
if ( ((hprob->Integral() - 1) > 1.0e-02) && ((hprob->Integral() - 1) < -1.0e-02)){
133-
throw cms::Exception("BadProbFunction") << "The probability function should be normalized!!! " << endl;
130+
throw cms::Exception("BadProbFunction") << "The probability function should be normalized!!! " << std::endl;
134131
}
135132

136133
averageNumber = hprob->GetMean();
@@ -168,6 +165,7 @@ namespace edm {
168165
// Constructor
169166
BMixingModule::BMixingModule(const edm::ParameterSet& pset) :
170167
bunchSpace_(pset.getParameter<int>("bunchspace")),
168+
vertexOffset_(0),
171169
minBunch_((pset.getParameter<int>("minBunch")*25)/pset.getParameter<int>("bunchspace")),
172170
maxBunch_((pset.getParameter<int>("maxBunch")*25)/pset.getParameter<int>("bunchspace")),
173171
mixProdStep1_(pset.getParameter<bool>("mixProdStep1")),

SimGeneral/MixingModule/interface/DigiAccumulatorMixModFactory.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ namespace edm {
1818
public:
1919
~DigiAccumulatorMixModFactory();
2020

21-
static DigiAccumulatorMixModFactory* get();
21+
static DigiAccumulatorMixModFactory const* get();
2222

2323
std::auto_ptr<DigiAccumulatorMixMod>
2424
makeDigiAccumulator(ParameterSet const&, one::EDProducerBase&, ConsumesCollector&) const;
2525

2626
private:
2727
DigiAccumulatorMixModFactory();
28-
static DigiAccumulatorMixModFactory singleInstance_;
28+
static DigiAccumulatorMixModFactory const singleInstance_;
2929
};
3030
}
3131

SimGeneral/MixingModule/plugins/MixingModule.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ namespace edm {
296296
LogDebug("MixingModule") <<" merging Event: id " << eventPrincipal.id();
297297
// std::cout <<"PILEALLWORKERS merging Event: id " << eventPrincipal.id() << std::endl;
298298

299-
workers_[ii]->addPileups(bunchCrossing,eventPrincipal, &moduleCallingContext, eventId, vertexoffset);
299+
workers_[ii]->addPileups(bunchCrossing,eventPrincipal, &moduleCallingContext, eventId, vertexOffset_);
300300
}
301301
}
302302

SimGeneral/MixingModule/src/DigiAccumulatorMixModFactory.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ namespace edm {
1919
DigiAccumulatorMixModFactory::DigiAccumulatorMixModFactory() {
2020
}
2121

22-
DigiAccumulatorMixModFactory DigiAccumulatorMixModFactory::singleInstance_;
22+
DigiAccumulatorMixModFactory const DigiAccumulatorMixModFactory::singleInstance_;
2323

24-
DigiAccumulatorMixModFactory* DigiAccumulatorMixModFactory::get() {
24+
DigiAccumulatorMixModFactory const* DigiAccumulatorMixModFactory::get() {
2525
// will not work with plugin factories
2626
//static DigiAccumulatorMixModFactory f;
2727
//return &f;

0 commit comments

Comments
 (0)