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

#include <CalibFormats/SiStripObjects/interface/SiStripGain.h>

Public Member Functions

float getApvGain (const uint16_t &apv, const SiStripApvGain::Range &range) const
 
float getApvGain (const uint16_t &apv, const SiStripApvGain::Range &range, const uint32_t index) const
 
void getDetIds (std::vector< uint32_t > &DetIds_) const
 ATTENTION: we assume the detIds are the same as those from the first gain. More...
 
std::string getLabelName (const uint32_t index) const
 
size_t getNumberOfTags () const
 
const SiStripApvGain::Range getRange (const uint32_t &detID) const
 
const SiStripApvGain::Range getRange (const uint32_t &detID, const uint32_t index) const
 
std::string getRcdName (const uint32_t index) const
 
float getStripGain (const uint16_t &strip, const SiStripApvGain::Range &range) const
 
float getStripGain (const uint16_t &strip, const SiStripApvGain::Range &range, const uint32_t index) const
 
double getTagNorm (const uint32_t index) const
 
void multiply (const SiStripApvGain &apvgain, const double &factor, const std::pair< std::string, std::string > &recordLabelPair)
 Used to input additional gain values that will be multiplied to the first one. More...
 
void printDebug (std::stringstream &ss) const
 
void printSummary (std::stringstream &ss) const
 
 SiStripGain ()
 
 SiStripGain (const SiStripApvGain &apvgain, const double &factor)
 Kept for compatibility. More...
 
 SiStripGain (const SiStripApvGain &apvgain, const double &factor, const std::pair< std::string, std::string > &recordLabelPair)
 
virtual ~SiStripGain ()
 

Private Member Functions

void fillNewGain (const SiStripApvGain *apvgain, const double &factor, const SiStripApvGain *apvgain2=0, const double &factor2=1.)
 
const SiStripGainoperator= (const SiStripGain &)
 
 SiStripGain (const SiStripGain &)
 

Private Attributes

const SiStripApvGainapvgain_
 
std::auto_ptr< SiStripApvGainapvgainAutoPtr_
 
std::vector< const
SiStripApvGain * > 
apvgainVector_
 
std::vector< double > normVector_
 
std::vector< std::pair
< std::string, std::string > > 
recordLabelPair_
 

Detailed Description

Description: give detector view for the cabling classes

Usage: <usage>

Original Author: gbruno Created: Wed Mar 22 12:24:20 CET 2006

Modifications by M. De Mattia (demat.nosp@m.tia@.nosp@m.pd.in.nosp@m.fn.i.nosp@m.t) on 11/11/2009: It now holds a std::vector of pointers to ApvGain and a std::vector of corresponding normalization factors.
It returns the product of all the Gain/norm ratios.
The multiply method allows to input additional gain records.
ATTENTION: the code assumes that the second tag has at least the same DetIds that the first tag and only the DetIds present in the first tag will be used.

There are two set of methods to access the gain value. The first one returns the products of all ApvGain/norm. The second set of methods take an additional integer paramter and return the corresponding ApvGain (without normalization). Note that no check is done inside these methods to see if the ApvGain really exists. It is responsibility of the user to not pass an index value that exceeds the number of ApvGains.
The normalization factors for each of the stored ApvGains are also accessible passing the corresponding index.
Additional method are provided to get the number of ApvGains used to build this object, the names of the records that stored those ApvGains and the labels (they can be used to go back to the tags looking in the cfg).

Definition at line 40 of file SiStripGain.h.

Constructor & Destructor Documentation

SiStripGain::SiStripGain ( )
inline

Definition at line 43 of file SiStripGain.h.

43 {};
virtual SiStripGain::~SiStripGain ( )
inlinevirtual

Definition at line 44 of file SiStripGain.h.

44 {};
SiStripGain::SiStripGain ( const SiStripApvGain apvgain,
const double &  factor 
)
inline

Kept for compatibility.

Definition at line 47 of file SiStripGain.h.

References multiply().

47  :
48  apvgain_(0)
49  {
50  multiply(apvgain, factor, std::make_pair("", ""));
51  }
void multiply(const SiStripApvGain &apvgain, const double &factor, const std::pair< std::string, std::string > &recordLabelPair)
Used to input additional gain values that will be multiplied to the first one.
Definition: SiStripGain.cc:17
const SiStripApvGain * apvgain_
Definition: SiStripGain.h:117
SiStripGain::SiStripGain ( const SiStripApvGain apvgain,
const double &  factor,
const std::pair< std::string, std::string > &  recordLabelPair 
)
inline

Definition at line 53 of file SiStripGain.h.

References multiply().

54  :
55  apvgain_(0)
56  {
57  multiply(apvgain, factor, recordLabelPair);
58  }
void multiply(const SiStripApvGain &apvgain, const double &factor, const std::pair< std::string, std::string > &recordLabelPair)
Used to input additional gain values that will be multiplied to the first one.
Definition: SiStripGain.cc:17
const SiStripApvGain * apvgain_
Definition: SiStripGain.h:117
SiStripGain::SiStripGain ( const SiStripGain )
private

Member Function Documentation

void SiStripGain::fillNewGain ( const SiStripApvGain apvgain,
const double &  factor,
const SiStripApvGain apvgain2 = 0,
const double &  factor2 = 1. 
)
private

Definition at line 39 of file SiStripGain.cc.

References apvgain_, apvgainAutoPtr_, edm::FileInPath::fullPath(), SiStripApvGain::getApvGain(), SiStripApvGain::getDetIds(), SiStripApvGain::getRange(), estimatePileup::inputRange, SiStripApvGain::put(), and matplotRender::reader.

Referenced by multiply().

41 {
42  SiStripApvGain * newApvGain = new SiStripApvGain;
43  edm::FileInPath fp("CalibTracker/SiStripCommon/data/SiStripDetInfo.dat");
44  SiStripDetInfoFileReader reader(fp.fullPath());
45  const std::map<uint32_t, SiStripDetInfoFileReader::DetInfo> DetInfos = reader.getAllData();
46 
47  // Loop on the apvgain in input and fill the newApvGain with the values/factor.
48  std::vector<uint32_t> detIds;
49  apvgain->getDetIds(detIds);
50  std::vector<uint32_t>::const_iterator it = detIds.begin();
51  for( ; it != detIds.end(); ++it ) {
52 
53  std::map<uint32_t, SiStripDetInfoFileReader::DetInfo>::const_iterator detInfoIt = DetInfos.find(*it);
54  if( detInfoIt != DetInfos.end() ) {
55 
56  std::vector<float> theSiStripVector;
57 
58  // Loop on all the apvs and then on the strips
59  SiStripApvGain::Range range = apvgain->getRange(*it);
60 
61  SiStripApvGain::Range range2;
62  if( apvgain2 != 0 ) {
63  range2 = apvgain2->getRange(*it);
64  }
65 
66  for( int apv = 0; apv < detInfoIt->second.nApvs; ++apv ) {
67  float apvGainValue = apvgain->getApvGain( apv, range )/factor;
68 
69  if( (apvgain2 != 0) && (factor2 != 0.) ) {
70  apvGainValue *= apvgain2->getApvGain( apv, range2 )/factor2;
71  }
72 
73  theSiStripVector.push_back(apvGainValue);
74  }
75  SiStripApvGain::Range inputRange(theSiStripVector.begin(), theSiStripVector.end());
76  if( ! newApvGain->put(*it, inputRange) ) {
77  edm::LogError("SiStripGain") << "detid already exists" << std::endl;
78  }
79  }
80  }
81  apvgain_ = newApvGain;
82  // Deletes the managed object and replaces it with the new one
83  apvgainAutoPtr_.reset(newApvGain);
84 }
inputRange
Get input source.
std::auto_ptr< SiStripApvGain > apvgainAutoPtr_
Definition: SiStripGain.h:118
void getDetIds(std::vector< uint32_t > &DetIds_) const
const SiStripApvGain * apvgain_
Definition: SiStripGain.h:117
bool put(const uint32_t &detID, Range input)
std::pair< ContainerIterator, ContainerIterator > Range
const Range getRange(const uint32_t &detID) const
float getApvGain(const uint16_t &apv, const Range &range) const
float SiStripGain::getApvGain ( const uint16_t &  apv,
const SiStripApvGain::Range range 
) const

Definition at line 104 of file SiStripGain.cc.

References apvgain_, and SiStripApvGain::getApvGain().

Referenced by getApvGain(), printDebug(), and printSummary().

105 {
106  if( apvgain_ == 0 ) {
107  edm::LogError("SiStripGain::getApvGain") << "ERROR: no gain available. Returning gain = 1." << std::endl;
108  return 1.;
109  }
110  return( apvgain_->getApvGain(apv, range) );
111 }
const SiStripApvGain * apvgain_
Definition: SiStripGain.h:117
float getApvGain(const uint16_t &apv, const Range &range) const
float SiStripGain::getApvGain ( const uint16_t &  apv,
const SiStripApvGain::Range range,
const uint32_t  index 
) const

Definition at line 113 of file SiStripGain.cc.

References apvgainVector_, getApvGain(), and normVector_.

114 {
115  if( !(apvgainVector_.empty()) ) {
116  return (apvgainVector_[index]->getApvGain(apv, range))/(normVector_[index]);
117  }
118  edm::LogError("SiStripGain::getApvGain") << "ERROR: no gain available. Returning gain = 1." << std::endl;
119  return 1.;
120 }
std::vector< const SiStripApvGain * > apvgainVector_
Definition: SiStripGain.h:115
float getApvGain(const uint16_t &apv, const SiStripApvGain::Range &range) const
Definition: SiStripGain.cc:104
std::vector< double > normVector_
Definition: SiStripGain.h:116
void SiStripGain::getDetIds ( std::vector< uint32_t > &  DetIds_) const

ATTENTION: we assume the detIds are the same as those from the first gain.

Definition at line 122 of file SiStripGain.cc.

References apvgain_, and SiStripApvGain::getDetIds().

Referenced by printDebug(), and printSummary().

123 {
124  // ATTENTION: we assume the detIds are the same as those from the first gain
125  return apvgain_->getDetIds(DetIds_);
126 }
void getDetIds(std::vector< uint32_t > &DetIds_) const
const SiStripApvGain * apvgain_
Definition: SiStripGain.h:117
std::string SiStripGain::getLabelName ( const uint32_t  index) const
inline

Definition at line 94 of file SiStripGain.h.

References getHLTprescales::index, and recordLabelPair_.

95  {
96  return recordLabelPair_[index].second;
97  }
std::vector< std::pair< std::string, std::string > > recordLabelPair_
Definition: SiStripGain.h:119
size_t SiStripGain::getNumberOfTags ( ) const
inline

Definition at line 86 of file SiStripGain.h.

References apvgainVector_.

87  {
88  return apvgainVector_.size();
89  }
std::vector< const SiStripApvGain * > apvgainVector_
Definition: SiStripGain.h:115
const SiStripApvGain::Range SiStripGain::getRange ( const uint32_t &  detID) const

Definition at line 128 of file SiStripGain.cc.

References apvgain_, and SiStripApvGain::getRange().

Referenced by printDebug(), printSummary(), and jptJetAnalysis::StripSignalOverNoiseCalculator::signalOverNoise().

129 {
130  return apvgain_->getRange(DetId);
131 }
const SiStripApvGain * apvgain_
Definition: SiStripGain.h:117
Definition: DetId.h:18
const Range getRange(const uint32_t &detID) const
const SiStripApvGain::Range SiStripGain::getRange ( const uint32_t &  detID,
const uint32_t  index 
) const

The second parameter allows to specify which gain to retrieve, considering that they are in input order. NOTE that no protection is inside the method (because we want to keep it very light) therefore it is the caller duty to check that the index is in the correct range.

Definition at line 133 of file SiStripGain.cc.

References apvgainVector_, and getHLTprescales::index.

134 {
135  return apvgainVector_[index]->getRange(DetId);
136 }
std::vector< const SiStripApvGain * > apvgainVector_
Definition: SiStripGain.h:115
Definition: DetId.h:18
std::string SiStripGain::getRcdName ( const uint32_t  index) const
inline

Definition at line 90 of file SiStripGain.h.

References getHLTprescales::index, and recordLabelPair_.

91  {
92  return recordLabelPair_[index].first;
93  }
std::vector< std::pair< std::string, std::string > > recordLabelPair_
Definition: SiStripGain.h:119
float SiStripGain::getStripGain ( const uint16_t &  strip,
const SiStripApvGain::Range range 
) const

Definition at line 86 of file SiStripGain.cc.

References apvgain_, and SiStripApvGain::getStripGain().

Referenced by getStripGain(), and jptJetAnalysis::StripSignalOverNoiseCalculator::signalOverNoise().

87 {
88  if( apvgain_ == 0 ) {
89  edm::LogError("SiStripGain::getStripGain") << "ERROR: no gain available. Returning gain = 1." << std::endl;
90  return 1.;
91  }
92  return( apvgain_->getStripGain(strip, range) );
93 }
const SiStripApvGain * apvgain_
Definition: SiStripGain.h:117
float getStripGain(const uint16_t &strip, const Range &range) const
float SiStripGain::getStripGain ( const uint16_t &  strip,
const SiStripApvGain::Range range,
const uint32_t  index 
) const

Definition at line 95 of file SiStripGain.cc.

References apvgainVector_, and getStripGain().

96 {
97  if( !(apvgainVector_.empty()) ) {
98  return( apvgainVector_[index]->getStripGain(strip, range) );
99  }
100  edm::LogError("SiStripGain::getStripGain") << "ERROR: no gain available. Returning gain = 1." << std::endl;
101  return 1.;
102 }
std::vector< const SiStripApvGain * > apvgainVector_
Definition: SiStripGain.h:115
float getStripGain(const uint16_t &strip, const SiStripApvGain::Range &range) const
Definition: SiStripGain.cc:86
double SiStripGain::getTagNorm ( const uint32_t  index) const
inline

Definition at line 98 of file SiStripGain.h.

References getHLTprescales::index, and normVector_.

99  {
100  return normVector_[index];
101  }
std::vector< double > normVector_
Definition: SiStripGain.h:116
void SiStripGain::multiply ( const SiStripApvGain apvgain,
const double &  factor,
const std::pair< std::string, std::string > &  recordLabelPair 
)

Used to input additional gain values that will be multiplied to the first one.

Definition at line 17 of file SiStripGain.cc.

References apvgain_, apvgainVector_, fillNewGain(), normVector_, and recordLabelPair_.

Referenced by SiStripGain(), and SiStripGainESProducerTemplate< TDependentRecord, TInputRecord >::SiStripGainNormalizationFunction().

19 {
20  // When inserting the first ApvGain
21  if( apvgain_ == 0 ) {
22  if( (factor != 1) && (factor != 0) ) {
23  fillNewGain( &apvgain, factor );
24  }
25  else {
26  // If the normalization factor is one, no need to create a new SiStripApvGain
27  apvgain_ = &apvgain;
28  }
29  }
30  else {
31  // There is already an ApvGain inside the SiStripGain. Multiply it by the new one and save the new pointer.
32  fillNewGain( apvgain_, 1., &apvgain, factor );
33  }
34  recordLabelPair_.push_back(recordLabelPair);
35  apvgainVector_.push_back(&apvgain);
36  normVector_.push_back(factor);
37 }
std::vector< const SiStripApvGain * > apvgainVector_
Definition: SiStripGain.h:115
std::vector< double > normVector_
Definition: SiStripGain.h:116
std::vector< std::pair< std::string, std::string > > recordLabelPair_
Definition: SiStripGain.h:119
const SiStripApvGain * apvgain_
Definition: SiStripGain.h:117
void fillNewGain(const SiStripApvGain *apvgain, const double &factor, const SiStripApvGain *apvgain2=0, const double &factor2=1.)
Definition: SiStripGain.cc:39
const SiStripGain& SiStripGain::operator= ( const SiStripGain )
private
void SiStripGain::printDebug ( std::stringstream &  ss) const

Definition at line 138 of file SiStripGain.cc.

References cond::rpcobgas::detid, getApvGain(), getDetIds(), and getRange().

139 {
140  std::vector<unsigned int> detIds;
141  getDetIds(detIds);
142  std::vector<unsigned int>::const_iterator detid = detIds.begin();
143  ss << "Number of detids " << detIds.size() << std::endl;
144 
145  for( ; detid != detIds.end(); ++detid ) {
146  SiStripApvGain::Range range = getRange(*detid);
147  int apv=0;
148  for( int it=0; it < range.second - range.first; ++it ) {
149  ss << "detid " << *detid << " \t"
150  << " apv " << apv++ << " \t"
151  << getApvGain(it,range) << " \t"
152  << std::endl;
153  }
154  }
155 }
float getApvGain(const uint16_t &apv, const SiStripApvGain::Range &range) const
Definition: SiStripGain.cc:104
std::pair< ContainerIterator, ContainerIterator > Range
void getDetIds(std::vector< uint32_t > &DetIds_) const
ATTENTION: we assume the detIds are the same as those from the first gain.
Definition: SiStripGain.cc:122
const SiStripApvGain::Range getRange(const uint32_t &detID) const
Definition: SiStripGain.cc:128
void SiStripGain::printSummary ( std::stringstream &  ss) const

Definition at line 157 of file SiStripGain.cc.

References SiStripDetSummary::add(), cond::rpcobgas::detid, getApvGain(), getDetIds(), getRange(), and SiStripDetSummary::print().

158 {
159  SiStripDetSummary summaryGain;
160 
161  std::vector<unsigned int> detIds;
162  getDetIds(detIds);
163  std::vector<uint32_t>::const_iterator detid = detIds.begin();
164  for( ; detid != detIds.end(); ++detid ) {
165  SiStripApvGain::Range range = getRange(*detid);
166  for( int it=0; it < range.second - range.first; ++it ) {
167  summaryGain.add(*detid, getApvGain(it, range));
168  }
169  }
170  ss << "Summary of gain values:" << std::endl;
171  summaryGain.print(ss, true);
172 }
float getApvGain(const uint16_t &apv, const SiStripApvGain::Range &range) const
Definition: SiStripGain.cc:104
std::pair< ContainerIterator, ContainerIterator > Range
void getDetIds(std::vector< uint32_t > &DetIds_) const
ATTENTION: we assume the detIds are the same as those from the first gain.
Definition: SiStripGain.cc:122
void print(std::stringstream &ss, const bool mean=true) const
const SiStripApvGain::Range getRange(const uint32_t &detID) const
Definition: SiStripGain.cc:128
void add(const DetId &detid, const float &value)
Used to compute the mean value of the value variable divided by subdetector, layer and mono/stereo...

Member Data Documentation

const SiStripApvGain* SiStripGain::apvgain_
private

Definition at line 117 of file SiStripGain.h.

Referenced by fillNewGain(), getApvGain(), getDetIds(), getRange(), getStripGain(), and multiply().

std::auto_ptr<SiStripApvGain> SiStripGain::apvgainAutoPtr_
private

Definition at line 118 of file SiStripGain.h.

Referenced by fillNewGain().

std::vector<const SiStripApvGain *> SiStripGain::apvgainVector_
private

Definition at line 115 of file SiStripGain.h.

Referenced by getApvGain(), getNumberOfTags(), getRange(), getStripGain(), and multiply().

std::vector<double> SiStripGain::normVector_
private

Definition at line 116 of file SiStripGain.h.

Referenced by getApvGain(), getTagNorm(), and multiply().

std::vector<std::pair<std::string, std::string> > SiStripGain::recordLabelPair_
private

Definition at line 119 of file SiStripGain.h.

Referenced by getLabelName(), getRcdName(), and multiply().