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 }
86 
88 
90  const edm::IOVSyncValue& iov,
91  edm::ValidityInterval& iValidity) {
92  iValidity = edm::ValidityInterval{iov.beginOfTime(), iov.endOfTime()};
93 }
94 
95 // ------------ method called to produce the data ------------
97  using namespace edm::es;
98 
99  const auto& tTopo = iRecord.get(m_tTopoToken);
100 
101  auto noises = std::make_unique<SiStripNoises>();
102 
103  uint32_t count{0};
104  for (const auto& elm : m_detInfo.getAllData()) {
105  //Generate Noises for det detid
106  SiStripNoises::InputVector theSiStripVector;
108 
109  if (m_stripLengthMode) {
110  // Use strip length
111  const double linearSlope{m_noisePar1.get(sl)};
112  const double linearQuote{m_noisePar2.get(sl)};
113  const double stripLength{elm.second.stripLength};
114  for (unsigned short j{0}; j < 128 * elm.second.nApvs; ++j) {
115  const float noise = (linearSlope * stripLength + linearQuote) / m_noisePar0;
116  if (count < m_printDebug)
117  printLog(elm.first, j, noise);
118  noises->setData(noise, theSiStripVector);
119  }
120  } else {
121  // Use random generator
122  const double meanN{m_noisePar1.get(sl)};
123  const double sigmaN{m_noisePar2.get(sl)};
124  for (unsigned short j{0}; j < 128 * elm.second.nApvs; ++j) {
125  const float noise = std::max(CLHEP::RandGauss::shoot(meanN, sigmaN), m_noisePar0);
126  if (count < m_printDebug)
127  printLog(elm.first, j, noise);
128  noises->setData(noise, theSiStripVector);
129  }
130  }
131  ++count;
132 
133  if (!noises->put(elm.first, theSiStripVector)) {
134  edm::LogError("SiStripNoisesFakeESSource::produce ") << " detid already exists";
135  }
136  }
137 
138  return noises;
139 }
140 
141 //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:89
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
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
edm::EventSetupRecordIntervalFinder
Definition: EventSetupRecordIntervalFinder.h:33
edm::eventsetup::EventSetupRecordKey
Definition: EventSetupRecordKey.h:30
SiStripNoisesRcd
Definition: SiStripCondDataRecords.h:40
SiStripDetInfoFileReader::read
SiStripDetInfo read(std::string filePath)
Definition: SiStripDetInfoFileReader.cc:11
SiStripNoisesFakeESSource::m_detInfo
SiStripDetInfo m_detInfo
Definition: SiStripNoisesFakeESSource.cc:50
edm::FileInPath
Definition: FileInPath.h:61
SiStripNoisesFakeESSource::produce
ReturnType produce(const SiStripNoisesRcd &)
Definition: SiStripNoisesFakeESSource.cc:96
SiStripNoisesFakeESSource::m_noisePar2
SiStripFakeAPVParameters m_noisePar2
Definition: SiStripNoisesFakeESSource.cc:48
TrackerTopology.h
submitPVResolutionJobs.count
count
Definition: submitPVResolutionJobs.py:352
SiStripDetInfo::getAllData
const std::map< uint32_t, DetInfo > & getAllData() const noexcept
Definition: SiStripDetInfo.h:59
SiStripDetInfoFileReader.h
edm::eventsetup::DependentRecordImplementation::get
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
Definition: DependentRecordImplementation.h:109
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
SiStripNoisesFakeESSource::ReturnType
std::unique_ptr< SiStripNoises > ReturnType
Definition: SiStripNoisesFakeESSource.cc:40
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
gpuVertexFinder::noise
__shared__ int noise
Definition: gpuFitVertices.h:50
SiStripNoisesFakeESSource
Definition: SiStripNoisesFakeESSource.cc:31
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd >
SiStripNoisesFakeESSource::SiStripNoisesFakeESSource
SiStripNoisesFakeESSource(const edm::ParameterSet &)
Definition: SiStripNoisesFakeESSource.cc:64
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
SiStripDetInfo
Definition: SiStripDetInfo.h:29
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
edm::FileInPath::fullPath
std::string fullPath() const
Definition: FileInPath.cc:161
SiStripNoisesFakeESSource::~SiStripNoisesFakeESSource
~SiStripNoisesFakeESSource() override
Definition: SiStripNoisesFakeESSource.cc:87