CMS 3D CMS Logo

CaloSamples.h
Go to the documentation of this file.
1 #ifndef CALOSAMPLES_H
2 #define CALOSAMPLES_H 1
3 
5 #include <ostream>
6 #include <vector>
7 
14 class CaloSamples {
15 public:
16  CaloSamples();
17  explicit CaloSamples(const DetId &id, int size);
18  explicit CaloSamples(const DetId &id, int size, int preciseSize);
19 
21  DetId id() const { return id_; }
22 
24  int size() const { return size_; }
26  double &operator[](int i) { return data_[i]; }
28  double operator[](int i) const { return data_[i]; }
29 
31  float &preciseAtMod(int i) { return preciseData_[i]; }
33  float preciseAt(int i) const { return preciseData_[i]; }
34 
36  int presamples() const { return presamples_; }
38  void setPresamples(int pre);
39 
41  CaloSamples &scale(double value);
43  CaloSamples &operator*=(double value) { return scale(value); }
44 
46  CaloSamples &operator+=(double value);
48 
50  // between values
51  CaloSamples &offsetTime(double offset);
52 
53  void setDetId(DetId detId) { id_ = detId; }
54 
55  void setSize(unsigned int size) {
56  size_ = size;
57  data_.resize(size, 0.);
58  }
59 
60  void setPreciseSize(unsigned int size) {
62  preciseData_.resize(preciseSize_, 0.);
63  }
64 
65  bool isBlank() const; // are the samples blank (zero?)
66 
67  void setBlank(); // keep id, presamples, size but zero out data
68 
70  int preciseSize() const {
71  if (preciseData_.empty())
72  return 0;
73  return preciseSize_;
74  }
75  int precisePresamples() const { return precisePresamples_; }
76  float preciseDeltaT() const { return deltaTprecise_; }
77 
78  void setPrecise(int precisePresamples, float deltaT) {
80  deltaTprecise_ = deltaT;
81  }
82 
83  void resetPrecise();
84 
85  // preserved for use in other packages - no longer used in this class
86  static const int MAXSAMPLES = 10;
87 
88 private:
91  std::vector<double> data_; //
93  std::vector<float> preciseData_;
95 };
96 
97 std::ostream &operator<<(std::ostream &s, const CaloSamples &samps);
98 
99 typedef std::vector<CaloSamples> CaloSamplesCollection;
100 
101 #endif
std::vector< CaloSamples > CaloSamplesCollection
Definition: CaloSamples.h:99
CaloSamples & scale(double value)
multiply each item by this value
Definition: CaloSamples.cc:35
static const int MAXSAMPLES
Definition: CaloSamples.h:86
int precisePresamples_
Definition: CaloSamples.h:94
void setSize(unsigned int size)
Definition: CaloSamples.h:55
double & operator[](int i)
mutable operator to access samples
Definition: CaloSamples.h:26
int precisePresamples() const
Definition: CaloSamples.h:75
int presamples() const
access presample information
Definition: CaloSamples.h:36
void resetPrecise()
Definition: CaloSamples.cc:31
int preciseSize() const
get the size
Definition: CaloSamples.h:70
std::vector< float > preciseData_
Definition: CaloSamples.h:93
float preciseAt(int i) const
const function to access precise samples
Definition: CaloSamples.h:33
bool isBlank() const
Definition: CaloSamples.cc:86
void setDetId(DetId detId)
Definition: CaloSamples.h:53
void setBlank()
Definition: CaloSamples.cc:95
Definition: value.py:1
float preciseDeltaT() const
Definition: CaloSamples.h:76
void setPresamples(int pre)
set presample information
Definition: CaloSamples.cc:33
std::vector< double > data_
Definition: CaloSamples.h:91
double operator[](int i) const
const operator to access samples
Definition: CaloSamples.h:28
Definition: DetId.h:17
std::ostream & operator<<(std::ostream &s, const CaloSamples &samps)
Definition: CaloSamples.cc:101
int size() const
get the size
Definition: CaloSamples.h:24
CaloSamples & offsetTime(double offset)
shift all the samples by a time, in ns, interpolating
Definition: CaloSamples.cc:69
float deltaTprecise_
Definition: CaloSamples.h:92
int presamples_
Definition: CaloSamples.h:90
float & preciseAtMod(int i)
mutable function to access precise samples
Definition: CaloSamples.h:31
void setPrecise(int precisePresamples, float deltaT)
Definition: CaloSamples.h:78
CaloSamples & operator+=(double value)
add a value to all samples
Definition: CaloSamples.cc:43
DetId id() const
get the (generic) id
Definition: CaloSamples.h:21
CaloSamples & operator*=(double value)
scale all samples
Definition: CaloSamples.h:43
void setPreciseSize(unsigned int size)
Definition: CaloSamples.h:60
int preciseSize_
Definition: CaloSamples.h:94