CMS 3D CMS Logo

SiStripApvGainFakeESSource.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: CalibTracker/SiStripESProducers
4 // Class: SiStripApvGainFakeESSource
5 //
14 // system include files
15 #include <memory>
16 
17 // user include files
20 
24 
26 
28 public:
30  ~SiStripApvGainFakeESSource() override;
31 
33  const edm::IOVSyncValue& iov,
34  edm::ValidityInterval& iValidity) override;
35 
36  typedef std::unique_ptr<SiStripApvGain> ReturnType;
38 
39 private:
41  double m_meanGain;
42  double m_sigmaGain;
44  uint32_t m_printDebug;
46 };
47 
49 #include "CLHEP/Random/RandGauss.h"
50 
52  setWhatProduced(this);
53  findingRecord<SiStripApvGainRcd>();
54 
55  m_genMode = iConfig.getParameter<std::string>("genMode");
56  m_meanGain = iConfig.getParameter<double>("MeanGain");
57  m_sigmaGain = iConfig.getParameter<double>("SigmaGain");
58  m_minimumPosValue = iConfig.getParameter<double>("MinPositiveGain");
59  m_printDebug = iConfig.getUntrackedParameter<uint32_t>("printDebug", 5);
61  SiStripDetInfoFileReader{iConfig.getParameter<edm::FileInPath>("SiStripDetInfoFile").fullPath()};
62 }
63 
65 
67  const edm::IOVSyncValue& iov,
68  edm::ValidityInterval& iValidity) {
69  iValidity = edm::ValidityInterval{iov.beginOfTime(), iov.endOfTime()};
70 }
71 
72 // ------------ method called to produce the data ------------
74  using namespace edm::es;
75 
76  auto apvGain = std::make_unique<SiStripApvGain>();
77 
78  uint32_t count{0};
79  for (const auto& elm : m_detInfoFileReader.getAllData()) {
80  std::vector<float> theSiStripVector;
81  for (unsigned short j = 0; j < elm.second.nApvs; ++j) {
82  float gainValue;
83  if (m_genMode == "default") {
84  gainValue = m_meanGain;
85  } else if (m_genMode == "gaussian") {
86  gainValue = CLHEP::RandGauss::shoot(m_meanGain, m_sigmaGain);
87  if (gainValue <= m_minimumPosValue) {
88  gainValue = m_minimumPosValue;
89  }
90  } else {
91  LogDebug("SiStripApvGain") << "ERROR: wrong genMode specifier : " << m_genMode
92  << ", please select one of \"default\" or \"gaussian\"";
93  exit(1);
94  }
95 
96  if (count < m_printDebug) {
97  edm::LogInfo("SiStripApvGainGenerator") << "detid: " << elm.first << " Apv: " << j << " gain: " << gainValue;
98  }
99  theSiStripVector.push_back(gainValue);
100  }
101  ++count;
102 
103  if (!apvGain->put(elm.first, SiStripApvGain::Range{theSiStripVector.begin(), theSiStripVector.end()})) {
104  edm::LogError("SiStripApvGainGenerator") << " detid already exists";
105  }
106  }
107 
108  return apvGain;
109 }
110 
111 //define this as a plug-in
SiStripApvGainFakeESSource::~SiStripApvGainFakeESSource
~SiStripApvGainFakeESSource() override
Definition: SiStripApvGainFakeESSource.cc:64
MessageLogger.h
contentValuesFiles.fullPath
fullPath
Definition: contentValuesFiles.py:64
edm::ESProducer::setWhatProduced
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:163
edm::ValidityInterval
Definition: ValidityInterval.h:28
SiStripApvGainFakeESSource::m_meanGain
double m_meanGain
Definition: SiStripApvGainFakeESSource.cc:41
ESProducer.h
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
SiStripDetInfoFileReader
Definition: SiStripDetInfoFileReader.h:30
edm::EventSetupRecordIntervalFinder
Definition: EventSetupRecordIntervalFinder.h:33
SiStripApvGainFakeESSource::ReturnType
std::unique_ptr< SiStripApvGain > ReturnType
Definition: SiStripApvGainFakeESSource.cc:36
edm::eventsetup::EventSetupRecordKey
Definition: EventSetupRecordKey.h:30
edm::FileInPath
Definition: FileInPath.h:64
SiStripApvGainFakeESSource::setIntervalFor
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &iov, edm::ValidityInterval &iValidity) override
Definition: SiStripApvGainFakeESSource.cc:66
SiStripApvGainFakeESSource
Definition: SiStripApvGainFakeESSource.cc:27
SiStripApvGainFakeESSource::m_printDebug
uint32_t m_printDebug
Definition: SiStripApvGainFakeESSource.cc:44
submitPVResolutionJobs.count
count
Definition: submitPVResolutionJobs.py:352
SiStripDetInfoFileReader.h
SiStripApvGain.h
edm::IOVSyncValue
Definition: IOVSyncValue.h:31
DEFINE_FWK_EVENTSETUP_SOURCE
#define DEFINE_FWK_EVENTSETUP_SOURCE(type)
Definition: SourceFactory.h:91
EventSetupRecordIntervalFinder.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
SourceFactory.h
SiStripApvGainFakeESSource::m_sigmaGain
double m_sigmaGain
Definition: SiStripApvGainFakeESSource.cc:42
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
edm::ParameterSet
Definition: ParameterSet.h:47
SiStripCondDataRecords.h
SiStripApvGainFakeESSource::produce
ReturnType produce(const SiStripApvGainRcd &)
Definition: SiStripApvGainFakeESSource.cc:73
edm::IOVSyncValue::endOfTime
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
SiStripApvGainRcd
Definition: SiStripCondDataRecords.h:8
SiStripApvGain::Range
std::pair< ContainerIterator, ContainerIterator > Range
Definition: SiStripApvGain.h:28
SiStripDetInfoFileReader::getAllData
const std::map< uint32_t, DetInfo > & getAllData() const
Definition: SiStripDetInfoFileReader.h:58
SiStripApvGainFakeESSource::m_minimumPosValue
double m_minimumPosValue
Definition: SiStripApvGainFakeESSource.cc:43
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
beamvalidation.exit
def exit(msg="")
Definition: beamvalidation.py:53
ParameterSet.h
SiStripApvGainFakeESSource::m_genMode
std::string m_genMode
Definition: SiStripApvGainFakeESSource.cc:40
SiStripApvGainFakeESSource::SiStripApvGainFakeESSource
SiStripApvGainFakeESSource(const edm::ParameterSet &)
Definition: SiStripApvGainFakeESSource.cc:51
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
SiStripApvGainFakeESSource::m_detInfoFileReader
SiStripDetInfoFileReader m_detInfoFileReader
Definition: SiStripApvGainFakeESSource.cc:45