Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef SiStripObjects_SiStripGain_h
0002 #define SiStripObjects_SiStripGain_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     SiStripObjects
0006 // Class  :     SiStripGain
0007 //
0008 /**\class SiStripGain SiStripGain.h
0009  * CalibFormats/SiStripObjects/interface/SiStripGain.h
0010  *
0011  * Description: give detector view for the cabling classes
0012  *
0013  * Usage:
0014  *  <usage>
0015  *
0016  * Original Author:  gbruno
0017  *         Created:  Wed Mar 22 12:24:20 CET 2006
0018  *
0019  * Modifications by M. De Mattia (demattia@pd.infn.it) on 11/11/2009:
0020  * It now holds a std::vector of pointers to ApvGain and a std::vector of
0021  * corresponding normalization factors. <br> It returns the product of all the
0022  * Gain/norm ratios. <br> The multiply method allows to input additional gain
0023  * records. <br> ATTENTION: the code assumes that the second tag has at least
0024  * the same DetIds that the first tag and only the DetIds present in the first
0025  * tag will be used. <br> <br> There are two set of methods to access the gain
0026  * value. The first one returns the products of all ApvGain/norm. The second set
0027  * of methods take an additional integer paramter and return the corresponding
0028  * ApvGain (without normalization). Note that no check is done inside these
0029  * methods to see if the ApvGain really exists. It is responsibility of the user
0030  * to not pass an index value that exceeds the number of ApvGains. <br> The
0031  * normalization factors for each of the stored ApvGains are also accessible
0032  * passing the corresponding index. <br> Additional method are provided to get
0033  * the number of ApvGains used to build this object, the names of the records
0034  * that stored those ApvGains and the labels (they can be used to go back to the
0035  * tags looking in the cfg).
0036  */
0037 
0038 #include "CondFormats/SiStripObjects/interface/SiStripApvGain.h"
0039 #include <memory>
0040 #include <vector>
0041 
0042 class TrackerTopology;
0043 class SiStripDetInfo;
0044 
0045 class SiStripGain {
0046 public:
0047   SiStripGain() {}
0048   SiStripGain(const SiStripGain &) = delete;
0049   const SiStripGain &operator=(const SiStripGain &) = delete;
0050 
0051   /// Kept for compatibility
0052   inline SiStripGain(const SiStripApvGain &apvgain, const double &factor, const SiStripDetInfo &detInfo)
0053       : apvgain_(nullptr) {
0054     multiply(apvgain, factor, std::make_pair("", ""), detInfo);
0055   }
0056 
0057   inline SiStripGain(const SiStripApvGain &apvgain,
0058                      const double &factor,
0059                      const std::pair<std::string, std::string> &recordLabelPair,
0060                      const SiStripDetInfo &detInfo)
0061       : apvgain_(nullptr) {
0062     multiply(apvgain, factor, recordLabelPair, detInfo);
0063   }
0064 
0065   /// Used to input additional gain values that will be multiplied to the first
0066   /// one
0067   void multiply(const SiStripApvGain &apvgain,
0068                 const double &factor,
0069                 const std::pair<std::string, std::string> &recordLabelPair,
0070                 const SiStripDetInfo &detInfo);
0071 
0072   // getters
0073   // For the product of all apvGains
0074   // -------------------------------
0075   const SiStripApvGain::Range getRange(uint32_t detID) const { return apvgain_->getRange(detID); }
0076   SiStripApvGain::Range getRangeByPos(unsigned short pos) const { return apvgain_->getRangeByPos(pos); }
0077   static float getStripGain(const uint16_t &strip, const SiStripApvGain::Range &range) {
0078     return SiStripApvGain::getStripGain(strip, range);
0079   }
0080   static float getApvGain(const uint16_t &apv, const SiStripApvGain::Range &range) {
0081     return SiStripApvGain::getApvGain(apv, range);
0082   }
0083 
0084   // For a specific apvGain
0085   // ----------------------
0086   /**
0087    * The second parameter allows to specify which gain to retrieve, considering
0088    * that they are in input order. NOTE that no protection is inside the method
0089    * (because we want to keep it very light) therefore it is the caller duty to
0090    * check that the index is in the correct range.
0091    */
0092   const SiStripApvGain::Range getRange(const uint32_t &detID, const uint32_t index) const;
0093   float getStripGain(const uint16_t &strip, const SiStripApvGain::Range &range, const uint32_t index) const;
0094   float getApvGain(const uint16_t &apv, const SiStripApvGain::Range &range, const uint32_t index) const;
0095 
0096   /// ATTENTION: we assume the detIds are the same as those from the first gain
0097   void getDetIds(std::vector<uint32_t> &DetIds_) const;
0098 
0099   inline size_t getNumberOfTags() const { return apvgainVector_.size(); }
0100   inline std::string getRcdName(const uint32_t index) const { return recordLabelPair_[index].first; }
0101   inline std::string getLabelName(const uint32_t index) const { return recordLabelPair_[index].second; }
0102   inline double getTagNorm(const uint32_t index) const { return normVector_[index]; }
0103 
0104   void printDebug(std::stringstream &ss, const TrackerTopology *trackerTopo) const;
0105   void printSummary(std::stringstream &ss, const TrackerTopology *trackerTopo) const;
0106 
0107 private:
0108   void fillNewGain(const SiStripApvGain *apvgain,
0109                    const double &factor,
0110                    SiStripDetInfo const &detInfo,
0111                    const SiStripApvGain *apvgain2 = nullptr,
0112                    const double &factor2 = 1.);
0113 
0114   // ---------- member data --------------------------------
0115 
0116   std::vector<const SiStripApvGain *> apvgainVector_;
0117   std::vector<double> normVector_;
0118   const SiStripApvGain *apvgain_;
0119   std::unique_ptr<SiStripApvGain> apvgainAutoPtr_;
0120   std::vector<std::pair<std::string, std::string>> recordLabelPair_;
0121 };
0122 
0123 #endif