#include <SiStripNoisesGenerator.h>
Public Member Functions | |
void | getObj (SiStripNoises *&obj) |
SiStripNoisesGenerator (const edm::ParameterSet &, const edm::ActivityRegistry &) | |
~SiStripNoisesGenerator () | |
Private Member Functions | |
void | createObject () |
void | fillParameters (std::map< int, std::vector< double > > &mapToFill, const std::string ¶meterName) const |
Fills the parameters read from cfg and matching the name in the given map. | |
void | fillSubDetParameter (std::map< int, std::vector< double > > &mapToFill, const std::vector< double > &v, const int subDet, const unsigned short layers) const |
void | printLog (const uint32_t detId, const unsigned short strip, const double &noise) const |
std::pair< int, int > | subDetAndLayer (const uint32_t detit) const |
Given the map and the detid it returns the corresponding layer/ring. | |
Private Attributes | |
double | electronsPerADC_ |
double | minimumPosValue_ |
uint32_t | printDebug_ |
bool | stripLengthMode_ |
Definition at line 12 of file SiStripNoisesGenerator.h.
SiStripNoisesGenerator::SiStripNoisesGenerator | ( | const edm::ParameterSet & | iConfig, |
const edm::ActivityRegistry & | aReg | ||
) | [explicit] |
Definition at line 14 of file SiStripNoisesGenerator.cc.
: SiStripCondObjBuilderBase<SiStripNoises>::SiStripCondObjBuilderBase(iConfig), electronsPerADC_(0.), minimumPosValue_(0.), stripLengthMode_(true), printDebug_(0) { edm::LogInfo("SiStripNoisesGenerator") << "[SiStripNoisesGenerator::SiStripNoisesGenerator]"; }
SiStripNoisesGenerator::~SiStripNoisesGenerator | ( | ) |
Definition at line 24 of file SiStripNoisesGenerator.cc.
{ edm::LogInfo("SiStripNoisesGenerator") << "[SiStripNoisesGenerator::~SiStripNoisesGenerator]"; }
void SiStripNoisesGenerator::createObject | ( | ) | [private] |
Definition at line 29 of file SiStripNoisesGenerator.cc.
References SiStripCondObjBuilderBase< SiStripNoises >::_pset, prof2calltree::count, electronsPerADC_, fillParameters(), edm::FileInPath::fullPath(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), j, minimumPosValue_, SiStripCondObjBuilderBase< SiStripNoises >::obj_, printDebug_, printLog(), SiStripNoises::put(), matplotRender::reader, SiStripNoises::setData(), stripLengthMode_, and subDetAndLayer().
Referenced by getObj().
{ obj_ = new SiStripNoises(); stripLengthMode_ = _pset.getParameter<bool>("StripLengthMode"); //parameters for random noise generation. not used if Strip length mode is chosen std::map<int, std::vector<double> > meanNoise; fillParameters(meanNoise, "MeanNoise"); std::map<int, std::vector<double> > sigmaNoise; fillParameters(sigmaNoise, "SigmaNoise"); minimumPosValue_ = _pset.getParameter<double>("MinPositiveNoise"); //parameters for strip length proportional noise generation. not used if random mode is chosen std::map<int, std::vector<double> > noiseStripLengthLinearSlope; fillParameters(noiseStripLengthLinearSlope, "NoiseStripLengthSlope"); std::map<int, std::vector<double> > noiseStripLengthLinearQuote; fillParameters(noiseStripLengthLinearQuote, "NoiseStripLengthQuote"); electronsPerADC_ = _pset.getParameter<double>("electronPerAdc"); printDebug_ = _pset.getUntrackedParameter<uint32_t>("printDebug", 5); uint32_t count = 0; edm::FileInPath fp_ = _pset.getParameter<edm::FileInPath>("file"); SiStripDetInfoFileReader reader(fp_.fullPath()); const std::map<uint32_t, SiStripDetInfoFileReader::DetInfo > DetInfos = reader.getAllData(); for(std::map<uint32_t, SiStripDetInfoFileReader::DetInfo >::const_iterator it = DetInfos.begin(); it != DetInfos.end(); ++it) { //Generate Noises for det detid SiStripNoises::InputVector theSiStripVector; float noise = 0.; uint32_t detId = it->first; std::pair<int, int> sl = subDetAndLayer(detId); unsigned short nApvs = it->second.nApvs; if(stripLengthMode_) { // Use strip length double linearSlope = noiseStripLengthLinearSlope[sl.first][sl.second]; double linearQuote = noiseStripLengthLinearQuote[sl.first][sl.second]; double stripLength = it->second.stripLength; 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); } } else { // Use random generator double meanN = meanNoise[sl.first][sl.second]; double sigmaN = sigmaNoise[sl.first][sl.second]; for( unsigned short j=0; j<128*nApvs; ++j ) { noise = CLHEP::RandGauss::shoot(meanN, sigmaN); if( noise<=minimumPosValue_ ) noise = minimumPosValue_; if( count<printDebug_ ) printLog(detId, j, noise); obj_->setData(noise, theSiStripVector); } } ++count; if ( ! obj_->put(it->first,theSiStripVector) ) { edm::LogError("SiStripNoisesFakeESSource::produce ")<<" detid already exists"<<std::endl; } } }
void SiStripNoisesGenerator::fillParameters | ( | std::map< int, std::vector< double > > & | mapToFill, |
const std::string & | parameterName | ||
) | const [private] |
Fills the parameters read from cfg and matching the name in the given map.
Definition at line 122 of file SiStripNoisesGenerator.cc.
References SiStripCondObjBuilderBase< SiStripNoises >::_pset, fillSubDetParameter(), edm::ParameterSet::getParameter(), StripSubdetector::TEC, StripSubdetector::TIB, StripSubdetector::TID, and StripSubdetector::TOB.
Referenced by createObject().
{ int layersTIB = 4; int ringsTID = 3; int layersTOB = 6; int ringsTEC = 7; fillSubDetParameter( mapToFill, _pset.getParameter<std::vector<double> >(parameterName+"TIB"), int(StripSubdetector::TIB), layersTIB ); fillSubDetParameter( mapToFill, _pset.getParameter<std::vector<double> >(parameterName+"TID"), int(StripSubdetector::TID), ringsTID ); fillSubDetParameter( mapToFill, _pset.getParameter<std::vector<double> >(parameterName+"TOB"), int(StripSubdetector::TOB), layersTOB ); fillSubDetParameter( mapToFill, _pset.getParameter<std::vector<double> >(parameterName+"TEC"), int(StripSubdetector::TEC), ringsTEC ); }
void SiStripNoisesGenerator::fillSubDetParameter | ( | std::map< int, std::vector< double > > & | mapToFill, |
const std::vector< double > & | v, | ||
const int | subDet, | ||
const unsigned short | layers | ||
) | const [private] |
Fills the map with the paramters for the given subdetector.
Each vector "v" holds the parameters for the layers/rings, if the vector has only one parameter all the layers/rings get that parameter.
The only other possibility is that the number of parameters equals the number of layers, otherwise an exception of type "Configuration" will be thrown.
Definition at line 135 of file SiStripNoisesGenerator.cc.
References Exception.
Referenced by fillParameters().
{ if( v.size() == layers ) { mapToFill.insert(std::make_pair( subDet, v )); } else if( v.size() == 1 ) { std::vector<double> parV(layers, v[0]); mapToFill.insert(std::make_pair( subDet, parV )); } else { throw cms::Exception("Configuration") << "ERROR: number of parameters for subDet " << subDet << " are " << v.size() << ". They must be either 1 or " << layers << std::endl; } }
void SiStripNoisesGenerator::getObj | ( | SiStripNoises *& | obj | ) | [inline, virtual] |
Returns the CondObj
Reimplemented from SiStripCondObjBuilderBase< SiStripNoises >.
Definition at line 18 of file SiStripNoisesGenerator.h.
References createObject(), and SiStripCondObjBuilderBase< SiStripNoises >::obj_.
{createObject(); obj=obj_;}
void SiStripNoisesGenerator::printLog | ( | const uint32_t | detId, |
const unsigned short | strip, | ||
const double & | noise | ||
) | const [inline, private] |
Definition at line 36 of file SiStripNoisesGenerator.h.
Referenced by createObject().
{ edm::LogInfo("SiStripNoisesDummyCalculator") << "detid: " << detId << " strip: " << strip << " noise: " << noise << " \t" << std::endl; }
std::pair< int, int > SiStripNoisesGenerator::subDetAndLayer | ( | const uint32_t | detit | ) | const [private] |
Given the map and the detid it returns the corresponding layer/ring.
Definition at line 96 of file SiStripNoisesGenerator.cc.
References TIBDetId::layer(), TOBDetId::layer(), TIDDetId::ring(), TECDetId::ring(), DetId::subdetId(), StripSubdetector::TEC, StripSubdetector::TIB, StripSubdetector::TID, and StripSubdetector::TOB.
Referenced by createObject().
{ int layerId = 0; StripSubdetector subid(detId); int subId = subid.subdetId(); if( subId == int(StripSubdetector::TIB)) { TIBDetId theTIBDetId(detId); layerId = theTIBDetId.layer() - 1; } else if(subId == int(StripSubdetector::TOB)) { TOBDetId theTOBDetId(detId); layerId = theTOBDetId.layer() - 1; } else if(subId == int(StripSubdetector::TID)) { TIDDetId theTIDDetId(detId); layerId = theTIDDetId.ring() - 1; } if(subId == int(StripSubdetector::TEC)) { TECDetId theTECDetId = TECDetId(detId); layerId = theTECDetId.ring() - 1; } return std::make_pair(subId, layerId); }
double SiStripNoisesGenerator::electronsPerADC_ [private] |
Definition at line 41 of file SiStripNoisesGenerator.h.
Referenced by createObject().
double SiStripNoisesGenerator::minimumPosValue_ [private] |
Definition at line 42 of file SiStripNoisesGenerator.h.
Referenced by createObject().
uint32_t SiStripNoisesGenerator::printDebug_ [private] |
Definition at line 44 of file SiStripNoisesGenerator.h.
Referenced by createObject().
bool SiStripNoisesGenerator::stripLengthMode_ [private] |
Definition at line 43 of file SiStripNoisesGenerator.h.
Referenced by createObject().