Skip to content

Commit

Permalink
Merge pull request #261 from gartung/CalibTracker-SiStripESProducers-…
Browse files Browse the repository at this point in the history
…getObj-thread-safe

Make getObj in the *Generator classes thread safe
  • Loading branch information
ktf committed Aug 19, 2013
2 parents a587eb5 + efc2073 commit 4211ada
Show file tree
Hide file tree
Showing 20 changed files with 68 additions and 59 deletions.
Expand Up @@ -19,11 +19,11 @@ class SiStripApvGainGenerator : public SiStripCondObjBuilderBase<SiStripApvGain>
explicit SiStripApvGainGenerator(const edm::ParameterSet&,const edm::ActivityRegistry&);
~SiStripApvGainGenerator();

void getObj(SiStripApvGain* & obj){createObject(); obj=obj_;}
void getObj(SiStripApvGain* & obj){obj=createObject();}

private:

void createObject();
SiStripApvGain* createObject();


};
Expand Down
Expand Up @@ -19,11 +19,11 @@ class SiStripBackPlaneCorrectionGenerator : public SiStripCondObjBuilderBase<SiS
explicit SiStripBackPlaneCorrectionGenerator(const edm::ParameterSet&,const edm::ActivityRegistry&);
~SiStripBackPlaneCorrectionGenerator();

void getObj(SiStripBackPlaneCorrection* & obj){createObject(); obj=obj_;}
void getObj(SiStripBackPlaneCorrection* & obj){obj=createObject();}

private:

void createObject();
SiStripBackPlaneCorrection* createObject();
};

#endif
Expand Up @@ -13,11 +13,11 @@ class SiStripBadModuleGenerator : public SiStripCondObjBuilderBase<SiStripBadStr
explicit SiStripBadModuleGenerator(const edm::ParameterSet&,const edm::ActivityRegistry&);
~SiStripBadModuleGenerator();

void getObj(SiStripBadStrip* & obj){createObject(); obj=obj_;}
void getObj(SiStripBadStrip* & obj){obj=createObject();}

private:

void createObject();
SiStripBadStrip* createObject();

void selectDetectors(const std::vector<uint32_t>& , std::vector<uint32_t>& );

Expand Down
Expand Up @@ -17,11 +17,11 @@ class SiStripBaseDelayGenerator : public SiStripCondObjBuilderBase<SiStripBaseDe
explicit SiStripBaseDelayGenerator(const edm::ParameterSet&,const edm::ActivityRegistry&);
~SiStripBaseDelayGenerator();

void getObj(SiStripBaseDelay* & obj){createObject(); obj=obj_;}
void getObj(SiStripBaseDelay* & obj){obj=createObject();}

private:

void createObject();
SiStripBaseDelay* createObject();

};

Expand Down
Expand Up @@ -18,11 +18,11 @@ class SiStripConfObjectGenerator : public SiStripCondObjBuilderBase<SiStripConfO
explicit SiStripConfObjectGenerator(const edm::ParameterSet&,const edm::ActivityRegistry&);
~SiStripConfObjectGenerator();

void getObj(SiStripConfObject* & obj){createObject(); obj=obj_;}
void getObj(SiStripConfObject* & obj){obj=createObject();}

private:

void createObject();
SiStripConfObject* createObject();

std::vector<edm::ParameterSet> parameters_;
};
Expand Down
Expand Up @@ -17,11 +17,11 @@ class SiStripLatencyGenerator : public SiStripCondObjBuilderBase<SiStripLatency>
explicit SiStripLatencyGenerator(const edm::ParameterSet&,const edm::ActivityRegistry&);
~SiStripLatencyGenerator();

void getObj(SiStripLatency* & obj){createObject(); obj=obj_;}
void getObj(SiStripLatency* & obj){obj=createObject();}

private:

void createObject();
SiStripLatency* createObject();

};

Expand Down
Expand Up @@ -25,11 +25,11 @@ class SiStripLorentzAngleGenerator : public SiStripCondObjBuilderBase<SiStripLor
explicit SiStripLorentzAngleGenerator(const edm::ParameterSet&,const edm::ActivityRegistry&);
~SiStripLorentzAngleGenerator();

void getObj(SiStripLorentzAngle* & obj){createObject(); obj=obj_;}
void getObj(SiStripLorentzAngle* & obj){obj=createObject();}

private:

void createObject();
SiStripLorentzAngle* createObject();
float hallMobility_;
/**
* This method fills the hallMobility_ variable with different values according to the parameters passed in the cfg. <br>
Expand Down
Expand Up @@ -15,11 +15,11 @@ class SiStripNoisesGenerator : public SiStripCondObjBuilderBase<SiStripNoises> {
explicit SiStripNoisesGenerator(const edm::ParameterSet&,const edm::ActivityRegistry&);
~SiStripNoisesGenerator();

void getObj(SiStripNoises* & obj){createObject(); obj=obj_;}
void getObj(SiStripNoises* & obj){obj=createObject();}

private:

void createObject();
SiStripNoises* createObject();
/// Given the map and the detid it returns the corresponding layer/ring
std::pair<int, int> subDetAndLayer(const uint32_t detit) const;
/// Fills the parameters read from cfg and matching the name in the given map
Expand Down
Expand Up @@ -13,11 +13,11 @@ class SiStripPedestalsGenerator : public SiStripCondObjBuilderBase<SiStripPedest
explicit SiStripPedestalsGenerator(const edm::ParameterSet&,const edm::ActivityRegistry&);
~SiStripPedestalsGenerator();

void getObj(SiStripPedestals* & obj){createObject(); obj=obj_;}
void getObj(SiStripPedestals* & obj){obj=createObject();}

private:

void createObject();
SiStripPedestals* createObject();


};
Expand Down
Expand Up @@ -13,11 +13,11 @@ class SiStripThresholdGenerator : public SiStripCondObjBuilderBase<SiStripThresh
explicit SiStripThresholdGenerator(const edm::ParameterSet&,const edm::ActivityRegistry&);
~SiStripThresholdGenerator();

void getObj(SiStripThreshold* & obj){createObject(); obj=obj_;}
void getObj(SiStripThreshold* & obj){obj=createObject();}

private:

void createObject();
SiStripThreshold* createObject();


};
Expand Down
Expand Up @@ -17,9 +17,9 @@ SiStripApvGainGenerator::~SiStripApvGainGenerator() {
edm::LogInfo("SiStripApvGainGenerator") << "[SiStripApvGainGenerator::~SiStripApvGainGenerator]";
}

void SiStripApvGainGenerator::createObject(){
SiStripApvGain* SiStripApvGainGenerator::createObject(){

obj_ = new SiStripApvGain();
SiStripApvGain* obj = new SiStripApvGain();

std::string genMode = _pset.getParameter<std::string>("genMode");

Expand Down Expand Up @@ -58,7 +58,8 @@ void SiStripApvGainGenerator::createObject(){
}
count++;
SiStripApvGain::Range range(theSiStripVector.begin(),theSiStripVector.end());
if ( ! obj_->put(it->first,range) )
if ( ! obj->put(it->first,range) )
edm::LogError("SiStripApvGainGenerator")<<" detid already exists"<<std::endl;
}
return obj;
}
Expand Up @@ -23,9 +23,9 @@ SiStripBackPlaneCorrectionGenerator::~SiStripBackPlaneCorrectionGenerator() {
edm::LogInfo("SiStripBackPlaneCorrectionGenerator") << "[SiStripBackPlaneCorrectionGenerator::~SiStripBackPlaneCorrectionGenerator]";
}

void SiStripBackPlaneCorrectionGenerator::createObject()
SiStripBackPlaneCorrection* SiStripBackPlaneCorrectionGenerator::createObject()
{
obj_ = new SiStripBackPlaneCorrection();
SiStripBackPlaneCorrection* obj = new SiStripBackPlaneCorrection();

edm::FileInPath fp_ = _pset.getParameter<edm::FileInPath>("file");
std::vector<double> valuePerModuleGeometry(_pset.getParameter<std::vector<double> >("BackPlaneCorrection_PerModuleGeometry"));
Expand All @@ -38,8 +38,9 @@ void SiStripBackPlaneCorrectionGenerator::createObject()
if(moduleGeometry>valuePerModuleGeometry.size())edm::LogError("SiStripBackPlaneCorrectionGenerator")<<" BackPlaneCorrection_PerModuleGeometry only contains "<< valuePerModuleGeometry.size() << "elements and module is out of range"<<std::endl;
float value = valuePerModuleGeometry[moduleGeometry];

if (!obj_->putBackPlaneCorrection(*detit, value) ) {
if (!obj->putBackPlaneCorrection(*detit, value) ) {
edm::LogError("SiStripBackPlaneCorrectionGenerator")<<" detid already exists"<<std::endl;
}
}
return obj;
}
Expand Up @@ -25,7 +25,7 @@ SiStripBadModuleGenerator::~SiStripBadModuleGenerator() {
}


void SiStripBadModuleGenerator::createObject(){
SiStripBadStrip* SiStripBadModuleGenerator::createObject(){

SiStripQuality* obj = new SiStripQuality();

Expand Down Expand Up @@ -79,8 +79,8 @@ void SiStripBadModuleGenerator::createObject(){
edm::LogInfo("SiStripQualityConfigurableFakeESSource") << ss1.str();
}

obj_ = new SiStripBadStrip( *(dynamic_cast<SiStripBadStrip*> (obj)));
delete obj;
// obj_ = new SiStripBadStrip( *(dynamic_cast<SiStripBadStrip*> (obj)));
return obj;
}


Expand Down
Expand Up @@ -18,9 +18,9 @@ SiStripBaseDelayGenerator::~SiStripBaseDelayGenerator()
edm::LogInfo("SiStripBaseDelayGenerator") << "[SiStripBaseDelayGenerator::~SiStripBaseDelayGenerator]";
}

void SiStripBaseDelayGenerator::createObject()
SiStripBaseDelay* SiStripBaseDelayGenerator::createObject()
{
obj_ = new SiStripBaseDelay();
SiStripBaseDelay* obj = new SiStripBaseDelay();

// Read the full list of detIds
edm::FileInPath fp_ = _pset.getParameter<edm::FileInPath>("file");
Expand All @@ -31,10 +31,11 @@ void SiStripBaseDelayGenerator::createObject()
if( !detInfos.empty() ) {
std::map<uint32_t, SiStripDetInfoFileReader::DetInfo>::const_iterator it = detInfos.begin();
for( ; it != detInfos.end(); ++it ) {
obj_->put(it->first, coarseDelay, fineDelay);
obj->put(it->first, coarseDelay, fineDelay);
}
}
else {
edm::LogError("SiStripBaseDelayGenerator") << "Error: detInfo map is empty." << std::endl;
}
return obj;
}
Expand Up @@ -12,20 +12,21 @@ SiStripConfObjectGenerator::~SiStripConfObjectGenerator()
edm::LogInfo("SiStripConfObjectGenerator") << "[SiStripConfObjectGenerator::~SiStripConfObjectGenerator]";
}

void SiStripConfObjectGenerator::createObject()
SiStripConfObject* SiStripConfObjectGenerator::createObject()
{
parameters_ = _pset.getParameter<std::vector<edm::ParameterSet> >("Parameters");
std::vector<edm::ParameterSet>::const_iterator parIt = parameters_.begin();
obj_ = new SiStripConfObject();
SiStripConfObject* obj = new SiStripConfObject();
for( ; parIt != parameters_.end(); ++parIt ) {
if( parIt->getParameter<std::string>("ParameterType") == "int" ) {
obj_->put(parIt->getParameter<std::string>("ParameterName"), parIt->getParameter<int32_t>("ParameterValue"));
obj->put(parIt->getParameter<std::string>("ParameterName"), parIt->getParameter<int32_t>("ParameterValue"));
}
else if( parIt->getParameter<std::string>("ParameterType") == "double" ) {
obj_->put(parIt->getParameter<std::string>("ParameterName"), parIt->getParameter<double>("ParameterValue"));
obj->put(parIt->getParameter<std::string>("ParameterName"), parIt->getParameter<double>("ParameterValue"));
}
if( parIt->getParameter<std::string>("ParameterType") == "string" ) {
obj_->put(parIt->getParameter<std::string>("ParameterName"), parIt->getParameter<std::string>("ParameterValue"));
obj->put(parIt->getParameter<std::string>("ParameterName"), parIt->getParameter<std::string>("ParameterValue"));
}
}
return obj;
}
Expand Up @@ -18,9 +18,9 @@ SiStripLatencyGenerator::~SiStripLatencyGenerator()
edm::LogInfo("SiStripLatencyGenerator") << "[SiStripLatencyGenerator::~SiStripLatencyGenerator]";
}

void SiStripLatencyGenerator::createObject()
SiStripLatency* SiStripLatencyGenerator::createObject()
{
obj_ = new SiStripLatency();
SiStripLatency* obj = new SiStripLatency();

// Read the full list of detIds
edm::FileInPath fp_ = _pset.getParameter<edm::FileInPath>("file");
Expand All @@ -32,12 +32,13 @@ void SiStripLatencyGenerator::createObject()
edm::LogInfo("SiStripLatencyGenerator") << "detId = " << detInfos.rbegin()->first << " apv = " << 6
<< " latency = " << _pset.getParameter<uint32_t>("latency")
<< " mode = " << _pset.getParameter<uint32_t>("mode") << std::endl;
obj_->put(detInfos.rbegin()->first, 6, _pset.getParameter<uint32_t>("latency"), _pset.getParameter<uint32_t>("mode") );
obj->put(detInfos.rbegin()->first, 6, _pset.getParameter<uint32_t>("latency"), _pset.getParameter<uint32_t>("mode") );

// Call this method to collapse all consecutive detIdAndApvs with the same latency and mode to a single entry
obj_->compress();
obj->compress();
}
else {
edm::LogError("SiStripLatencyGenerator") << "Error: detInfo map is empty. Cannot get the last detId." << std::endl;
}
return obj;
}
Expand Up @@ -47,9 +47,9 @@ void SiStripLorentzAngleGenerator::setUniform(const std::vector<double> & estima
}
}

void SiStripLorentzAngleGenerator::createObject()
SiStripLorentzAngle* SiStripLorentzAngleGenerator::createObject()
{
obj_ = new SiStripLorentzAngle();
SiStripLorentzAngle* obj = new SiStripLorentzAngle();

edm::FileInPath fp_ = _pset.getParameter<edm::FileInPath>("file");

Expand Down Expand Up @@ -125,8 +125,10 @@ void SiStripLorentzAngleGenerator::createObject()
}
}

if ( ! obj_->putLorentzAngle(*detit, hallMobility_) ) {
if ( ! obj->putLorentzAngle(*detit, hallMobility_) ) {
edm::LogError("SiStripLorentzAngleGenerator")<<" detid already exists"<<std::endl;
}
}
return obj;
}

11 changes: 6 additions & 5 deletions CalibTracker/SiStripESProducers/src/SiStripNoisesGenerator.cc
Expand Up @@ -26,9 +26,9 @@ SiStripNoisesGenerator::~SiStripNoisesGenerator()
edm::LogInfo("SiStripNoisesGenerator") << "[SiStripNoisesGenerator::~SiStripNoisesGenerator]";
}

void SiStripNoisesGenerator::createObject()
SiStripNoises* SiStripNoisesGenerator::createObject()
{
obj_ = new SiStripNoises();
SiStripNoises* obj = new SiStripNoises();

stripLengthMode_ = _pset.getParameter<bool>("StripLengthMode");

Expand Down Expand Up @@ -71,7 +71,7 @@ void SiStripNoisesGenerator::createObject()
for( unsigned short j=0; j<128*nApvs; ++j ) {
noise = ( linearSlope*stripLength + linearQuote) / electronsPerADC_;
if( count<printDebug_ ) printLog(detId, j, noise);
obj_->setData(noise, theSiStripVector);
obj->setData(noise, theSiStripVector);
}
}
else {
Expand All @@ -82,15 +82,16 @@ void SiStripNoisesGenerator::createObject()
noise = CLHEP::RandGauss::shoot(meanN, sigmaN);
if( noise<=minimumPosValue_ ) noise = minimumPosValue_;
if( count<printDebug_ ) printLog(detId, j, noise);
obj_->setData(noise, theSiStripVector);
obj->setData(noise, theSiStripVector);
}
}
++count;

if ( ! obj_->put(it->first,theSiStripVector) ) {
if ( ! obj->put(it->first,theSiStripVector) ) {
edm::LogError("SiStripNoisesFakeESSource::produce ")<<" detid already exists"<<std::endl;
}
}
return obj;
}

std::pair<int, int> SiStripNoisesGenerator::subDetAndLayer( const uint32_t detId ) const
Expand Down
Expand Up @@ -16,9 +16,9 @@ SiStripPedestalsGenerator::~SiStripPedestalsGenerator() {
}


void SiStripPedestalsGenerator::createObject(){
SiStripPedestals* SiStripPedestalsGenerator::createObject(){

obj_ = new SiStripPedestals();
SiStripPedestals* obj = new SiStripPedestals();

uint32_t PedestalValue_ = _pset.getParameter<uint32_t>("PedestalsValue");
edm::FileInPath fp_ = _pset.getParameter<edm::FileInPath>("file");
Expand All @@ -37,10 +37,11 @@ void SiStripPedestalsGenerator::createObject(){
if (count<printdebug_) {
edm::LogInfo("SiStripPedestalsFakeESSource::makePedestals(): ") << "detid: " << it->first << " strip: " << j << " ped: " << PedestalValue_ << std::endl;
}
obj_->setData(PedestalValue_,theSiStripVector);
obj->setData(PedestalValue_,theSiStripVector);
}
count++;
if ( ! obj_->put(it->first, theSiStripVector) )
if ( ! obj->put(it->first, theSiStripVector) )
edm::LogError("SiStripPedestalsFakeESSource::produce ")<<" detid already exists"<<std::endl;
}
return obj;
}

0 comments on commit 4211ada

Please sign in to comment.