CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripApvGainGenerator.cc
Go to the documentation of this file.
3 #include <boost/cstdint.hpp>
6 
7 #include "CLHEP/Random/RandFlat.h"
8 #include "CLHEP/Random/RandGauss.h"
9 
12 {
13  edm::LogInfo("SiStripApvGainGenerator") << "[SiStripApvGainGenerator::SiStripApvGainGenerator]";
14 }
15 
17  edm::LogInfo("SiStripApvGainGenerator") << "[SiStripApvGainGenerator::~SiStripApvGainGenerator]";
18 }
19 
21 
22  obj_ = new SiStripApvGain();
23 
24  std::string genMode = _pset.getParameter<std::string>("genMode");
25 
26  double meanGain_=_pset.getParameter<double>("MeanGain");
27  double sigmaGain_=_pset.getParameter<double>("SigmaGain");
28  double minimumPosValue_=_pset.getParameter<double>("MinPositiveGain");
29 
31  uint32_t printdebug_ = _pset.getUntrackedParameter<uint32_t>("printDebug", 5);
32  uint32_t count=0;
33 
34  SiStripDetInfoFileReader reader(fp_.fullPath());
35 
36  const std::map<uint32_t, SiStripDetInfoFileReader::DetInfo > DetInfos = reader.getAllData();
37  float gainValue;
38  for(std::map<uint32_t, SiStripDetInfoFileReader::DetInfo >::const_iterator it = DetInfos.begin(); it != DetInfos.end(); it++){
39 
40  std::vector<float> theSiStripVector;
41  for(unsigned short j=0; j<it->second.nApvs; j++){
42 
43  if(genMode=="default")
44  gainValue=meanGain_;
45  else if (genMode=="gaussian") {
46  gainValue = CLHEP::RandGauss::shoot(meanGain_, sigmaGain_);
47  if(gainValue<=minimumPosValue_) gainValue=minimumPosValue_;
48  }
49  else {
50  LogDebug("SiStripApvGain") << "ERROR: wrong genMode specifier : " << genMode << ", please select one of \"default\" or \"gaussian\"" << std::endl;
51  exit(1);
52  }
53 
54  if (count<printdebug_) {
55  edm::LogInfo("SiStripApvGainGenerator") << "detid: " << it->first << " Apv: " << j << " gain: " << gainValue << std::endl;
56  }
57  theSiStripVector.push_back(gainValue);
58  }
59  count++;
60  SiStripApvGain::Range range(theSiStripVector.begin(),theSiStripVector.end());
61  if ( ! obj_->put(it->first,range) )
62  edm::LogError("SiStripApvGainGenerator")<<" detid already exists"<<std::endl;
63  }
64 }
#define LogDebug(id)
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
SiStripApvGainGenerator(const edm::ParameterSet &, const edm::ActivityRegistry &)
bool put(const uint32_t &detID, Range input)
const std::map< uint32_t, DetInfo > & getAllData() const
std::pair< ContainerIterator, ContainerIterator > Range
int j
Definition: DBlmapReader.cc:9