CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
SiStripApvSimulationParametersESSource Class Reference
Inheritance diagram for SiStripApvSimulationParametersESSource:
edm::ESProducer edm::EventSetupRecordIntervalFinder edm::ESProxyFactoryProducer edm::eventsetup::DataProxyProvider

Public Member Functions

std::unique_ptr< SiStripApvSimulationParametersproduce (const SiStripApvSimulationParametersRcd &record)
 
void setIntervalFor (const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &iov, edm::ValidityInterval &iValidity) override
 
 SiStripApvSimulationParametersESSource (const edm::ParameterSet &conf)
 
 ~SiStripApvSimulationParametersESSource () override
 
- Public Member Functions inherited from edm::ESProducer
 ESProducer ()
 
ESProxyIndex const * getTokenIndices (unsigned int iIndex) const
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &) final
 
 ~ESProducer ()(false) override
 
- Public Member Functions inherited from edm::ESProxyFactoryProducer
 ESProxyFactoryProducer ()
 
void newInterval (const eventsetup::EventSetupRecordKey &iRecordType, const ValidityInterval &iInterval) override
 overrides DataProxyProvider method More...
 
 ~ESProxyFactoryProducer () noexcept(false) override
 
- Public Member Functions inherited from edm::eventsetup::DataProxyProvider
 DataProxyProvider ()
 
const ComponentDescriptiondescription () const
 
bool isUsingRecord (const EventSetupRecordKey &) const
 
const KeyedProxieskeyedProxies (const EventSetupRecordKey &iRecordKey) const
 
void resetProxies (const EventSetupRecordKey &iRecordType)
 
void resetProxiesIfTransient (const EventSetupRecordKey &iRecordType)
 
void setAppendToDataLabel (const edm::ParameterSet &)
 
void setDescription (const ComponentDescription &iDescription)
 
std::set< EventSetupRecordKeyusingRecords () const
 
virtual ~DataProxyProvider () noexcept(false)
 
- Public Member Functions inherited from edm::EventSetupRecordIntervalFinder
const eventsetup::ComponentDescriptiondescriptionForFinder () const
 
 EventSetupRecordIntervalFinder ()
 
std::set< eventsetup::EventSetupRecordKeyfindingForRecords () const
 
const ValidityIntervalfindIntervalFor (const eventsetup::EventSetupRecordKey &, const IOVSyncValue &)
 
void setDescriptionForFinder (const eventsetup::ComponentDescription &iDescription)
 
virtual ~EventSetupRecordIntervalFinder () noexcept(false)
 

Private Member Functions

SiStripApvSimulationParameters::LayerParameters makeLayerParameters (const std::string &apvBaselinesFileName, const std::vector< float > &rzBinEdges) const
 

Private Attributes

float baseline_max_
 
float baseline_min_
 
unsigned int baseline_nBins_
 
std::vector< edm::FileInPathbaselineFiles_TEC_
 
std::vector< edm::FileInPathbaselineFiles_TIB_
 
std::vector< edm::FileInPathbaselineFiles_TID_
 
std::vector< edm::FileInPathbaselineFiles_TOB_
 
std::vector< float > puBinEdges_
 
std::vector< float > rBinEdgesTEC_
 
std::vector< float > rBinEdgesTID_
 
std::vector< float > zBinEdges_
 

Additional Inherited Members

- Public Types inherited from edm::eventsetup::DataProxyProvider
typedef std::vector< std::pair< DataKey, edm::propagate_const< std::shared_ptr< DataProxy > > > > KeyedProxies
 
typedef std::vector< EventSetupRecordKeyKeys
 
typedef std::map< EventSetupRecordKey, KeyedProxiesRecordProxies
 
- Static Public Member Functions inherited from edm::eventsetup::DataProxyProvider
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::ESProducer
 ESProducer (const ESProducer &)=delete
 
ESProducer const & operator= (const ESProducer &)=delete
 
template<typename T >
auto setWhatProduced (T *iThis, const es::Label &iLabel={})
 
template<typename T >
auto setWhatProduced (T *iThis, const char *iLabel)
 
template<typename T >
auto setWhatProduced (T *iThis, const std::string &iLabel)
 
template<typename T , typename TDecorator >
auto setWhatProduced (T *iThis, const TDecorator &iDec, const es::Label &iLabel={})
 
template<typename T , typename TReturn , typename TRecord >
auto setWhatProduced (T *iThis, TReturn(T::*iMethod)(const TRecord &), const es::Label &iLabel={})
 
template<typename T , typename TReturn , typename TRecord , typename TArg >
ESConsumesCollectorT< TRecord > setWhatProduced (T *iThis, TReturn(T::*iMethod)(const TRecord &), const TArg &iDec, const es::Label &iLabel={})
 
- Protected Member Functions inherited from edm::ESProxyFactoryProducer
template<class TFactory >
void registerFactory (std::unique_ptr< TFactory > iFactory, const std::string &iLabel=std::string())
 
virtual void registerFactoryWithKey (const eventsetup::EventSetupRecordKey &iRecord, std::unique_ptr< eventsetup::ProxyFactoryBase > iFactory, const std::string &iLabel=std::string())
 
void registerProxies (const eventsetup::EventSetupRecordKey &iRecord, KeyedProxies &aProxyList) override
 override DataProxyProvider method More...
 
- Protected Member Functions inherited from edm::eventsetup::DataProxyProvider
void eraseAll (const EventSetupRecordKey &iRecordKey)
 deletes all the Proxies in aStream More...
 
void invalidateProxies (const EventSetupRecordKey &iRecordKey)
 
template<class T >
void usingRecord ()
 
void usingRecordWithKey (const EventSetupRecordKey &)
 
- Protected Member Functions inherited from edm::EventSetupRecordIntervalFinder
template<class T >
void findingRecord ()
 
void findingRecordWithKey (const eventsetup::EventSetupRecordKey &)
 

Detailed Description

Definition at line 10 of file SiStripApvSimulationParametersESProducer.cc.

Constructor & Destructor Documentation

SiStripApvSimulationParametersESSource::SiStripApvSimulationParametersESSource ( const edm::ParameterSet conf)
explicit

Definition at line 38 of file SiStripApvSimulationParametersESProducer.cc.

References baselineFiles_TEC_, baselineFiles_TIB_, baselineFiles_TID_, baselineFiles_TOB_, edm::ParameterSet::getUntrackedParameter(), puBinEdges_, rBinEdgesTEC_, rBinEdgesTID_, edm::ESProducer::setWhatProduced(), x, and zBinEdges_.

39  : baseline_nBins_(conf.getUntrackedParameter<unsigned int>("apvBaselines_nBinsPerBaseline")),
40  baseline_min_(conf.getUntrackedParameter<double>("apvBaselines_minBaseline")),
41  baseline_max_(conf.getUntrackedParameter<double>("apvBaselines_maxBaseline")) {
42  setWhatProduced(this);
43  findingRecord<SiStripApvSimulationParametersRcd>();
44  for (const auto x : conf.getUntrackedParameter<std::vector<double>>("apvBaselines_puBinEdges")) {
45  puBinEdges_.push_back(x);
46  }
47  for (const auto x : conf.getUntrackedParameter<std::vector<double>>("apvBaselines_zBinEdges")) {
48  zBinEdges_.push_back(x);
49  }
50  for (const auto x : conf.getUntrackedParameter<std::vector<double>>("apvBaselines_rBinEdges_TID")) {
51  rBinEdgesTID_.push_back(x);
52  }
53  for (const auto x : conf.getUntrackedParameter<std::vector<double>>("apvBaselines_rBinEdges_TEC")) {
54  rBinEdgesTEC_.push_back(x);
55  }
56  baselineFiles_TIB_ = {conf.getUntrackedParameter<edm::FileInPath>("apvBaselinesFile_tib1"),
57  conf.getUntrackedParameter<edm::FileInPath>("apvBaselinesFile_tib2"),
58  conf.getUntrackedParameter<edm::FileInPath>("apvBaselinesFile_tib3"),
59  conf.getUntrackedParameter<edm::FileInPath>("apvBaselinesFile_tib4")};
60  baselineFiles_TOB_ = {conf.getUntrackedParameter<edm::FileInPath>("apvBaselinesFile_tob1"),
61  conf.getUntrackedParameter<edm::FileInPath>("apvBaselinesFile_tob2"),
62  conf.getUntrackedParameter<edm::FileInPath>("apvBaselinesFile_tob3"),
63  conf.getUntrackedParameter<edm::FileInPath>("apvBaselinesFile_tob4"),
64  conf.getUntrackedParameter<edm::FileInPath>("apvBaselinesFile_tob5"),
65  conf.getUntrackedParameter<edm::FileInPath>("apvBaselinesFile_tob6")};
66 
67  if(rBinEdgesTID_.size()>0){
68  baselineFiles_TID_ = {conf.getUntrackedParameter<edm::FileInPath>("apvBaselinesFile_tid1"),
69  conf.getUntrackedParameter<edm::FileInPath>("apvBaselinesFile_tid2"),
70  conf.getUntrackedParameter<edm::FileInPath>("apvBaselinesFile_tid3")};
71  }
72 
73  if( rBinEdgesTEC_.size()>0){
74  baselineFiles_TEC_ = {conf.getUntrackedParameter<edm::FileInPath>("apvBaselinesFile_tec1"),
75  conf.getUntrackedParameter<edm::FileInPath>("apvBaselinesFile_tec2"),
76  conf.getUntrackedParameter<edm::FileInPath>("apvBaselinesFile_tec3"),
77  conf.getUntrackedParameter<edm::FileInPath>("apvBaselinesFile_tec4"),
78  conf.getUntrackedParameter<edm::FileInPath>("apvBaselinesFile_tec5"),
79  conf.getUntrackedParameter<edm::FileInPath>("apvBaselinesFile_tec6"),
80  conf.getUntrackedParameter<edm::FileInPath>("apvBaselinesFile_tec7"),
81  conf.getUntrackedParameter<edm::FileInPath>("apvBaselinesFile_tec8"),
82  conf.getUntrackedParameter<edm::FileInPath>("apvBaselinesFile_tec9")};
83  }
84 }
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:124
T getUntrackedParameter(std::string const &, T const &) const
SiStripApvSimulationParametersESSource::~SiStripApvSimulationParametersESSource ( )
inlineoverride

Definition at line 13 of file SiStripApvSimulationParametersESProducer.cc.

References produce(), record, and setIntervalFor().

13 {}

Member Function Documentation

SiStripApvSimulationParameters::LayerParameters SiStripApvSimulationParametersESSource::makeLayerParameters ( const std::string &  apvBaselinesFileName,
const std::vector< float > &  rzBinEdges 
) const
private

Definition at line 92 of file SiStripApvSimulationParametersESProducer.cc.

References baseline_max_, baseline_min_, baseline_nBins_, Exception, mps_fire::i, createfilelist::int, mps_splice::line, puBinEdges_, AlCaHLTBitMon_QueryRunRegistry::string, and relativeConstraints::value.

Referenced by produce().

93  {
94  // Prepare histograms
95  unsigned int nZBins = rzBinEdges.size();
96  unsigned int nPUBins = puBinEdges_.size();
97 
98  if (nPUBins == 0 || nZBins == 0 || baseline_nBins_ == 0) {
99  throw cms::Exception("MissingInput") << "The parameters for the APV simulation are not correctly configured\n";
100  }
101  std::vector<float> baselineBinEdges{};
102  const auto baseline_binWidth = (baseline_max_ - baseline_min_) / baseline_nBins_;
103  for (unsigned i{0}; i != baseline_nBins_; ++i) {
104  baselineBinEdges.push_back(baseline_min_ + i * baseline_binWidth);
105  }
106  baselineBinEdges.push_back(baseline_max_);
107 
108  SiStripApvSimulationParameters::LayerParameters layerParams{baselineBinEdges, puBinEdges_, rzBinEdges};
109 
110  // Read apv baselines from text files
111  std::vector<double> theAPVBaselines;
112  std::ifstream apvBaselineFile(apvBaselinesFileName.c_str());
113  if (!apvBaselineFile.good()) {
114  throw cms::Exception("FileError") << "Problem opening APV baselines file: " << apvBaselinesFileName;
115  }
117  while (std::getline(apvBaselineFile, line)) {
118  if (!line.empty()) {
119  std::istringstream lStr{line};
120  double value;
121  while (lStr >> value) {
122  theAPVBaselines.push_back(value);
123  }
124  }
125  }
126  if (theAPVBaselines.empty()) {
127  throw cms::Exception("WrongAPVBaselines")
128  << "Problem reading from APV baselines file " << apvBaselinesFileName << ": no values read in";
129  }
130 
131  if (theAPVBaselines.size() != nZBins * nPUBins * baseline_nBins_) {
132  throw cms::Exception("WrongAPVBaselines") << "Problem reading from APV baselines file " << apvBaselinesFileName
133  << ": number of baselines read different to that expected i.e. nZBins * "
134  "nPUBins * apvBaselines_nBinsPerBaseline_";
135  }
136 
137  // Put baselines into histograms
138  for (auto const& apvBaseline : theAPVBaselines | boost::adaptors::indexed(0)) {
139  unsigned int binInCurrentHistogram = apvBaseline.index() % baseline_nBins_ + 1;
140  unsigned int binInZ = int(apvBaseline.index()) / (nPUBins * baseline_nBins_);
141  unsigned int binInPU = int(apvBaseline.index() - binInZ * (nPUBins)*baseline_nBins_) / baseline_nBins_;
142 
143  layerParams.setBinContent(binInCurrentHistogram, binInPU+1, binInZ+1, apvBaseline.value());
144  }
145 
146  return layerParams;
147 }
std::unique_ptr< SiStripApvSimulationParameters > SiStripApvSimulationParametersESSource::produce ( const SiStripApvSimulationParametersRcd record)

Definition at line 149 of file SiStripApvSimulationParametersESProducer.cc.

References baselineFiles_TEC_, baselineFiles_TIB_, baselineFiles_TID_, baselineFiles_TOB_, DEFINE_FWK_EVENTSETUP_SOURCE, Exception, mps_fire::i, LogDebug, makeLayerParameters(), rBinEdgesTEC_, rBinEdgesTID_, and zBinEdges_.

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), HTMLExport.HTMLExportStatic::export(), and ~SiStripApvSimulationParametersESSource().

150  {
151  auto apvSimParams = std::make_unique<SiStripApvSimulationParameters>(
153  for (unsigned int i{0}; i != baselineFiles_TIB_.size(); ++i) {
154 
155  if (!apvSimParams->putTIB(i + 1, makeLayerParameters(baselineFiles_TIB_[i].fullPath(), zBinEdges_))) {
156  throw cms::Exception("SiStripApvSimulationParameters") << "Could not add parameters for TIB layer " << (i + 1);
157  } else {
158  LogDebug("SiStripApvSimulationParameters") << "Added parameters for TIB layer " << (i+1);
159  }
160  }
161  for (unsigned int i{0}; i != baselineFiles_TOB_.size(); ++i) {
162  if (!apvSimParams->putTOB(i + 1, makeLayerParameters(baselineFiles_TOB_[i].fullPath(), zBinEdges_))) {
163  throw cms::Exception("SiStripApvSimulationParameters") << "Could not add parameters for TOB layer " << (i + 1);
164  } else {
165  LogDebug("SiStripApvSimulationParameters") << "Added parameters for TOB layer " << (i+1);
166  }
167  }
168  for (unsigned int i{0}; i != baselineFiles_TID_.size(); ++i) {
169  if (!apvSimParams->putTID(i + 1, makeLayerParameters(baselineFiles_TID_[i].fullPath(), rBinEdgesTID_))) {
170  throw cms::Exception("SiStripApvSimulationParameters") << "Could not add parameters for TID wheel " << (i + 1);
171  } else {
172  LogDebug("SiStripApvSimulationParameters") << "Added parameters for TID wheel " << (i + 1);
173  }
174  }
175  for (unsigned int i{0}; i != baselineFiles_TEC_.size(); ++i) {
176  if (!apvSimParams->putTEC(i + 1, makeLayerParameters(baselineFiles_TEC_[i].fullPath(), rBinEdgesTEC_))) {
177  throw cms::Exception("SiStripApvSimulationParameters") << "Could not add parameters for TEC wheel " << (i + 1);
178  } else {
179  LogDebug("SiStripApvSimulationParameters") << "Added parameters for TEC wheel " << (i + 1);
180  }
181  }
182  return apvSimParams;
183 }
#define LogDebug(id)
SiStripApvSimulationParameters::LayerParameters makeLayerParameters(const std::string &apvBaselinesFileName, const std::vector< float > &rzBinEdges) const
void SiStripApvSimulationParametersESSource::setIntervalFor ( const edm::eventsetup::EventSetupRecordKey ,
const edm::IOVSyncValue iov,
edm::ValidityInterval iValidity 
)
overridevirtual

Implements edm::EventSetupRecordIntervalFinder.

Definition at line 86 of file SiStripApvSimulationParametersESProducer.cc.

References edm::IOVSyncValue::beginOfTime(), and edm::IOVSyncValue::endOfTime().

Referenced by ~SiStripApvSimulationParametersESSource().

88  {
89  iValidity = edm::ValidityInterval{iov.beginOfTime(), iov.endOfTime()};
90 }
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
static const IOVSyncValue & beginOfTime()
Definition: IOVSyncValue.cc:88

Member Data Documentation

float SiStripApvSimulationParametersESSource::baseline_max_
private

Definition at line 28 of file SiStripApvSimulationParametersESProducer.cc.

Referenced by makeLayerParameters().

float SiStripApvSimulationParametersESSource::baseline_min_
private

Definition at line 27 of file SiStripApvSimulationParametersESProducer.cc.

Referenced by makeLayerParameters().

unsigned int SiStripApvSimulationParametersESSource::baseline_nBins_
private

Definition at line 26 of file SiStripApvSimulationParametersESProducer.cc.

Referenced by makeLayerParameters().

std::vector<edm::FileInPath> SiStripApvSimulationParametersESSource::baselineFiles_TEC_
private
std::vector<edm::FileInPath> SiStripApvSimulationParametersESSource::baselineFiles_TIB_
private
std::vector<edm::FileInPath> SiStripApvSimulationParametersESSource::baselineFiles_TID_
private
std::vector<edm::FileInPath> SiStripApvSimulationParametersESSource::baselineFiles_TOB_
private
std::vector<float> SiStripApvSimulationParametersESSource::puBinEdges_
private
std::vector<float> SiStripApvSimulationParametersESSource::rBinEdgesTEC_
private
std::vector<float> SiStripApvSimulationParametersESSource::rBinEdgesTID_
private
std::vector<float> SiStripApvSimulationParametersESSource::zBinEdges_
private