Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:51:38

0001 #ifndef SiStripApvGain_h
0002 #define SiStripApvGain_h
0003 
0004 #include "CondFormats/Serialization/interface/Serializable.h"
0005 
0006 #include <vector>
0007 #include <map>
0008 #include <iostream>
0009 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0010 #include <cstdint>
0011 
0012 class TrackerTopology;
0013 
0014 /**
0015  * Stores the information of the gain for each apv using four vectors <br>
0016  * A vector<unsigned int> (v_detids) stores the detId. <br>
0017  * A vector<float> (v_gains) stores the value of the gain (more than one per detId). <br>
0018  * Two vector<unsigned int> (v_ibegin and v_iend) store the correspondence of the v_detids
0019  * and the ranges of values in v_gain. <br>
0020  *
0021  * The printSummary method uses SiStripDetSummary. See description therein. <br>
0022  * The printDebug method prints the gain value for every apv of every detId. <br>
0023  */
0024 
0025 class SiStripApvGain {
0026 public:
0027   typedef std::vector<float>::const_iterator ContainerIterator;
0028   typedef std::pair<ContainerIterator, ContainerIterator> Range;
0029   typedef std::vector<unsigned int> Registry;
0030   typedef Registry::iterator RegistryIterator;
0031   typedef Registry::const_iterator RegistryConstIterator;
0032   typedef std::vector<float> InputVector;
0033 
0034   struct RegistryPointers {
0035     RegistryConstIterator detid_begin;
0036     RegistryConstIterator detid_end;
0037     RegistryConstIterator ibegin_begin;
0038     RegistryConstIterator ibegin_end;
0039     RegistryConstIterator iend_begin;
0040     RegistryConstIterator iend_end;
0041     ContainerIterator v_begin;
0042     ContainerIterator v_end;
0043 
0044     ContainerIterator getFirstElement(RegistryConstIterator& idet) {
0045       return v_begin + *(ibegin_begin + (idet - detid_begin));
0046     }
0047     ContainerIterator getLastElement(RegistryConstIterator& idet) {
0048       return v_begin + *(iend_begin + (idet - detid_begin));
0049     }
0050   };
0051 
0052   SiStripApvGain() {}
0053   ~SiStripApvGain() {}
0054 
0055   RegistryPointers getRegistryPointers() const {
0056     RegistryPointers p;
0057     p.detid_begin = v_detids.begin();
0058     p.detid_end = v_detids.end();
0059     p.ibegin_begin = v_ibegin.begin();
0060     p.ibegin_end = v_ibegin.end();
0061     p.iend_begin = v_iend.begin();
0062     p.iend_end = v_iend.end();
0063     p.v_begin = v_gains.begin();
0064     p.v_end = v_gains.end();
0065 
0066     return p;
0067   }
0068 
0069   bool put(const uint32_t& detID, Range input);
0070   const Range getRange(const uint32_t detID) const;
0071   Range getRangeByPos(unsigned short pos) const;
0072   void getDetIds(std::vector<uint32_t>& DetIds_) const;
0073 
0074 #ifdef EDM_ML_DEBUG
0075   static float getStripGain(const uint16_t& strip, const Range& range);
0076   static float getApvGain(const uint16_t& apv, const Range& range);
0077 #else
0078   static float getStripGain(uint16_t strip, const Range& range) {
0079     uint16_t apv = strip / 128;
0080     return *(range.first + apv);
0081   }
0082   static float getApvGain(uint16_t apv, const Range& range) { return *(range.first + apv); }
0083 #endif
0084 
0085   void printDebug(std::stringstream& ss, const TrackerTopology* trackerTopo) const;
0086   void printSummary(std::stringstream& ss, const TrackerTopology* trackerTopo) const;
0087 
0088 private:
0089   std::vector<float> v_gains;
0090   std::vector<unsigned int> v_detids;
0091   std::vector<unsigned int> v_ibegin;
0092   std::vector<unsigned int> v_iend;
0093 
0094   COND_SERIALIZABLE;
0095 };
0096 
0097 #endif