Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef SiStripObjects_SiStripDelay_h
0002 #define SiStripObjects_SiStripDelay_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     SiStripObjects
0006 // Class  :     SiStripDelay
0007 //
0008 /**
0009  * Author: M. De Mattia (demattia@pd.infn.it) 25/10/2010:
0010  *
0011  * Dependent record used to combine the SiStripBaseDelays and provide the
0012  * reconstruction with a single delay value. <br> When the object is built the
0013  * list of values is stored in boost::unordered_map which, for the number of
0014  * modules in the Tracker (~15000) resulted much faster (more than a factor 2)
0015  * than a std::map or a lower_bound search in a sorted vector. <br>
0016  * The base delays must be filled in together with the sign they will get in the
0017  * summation: baseDelay1*sign1 + baseDelay2*sign2 + ... <br> Pointers to the
0018  * baseDelays are stored and after the fill is complete the method "makeDelay"
0019  * must be called to build the internal map. <br>
0020  * This additional step is required such that we don't build the map anytime a
0021  * new baseDelay is inserted and we don't make checks anytime the getDelay
0022  * method is called. <br> NOTE: Even if the code does not rely on the presence
0023  * of the same detIds in all the baseDelays, this condition should be fullfilled
0024  * for consistency. The code checks only that the number of detIds is the same
0025  * in all baseDelays.
0026  */
0027 
0028 #include "CondFormats/SiStripObjects/interface/SiStripBaseDelay.h"
0029 #include <memory>
0030 #include <unordered_map>
0031 #include <vector>
0032 
0033 class SiStripDelay {
0034 public:
0035   SiStripDelay(){};
0036   virtual ~SiStripDelay(){};
0037 
0038   SiStripDelay(const SiStripDelay &) = delete;
0039   const SiStripDelay &operator=(const SiStripDelay &) = delete;
0040 
0041   inline SiStripDelay(const SiStripBaseDelay &baseDelay,
0042                       const int sumSign,
0043                       const std::pair<std::string, std::string> &recordLabelPair) {
0044     fillNewDelay(baseDelay, sumSign, recordLabelPair);
0045   }
0046 
0047   void fillNewDelay(const SiStripBaseDelay &baseDelay,
0048                     const int sumSign,
0049                     const std::pair<std::string, std::string> &recordLabelPair);
0050 
0051   /// Return the delay combining all the baseDelays
0052   float getDelay(const uint32_t detId) const;
0053 
0054   /// Builds the boost::unordered_map
0055   bool makeDelay();
0056 
0057   /// Empty all the containers
0058   void clear();
0059 
0060   /**
0061    * The second parameter allows to specify which delay to retrieve, considering
0062    * that they are in input order. NOTE that no protection is inside the method
0063    * (because we want to keep it very light) therefore it is the caller duty to
0064    * check that the index is in the correct range.
0065    */
0066   inline const SiStripBaseDelay *getBaseDelay(const uint32_t index) const { return baseDelayVector_[index]; }
0067 
0068   inline size_t getNumberOfTags() const { return baseDelayVector_.size(); }
0069   inline std::string getRcdName(const uint32_t index) const { return recordLabelPair_[index].first; }
0070   inline std::string getLabelName(const uint32_t index) const { return recordLabelPair_[index].second; }
0071   inline int getTagSign(const uint32_t index) const { return sumSignVector_[index]; }
0072 
0073   /// Prints the average value of the delays for all layers and wheels in the
0074   /// SiStripTracker
0075   void printSummary(std::stringstream &ss, const TrackerTopology *trackerTopo) const;
0076   /// Prints the delays for all the detIds
0077   void printDebug(std::stringstream &ss, const TrackerTopology *tTopo) const;
0078 
0079 private:
0080   // ---------- member data --------------------------------
0081 
0082   std::vector<const SiStripBaseDelay *> baseDelayVector_;
0083   std::vector<int> sumSignVector_;
0084   std::vector<std::pair<std::string, std::string>> recordLabelPair_;
0085   std::unordered_map<uint32_t, double> delays_;
0086 };
0087 
0088 #endif