Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:58:11

0001 #ifndef CALOSAMPLES_H
0002 #define CALOSAMPLES_H 1
0003 
0004 #include "DataFormats/DetId/interface/DetId.h"
0005 #include <ostream>
0006 #include <vector>
0007 
0008 /** \class CaloSamples
0009 
0010 Class which represents the charge/voltage measurements of an event/channel
0011 with the ADC decoding performed.
0012 
0013 */
0014 class CaloSamples {
0015 public:
0016   CaloSamples();
0017   explicit CaloSamples(const DetId &id, int size);
0018   explicit CaloSamples(const DetId &id, int size, int preciseSize);
0019 
0020   /// get the (generic) id
0021   DetId id() const { return id_; }
0022 
0023   /// get the size
0024   int size() const { return size_; }
0025   /// mutable operator to access samples
0026   double &operator[](int i) { return data_[i]; }
0027   /// const operator to access samples
0028   double operator[](int i) const { return data_[i]; }
0029 
0030   /// mutable function to access precise samples
0031   float &preciseAtMod(int i) { return preciseData_[i]; }
0032   /// const function to access precise samples
0033   float preciseAt(int i) const { return preciseData_[i]; }
0034 
0035   /// access presample information
0036   int presamples() const { return presamples_; }
0037   /// set presample information
0038   void setPresamples(int pre);
0039 
0040   /// multiply each item by this value
0041   CaloSamples &scale(double value);
0042   /// scale all samples
0043   CaloSamples &operator*=(double value) { return scale(value); }
0044 
0045   /// add a value to all samples
0046   CaloSamples &operator+=(double value);
0047   CaloSamples &operator+=(const CaloSamples &other);
0048 
0049   /// shift all the samples by a time, in ns, interpolating
0050   // between values
0051   CaloSamples &offsetTime(double offset);
0052 
0053   void setDetId(DetId detId) { id_ = detId; }
0054 
0055   void setSize(unsigned int size) {
0056     size_ = size;
0057     data_.resize(size, 0.);
0058   }
0059 
0060   void setPreciseSize(unsigned int size) {
0061     preciseSize_ = size;
0062     preciseData_.resize(preciseSize_, 0.);
0063   }
0064 
0065   bool isBlank() const;  // are the samples blank (zero?)
0066 
0067   void setBlank();  // keep id, presamples, size but zero out data
0068 
0069   /// get the size
0070   int preciseSize() const {
0071     if (preciseData_.empty())
0072       return 0;
0073     return preciseSize_;
0074   }
0075   int precisePresamples() const { return precisePresamples_; }
0076   float preciseDeltaT() const { return deltaTprecise_; }
0077 
0078   void setPrecise(int precisePresamples, float deltaT) {
0079     precisePresamples_ = precisePresamples;
0080     deltaTprecise_ = deltaT;
0081   }
0082 
0083   void resetPrecise();
0084 
0085   // preserved for use in other packages - no longer used in this class
0086   static const int MAXSAMPLES = 10;
0087 
0088 private:
0089   DetId id_;
0090   int size_, presamples_;
0091   std::vector<double> data_;  //
0092   float deltaTprecise_;
0093   std::vector<float> preciseData_;
0094   int preciseSize_, precisePresamples_;
0095 };
0096 
0097 std::ostream &operator<<(std::ostream &s, const CaloSamples &samps);
0098 
0099 typedef std::vector<CaloSamples> CaloSamplesCollection;
0100 
0101 #endif