2 #include <boost/cstdint.hpp>
6 #include "CLHEP/Random/RandFlat.h"
7 #include "CLHEP/Random/RandGauss.h"
13 stripLengthMode_(
true),
16 edm::LogInfo(
"SiStripNoisesGenerator") <<
"[SiStripNoisesGenerator::SiStripNoisesGenerator]";
21 edm::LogInfo(
"SiStripNoisesGenerator") <<
"[SiStripNoisesGenerator::~SiStripNoisesGenerator]";
31 std::map<int, std::vector<double> > meanNoise;
33 std::map<int, std::vector<double> > sigmaNoise;
38 std::map<int, std::vector<double> > noiseStripLengthLinearSlope;
39 fillParameters(noiseStripLengthLinearSlope,
"NoiseStripLengthSlope");
40 std::map<int, std::vector<double> > noiseStripLengthLinearQuote;
41 fillParameters(noiseStripLengthLinearQuote,
"NoiseStripLengthQuote");
49 const std::map<uint32_t, SiStripDetInfoFileReader::DetInfo > DetInfos =
reader.getAllData();
51 for(std::map<uint32_t, SiStripDetInfoFileReader::DetInfo >::const_iterator it = DetInfos.begin(); it != DetInfos.end(); ++it) {
56 uint32_t detId = it->first;
58 unsigned short nApvs = it->second.nApvs;
63 double linearSlope = noiseStripLengthLinearSlope[sl.first][sl.second];
64 double linearQuote = noiseStripLengthLinearQuote[sl.first][sl.second];
65 double stripLength = it->second.stripLength;
66 for(
unsigned short j=0;
j<128*nApvs; ++
j ) {
68 if( count<printDebug_ )
printLog(detId,
j, noise);
69 obj->
setData(noise, theSiStripVector);
74 double meanN = meanNoise[sl.first][sl.second];
75 double sigmaN = sigmaNoise[sl.first][sl.second];
76 for(
unsigned short j=0;
j<128*nApvs; ++
j ) {
77 noise = CLHEP::RandGauss::shoot(meanN, sigmaN);
79 if( count<printDebug_ )
printLog(detId,
j, noise);
80 obj->
setData(noise, theSiStripVector);
85 if ( ! obj->
put(it->first,theSiStripVector) ) {
86 edm::LogError(
"SiStripNoisesFakeESSource::produce ")<<
" detid already exists"<<std::endl;
97 const int subDet = detectorId.
subdetId();
100 layerId = tTopo->
tibLayer(detectorId) - 1;
103 layerId = tTopo->
tobLayer(detectorId) - 1;
106 layerId = tTopo->
tidRing(detectorId) - 1;
109 layerId = tTopo->
tecRing(detectorId) - - 1;
111 return std::make_pair(subDet, layerId);
129 if( v.size() ==
layers ) {
130 mapToFill.insert(std::make_pair( subDet, v ));
132 else if( v.size() == 1 ) {
133 std::vector<double> parV(layers, v[0]);
134 mapToFill.insert(std::make_pair( subDet, parV ));
137 throw cms::Exception(
"Configuration") <<
"ERROR: number of parameters for subDet " << subDet <<
" are " << v.size() <<
". They must be either 1 or " << layers << std::endl;
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
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.
std::vector< LayerSetAndLayers > layers(const SeedingLayerSetsHits &sets)
SiStripNoises * createObject(const TrackerTopology *tTopo)
unsigned int tibLayer(const DetId &id) const
unsigned int tidRing(const DetId &id) const
unsigned int tecRing(const DetId &id) const
ring id
std::vector< uint16_t > InputVector
SiStripNoisesGenerator(const edm::ParameterSet &, const edm::ActivityRegistry &)
void fillSubDetParameter(std::map< int, std::vector< double > > &mapToFill, const std::vector< double > &v, const int subDet, const unsigned short layers) const
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
bool put(const uint32_t &detID, const InputVector &input)
std::pair< int, int > subDetAndLayer(const uint32_t detit, const TrackerTopology *tTopo) const
Given the map and the detid it returns the corresponding layer/ring.
void printLog(const uint32_t detId, const unsigned short strip, const double &noise) const
std::string fullPath() const
~SiStripNoisesGenerator()
void setData(float noise_, InputVector &vped)
unsigned int tobLayer(const DetId &id) const