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

SiStripNoisescreateObject ()
 
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

SiStripNoises * 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_, getGTfromDQMFile::obj, printDebug_, printLog(), SiStripNoises::put(), matplotRender::reader, SiStripNoises::setData(), stripLengthMode_, and subDetAndLayer().

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

30 {
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  return obj;
95 }
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:51
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:165
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 123 of file SiStripNoisesGenerator.cc.

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

Referenced by createObject().

124 {
125  int layersTIB = 4;
126  int ringsTID = 3;
127  int layersTOB = 6;
128  int ringsTEC = 7;
129 
130  fillSubDetParameter( mapToFill, _pset.getParameter<std::vector<double> >(parameterName+"TIB"), int(StripSubdetector::TIB), layersTIB );
131  fillSubDetParameter( mapToFill, _pset.getParameter<std::vector<double> >(parameterName+"TID"), int(StripSubdetector::TID), ringsTID );
132  fillSubDetParameter( mapToFill, _pset.getParameter<std::vector<double> >(parameterName+"TOB"), int(StripSubdetector::TOB), layersTOB );
133  fillSubDetParameter( mapToFill, _pset.getParameter<std::vector<double> >(parameterName+"TEC"), int(StripSubdetector::TEC), ringsTEC );
134 }
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 136 of file SiStripNoisesGenerator.cc.

References edm::hlt::Exception, and LayerTriplets::layers().

Referenced by fillParameters().

137 {
138  if( v.size() == layers ) {
139  mapToFill.insert(std::make_pair( subDet, v ));
140  }
141  else if( v.size() == 1 ) {
142  std::vector<double> parV(layers, v[0]);
143  mapToFill.insert(std::make_pair( subDet, parV ));
144  }
145  else {
146  throw cms::Exception("Configuration") << "ERROR: number of parameters for subDet " << subDet << " are " << v.size() << ". They must be either 1 or " << layers << std::endl;
147  }
148 }
std::vector< LayerSetAndLayers > layers(const SeedingLayerSetsHits &sets)
Definition: LayerTriplets.cc:4
void SiStripNoisesGenerator::getObj ( SiStripNoises *&  obj)
inlinevirtual

Returns the CondObj

Reimplemented from SiStripCondObjBuilderBase< SiStripNoises >.

Definition at line 18 of file SiStripNoisesGenerator.h.

References createObject().

18 {obj=createObject();}
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  }
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 97 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().

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