Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 10:46:58

0001 #ifndef HcalFrontEndMap_h
0002 #define HcalFrontEndMap_h
0003 
0004 #include "CondFormats/Serialization/interface/Serializable.h"
0005 
0006 #include <set>
0007 #include <vector>
0008 #include <algorithm>
0009 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
0010 #include <atomic>
0011 #endif
0012 
0013 #include "DataFormats/DetId/interface/DetId.h"
0014 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
0015 #include "DataFormats/HcalDetId/interface/HcalFrontEndId.h"
0016 #include <cstdint>
0017 
0018 //forward declaration
0019 namespace HcalFrontEndMapAddons {
0020   class Helper;
0021 }
0022 
0023 class HcalFrontEndMap {
0024 public:
0025   class PrecisionItem {
0026   public:
0027     PrecisionItem() {
0028       mId = mRM = 0;
0029       mRBX = "";
0030     }
0031     PrecisionItem(uint32_t fId, int fRM, std::string fRBX) : mId(fId), mRM(fRM), mRBX(fRBX) {}
0032     uint32_t mId;
0033     int mRM;
0034     std::string mRBX;
0035 
0036     COND_SERIALIZABLE;
0037   };
0038 
0039   HcalFrontEndMap() {}
0040   HcalFrontEndMap(const HcalFrontEndMapAddons::Helper& helper);
0041   ~HcalFrontEndMap();
0042 
0043   // swap function
0044   void swap(HcalFrontEndMap& other);
0045   // copy-ctor
0046   HcalFrontEndMap(const HcalFrontEndMap& src);
0047   // copy assignment operator
0048   HcalFrontEndMap& operator=(const HcalFrontEndMap& rhs);
0049   // move constructor
0050 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
0051   HcalFrontEndMap(HcalFrontEndMap&& other);
0052 #endif
0053 
0054   /// brief lookup the RM associated with the given logical id
0055   //return Null item if no such mapping
0056   const int lookupRM(DetId fId) const;
0057   const int lookupRMIndex(DetId fId) const;
0058   const int maxRMIndex() const { return HcalFrontEndId::maxRmIndex; }
0059 
0060   /// brief lookup the RBX associated with the given logical id
0061   //return Null item if no such mapping
0062   const std::string lookupRBX(DetId fId) const;
0063   const int lookupRBXIndex(DetId fId) const;
0064 
0065   std::vector<DetId> allDetIds() const;
0066   std::vector<int> allRMs() const;
0067   std::vector<std::string> allRBXs() const;
0068 
0069   const PrecisionItem* findById(uint32_t fId) const;
0070 
0071   // sorting
0072   void sortById();
0073   void initialize();
0074 
0075 protected:
0076   std::vector<PrecisionItem> mPItems;
0077   std::vector<const PrecisionItem*> mPItemsById COND_TRANSIENT;
0078 
0079   COND_SERIALIZABLE;
0080 };
0081 
0082 namespace HcalFrontEndMapAddons {
0083   class LessById {
0084   public:
0085     bool operator()(const HcalFrontEndMap::PrecisionItem* a, const HcalFrontEndMap::PrecisionItem* b) const {
0086       return a->mId < b->mId;
0087     }
0088     bool operator()(const HcalFrontEndMap::PrecisionItem& a, const HcalFrontEndMap::PrecisionItem& b) const {
0089       return a.mId < b.mId;
0090     }
0091     bool equal(const HcalFrontEndMap::PrecisionItem* a, const HcalFrontEndMap::PrecisionItem* b) const {
0092       return a->mId == b->mId;
0093     }
0094     bool good(const HcalFrontEndMap::PrecisionItem& a) const { return a.mId; }
0095   };
0096   class Helper {
0097   public:
0098     Helper();
0099     /// load a new entry
0100     bool loadObject(DetId fId, int rm, std::string rbx);
0101 
0102     std::set<HcalFrontEndMap::PrecisionItem, LessById> mPItems;
0103   };
0104 }  // namespace HcalFrontEndMapAddons
0105 
0106 #endif