CMS 3D CMS Logo

SiStripNoisesFakeESSource.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: CalibTracker/SiStripESProducers
4 // Class: SiStripNoisesFakeESSource
5 //
16 // system include files
17 #include <memory>
18 
19 // user include files
22 
26 
28 
30 
32 public:
34  ~SiStripNoisesFakeESSource() override;
35 
37  const edm::IOVSyncValue& iov,
38  edm::ValidityInterval& iValidity) override;
39 
40  typedef std::unique_ptr<SiStripNoises> ReturnType;
42 
43 private:
46  double m_noisePar0;
49  uint32_t m_printDebug;
51 };
52 
55 
56 #include "CLHEP/Random/RandGauss.h"
57 
58 namespace { // helper methods
59  inline void printLog(const uint32_t detId, const unsigned short strip, const double& noise) {
60  edm::LogInfo("SiStripNoisesDummyCalculator") << "detid: " << detId << " strip: " << strip << " noise: " << noise;
61  }
62 } // namespace
63 
65  : m_tTopoToken(setWhatProduced(this).consumes()) {
66  findingRecord<SiStripNoisesRcd>();
67 
68  m_stripLengthMode = iConfig.getParameter<bool>("StripLengthMode");
69 
70  if (!m_stripLengthMode) {
71  //parameters for random noise generation. not used if Strip length mode is chosen
72  m_noisePar0 = iConfig.getParameter<double>("MinPositiveNoise");
73  m_noisePar1 = SiStripFakeAPVParameters(iConfig, "MeanNoise");
74  m_noisePar2 = SiStripFakeAPVParameters(iConfig, "SigmaNoise");
75  } else {
76  //parameters for strip length proportional noise generation. not used if random mode is chosen
77  m_noisePar0 = iConfig.getParameter<double>("electronPerAdc");
78  m_noisePar1 = SiStripFakeAPVParameters(iConfig, "NoiseStripLengthSlope");
79  m_noisePar2 = SiStripFakeAPVParameters(iConfig, "NoiseStripLengthQuote");
80  }
81 
82  m_printDebug = iConfig.getUntrackedParameter<uint32_t>("printDebug", 5);
83 
85  SiStripDetInfoFileReader{iConfig.getParameter<edm::FileInPath>("SiStripDetInfoFile").fullPath()};
86 }
87 
89 
91  const edm::IOVSyncValue& iov,
92  edm::ValidityInterval& iValidity) {
93  iValidity = edm::ValidityInterval{iov.beginOfTime(), iov.endOfTime()};
94 }
95 
96 // ------------ method called to produce the data ------------
98  using namespace edm::es;
99 
100  const auto& tTopo = iRecord.get(m_tTopoToken);
101 
102  auto noises = std::make_unique<SiStripNoises>();
103 
104  uint32_t count{0};
105  for (const auto& elm : m_detInfoFileReader.getAllData()) {
106  //Generate Noises for det detid
107  SiStripNoises::InputVector theSiStripVector;
109 
110  if (m_stripLengthMode) {
111  // Use strip length
112  const double linearSlope{m_noisePar1.get(sl)};
113  const double linearQuote{m_noisePar2.get(sl)};
114  const double stripLength{elm.second.stripLength};
115  for (unsigned short j{0}; j < 128 * elm.second.nApvs; ++j) {
116  const float noise = (linearSlope * stripLength + linearQuote) / m_noisePar0;
117  if (count < m_printDebug)
118  printLog(elm.first, j, noise);
119  noises->setData(noise, theSiStripVector);
120  }
121  } else {
122  // Use random generator
123  const double meanN{m_noisePar1.get(sl)};
124  const double sigmaN{m_noisePar2.get(sl)};
125  for (unsigned short j{0}; j < 128 * elm.second.nApvs; ++j) {
126  const float noise = std::max(CLHEP::RandGauss::shoot(meanN, sigmaN), m_noisePar0);
127  if (count < m_printDebug)
128  printLog(elm.first, j, noise);
129  noises->setData(noise, theSiStripVector);
130  }
131  }
132  ++count;
133 
134  if (!noises->put(elm.first, theSiStripVector)) {
135  edm::LogError("SiStripNoisesFakeESSource::produce ") << " detid already exists";
136  }
137  }
138 
139  return noises;
140 }
141 
142 //define this as a plug-in
SiStripNoisesFakeESSource::m_noisePar0
double m_noisePar0
Definition: SiStripNoisesFakeESSource.cc:46
SiStripNoisesFakeESSource::setIntervalFor
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &iov, edm::ValidityInterval &iValidity) override
Definition: SiStripNoisesFakeESSource.cc:90
SiStripFakeAPVParameters::getIndex
static index getIndex(const TrackerTopology *tTopo, DetId id)
Definition: SiStripFakeAPVParameters.h:34
MessageLogger.h
SiStripFakeAPVParameters
Definition: SiStripFakeAPVParameters.h:9
SiStripNoisesFakeESSource::m_stripLengthMode
bool m_stripLengthMode
Definition: SiStripNoisesFakeESSource.cc:45
SiStripNoisesFakeESSource::m_tTopoToken
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > m_tTopoToken
Definition: SiStripNoisesFakeESSource.cc:44
contentValuesFiles.fullPath
fullPath
Definition: contentValuesFiles.py:64
digitizers_cfi.strip
strip
Definition: digitizers_cfi.py:19
edm::ValidityInterval
Definition: ValidityInterval.h:28
ESProducer.h
SiStripFakeAPVParameters.h
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
SiStripNoises.h
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
SiStripDetInfoFileReader
Definition: SiStripDetInfoFileReader.h:30
edm::EventSetupRecordIntervalFinder
Definition: EventSetupRecordIntervalFinder.h:33
edm::eventsetup::EventSetupRecordKey
Definition: EventSetupRecordKey.h:30
SiStripNoisesRcd
Definition: SiStripCondDataRecords.h:40
edm::FileInPath
Definition: FileInPath.h:64
SiStripNoisesFakeESSource::produce
ReturnType produce(const SiStripNoisesRcd &)
Definition: SiStripNoisesFakeESSource.cc:97
SiStripNoisesFakeESSource::m_noisePar2
SiStripFakeAPVParameters m_noisePar2
Definition: SiStripNoisesFakeESSource.cc:48
TrackerTopology.h
SiStripNoisesFakeESSource::m_detInfoFileReader
SiStripDetInfoFileReader m_detInfoFileReader
Definition: SiStripNoisesFakeESSource.cc:50
submitPVResolutionJobs.count
count
Definition: submitPVResolutionJobs.py:352
SiStripDetInfoFileReader.h
edm::eventsetup::DependentRecordImplementation::get
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
Definition: DependentRecordImplementation.h:103
SiStripNoisesFakeESSource::m_noisePar1
SiStripFakeAPVParameters m_noisePar1
Definition: SiStripNoisesFakeESSource.cc:47
edm::IOVSyncValue
Definition: IOVSyncValue.h:31
DEFINE_FWK_EVENTSETUP_SOURCE
#define DEFINE_FWK_EVENTSETUP_SOURCE(type)
Definition: SourceFactory.h:91
EventSetupRecordIntervalFinder.h
SiStripFakeAPVParameters::index
std::pair< int, int > index
Definition: SiStripFakeAPVParameters.h:11
SourceFactory.h
edm::ParameterSet
Definition: ParameterSet.h:47
SiStripCondDataRecords.h
edm::IOVSyncValue::endOfTime
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
SiStripFakeAPVParameters::get
double get(const index &idx) const
Definition: SiStripFakeAPVParameters.h:32
hgcalDigitizer_cfi.noise
noise
Definition: hgcalDigitizer_cfi.py:155
SiStripNoisesFakeESSource::ReturnType
std::unique_ptr< SiStripNoises > ReturnType
Definition: SiStripNoisesFakeESSource.cc:40
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
SiStripNoisesFakeESSource
Definition: SiStripNoisesFakeESSource.cc:31
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd >
SiStripNoisesFakeESSource::SiStripNoisesFakeESSource
SiStripNoisesFakeESSource(const edm::ParameterSet &)
Definition: SiStripNoisesFakeESSource.cc:64
SiStripDetInfoFileReader::getAllData
const std::map< uint32_t, DetInfo > & getAllData() const
Definition: SiStripDetInfoFileReader.h:58
edm::es
Definition: es_Label.h:33
edm::IOVSyncValue::beginOfTime
static const IOVSyncValue & beginOfTime()
Definition: IOVSyncValue.cc:88
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::ESProducer
Definition: ESProducer.h:104
SiStripNoises::InputVector
std::vector< uint16_t > InputVector
Definition: SiStripNoises.h:50
ParameterSet.h
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
SiStripNoisesFakeESSource::m_printDebug
uint32_t m_printDebug
Definition: SiStripNoisesFakeESSource.cc:49
HLTEgPhaseIITestSequence_cff.noises
noises
Definition: HLTEgPhaseIITestSequence_cff.py:1348
SiStripNoisesFakeESSource::~SiStripNoisesFakeESSource
~SiStripNoisesFakeESSource() override
Definition: SiStripNoisesFakeESSource.cc:88