CMS 3D CMS Logo

CaloSamples.h
Go to the documentation of this file.
1 #ifndef CALOSAMPLES_H
2 #define CALOSAMPLES_H 1
3 
4 #include <ostream>
5 #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 ) { size_ = size ; data_.resize(size,0.); }
56 
57  void setPreciseSize( unsigned int size ) { preciseSize_ = size ; preciseData_.resize(preciseSize_,0.); }
58 
59  bool isBlank() const ; // are the samples blank (zero?)
60 
61  void setBlank() ; // keep id, presamples, size but zero out data
62 
64  int preciseSize() const { if ( preciseData_.empty() ) return 0; return preciseSize_; }
65  int precisePresamples() const { return precisePresamples_; }
66  float preciseDeltaT() const { return deltaTprecise_; }
67 
68  void setPrecise( int precisePresamples, float deltaT ) {
70  deltaTprecise_=deltaT;
71  }
72 
73  void resetPrecise();
74 
75  //preserved for use in other packages - no longer used in this class
76  static const int MAXSAMPLES=10;
77 private:
80  std::vector<double> data_; //
82  std::vector<float> preciseData_;
84 };
85 
86 std::ostream& operator<<(std::ostream& s, const CaloSamples& samps);
87 
88 typedef std::vector<CaloSamples> CaloSamplesCollection;
89 
90 #endif
std::vector< CaloSamples > CaloSamplesCollection
Definition: CaloSamples.h:88
CaloSamples & scale(double value)
multiply each item by this value
Definition: CaloSamples.cc:35
static const int MAXSAMPLES
Definition: CaloSamples.h:76
int precisePresamples_
Definition: CaloSamples.h:83
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:65
int presamples() const
access presample information
Definition: CaloSamples.h:36
void resetPrecise()
Definition: CaloSamples.cc:27
int preciseSize() const
get the size
Definition: CaloSamples.h:64
std::vector< float > preciseData_
Definition: CaloSamples.h:82
float preciseAt(int i) const
const function to access precise samples
Definition: CaloSamples.h:33
bool isBlank() const
Definition: CaloSamples.cc:90
void setDetId(DetId detId)
Definition: CaloSamples.h:53
void setBlank()
Definition: CaloSamples.cc:100
Definition: value.py:1
float preciseDeltaT() const
Definition: CaloSamples.h:66
void setPresamples(int pre)
set presample information
Definition: CaloSamples.cc:31
std::vector< double > data_
Definition: CaloSamples.h:80
double operator[](int i) const
const operator to access samples
Definition: CaloSamples.h:28
Definition: DetId.h:18
std::ostream & operator<<(std::ostream &s, const CaloSamples &samps)
Definition: CaloSamples.cc:106
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:81
int presamples_
Definition: CaloSamples.h:79
float & preciseAtMod(int i)
mutable function to access precise samples
Definition: CaloSamples.h:31
void setPrecise(int precisePresamples, float deltaT)
Definition: CaloSamples.h:68
CaloSamples & operator+=(double value)
add a value to all samples
Definition: CaloSamples.cc:42
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:57
int preciseSize_
Definition: CaloSamples.h:83