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
SiStripNoiseNormalizedWithApvGainBuilder Class Reference

#include <SiStripNoiseNormalizedWithApvGainBuilder.h>

Inheritance diagram for SiStripNoiseNormalizedWithApvGainBuilder:
edm::EDAnalyzer

Public Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 
 SiStripNoiseNormalizedWithApvGainBuilder (const edm::ParameterSet &iConfig)
 
 ~SiStripNoiseNormalizedWithApvGainBuilder ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

Private Member Functions

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_
 
edm::FileInPath fp_
 
double minimumPosValue_
 
bool printdebug_
 
uint32_t printDebug_
 
edm::ParameterSet pset_
 
bool stripLengthMode_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

Detailed Description

Produces a noise tag using the same settings as the service used in the DummyDBWriter, but it receives a SiStripApvGain tag from the EventSetup and uses the gain values (per apv) to rescale the noise (per strip).

Definition at line 28 of file SiStripNoiseNormalizedWithApvGainBuilder.h.

Constructor & Destructor Documentation

SiStripNoiseNormalizedWithApvGainBuilder::SiStripNoiseNormalizedWithApvGainBuilder ( const edm::ParameterSet iConfig)
explicit
SiStripNoiseNormalizedWithApvGainBuilder::~SiStripNoiseNormalizedWithApvGainBuilder ( )
inline

Definition at line 34 of file SiStripNoiseNormalizedWithApvGainBuilder.h.

34 {};

Member Function Documentation

void SiStripNoiseNormalizedWithApvGainBuilder::analyze ( const edm::Event evt,
const edm::EventSetup iSetup 
)
virtual

Implements edm::EDAnalyzer.

Definition at line 25 of file SiStripNoiseNormalizedWithApvGainBuilder.cc.

References cond::service::PoolDBOutputService::appendSinceTime(), cond::service::PoolDBOutputService::beginOfTime(), prof2calltree::count, cond::service::PoolDBOutputService::createNewIOV(), cond::service::PoolDBOutputService::currentTime(), electronsPerADC_, cond::service::PoolDBOutputService::endOfTime(), fillParameters(), fp_, edm::FileInPath::fullPath(), edm::EventSetup::get(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), estimatePileup::inputRange, edm::Service< T >::isAvailable(), cond::service::PoolDBOutputService::isNewTagRequest(), j, minimumPosValue_, VarParsing::obj, printDebug_, printLog(), pset_, SiStripNoises::put(), SiStripNoises::setData(), stripLengthMode_, and subDetAndLayer().

26 {
27  // Read the gain from the given tag
28  edm::ESHandle<SiStripApvGain> inputApvGain;
29  iSetup.get<SiStripApvGainRcd>().get( inputApvGain );
30  std::vector<uint32_t> inputDetIds;
31  inputApvGain->getDetIds(inputDetIds);
32 
33  // Prepare the new object
35 
37 
38 
39 
40  stripLengthMode_ = pset_.getParameter<bool>("StripLengthMode");
41 
42  //parameters for random noise generation. not used if Strip length mode is chosen
43  std::map<int, std::vector<double> > meanNoise;
44  fillParameters(meanNoise, "MeanNoise");
45  std::map<int, std::vector<double> > sigmaNoise;
46  fillParameters(sigmaNoise, "SigmaNoise");
47  minimumPosValue_ = pset_.getParameter<double>("MinPositiveNoise");
48 
49  //parameters for strip length proportional noise generation. not used if random mode is chosen
50  std::map<int, std::vector<double> > noiseStripLengthLinearSlope;
51  fillParameters(noiseStripLengthLinearSlope, "NoiseStripLengthSlope");
52  std::map<int, std::vector<double> > noiseStripLengthLinearQuote;
53  fillParameters(noiseStripLengthLinearQuote, "NoiseStripLengthQuote");
54  electronsPerADC_ = pset_.getParameter<double>("electronPerAdc");
55 
56  printDebug_ = pset_.getUntrackedParameter<uint32_t>("printDebug", 5);
57 
58  unsigned int count = 0;
59  const std::map<uint32_t, SiStripDetInfoFileReader::DetInfo > DetInfos = reader.getAllData();
60  for(std::map<uint32_t, SiStripDetInfoFileReader::DetInfo >::const_iterator it = DetInfos.begin(); it != DetInfos.end(); it++) {
61 
62  // Find if this DetId is in the input tag and if so how many are the Apvs for which it contains information
63  SiStripApvGain::Range inputRange(inputApvGain->getRange(it->first));
64 
65  //Generate Noises for det detid
66  SiStripNoises::InputVector theSiStripVector;
67  float noise = 0.;
68  uint32_t detId = it->first;
69  std::pair<int, int> sl = subDetAndLayer(detId);
70  unsigned short nApvs = it->second.nApvs;
71 
72  if(stripLengthMode_) {
73  // Use strip length
74  double linearSlope = noiseStripLengthLinearSlope[sl.first][sl.second];
75  double linearQuote = noiseStripLengthLinearQuote[sl.first][sl.second];
76  double stripLength = it->second.stripLength;
77  for( unsigned short j=0; j<nApvs; ++j ) {
78 
79  double gain = inputApvGain->getApvGain(j, inputRange);
80 
81  for( unsigned short stripId = 0; stripId < 128; ++stripId ) {
82  noise = ( ( linearSlope*stripLength + linearQuote) / electronsPerADC_ ) * gain;
83  if( count<printDebug_ ) printLog(detId, stripId+128*j, noise);
84  obj->setData(noise, theSiStripVector);
85  }
86  }
87  }
88  else {
89  // Use random generator
90  double meanN = meanNoise[sl.first][sl.second];
91  double sigmaN = sigmaNoise[sl.first][sl.second];
92  for( unsigned short j=0; j<nApvs; ++j ) {
93 
94  double gain = inputApvGain->getApvGain(j, inputRange);
95 
96  for( unsigned short stripId = 0; stripId < 128; ++stripId ) {
97  noise = ( CLHEP::RandGauss::shoot(meanN, sigmaN) ) * gain;
98  if( noise<=minimumPosValue_ ) noise = minimumPosValue_;
99  if( count<printDebug_ ) printLog(detId, stripId+128*j, noise);
100  obj->setData(noise, theSiStripVector);
101  }
102  }
103  }
104  ++count;
105 
106  if ( ! obj->put(it->first,theSiStripVector) ) {
107  edm::LogError("SiStripNoisesFakeESSource::produce ")<<" detid already exists"<<std::endl;
108  }
109  }
110 
111  //End now write data in DB
113 
114  if( mydbservice.isAvailable() ){
115  if( mydbservice->isNewTagRequest("SiStripNoisesRcd") ){
116  mydbservice->createNewIOV<SiStripNoises>(obj,mydbservice->beginOfTime(),mydbservice->endOfTime(),"SiStripNoisesRcd");
117  }
118  else {
119  mydbservice->appendSinceTime<SiStripNoises>(obj,mydbservice->currentTime(),"SiStripNoisesRcd");
120  }
121  }
122  else {
123  edm::LogError("SiStripNoiseNormalizedWithApvGainBuilder")<<"Service is unavailable"<<std::endl;
124  }
125 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
inputRange
Get input source.
std::vector< uint16_t > InputVector
Definition: SiStripNoises.h:44
void appendSinceTime(T *payloadObj, cond::Time_t sinceTime, const std::string &recordName, bool withlogging=false)
tuple obj
Example code starts here #.
Definition: VarParsing.py:655
bool isNewTagRequest(const std::string &recordName)
bool isAvailable() const
Definition: Service.h:47
std::pair< ContainerIterator, ContainerIterator > Range
int j
Definition: DBlmapReader.cc:9
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.
void printLog(const uint32_t detId, const unsigned short strip, const double &noise) const
void createNewIOV(T *firstPayloadObj, cond::Time_t firstSinceTime, cond::Time_t firstTillTime, const std::string &recordName, bool withlogging=false)
bool put(const uint32_t &detID, const InputVector &input)
const T & get() const
Definition: EventSetup.h:55
std::string fullPath() const
Definition: FileInPath.cc:170
std::pair< int, int > subDetAndLayer(const uint32_t detit) const
Given the map and the detid it returns the corresponding layer/ring.
void setData(float noise_, InputVector &vped)
void SiStripNoiseNormalizedWithApvGainBuilder::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 153 of file SiStripNoiseNormalizedWithApvGainBuilder.cc.

References fillSubDetParameter(), edm::ParameterSet::getParameter(), pset_, StripSubdetector::TEC, StripSubdetector::TIB, StripSubdetector::TID, and StripSubdetector::TOB.

Referenced by analyze().

154 {
155  int layersTIB = 4;
156  int ringsTID = 3;
157  int layersTOB = 6;
158  int ringsTEC = 7;
159 
160  fillSubDetParameter( mapToFill, pset_.getParameter<std::vector<double> >(parameterName+"TIB"), int(StripSubdetector::TIB), layersTIB );
161  fillSubDetParameter( mapToFill, pset_.getParameter<std::vector<double> >(parameterName+"TID"), int(StripSubdetector::TID), ringsTID );
162  fillSubDetParameter( mapToFill, pset_.getParameter<std::vector<double> >(parameterName+"TOB"), int(StripSubdetector::TOB), layersTOB );
163  fillSubDetParameter( mapToFill, pset_.getParameter<std::vector<double> >(parameterName+"TEC"), int(StripSubdetector::TEC), ringsTEC );
164 }
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 SiStripNoiseNormalizedWithApvGainBuilder::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 166 of file SiStripNoiseNormalizedWithApvGainBuilder.cc.

References edm::hlt::Exception.

Referenced by fillParameters().

167 {
168  if( v.size() == layers ) {
169  mapToFill.insert(std::make_pair( subDet, v ));
170  }
171  else if( v.size() == 1 ) {
172  std::vector<double> parV(layers, v[0]);
173  mapToFill.insert(std::make_pair( subDet, parV ));
174  }
175  else {
176  throw cms::Exception("Configuration") << "ERROR: number of parameters for subDet " << subDet << " are " << v.size() << ". They must be either 1 or " << layers << std::endl;
177  }
178 }
mathSSE::Vec4< T > v
void SiStripNoiseNormalizedWithApvGainBuilder::printLog ( const uint32_t  detId,
const unsigned short  strip,
const double &  noise 
) const
inlineprivate

Definition at line 52 of file SiStripNoiseNormalizedWithApvGainBuilder.h.

Referenced by analyze().

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

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

Definition at line 127 of file SiStripNoiseNormalizedWithApvGainBuilder.cc.

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

Referenced by analyze().

128 {
129  int layerId = 0;
130 
131  StripSubdetector subid(detId);
132  int subId = subid.subdetId();
133 
134  if( subId == int(StripSubdetector::TIB)) {
135  TIBDetId theTIBDetId(detId);
136  layerId = theTIBDetId.layer() - 1;
137  }
138  else if(subId == int(StripSubdetector::TOB)) {
139  TOBDetId theTOBDetId(detId);
140  layerId = theTOBDetId.layer() - 1;
141  }
142  else if(subId == int(StripSubdetector::TID)) {
143  TIDDetId theTIDDetId(detId);
144  layerId = theTIDDetId.ring() - 1;
145  }
146  if(subId == int(StripSubdetector::TEC)) {
147  TECDetId theTECDetId = TECDetId(detId);
148  layerId = theTECDetId.ring() - 1;
149  }
150  return std::make_pair(subId, layerId);
151 }
unsigned int ring() const
ring id
Definition: TECDetId.h:71

Member Data Documentation

double SiStripNoiseNormalizedWithApvGainBuilder::electronsPerADC_
private

Definition at line 61 of file SiStripNoiseNormalizedWithApvGainBuilder.h.

Referenced by analyze().

edm::FileInPath SiStripNoiseNormalizedWithApvGainBuilder::fp_
private

Definition at line 57 of file SiStripNoiseNormalizedWithApvGainBuilder.h.

Referenced by analyze().

double SiStripNoiseNormalizedWithApvGainBuilder::minimumPosValue_
private

Definition at line 62 of file SiStripNoiseNormalizedWithApvGainBuilder.h.

Referenced by analyze().

bool SiStripNoiseNormalizedWithApvGainBuilder::printdebug_
private

Definition at line 58 of file SiStripNoiseNormalizedWithApvGainBuilder.h.

uint32_t SiStripNoiseNormalizedWithApvGainBuilder::printDebug_
private

Definition at line 64 of file SiStripNoiseNormalizedWithApvGainBuilder.h.

Referenced by analyze().

edm::ParameterSet SiStripNoiseNormalizedWithApvGainBuilder::pset_
private

Definition at line 59 of file SiStripNoiseNormalizedWithApvGainBuilder.h.

Referenced by analyze(), and fillParameters().

bool SiStripNoiseNormalizedWithApvGainBuilder::stripLengthMode_
private

Definition at line 63 of file SiStripNoiseNormalizedWithApvGainBuilder.h.

Referenced by analyze().