CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
SiStripGain Class Reference

#include <SiStripGain.h>

Public Member Functions

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 (uint32_t detID) const
 
const SiStripApvGain::Range getRange (const uint32_t &detID, const uint32_t index) const
 
SiStripApvGain::Range getRangeByPos (unsigned short pos) const
 
std::string getRcdName (const uint32_t index) 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, const SiStripDetInfo &detInfo)
 
const SiStripGainoperator= (const SiStripGain &)=delete
 
void printDebug (std::stringstream &ss, const TrackerTopology *trackerTopo) const
 
void printSummary (std::stringstream &ss, const TrackerTopology *trackerTopo) const
 
 SiStripGain ()
 
 SiStripGain (const SiStripGain &)=delete
 
 SiStripGain (const SiStripApvGain &apvgain, const double &factor, const SiStripDetInfo &detInfo)
 Kept for compatibility. More...
 
 SiStripGain (const SiStripApvGain &apvgain, const double &factor, const std::pair< std::string, std::string > &recordLabelPair, const SiStripDetInfo &detInfo)
 

Static Public Member Functions

static float getApvGain (const uint16_t &apv, const SiStripApvGain::Range &range)
 
static float getStripGain (const uint16_t &strip, const SiStripApvGain::Range &range)
 

Private Member Functions

void fillNewGain (const SiStripApvGain *apvgain, const double &factor, SiStripDetInfo const &detInfo, const SiStripApvGain *apvgain2=nullptr, const double &factor2=1.)
 

Private Attributes

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

Detailed Description

CalibFormats/SiStripObjects/interface/SiStripGain.h

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 45 of file SiStripGain.h.

Constructor & Destructor Documentation

◆ SiStripGain() [1/4]

SiStripGain::SiStripGain ( )
inline

Definition at line 47 of file SiStripGain.h.

47 {}

◆ SiStripGain() [2/4]

SiStripGain::SiStripGain ( const SiStripGain )
delete

◆ SiStripGain() [3/4]

SiStripGain::SiStripGain ( const SiStripApvGain apvgain,
const double &  factor,
const SiStripDetInfo detInfo 
)
inline

Kept for compatibility.

Definition at line 52 of file SiStripGain.h.

References multiply().

53  : apvgain_(nullptr) {
54  multiply(apvgain, factor, std::make_pair("", ""), detInfo);
55  }
const SiStripApvGain * apvgain_
Definition: SiStripGain.h:118
void multiply(const SiStripApvGain &apvgain, const double &factor, const std::pair< std::string, std::string > &recordLabelPair, const SiStripDetInfo &detInfo)
Definition: SiStripGain.cc:17

◆ SiStripGain() [4/4]

SiStripGain::SiStripGain ( const SiStripApvGain apvgain,
const double &  factor,
const std::pair< std::string, std::string > &  recordLabelPair,
const SiStripDetInfo detInfo 
)
inline

Definition at line 57 of file SiStripGain.h.

References multiply().

61  : apvgain_(nullptr) {
62  multiply(apvgain, factor, recordLabelPair, detInfo);
63  }
const SiStripApvGain * apvgain_
Definition: SiStripGain.h:118
void multiply(const SiStripApvGain &apvgain, const double &factor, const std::pair< std::string, std::string > &recordLabelPair, const SiStripDetInfo &detInfo)
Definition: SiStripGain.cc:17

Member Function Documentation

◆ fillNewGain()

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

Definition at line 40 of file SiStripGain.cc.

References apvgain_, apvgainAutoPtr_, SiStripDetInfo::getAllData(), SiStripApvGain::getApvGain(), SiStripApvGain::getDetIds(), SiStripApvGain::getRange(), pileupCalc::inputRange, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, SiStripApvGain::put(), and FastTimerService_cff::range.

Referenced by multiply().

44  {
45  SiStripApvGain *newApvGain = new SiStripApvGain;
46  const auto &DetInfos = detInfo.getAllData();
47 
48  // Loop on the apvgain in input and fill the newApvGain with the
49  // values/factor.
50  std::vector<uint32_t> detIds;
51  apvgain->getDetIds(detIds);
52  std::vector<uint32_t>::const_iterator it = detIds.begin();
53  for (; it != detIds.end(); ++it) {
54  auto detInfoIt = DetInfos.find(*it);
55  if (detInfoIt != DetInfos.end()) {
56  std::vector<float> theSiStripVector;
57 
58  // Loop on all the apvs and then on the strips
60 
61  SiStripApvGain::Range range2;
62  if (apvgain2 != nullptr) {
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 != nullptr) && (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 }
static float getApvGain(uint16_t apv, const Range &range)
std::unique_ptr< SiStripApvGain > apvgainAutoPtr_
Definition: SiStripGain.h:119
Log< level::Error, false > LogError
const SiStripApvGain * apvgain_
Definition: SiStripGain.h:118
bool put(const uint32_t &detID, Range input)
void getDetIds(std::vector< uint32_t > &DetIds_) const
std::pair< ContainerIterator, ContainerIterator > Range
const Range getRange(const uint32_t detID) const

◆ getApvGain() [1/2]

static float SiStripGain::getApvGain ( const uint16_t &  apv,
const SiStripApvGain::Range range 
)
inlinestatic

◆ getApvGain() [2/2]

float SiStripGain::getApvGain ( const uint16_t &  apv,
const SiStripApvGain::Range range,
const uint32_t  index 
) const

Definition at line 94 of file SiStripGain.cc.

References apvgainVector_, getApvGain(), normVector_, and FastTimerService_cff::range.

94  {
95  if (!(apvgainVector_.empty())) {
96  return (apvgainVector_[index]->getApvGain(apv, range)) / (normVector_[index]);
97  }
98  edm::LogError("SiStripGain::getApvGain") << "ERROR: no gain available. Returning gain = 1." << std::endl;
99  return 1.;
100 }
std::vector< const SiStripApvGain * > apvgainVector_
Definition: SiStripGain.h:116
std::vector< double > normVector_
Definition: SiStripGain.h:117
Log< level::Error, false > LogError
static float getApvGain(const uint16_t &apv, const SiStripApvGain::Range &range)
Definition: SiStripGain.h:80

◆ getDetIds()

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 102 of file SiStripGain.cc.

References apvgain_, and SiStripApvGain::getDetIds().

Referenced by printDebug(), and printSummary().

102  {
103  // ATTENTION: we assume the detIds are the same as those from the first gain
104  return apvgain_->getDetIds(DetIds_);
105 }
const SiStripApvGain * apvgain_
Definition: SiStripGain.h:118
void getDetIds(std::vector< uint32_t > &DetIds_) const

◆ getLabelName()

std::string SiStripGain::getLabelName ( const uint32_t  index) const
inline

Definition at line 101 of file SiStripGain.h.

References recordLabelPair_.

101 { return recordLabelPair_[index].second; }
std::vector< std::pair< std::string, std::string > > recordLabelPair_
Definition: SiStripGain.h:120

◆ getNumberOfTags()

size_t SiStripGain::getNumberOfTags ( ) const
inline

Definition at line 99 of file SiStripGain.h.

References apvgainVector_.

Referenced by SiStripApvGainInspector::analyze().

99 { return apvgainVector_.size(); }
std::vector< const SiStripApvGain * > apvgainVector_
Definition: SiStripGain.h:116

◆ getRange() [1/2]

const SiStripApvGain::Range SiStripGain::getRange ( uint32_t  detID) const
inline

◆ getRange() [2/2]

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 107 of file SiStripGain.cc.

References apvgainVector_.

107  {
108  return apvgainVector_[index]->getRange(DetId);
109 }
std::vector< const SiStripApvGain * > apvgainVector_
Definition: SiStripGain.h:116
Definition: DetId.h:17

◆ getRangeByPos()

SiStripApvGain::Range SiStripGain::getRangeByPos ( unsigned short  pos) const
inline

Definition at line 76 of file SiStripGain.h.

References apvgain_, and SiStripApvGain::getRangeByPos().

76 { return apvgain_->getRangeByPos(pos); }
Range getRangeByPos(unsigned short pos) const
const SiStripApvGain * apvgain_
Definition: SiStripGain.h:118

◆ getRcdName()

std::string SiStripGain::getRcdName ( const uint32_t  index) const
inline

Definition at line 100 of file SiStripGain.h.

References recordLabelPair_.

100 { return recordLabelPair_[index].first; }
std::vector< std::pair< std::string, std::string > > recordLabelPair_
Definition: SiStripGain.h:120

◆ getStripGain() [1/2]

static float SiStripGain::getStripGain ( const uint16_t &  strip,
const SiStripApvGain::Range range 
)
inlinestatic

◆ getStripGain() [2/2]

float SiStripGain::getStripGain ( const uint16_t &  strip,
const SiStripApvGain::Range range,
const uint32_t  index 
) const

Definition at line 86 of file SiStripGain.cc.

References apvgainVector_, getStripGain(), FastTimerService_cff::range, and nano_mu_digi_cff::strip.

86  {
87  if (!(apvgainVector_.empty())) {
89  }
90  edm::LogError("SiStripGain::getStripGain") << "ERROR: no gain available. Returning gain = 1." << std::endl;
91  return 1.;
92 }
std::vector< const SiStripApvGain * > apvgainVector_
Definition: SiStripGain.h:116
Log< level::Error, false > LogError
static float getStripGain(const uint16_t &strip, const SiStripApvGain::Range &range)
Definition: SiStripGain.h:77

◆ getTagNorm()

double SiStripGain::getTagNorm ( const uint32_t  index) const
inline

Definition at line 102 of file SiStripGain.h.

References normVector_.

102 { return normVector_[index]; }
std::vector< double > normVector_
Definition: SiStripGain.h:117

◆ multiply()

void SiStripGain::multiply ( const SiStripApvGain apvgain,
const double &  factor,
const std::pair< std::string, std::string > &  recordLabelPair,
const SiStripDetInfo detInfo 
)

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

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

◆ operator=()

const SiStripGain& SiStripGain::operator= ( const SiStripGain )
delete

◆ printDebug()

void SiStripGain::printDebug ( std::stringstream &  ss,
const TrackerTopology trackerTopo 
) const

Definition at line 111 of file SiStripGain.cc.

References getApvGain(), getDetIds(), getRange(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, FastTimerService_cff::range, and contentValuesCheck::ss.

111  {
112  std::vector<unsigned int> detIds;
113  getDetIds(detIds);
114  std::vector<unsigned int>::const_iterator detid = detIds.begin();
115  ss << "Number of detids " << detIds.size() << std::endl;
116 
117  for (; detid != detIds.end(); ++detid) {
119  int apv = 0;
120  for (int it = 0; it < range.second - range.first; ++it) {
121  ss << "detid " << *detid << " \t"
122  << " apv " << apv++ << " \t" << getApvGain(it, range) << " \t" << std::endl;
123  }
124  }
125 }
const SiStripApvGain::Range getRange(uint32_t detID) const
Definition: SiStripGain.h:75
static float getApvGain(const uint16_t &apv, const SiStripApvGain::Range &range)
Definition: SiStripGain.h:80
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:102

◆ printSummary()

void SiStripGain::printSummary ( std::stringstream &  ss,
const TrackerTopology trackerTopo 
) const

Definition at line 127 of file SiStripGain.cc.

References getApvGain(), getDetIds(), getRange(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, FastTimerService_cff::range, and contentValuesCheck::ss.

127  {
128  SiStripDetSummary summaryGain{trackerTopo};
129 
130  std::vector<unsigned int> detIds;
131  getDetIds(detIds);
132  std::vector<uint32_t>::const_iterator detid = detIds.begin();
133  for (; detid != detIds.end(); ++detid) {
135  for (int it = 0; it < range.second - range.first; ++it) {
136  summaryGain.add(*detid, getApvGain(it, range));
137  }
138  }
139  ss << "Summary of gain values:" << std::endl;
140  summaryGain.print(ss, true);
141 }
const SiStripApvGain::Range getRange(uint32_t detID) const
Definition: SiStripGain.h:75
static float getApvGain(const uint16_t &apv, const SiStripApvGain::Range &range)
Definition: SiStripGain.h:80
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:102

Member Data Documentation

◆ apvgain_

const SiStripApvGain* SiStripGain::apvgain_
private

Definition at line 118 of file SiStripGain.h.

Referenced by fillNewGain(), getDetIds(), getRange(), getRangeByPos(), and multiply().

◆ apvgainAutoPtr_

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

Definition at line 119 of file SiStripGain.h.

Referenced by fillNewGain().

◆ apvgainVector_

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

Definition at line 116 of file SiStripGain.h.

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

◆ normVector_

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

Definition at line 117 of file SiStripGain.h.

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

◆ recordLabelPair_

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

Definition at line 120 of file SiStripGain.h.

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