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:
SiStripDepCondObjBuilderBase< SiStripNoises, TrackerTopology >

Public Member Functions

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

Private Member Functions

SiStripNoisescreateObject (const TrackerTopology *tTopo)
 
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 TrackerTopology *tTopo) 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 SiStripDepCondObjBuilderBase< SiStripNoises, TrackerTopology >
edm::ParameterSet _pset
 
SiStripNoisesobj_
 

Detailed Description

Definition at line 13 of file SiStripNoisesGenerator.h.

Constructor & Destructor Documentation

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

Definition at line 9 of file SiStripNoisesGenerator.cc.

9  :
11  electronsPerADC_(0.),
12  minimumPosValue_(0.),
13  stripLengthMode_(true),
14  printDebug_(0)
15 {
16  edm::LogInfo("SiStripNoisesGenerator") << "[SiStripNoisesGenerator::SiStripNoisesGenerator]";
17 }
SiStripDepCondObjBuilderBase(const edm::ParameterSet &pset)
SiStripNoisesGenerator::~SiStripNoisesGenerator ( )

Definition at line 19 of file SiStripNoisesGenerator.cc.

20 {
21  edm::LogInfo("SiStripNoisesGenerator") << "[SiStripNoisesGenerator::~SiStripNoisesGenerator]";
22 }

Member Function Documentation

SiStripNoises * SiStripNoisesGenerator::createObject ( const TrackerTopology tTopo)
private

Definition at line 24 of file SiStripNoisesGenerator.cc.

References SiStripDepCondObjBuilderBase< SiStripNoises, TrackerTopology >::_pset, KineDebug3::count(), electronsPerADC_, fillParameters(), edm::FileInPath::fullPath(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), j, minimumPosValue_, HLT_25ns10e33_v2_cff::noise, getGTfromDQMFile::obj, printDebug_, printLog(), SiStripNoises::put(), matplotRender::reader, SiStripNoises::setData(), stripLengthMode_, and subDetAndLayer().

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

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

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

Referenced by createObject().

115 {
116  int layersTIB = 4;
117  int ringsTID = 3;
118  int layersTOB = 6;
119  int ringsTEC = 7;
120 
121  fillSubDetParameter( mapToFill, _pset.getParameter<std::vector<double> >(parameterName+"TIB"), int(StripSubdetector::TIB), layersTIB );
122  fillSubDetParameter( mapToFill, _pset.getParameter<std::vector<double> >(parameterName+"TID"), int(StripSubdetector::TID), ringsTID );
123  fillSubDetParameter( mapToFill, _pset.getParameter<std::vector<double> >(parameterName+"TOB"), int(StripSubdetector::TOB), layersTOB );
124  fillSubDetParameter( mapToFill, _pset.getParameter<std::vector<double> >(parameterName+"TEC"), int(StripSubdetector::TEC), ringsTEC );
125 }
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 127 of file SiStripNoisesGenerator.cc.

References Exception, and LayerTriplets::layers().

Referenced by fillParameters().

128 {
129  if( v.size() == layers ) {
130  mapToFill.insert(std::make_pair( subDet, v ));
131  }
132  else if( v.size() == 1 ) {
133  std::vector<double> parV(layers, v[0]);
134  mapToFill.insert(std::make_pair( subDet, parV ));
135  }
136  else {
137  throw cms::Exception("Configuration") << "ERROR: number of parameters for subDet " << subDet << " are " << v.size() << ". They must be either 1 or " << layers << std::endl;
138  }
139 }
std::vector< LayerSetAndLayers > layers(const SeedingLayerSetsHits &sets)
Definition: LayerTriplets.cc:4
void SiStripNoisesGenerator::getObj ( SiStripNoises *&  obj,
const TrackerTopology depObj 
)
inlinevirtual

Returns the CondObj

Reimplemented from SiStripDepCondObjBuilderBase< SiStripNoises, TrackerTopology >.

Definition at line 19 of file SiStripNoisesGenerator.h.

References createObject().

19 {obj=createObject(tTopo);}
SiStripNoises * createObject(const TrackerTopology *tTopo)
void SiStripNoisesGenerator::printLog ( const uint32_t  detId,
const unsigned short  strip,
const double &  noise 
) const
inlineprivate

Definition at line 37 of file SiStripNoisesGenerator.h.

Referenced by createObject().

38  {
39  edm::LogInfo("SiStripNoisesDummyCalculator") << "detid: " << detId << " strip: " << strip << " noise: " << noise << " \t" << std::endl;
40  }
std::pair< int, int > SiStripNoisesGenerator::subDetAndLayer ( const uint32_t  detit,
const TrackerTopology tTopo 
) const
private

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

Definition at line 92 of file SiStripNoisesGenerator.cc.

References DetId::subdetId(), StripSubdetector::TEC, TrackerTopology::tecRing(), StripSubdetector::TIB, TrackerTopology::tibLayer(), StripSubdetector::TID, TrackerTopology::tidRing(), StripSubdetector::TOB, and TrackerTopology::tobLayer().

Referenced by createObject().

93 {
94  int layerId = 0;
95 
96  const DetId detectorId=DetId(detId);
97  const int subDet = detectorId.subdetId();
98 
99  if( subDet == int(StripSubdetector::TIB)) {
100  layerId = tTopo->tibLayer(detectorId) - 1;
101  }
102  else if(subDet == int(StripSubdetector::TOB)) {
103  layerId = tTopo->tobLayer(detectorId) - 1;
104  }
105  else if(subDet == int(StripSubdetector::TID)) {
106  layerId = tTopo->tidRing(detectorId) - 1;
107  }
108  if(subDet == int(StripSubdetector::TEC)) {
109  layerId = tTopo->tecRing(detectorId) - - 1;
110  }
111  return std::make_pair(subDet, layerId);
112 }
unsigned int tibLayer(const DetId &id) const
unsigned int tidRing(const DetId &id) const
unsigned int tecRing(const DetId &id) const
ring id
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
Definition: DetId.h:18
unsigned int tobLayer(const DetId &id) const

Member Data Documentation

double SiStripNoisesGenerator::electronsPerADC_
private

Definition at line 42 of file SiStripNoisesGenerator.h.

Referenced by createObject().

double SiStripNoisesGenerator::minimumPosValue_
private

Definition at line 43 of file SiStripNoisesGenerator.h.

Referenced by createObject().

uint32_t SiStripNoisesGenerator::printDebug_
private

Definition at line 45 of file SiStripNoisesGenerator.h.

Referenced by createObject().

bool SiStripNoisesGenerator::stripLengthMode_
private

Definition at line 44 of file SiStripNoisesGenerator.h.

Referenced by createObject().