CMS 3D CMS Logo

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

#include <CaloSamples.h>

Public Member Functions

 CaloSamples ()
 
 CaloSamples (const DetId &id, int size)
 
 CaloSamples (const DetId &id, int size, int preciseSize)
 
DetId id () const
 get the (generic) id More...
 
bool isBlank () const
 
CaloSamplesoffsetTime (double offset)
 shift all the samples by a time, in ns, interpolating More...
 
CaloSamplesoperator*= (double value)
 scale all samples More...
 
CaloSamplesoperator+= (double value)
 add a value to all samples More...
 
CaloSamplesoperator+= (const CaloSamples &other)
 
double & operator[] (int i)
 mutable operator to access samples More...
 
double operator[] (int i) const
 const operator to access samples More...
 
float preciseAt (int i) const
 const function to access precise samples More...
 
float & preciseAtMod (int i)
 mutable function to access precise samples More...
 
float preciseDeltaT () const
 
int precisePresamples () const
 
int preciseSize () const
 get the size More...
 
int presamples () const
 access presample information More...
 
void resetPrecise ()
 
CaloSamplesscale (double value)
 multiply each item by this value More...
 
void setBlank ()
 
void setDetId (DetId detId)
 
void setPrecise (int precisePresamples, float deltaT)
 
void setPreciseSize (unsigned int size)
 
void setPresamples (int pre)
 set presample information More...
 
void setSize (unsigned int size)
 
int size () const
 get the size More...
 

Static Public Attributes

static const int MAXSAMPLES = 10
 

Private Attributes

std::vector< double > data_
 
float deltaTprecise_
 
DetId id_
 
std::vector< float > preciseData_
 
int precisePresamples_
 
int preciseSize_
 
int presamples_
 
int size_
 

Detailed Description

Class which represents the charge/voltage measurements of an event/channel with the ADC decoding performed.

Definition at line 14 of file CaloSamples.h.

Constructor & Destructor Documentation

◆ CaloSamples() [1/3]

CaloSamples::CaloSamples ( )

Definition at line 6 of file CaloSamples.cc.

References setBlank().

int precisePresamples_
Definition: CaloSamples.h:94
void setBlank()
Definition: CaloSamples.cc:109
int presamples_
Definition: CaloSamples.h:90
int preciseSize_
Definition: CaloSamples.h:94

◆ CaloSamples() [2/3]

CaloSamples::CaloSamples ( const DetId id,
int  size 
)
explicit

Definition at line 8 of file CaloSamples.cc.

References setBlank().

9  : id_(id),
10  size_(size),
11  presamples_(0),
12  data_(size_, 0.0),
13  deltaTprecise_(0.0f),
14  preciseSize_(0),
16  setBlank();
17 }
int size() const
get the size
Definition: CaloSamples.h:24
int precisePresamples_
Definition: CaloSamples.h:94
void setBlank()
Definition: CaloSamples.cc:109
double f[11][100]
std::vector< double > data_
Definition: CaloSamples.h:91
float deltaTprecise_
Definition: CaloSamples.h:92
int presamples_
Definition: CaloSamples.h:90
int preciseSize_
Definition: CaloSamples.h:94

◆ CaloSamples() [3/3]

CaloSamples::CaloSamples ( const DetId id,
int  size,
int  preciseSize 
)
explicit

Definition at line 19 of file CaloSamples.cc.

References setBlank().

20  : id_(id),
21  size_(size),
22  presamples_(0),
23  data_(size_, 0.0),
24  deltaTprecise_(0.0f),
25  preciseSize_(presize),
27  setBlank();
28 }
int size() const
get the size
Definition: CaloSamples.h:24
int precisePresamples_
Definition: CaloSamples.h:94
void setBlank()
Definition: CaloSamples.cc:109
double f[11][100]
std::vector< double > data_
Definition: CaloSamples.h:91
float deltaTprecise_
Definition: CaloSamples.h:92
int presamples_
Definition: CaloSamples.h:90
int preciseSize_
Definition: CaloSamples.h:94

Member Function Documentation

◆ id()

DetId CaloSamples::id ( ) const
inline

◆ isBlank()

bool CaloSamples::isBlank ( ) const

Definition at line 100 of file CaloSamples.cc.

References data_, MillePedeFileConverter_cfg::e, mps_fire::i, and size_.

101 {
102  for (int i(0); i != size_; ++i) {
103  if (1.e-6 < fabs(data_[i]))
104  return false;
105  }
106  return true;
107 }
std::vector< double > data_
Definition: CaloSamples.h:91

◆ offsetTime()

CaloSamples & CaloSamples::offsetTime ( double  offset)

shift all the samples by a time, in ns, interpolating

Definition at line 83 of file CaloSamples.cc.

References data, data_, f, mps_fire::i, hltrates_dqm_sourceclient-live_cfg::offset, size_, and submitPVValidationJobs::t.

83  {
84  std::vector<double> data(size_, 0.0);
85  for (int i(0); i != size_; ++i) {
86  double t = i * 25. - offset;
87  int firstbin = floor(t / 25.);
88  double f = t / 25. - firstbin;
89  int nextbin = firstbin + 1;
90  double v1 = (firstbin < 0 || firstbin >= size_) ? 0. : data_[firstbin];
91  double v2 = (nextbin < 0 || nextbin >= size_) ? 0. : data_[nextbin];
92  data[i] = (v1 * (1. - f) + v2 * f);
93  }
94  for (int i(0); i != size_; ++i) {
95  data_[i] = data[i];
96  }
97  return (*this);
98 }
double f[11][100]
std::vector< double > data_
Definition: CaloSamples.h:91
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79

◆ operator*=()

CaloSamples& CaloSamples::operator*= ( double  value)
inline

scale all samples

Definition at line 43 of file CaloSamples.h.

References scale().

43 { return scale(value); }
CaloSamples & scale(double value)
multiply each item by this value
Definition: CaloSamples.cc:35
Definition: value.py:1

◆ operator+=() [1/2]

CaloSamples & CaloSamples::operator+= ( double  value)

add a value to all samples

Definition at line 43 of file CaloSamples.cc.

References data_, deltaTprecise_, mps_fire::i, dqmiolumiharvest::j, preciseData_, and size_.

43  {
44  for (int i = 0; i < size_; i++)
45  data_[i] += value;
46  for (std::vector<float>::iterator j = preciseData_.begin(); j != preciseData_.end(); ++j)
47  (*j) += value * deltaTprecise_ / 25.0; // note that the scale is conserved!
48  return (*this);
49 }
std::vector< float > preciseData_
Definition: CaloSamples.h:93
Definition: value.py:1
std::vector< double > data_
Definition: CaloSamples.h:91
float deltaTprecise_
Definition: CaloSamples.h:92

◆ operator+=() [2/2]

CaloSamples & CaloSamples::operator+= ( const CaloSamples other)

Definition at line 51 of file CaloSamples.cc.

References data_, deltaTprecise_, mps_fire::i, trackingPlots::other, preciseData_, preciseSize_, presamples_, resetPrecise(), and size_.

51  {
52  bool addHighFidelityPreMix = false;
53  if (size_ != other.size_ || presamples_ != other.presamples_ || preciseSize_ != other.preciseSize_) {
54  if (presamples_ == other.presamples_ && preciseSize_ == other.size_) {
55  addHighFidelityPreMix = true;
56  } else {
57  edm::LogError("CaloHitResponse") << "Mismatched calo signals ";
58  }
59  }
60  if (addHighFidelityPreMix) {
61  int sampleBin(0);
62  for (int i = 0; i < preciseSize_; ++i) {
63  sampleBin = floor(i * deltaTprecise_ / 25);
64  data_[sampleBin] += other.data_[i];
65  preciseData_[i] += other.data_[i];
66  }
67  } else {
68  int i;
69  for (i = 0; i < size_; ++i) {
70  data_[i] += other.data_[i];
71  }
72  if (preciseData_.empty() && !other.preciseData_.empty())
73  resetPrecise();
74  if (!other.preciseData_.empty()) {
75  for (i = 0; i < preciseSize_; ++i) {
76  preciseData_[i] += other.preciseData_[i];
77  }
78  }
79  }
80  return *this;
81 }
void resetPrecise()
Definition: CaloSamples.cc:31
Log< level::Error, false > LogError
std::vector< float > preciseData_
Definition: CaloSamples.h:93
std::vector< double > data_
Definition: CaloSamples.h:91
float deltaTprecise_
Definition: CaloSamples.h:92
int presamples_
Definition: CaloSamples.h:90
int preciseSize_
Definition: CaloSamples.h:94

◆ operator[]() [1/2]

double& CaloSamples::operator[] ( int  i)
inline

mutable operator to access samples

Definition at line 26 of file CaloSamples.h.

References data_, and mps_fire::i.

26 { return data_[i]; }
std::vector< double > data_
Definition: CaloSamples.h:91

◆ operator[]() [2/2]

double CaloSamples::operator[] ( int  i) const
inline

const operator to access samples

Definition at line 28 of file CaloSamples.h.

References data_, and mps_fire::i.

28 { return data_[i]; }
std::vector< double > data_
Definition: CaloSamples.h:91

◆ preciseAt()

float CaloSamples::preciseAt ( int  i) const
inline

const function to access precise samples

Definition at line 33 of file CaloSamples.h.

References mps_fire::i, and preciseData_.

Referenced by HcalTDC::leadingEdgeTDC().

33 { return preciseData_[i]; }
std::vector< float > preciseData_
Definition: CaloSamples.h:93

◆ preciseAtMod()

float& CaloSamples::preciseAtMod ( int  i)
inline

mutable function to access precise samples

Definition at line 31 of file CaloSamples.h.

References mps_fire::i, and preciseData_.

Referenced by HcalSiPMHitResponse::makeSiPMSignal().

31 { return preciseData_[i]; }
std::vector< float > preciseData_
Definition: CaloSamples.h:93

◆ preciseDeltaT()

float CaloSamples::preciseDeltaT ( ) const
inline

Definition at line 76 of file CaloSamples.h.

References deltaTprecise_.

76 { return deltaTprecise_; }
float deltaTprecise_
Definition: CaloSamples.h:92

◆ precisePresamples()

int CaloSamples::precisePresamples ( ) const
inline

Definition at line 75 of file CaloSamples.h.

References precisePresamples_.

Referenced by setPrecise().

75 { return precisePresamples_; }
int precisePresamples_
Definition: CaloSamples.h:94

◆ preciseSize()

int CaloSamples::preciseSize ( ) const
inline

get the size

Definition at line 70 of file CaloSamples.h.

References preciseData_, and preciseSize_.

Referenced by HcalTDC::leadingEdgeTDC(), and HcalSiPMHitResponse::makeSiPMSignal().

70  {
71  if (preciseData_.empty())
72  return 0;
73  return preciseSize_;
74  }
std::vector< float > preciseData_
Definition: CaloSamples.h:93
int preciseSize_
Definition: CaloSamples.h:94

◆ presamples()

int CaloSamples::presamples ( ) const
inline

◆ resetPrecise()

void CaloSamples::resetPrecise ( )

Definition at line 31 of file CaloSamples.cc.

References preciseData_, and preciseSize_.

Referenced by HcalSiPMHitResponse::makeSiPMSignal(), and operator+=().

31 { preciseData_.resize(preciseSize_, 0); }
std::vector< float > preciseData_
Definition: CaloSamples.h:93
int preciseSize_
Definition: CaloSamples.h:94

◆ scale()

CaloSamples & CaloSamples::scale ( double  value)

multiply each item by this value

Definition at line 35 of file CaloSamples.cc.

References data_, mps_fire::i, dqmiolumiharvest::j, preciseData_, size_, and relativeConstraints::value.

Referenced by operator*=().

35  {
36  for (int i = 0; i < size_; i++)
37  data_[i] *= value;
38  for (std::vector<float>::iterator j = preciseData_.begin(); j != preciseData_.end(); ++j)
39  (*j) *= value;
40  return (*this);
41 }
std::vector< float > preciseData_
Definition: CaloSamples.h:93
Definition: value.py:1
std::vector< double > data_
Definition: CaloSamples.h:91

◆ setBlank()

void CaloSamples::setBlank ( )

Definition at line 109 of file CaloSamples.cc.

References data_, ntuplemaker::fill, and preciseData_.

Referenced by CaloSamples().

110 {
111  std::fill(data_.begin(), data_.end(), (double)0.0);
112  std::fill(preciseData_.begin(), preciseData_.end(), (double)0.0);
113 }
std::vector< float > preciseData_
Definition: CaloSamples.h:93
std::vector< double > data_
Definition: CaloSamples.h:91

◆ setDetId()

void CaloSamples::setDetId ( DetId  detId)
inline

Definition at line 53 of file CaloSamples.h.

References id_.

53 { id_ = detId; }

◆ setPrecise()

void CaloSamples::setPrecise ( int  precisePresamples,
float  deltaT 
)
inline

Definition at line 78 of file CaloSamples.h.

References deltaTprecise_, precisePresamples(), and precisePresamples_.

78  {
80  deltaTprecise_ = deltaT;
81  }
int precisePresamples_
Definition: CaloSamples.h:94
int precisePresamples() const
Definition: CaloSamples.h:75
float deltaTprecise_
Definition: CaloSamples.h:92

◆ setPreciseSize()

void CaloSamples::setPreciseSize ( unsigned int  size)
inline

Definition at line 60 of file CaloSamples.h.

References preciseData_, preciseSize_, and size().

Referenced by HcalSiPMHitResponse::finalizeHits().

60  {
62  preciseData_.resize(preciseSize_, 0.);
63  }
int size() const
get the size
Definition: CaloSamples.h:24
std::vector< float > preciseData_
Definition: CaloSamples.h:93
int preciseSize_
Definition: CaloSamples.h:94

◆ setPresamples()

void CaloSamples::setPresamples ( int  pre)

set presample information

Definition at line 33 of file CaloSamples.cc.

References presamples_.

Referenced by CastorNominalCoder::adc2fC(), HcalNominalCoder::adc2fC(), CastorCoderDb::adc2fC_(), and HcalCoderDb::adc2fC_().

33 { presamples_ = pre; }
int presamples_
Definition: CaloSamples.h:90

◆ setSize()

void CaloSamples::setSize ( unsigned int  size)
inline

Definition at line 55 of file CaloSamples.h.

References data_, size(), and size_.

55  {
56  size_ = size;
57  data_.resize(size, 0.);
58  }
int size() const
get the size
Definition: CaloSamples.h:24
std::vector< double > data_
Definition: CaloSamples.h:91

◆ size()

int CaloSamples::size ( void  ) const
inline

Member Data Documentation

◆ data_

std::vector<double> CaloSamples::data_
private

Definition at line 91 of file CaloSamples.h.

Referenced by isBlank(), offsetTime(), operator+=(), operator[](), scale(), setBlank(), and setSize().

◆ deltaTprecise_

float CaloSamples::deltaTprecise_
private

Definition at line 92 of file CaloSamples.h.

Referenced by operator+=(), preciseDeltaT(), and setPrecise().

◆ id_

DetId CaloSamples::id_
private

Definition at line 89 of file CaloSamples.h.

Referenced by id(), and setDetId().

◆ MAXSAMPLES

const int CaloSamples::MAXSAMPLES = 10
static

◆ preciseData_

std::vector<float> CaloSamples::preciseData_
private

◆ precisePresamples_

int CaloSamples::precisePresamples_
private

Definition at line 94 of file CaloSamples.h.

Referenced by precisePresamples(), and setPrecise().

◆ preciseSize_

int CaloSamples::preciseSize_
private

Definition at line 94 of file CaloSamples.h.

Referenced by operator+=(), preciseSize(), resetPrecise(), and setPreciseSize().

◆ presamples_

int CaloSamples::presamples_
private

Definition at line 90 of file CaloSamples.h.

Referenced by operator+=(), presamples(), and setPresamples().

◆ size_

int CaloSamples::size_
private

Definition at line 90 of file CaloSamples.h.

Referenced by isBlank(), offsetTime(), operator+=(), scale(), setSize(), and size().