CMS 3D CMS Logo

CaloSamples.cc
Go to the documentation of this file.
3 #include <cmath>
4 #include <iostream>
5 
6 CaloSamples::CaloSamples() : id_(), size_(0), presamples_(0), preciseSize_(0), precisePresamples_(0) { setBlank(); }
7 
9  : id_(id),
10  size_(size),
11  presamples_(0),
12  data_(size_, 0.0),
13  deltaTprecise_(0.0f),
14  preciseSize_(0),
15  precisePresamples_(0) {
16  setBlank();
17 }
18 
19 CaloSamples::CaloSamples(const DetId &id, int size, int presize)
20  : id_(id),
21  size_(size),
22  presamples_(0),
23  data_(size_, 0.0),
24  deltaTprecise_(0.0f),
25  preciseSize_(presize),
26  precisePresamples_(0) {
27  setBlank();
28 }
29 
30 // add option to set these later.
32 
33 void CaloSamples::setPresamples(int pre) { presamples_ = pre; }
34 
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 }
42 
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 }
50 
52  if (size_ != other.size_ || presamples_ != other.presamples_ || preciseSize_ != other.preciseSize_) {
53  edm::LogError("CaloHitResponse") << "Mismatched calo signals ";
54  }
55  int i;
56  for (i = 0; i < size_; ++i) {
57  data_[i] += other.data_[i];
58  }
59  if (preciseData_.empty() && !other.preciseData_.empty())
60  resetPrecise();
61  if (!other.preciseData_.empty()) {
62  for (i = 0; i < preciseSize_; ++i) {
63  preciseData_[i] += other.preciseData_[i];
64  }
65  }
66  return *this;
67 }
68 
70  std::vector<double> data(size_, 0.0);
71  for (int i(0); i != size_; ++i) {
72  double t = i * 25. - offset;
73  int firstbin = floor(t / 25.);
74  double f = t / 25. - firstbin;
75  int nextbin = firstbin + 1;
76  double v1 = (firstbin < 0 || firstbin >= size_) ? 0. : data_[firstbin];
77  double v2 = (nextbin < 0 || nextbin >= size_) ? 0. : data_[nextbin];
78  data[i] = (v1 * (1. - f) + v2 * f);
79  }
80  for (int i(0); i != size_; ++i) {
81  data_[i] = data[i];
82  }
83  return (*this);
84 }
85 
86 bool CaloSamples::isBlank() const // are the samples blank (zero?)
87 {
88  for (int i(0); i != size_; ++i) {
89  if (1.e-6 < fabs(data_[i]))
90  return false;
91  }
92  return true;
93 }
94 
95 void CaloSamples::setBlank() // keep id, presamples, size but zero out data
96 {
97  std::fill(data_.begin(), data_.end(), (double)0.0);
98  std::fill(preciseData_.begin(), preciseData_.end(), (double)0.0);
99 }
100 
101 std::ostream &operator<<(std::ostream &s, const CaloSamples &samples) {
102  s << "DetId " << samples.id();
103  // print out every so many precise samples
104  float preciseStep = samples.preciseSize() / samples.size();
105  s << ", " << samples.size() << " samples";
106  if (preciseStep > 0)
107  s << ", " << samples.preciseSize() << " preciseSamples"
108  << ", " << preciseStep << " preciseStep";
109  s << '\n';
110  for (int i = 0; i < samples.size(); i++) {
111  s << i << ":" << samples[i] << " precise:";
112  int precise_start(i * preciseStep), precise_end(precise_start + preciseStep);
113  for (int j(precise_start); ((j < precise_end) && (j < samples.preciseSize())); ++j)
114  s << " " << samples.preciseAt(j);
115  s << std::endl;
116  }
117  return s;
118 }
mps_fire.i
i
Definition: mps_fire.py:355
MessageLogger.h
operator<<
std::ostream & operator<<(std::ostream &s, const CaloSamples &samples)
Definition: CaloSamples.cc:101
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
CaloSamples.h
CaloSamples::scale
CaloSamples & scale(double value)
multiply each item by this value
Definition: CaloSamples.cc:35
watchdog.const
const
Definition: watchdog.py:83
CaloSamples::size_
int size_
Definition: CaloSamples.h:90
EgammaValidation_cff.samples
samples
Definition: EgammaValidation_cff.py:19
DetId
Definition: DetId.h:17
alignCSCRings.s
s
Definition: alignCSCRings.py:92
CaloSamples::preciseData_
std::vector< float > preciseData_
Definition: CaloSamples.h:93
CaloSamples::CaloSamples
CaloSamples()
Definition: CaloSamples.cc:6
CaloSamples::resetPrecise
void resetPrecise()
Definition: CaloSamples.cc:31
trackingPlots.other
other
Definition: trackingPlots.py:1465
OrderedSet.t
t
Definition: OrderedSet.py:90
CaloSamples::setBlank
void setBlank()
Definition: CaloSamples.cc:95
CaloSamples::setPresamples
void setPresamples(int pre)
set presample information
Definition: CaloSamples.cc:33
ntuplemaker.fill
fill
Definition: ntuplemaker.py:304
CaloSamples::data_
std::vector< double > data_
Definition: CaloSamples.h:91
edm::LogError
Definition: MessageLogger.h:183
value
Definition: value.py:1
CaloSamples
Definition: CaloSamples.h:14
CaloSamples::deltaTprecise_
float deltaTprecise_
Definition: CaloSamples.h:92
CaloSamples::presamples_
int presamples_
Definition: CaloSamples.h:90
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
relativeConstraints.value
value
Definition: relativeConstraints.py:53
CaloSamples::operator+=
CaloSamples & operator+=(double value)
add a value to all samples
Definition: CaloSamples.cc:43
CaloSamples::preciseSize_
int preciseSize_
Definition: CaloSamples.h:94
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
CaloSamples::offsetTime
CaloSamples & offsetTime(double offset)
shift all the samples by a time, in ns, interpolating
Definition: CaloSamples.cc:69
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
CaloSamples::isBlank
bool isBlank() const
Definition: CaloSamples.cc:86
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:78
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37