CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
SiStripGainFactor Class Reference

#include <SiStripGainFactor.h>

Public Member Functions

double get (const SiStripApvGain &gain, const int apvGainIndex) const
 
void push_back_norm (double norm)
 
void resetIfBadNorm ()
 
 SiStripGainFactor (const edm::ParameterSet &iConfig)
 

Private Attributes

bool automaticMode_
 
std::vector< double > norm_
 
bool printdebug_
 

Detailed Description

Definition at line 9 of file SiStripGainFactor.h.

Constructor & Destructor Documentation

SiStripGainFactor::SiStripGainFactor ( const edm::ParameterSet iConfig)
inline

Definition at line 11 of file SiStripGainFactor.h.

References edm::ParameterSet::getParameter(), and printdebug_.

12  : automaticMode_{iConfig.getParameter<bool>("AutomaticNormalization")},
13  printdebug_{iConfig.getUntrackedParameter<bool>("printDebug", false)} {}
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const

Member Function Documentation

double SiStripGainFactor::get ( const SiStripApvGain gain,
const int  apvGainIndex 
) const
inline

Definition at line 28 of file SiStripGainFactor.h.

References automaticMode_, NGains, norm_, and printdebug_.

Referenced by Options.Options::__getitem__(), betterConfigParser.BetterConfigParser::__updateDict(), data_sources.json_list::as_dicts(), data_sources.json_list::as_table(), util.rrapi.RRApi::columns(), rrapi.RRApi::columns(), util.rrapi.RRApi::count(), rrapi.RRApi::count(), util.rrapi.RRApi::data(), rrapi.RRApi::data(), data_sources.json_list::first(), betterConfigParser.BetterConfigParser::getCompares(), betterConfigParser.BetterConfigParser::getGeneral(), betterConfigParser.BetterConfigParser::getResultingSection(), data_sources.json_list::indices(), data_sources.json_list::last(), SiStripGainSimESProducer::produce(), SiStripGainESProducer::produce(), util.rrapi.RRApi::report(), rrapi.RRApi::report(), rrapi.RRApi::reports(), util.rrapi.RRApi::reports(), util.rrapi.RRApi::tables(), rrapi.RRApi::tables(), util.rrapi.RRApi::tags(), rrapi.RRApi::tags(), util.rrapi.RRApi::templates(), rrapi.RRApi::templates(), util.rrapi.RRApi::workspaces(), and rrapi.RRApi::workspaces().

28  {
29  double NFactor = 0.;
30 
31  if (automaticMode_ || printdebug_) {
32  std::vector<uint32_t> DetIds;
33  gain.getDetIds(DetIds);
34 
35  double SumOfGains = 0.;
36  int NGains = 0;
37  for (uint32_t detid : DetIds) {
38  SiStripApvGain::Range detRange = gain.getRange(detid);
39 
40  int iComp = 0;
41  for (std::vector<float>::const_iterator apvit = detRange.first; apvit != detRange.second; apvit++) {
42  SumOfGains += (*apvit);
43  NGains++;
44  if (printdebug_)
45  edm::LogInfo("SiStripGainESProducer::produce()")
46  << "detid/component: " << detid << "/" << iComp << " gain factor " << *apvit;
47  iComp++;
48  }
49  }
50 
51  if (automaticMode_) {
52  if (SumOfGains > 0 && NGains > 0) {
53  NFactor = SumOfGains / NGains;
54  } else {
56  "SiStripGainESProducer::produce() - ERROR: empty set of gain values received. Cannot compute "
57  "normalization factor. Assuming 1 for such factor")
58  << std::endl;
59  NFactor = 1.;
60  }
61  }
62  }
63 
64  if (!automaticMode_) {
65  NFactor = norm_[apvGainIndex];
66  }
67 
68  if (printdebug_)
69  edm::LogInfo("SiStripGainESProducer")
70  << " putting A SiStrip Gain object in eventSetup with normalization factor " << NFactor;
71  return NFactor;
72  }
void getDetIds(std::vector< uint32_t > &DetIds_) const
std::pair< ContainerIterator, ContainerIterator > Range
constexpr int NGains
const Range getRange(const uint32_t detID) const
std::vector< double > norm_
void SiStripGainFactor::push_back_norm ( double  norm)
inline

Definition at line 15 of file SiStripGainFactor.h.

References norm_.

Referenced by SiStripGainESProducer::SiStripGainESProducer(), and SiStripGainSimESProducer::SiStripGainSimESProducer().

15 { norm_.push_back(norm); }
std::vector< double > norm_
void SiStripGainFactor::resetIfBadNorm ( )
inline

Definition at line 17 of file SiStripGainFactor.h.

References automaticMode_, norm_, and x.

Referenced by SiStripGainESProducer::SiStripGainESProducer(), and SiStripGainSimESProducer::SiStripGainSimESProducer().

17  {
18  bool badNorm = std::find_if(norm_.begin(), norm_.end(), [](double x) { return x <= 0.; }) != norm_.end();
19 
20  if (!automaticMode_ && badNorm) {
21  edm::LogError("SiStripGainESProducer") << "[SiStripGainESProducer] - ERROR: negative or zero Normalization "
22  "factor provided. Assuming 1 for such factor"
23  << std::endl;
24  norm_ = std::vector<double>(norm_.size(), 1.);
25  }
26  }
std::vector< double > norm_

Member Data Documentation

bool SiStripGainFactor::automaticMode_
private

Definition at line 76 of file SiStripGainFactor.h.

Referenced by get(), and resetIfBadNorm().

std::vector<double> SiStripGainFactor::norm_
private

Definition at line 75 of file SiStripGainFactor.h.

Referenced by get(), push_back_norm(), and resetIfBadNorm().

bool SiStripGainFactor::printdebug_
private

Definition at line 77 of file SiStripGainFactor.h.

Referenced by get(), and SiStripGainFactor().