14 fp_(iConfig.getUntrackedParameter<edm::
FileInPath>(
"file",edm::
FileInPath(
"CalibTracker/SiStripCommon/data/SiStripDetInfo.dat"))),
15 printdebug_(iConfig.getUntrackedParameter<uint32_t>(
"printDebug",1)),
19 stripLengthMode_(
true),
33 std::vector<uint32_t> inputDetIds;
34 inputApvGain->getDetIds(inputDetIds);
46 std::map<int, std::vector<double> > meanNoise;
48 std::map<int, std::vector<double> > sigmaNoise;
53 std::map<int, std::vector<double> > noiseStripLengthLinearSlope;
54 fillParameters(noiseStripLengthLinearSlope,
"NoiseStripLengthSlope");
55 std::map<int, std::vector<double> > noiseStripLengthLinearQuote;
56 fillParameters(noiseStripLengthLinearQuote,
"NoiseStripLengthQuote");
61 unsigned int count = 0;
62 const std::map<uint32_t, SiStripDetInfoFileReader::DetInfo > DetInfos =
reader.getAllData();
63 for(std::map<uint32_t, SiStripDetInfoFileReader::DetInfo >::const_iterator it = DetInfos.begin(); it != DetInfos.end(); it++) {
71 uint32_t detId = it->first;
73 unsigned short nApvs = it->second.nApvs;
75 if(stripLengthMode_) {
77 double linearSlope = noiseStripLengthLinearSlope[sl.first][sl.second];
78 double linearQuote = noiseStripLengthLinearQuote[sl.first][sl.second];
79 double stripLength = it->second.stripLength;
80 for(
unsigned short j=0;
j<nApvs; ++
j ) {
82 double gain = inputApvGain->getApvGain(
j,
inputRange);
84 for(
unsigned short stripId = 0; stripId < 128; ++stripId ) {
85 noise = ( ( linearSlope*stripLength + linearQuote) /
electronsPerADC_ ) * gain;
86 if( count<printDebug_ )
printLog(detId, stripId+128*
j, noise);
87 obj->
setData(noise, theSiStripVector);
93 double meanN = meanNoise[sl.first][sl.second];
94 double sigmaN = sigmaNoise[sl.first][sl.second];
95 for(
unsigned short j=0;
j<nApvs; ++
j ) {
97 double gain = inputApvGain->getApvGain(
j,
inputRange);
99 for(
unsigned short stripId = 0; stripId < 128; ++stripId ) {
100 noise = ( CLHEP::RandGauss::shoot(meanN, sigmaN) ) * gain;
102 if( count<printDebug_ )
printLog(detId, stripId+128*
j, noise);
103 obj->
setData(noise, theSiStripVector);
109 if ( ! obj->
put(it->first,theSiStripVector) ) {
110 edm::LogError(
"SiStripNoisesFakeESSource::produce ")<<
" detid already exists"<<std::endl;
126 edm::LogError(
"SiStripNoiseNormalizedWithApvGainBuilder")<<
"Service is unavailable"<<std::endl;
138 layerId = tTopo->
tibLayer(detId) - 1;
141 layerId = tTopo->
tobLayer(detId) - 1;
144 layerId = tTopo->
tidRing(detId) - 1;
147 layerId = tTopo->
tecRing(detId) - 1;
149 return std::make_pair(subId, layerId);
167 if( v.size() == layers ) {
168 mapToFill.insert(std::make_pair( subDet, v ));
170 else if( v.size() == 1 ) {
171 std::vector<double> parV(layers, v[0]);
172 mapToFill.insert(std::make_pair( subDet, parV ));
175 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
inputRange
Get input source.
unsigned int tibLayer(const DetId &id) const
unsigned int tidRing(const DetId &id) const
unsigned int tecRing(const DetId &id) const
ring id
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.
std::vector< uint16_t > InputVector
SiStripNoiseNormalizedWithApvGainBuilder(const edm::ParameterSet &iConfig)
void appendSinceTime(T *payloadObj, cond::Time_t sinceTime, const std::string &recordName, bool withlogging=false)
bool isNewTagRequest(const std::string &recordName)
cond::Time_t beginOfTime() const
std::pair< ContainerIterator, ContainerIterator > Range
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 printLog(const uint32_t detId, const unsigned short strip, const double &noise) const
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
void createNewIOV(T *firstPayloadObj, cond::Time_t firstSinceTime, cond::Time_t firstTillTime, const std::string &recordName, bool withlogging=false)
bool put(const uint32_t &detID, const InputVector &input)
void fillSubDetParameter(std::map< int, std::vector< double > > &mapToFill, const std::vector< double > &v, const int subDet, const unsigned short layers) const
virtual void analyze(const edm::Event &, const edm::EventSetup &)
T const * product() const
cond::Time_t endOfTime() const
cond::Time_t currentTime() const
std::string fullPath() const
void setData(float noise_, InputVector &vped)
unsigned int tobLayer(const DetId &id) const