Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:24:39

0001 #ifndef CSCRecHitD_CSCStripData_h
0002 #define CSCRecHitD_CSCStripData_h
0003 
0004 /** \class CSCStripData
0005  *
0006  * Hold strip data while building strip hits in CSCHitFromStripOnly.
0007  *
0008  */
0009 
0010 #include <algorithm>
0011 #include <functional>
0012 #include <vector>
0013 #include <iosfwd>
0014 
0015 class CSCStripData {
0016 public:
0017   /** The default ctor initializes all elements of thePulseHeightMap for
0018    * which explicit digis do not exist.
0019    * Use sentinel value for istrip and tmax. 
0020    *
0021    * Note that _raw_ pulseheights are int.
0022    */
0023   CSCStripData() : phmax_(0.f), tmax_(-1), phRaw_(ntbins_), ph_(ntbins_) {}
0024   CSCStripData(float phmax, int tmax, const std::vector<int>& phRaw, const std::vector<float>& ph)
0025       : phmax_(phmax), tmax_(tmax), phRaw_(phRaw), ph_(ph) {}
0026 
0027   CSCStripData(float phmax, int tmax, std::vector<int>&& phRaw, std::vector<float>&& ph)
0028       : phmax_(phmax), tmax_(tmax), phRaw_(std::move(phRaw)), ph_(std::move(ph)) {}
0029 
0030   void reset() {
0031     phmax_ = 0.f;
0032     tmax_ = -1;
0033   }
0034   bool valid() const { return tmax_ >= 0; }
0035 
0036   /// maximum pulseheight in one SCA time bin
0037   float phmax() const { return phmax_; }
0038   /// the time bin in which the maximum pulseheight occurs (counts from 0)
0039   int tmax() const { return tmax_; }
0040 
0041   /**
0042    * pulseheights in the 8 SCA time bins, after pedestal subtraction and (possibly) gain-correction
0043    */
0044   const std::vector<float>& ph() const { return ph_; }
0045 
0046   /**
0047    * pulseheights in the 8 SCA time bins, after pedestal subtraction but without gain-correction
0048    */
0049   const std::vector<int>& phRaw() const { return phRaw_; }
0050 
0051   /**
0052    * scale pulseheights by argument, but leave raw pulseheights unchanged.
0053    */
0054   void operator*=(float factor) {
0055     // scale all elements of ph by 'factor'. Leaves phRaw_ unchanged.
0056     std::transform(ph_.begin(), ph_.end(), ph_.begin(), [&factor](auto c) { return c * factor; });
0057     phmax_ *= factor;
0058   }
0059 
0060   bool operator<(const CSCStripData& data) const { return phmax_ < data.phmax_; }
0061 
0062   /// for debugging purposes
0063   friend std::ostream& operator<<(std::ostream&, const CSCStripData&);
0064 
0065   // private:
0066 
0067   static constexpr int ntbins_ = 8;  //@@ Number of time bins & hence length of ph vectors
0068   float phmax_;
0069   int tmax_;
0070   std::vector<int> phRaw_;
0071   std::vector<float> ph_;
0072 };
0073 
0074 #endif