CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
SiStripNoisesGenerator Class Reference

#include <SiStripNoisesGenerator.h>

Inheritance diagram for SiStripNoisesGenerator:
SiStripCondObjBuilderBase< SiStripNoises >

Public Member Functions

void getObj (SiStripNoises *&obj)
 
 SiStripNoisesGenerator (const edm::ParameterSet &, const edm::ActivityRegistry &)
 
 ~SiStripNoisesGenerator ()
 
- Public Member Functions inherited from SiStripCondObjBuilderBase< SiStripNoises >
virtual bool checkForCompatibility (std::string ss)
 
virtual void getMetaDataString (std::stringstream &ss)
 
virtual void initialize ()
 
 SiStripCondObjBuilderBase (const edm::ParameterSet &pset)
 
virtual ~SiStripCondObjBuilderBase ()
 

Private Member Functions

void createObject ()
 
void fillParameters (std::map< int, std::vector< double > > &mapToFill, const std::string &parameterName) const
 Fills the parameters read from cfg and matching the name in the given map. More...
 
void fillSubDetParameter (std::map< int, std::vector< double > > &mapToFill, const std::vector< double > &v, const int subDet, const unsigned short layers) const
 
void printLog (const uint32_t detId, const unsigned short strip, const double &noise) const
 
std::pair< int, int > subDetAndLayer (const uint32_t detit) const
 Given the map and the detid it returns the corresponding layer/ring. More...
 

Private Attributes

double electronsPerADC_
 
double minimumPosValue_
 
uint32_t printDebug_
 
bool stripLengthMode_
 

Additional Inherited Members

- Protected Attributes inherited from SiStripCondObjBuilderBase< SiStripNoises >
edm::ParameterSet _pset
 
SiStripNoisesobj_
 

Detailed Description

Definition at line 12 of file SiStripNoisesGenerator.h.

Constructor & Destructor Documentation

SiStripNoisesGenerator::SiStripNoisesGenerator ( const edm::ParameterSet iConfig,
const edm::ActivityRegistry aReg 
)
explicit

Definition at line 14 of file SiStripNoisesGenerator.cc.

14  :
16  electronsPerADC_(0.),
17  minimumPosValue_(0.),
18  stripLengthMode_(true),
19  printDebug_(0)
20 {
21  edm::LogInfo("SiStripNoisesGenerator") << "[SiStripNoisesGenerator::SiStripNoisesGenerator]";
22 }
SiStripCondObjBuilderBase(const edm::ParameterSet &pset)
SiStripNoisesGenerator::~SiStripNoisesGenerator ( )

Definition at line 24 of file SiStripNoisesGenerator.cc.

25 {
26  edm::LogInfo("SiStripNoisesGenerator") << "[SiStripNoisesGenerator::~SiStripNoisesGenerator]";
27 }

Member Function Documentation

void SiStripNoisesGenerator::createObject ( )
private

Definition at line 29 of file SiStripNoisesGenerator.cc.

References SiStripCondObjBuilderBase< SiStripNoises >::_pset, prof2calltree::count, electronsPerADC_, fillParameters(), edm::FileInPath::fullPath(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), j, minimumPosValue_, SiStripCondObjBuilderBase< SiStripNoises >::obj_, printDebug_, printLog(), SiStripNoises::put(), matplotRender::reader, SiStripNoises::setData(), stripLengthMode_, and subDetAndLayer().

Referenced by Vispa.Views.LineDecayView.LineDecayContainer::dropEvent(), and getObj().

30 {
31  obj_ = new SiStripNoises();
32 
33  stripLengthMode_ = _pset.getParameter<bool>("StripLengthMode");
34 
35  //parameters for random noise generation. not used if Strip length mode is chosen
36  std::map<int, std::vector<double> > meanNoise;
37  fillParameters(meanNoise, "MeanNoise");
38  std::map<int, std::vector<double> > sigmaNoise;
39  fillParameters(sigmaNoise, "SigmaNoise");
40  minimumPosValue_ = _pset.getParameter<double>("MinPositiveNoise");
41 
42  //parameters for strip length proportional noise generation. not used if random mode is chosen
43  std::map<int, std::vector<double> > noiseStripLengthLinearSlope;
44  fillParameters(noiseStripLengthLinearSlope, "NoiseStripLengthSlope");
45  std::map<int, std::vector<double> > noiseStripLengthLinearQuote;
46  fillParameters(noiseStripLengthLinearQuote, "NoiseStripLengthQuote");
47  electronsPerADC_ = _pset.getParameter<double>("electronPerAdc");
48 
49  printDebug_ = _pset.getUntrackedParameter<uint32_t>("printDebug", 5);
50 
51  uint32_t count = 0;
54  const std::map<uint32_t, SiStripDetInfoFileReader::DetInfo > DetInfos = reader.getAllData();
55 
56  for(std::map<uint32_t, SiStripDetInfoFileReader::DetInfo >::const_iterator it = DetInfos.begin(); it != DetInfos.end(); ++it) {
57 
58  //Generate Noises for det detid
59  SiStripNoises::InputVector theSiStripVector;
60  float noise = 0.;
61  uint32_t detId = it->first;
62  std::pair<int, int> sl = subDetAndLayer(detId);
63  unsigned short nApvs = it->second.nApvs;
64 
65 
66  if(stripLengthMode_) {
67  // Use strip length
68  double linearSlope = noiseStripLengthLinearSlope[sl.first][sl.second];
69  double linearQuote = noiseStripLengthLinearQuote[sl.first][sl.second];
70  double stripLength = it->second.stripLength;
71  for( unsigned short j=0; j<128*nApvs; ++j ) {
72  noise = ( linearSlope*stripLength + linearQuote) / electronsPerADC_;
73  if( count<printDebug_ ) printLog(detId, j, noise);
74  obj_->setData(noise, theSiStripVector);
75  }
76  }
77  else {
78  // Use random generator
79  double meanN = meanNoise[sl.first][sl.second];
80  double sigmaN = sigmaNoise[sl.first][sl.second];
81  for( unsigned short j=0; j<128*nApvs; ++j ) {
82  noise = CLHEP::RandGauss::shoot(meanN, sigmaN);
83  if( noise<=minimumPosValue_ ) noise = minimumPosValue_;
84  if( count<printDebug_ ) printLog(detId, j, noise);
85  obj_->setData(noise, theSiStripVector);
86  }
87  }
88  ++count;
89 
90  if ( ! obj_->put(it->first,theSiStripVector) ) {
91  edm::LogError("SiStripNoisesFakeESSource::produce ")<<" detid already exists"<<std::endl;
92  }
93  }
94 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
void fillParameters(std::map< int, std::vector< double > > &mapToFill, const std::string &parameterName) const
Fills the parameters read from cfg and matching the name in the given map.
std::pair< int, int > subDetAndLayer(const uint32_t detit) const
Given the map and the detid it returns the corresponding layer/ring.
std::vector< uint16_t > InputVector
Definition: SiStripNoises.h:44
int j
Definition: DBlmapReader.cc:9
bool put(const uint32_t &detID, const InputVector &input)
void printLog(const uint32_t detId, const unsigned short strip, const double &noise) const
std::string fullPath() const
Definition: FileInPath.cc:171
void setData(float noise_, InputVector &vped)
void SiStripNoisesGenerator::fillParameters ( std::map< int, std::vector< double > > &  mapToFill,
const std::string &  parameterName 
) const
private

Fills the parameters read from cfg and matching the name in the given map.

Definition at line 122 of file SiStripNoisesGenerator.cc.

References SiStripCondObjBuilderBase< SiStripNoises >::_pset, fillSubDetParameter(), edm::ParameterSet::getParameter(), StripSubdetector::TEC, StripSubdetector::TIB, StripSubdetector::TID, and StripSubdetector::TOB.

Referenced by createObject().

123 {
124  int layersTIB = 4;
125  int ringsTID = 3;
126  int layersTOB = 6;
127  int ringsTEC = 7;
128 
129  fillSubDetParameter( mapToFill, _pset.getParameter<std::vector<double> >(parameterName+"TIB"), int(StripSubdetector::TIB), layersTIB );
130  fillSubDetParameter( mapToFill, _pset.getParameter<std::vector<double> >(parameterName+"TID"), int(StripSubdetector::TID), ringsTID );
131  fillSubDetParameter( mapToFill, _pset.getParameter<std::vector<double> >(parameterName+"TOB"), int(StripSubdetector::TOB), layersTOB );
132  fillSubDetParameter( mapToFill, _pset.getParameter<std::vector<double> >(parameterName+"TEC"), int(StripSubdetector::TEC), ringsTEC );
133 }
T getParameter(std::string const &) const
void fillSubDetParameter(std::map< int, std::vector< double > > &mapToFill, const std::vector< double > &v, const int subDet, const unsigned short layers) const
void SiStripNoisesGenerator::fillSubDetParameter ( std::map< int, std::vector< double > > &  mapToFill,
const std::vector< double > &  v,
const int  subDet,
const unsigned short  layers 
) const
private

Fills the map with the paramters for the given subdetector.
Each vector "v" holds the parameters for the layers/rings, if the vector has only one parameter all the layers/rings get that parameter.
The only other possibility is that the number of parameters equals the number of layers, otherwise an exception of type "Configuration" will be thrown.

Definition at line 135 of file SiStripNoisesGenerator.cc.

References edm::hlt::Exception.

Referenced by fillParameters().

136 {
137  if( v.size() == layers ) {
138  mapToFill.insert(std::make_pair( subDet, v ));
139  }
140  else if( v.size() == 1 ) {
141  std::vector<double> parV(layers, v[0]);
142  mapToFill.insert(std::make_pair( subDet, parV ));
143  }
144  else {
145  throw cms::Exception("Configuration") << "ERROR: number of parameters for subDet " << subDet << " are " << v.size() << ". They must be either 1 or " << layers << std::endl;
146  }
147 }
mathSSE::Vec4< T > v
void SiStripNoisesGenerator::getObj ( SiStripNoises *&  obj)
inlinevirtual
void SiStripNoisesGenerator::printLog ( const uint32_t  detId,
const unsigned short  strip,
const double &  noise 
) const
inlineprivate

Definition at line 36 of file SiStripNoisesGenerator.h.

Referenced by createObject().

37  {
38  edm::LogInfo("SiStripNoisesDummyCalculator") << "detid: " << detId << " strip: " << strip << " noise: " << noise << " \t" << std::endl;
39  }
void strip(std::string &input, const std::string &blanks=" \n\t")
Definition: stringTools.cc:16
std::pair< int, int > SiStripNoisesGenerator::subDetAndLayer ( const uint32_t  detit) const
private

Given the map and the detid it returns the corresponding layer/ring.

Definition at line 96 of file SiStripNoisesGenerator.cc.

References TOBDetId::layer(), TIBDetId::layer(), TIDDetId::ring(), TECDetId::ring(), DetId::subdetId(), StripSubdetector::TEC, StripSubdetector::TIB, StripSubdetector::TID, and StripSubdetector::TOB.

Referenced by createObject().

97 {
98  int layerId = 0;
99 
100  StripSubdetector subid(detId);
101  int subId = subid.subdetId();
102 
103  if( subId == int(StripSubdetector::TIB)) {
104  TIBDetId theTIBDetId(detId);
105  layerId = theTIBDetId.layer() - 1;
106  }
107  else if(subId == int(StripSubdetector::TOB)) {
108  TOBDetId theTOBDetId(detId);
109  layerId = theTOBDetId.layer() - 1;
110  }
111  else if(subId == int(StripSubdetector::TID)) {
112  TIDDetId theTIDDetId(detId);
113  layerId = theTIDDetId.ring() - 1;
114  }
115  if(subId == int(StripSubdetector::TEC)) {
116  TECDetId theTECDetId = TECDetId(detId);
117  layerId = theTECDetId.ring() - 1;
118  }
119  return std::make_pair(subId, layerId);
120 }
unsigned int ring() const
ring id
Definition: TECDetId.h:71

Member Data Documentation

double SiStripNoisesGenerator::electronsPerADC_
private

Definition at line 41 of file SiStripNoisesGenerator.h.

Referenced by createObject().

double SiStripNoisesGenerator::minimumPosValue_
private

Definition at line 42 of file SiStripNoisesGenerator.h.

Referenced by createObject().

uint32_t SiStripNoisesGenerator::printDebug_
private

Definition at line 44 of file SiStripNoisesGenerator.h.

Referenced by createObject().

bool SiStripNoisesGenerator::stripLengthMode_
private

Definition at line 43 of file SiStripNoisesGenerator.h.

Referenced by createObject().