Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:01:57

0001 #ifndef CastorElectronicsMap_h
0002 #define CastorElectronicsMap_h
0003 
0004 /** 
0005 \class CastorElectronicsMap
0006 \author Fedor Ratnikov (UMd)
0007 POOL object to store map between detector ID, electronics ID and trigger ID
0008 $Author: ratnikov 
0009 $Date: 2007/12/14 13:31:21 $
0010 $Revision: 1.17 $
0011 Modified for CASTOR by L. Mundim
0012 */
0013 
0014 #include "CondFormats/Serialization/interface/Serializable.h"
0015 
0016 #include <vector>
0017 #include <algorithm>
0018 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
0019 #include <atomic>
0020 #endif
0021 
0022 #include "DataFormats/DetId/interface/DetId.h"
0023 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
0024 #include "DataFormats/HcalDetId/interface/HcalCalibDetId.h"
0025 #include "DataFormats/HcalDetId/interface/HcalTrigTowerDetId.h"
0026 #include "DataFormats/HcalDetId/interface/CastorElectronicsId.h"
0027 #include "DataFormats/HcalDetId/interface/HcalGenericDetId.h"
0028 #include <cstdint>
0029 //
0030 class CastorElectronicsMap {
0031 public:
0032   CastorElectronicsMap();
0033   ~CastorElectronicsMap();
0034 
0035   // swap function
0036   void swap(CastorElectronicsMap& other);
0037   // copy-ctor
0038   CastorElectronicsMap(const CastorElectronicsMap& src);  // copy assignment operator
0039   CastorElectronicsMap& operator=(const CastorElectronicsMap& rhs);
0040   // move constructor
0041 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
0042   CastorElectronicsMap(CastorElectronicsMap&& other);
0043 #endif
0044 
0045   /// lookup the logical detid associated with the given electronics id
0046   //return Null item if no such mapping
0047   const DetId lookup(CastorElectronicsId fId) const;
0048 
0049   /// brief lookup the electronics detid associated with the given logical id
0050   //return Null item if no such mapping
0051   const CastorElectronicsId lookup(DetId fId) const;
0052 
0053   /// brief lookup the trigger logical detid associated with the given electronics id
0054   //return Null item if no such mapping
0055   const DetId lookupTrigger(CastorElectronicsId fId) const;
0056 
0057   /// brief lookup the electronics detid associated with the given trigger logical id
0058   //return Null item if no such mapping
0059   const CastorElectronicsId lookupTrigger(DetId fId) const;
0060 
0061   /// brief lookup the DetId and full electronics id associated with this partial (dcc/spigot/fiber/fiberchan) id
0062   bool lookup(const CastorElectronicsId pId, CastorElectronicsId& eid, HcalGenericDetId& did) const;
0063   /// brief lookup the DetId and full electronics id associated with this partial (dcc/spigot/slb/slbchan) id
0064   bool lookup(const CastorElectronicsId pId, CastorElectronicsId& eid, HcalTrigTowerDetId& did) const;
0065 
0066   std::vector<CastorElectronicsId> allElectronicsId() const;
0067   std::vector<CastorElectronicsId> allElectronicsIdPrecision() const;
0068   std::vector<CastorElectronicsId> allElectronicsIdTrigger() const;
0069   std::vector<HcalGenericDetId> allPrecisionId() const;
0070   std::vector<HcalTrigTowerDetId> allTriggerId() const;
0071 
0072   // map channels
0073   bool mapEId2tId(CastorElectronicsId fElectronicsId, HcalTrigTowerDetId fTriggerId);
0074   bool mapEId2chId(CastorElectronicsId fElectronicsId, DetId fId);
0075   // sorting
0076   void sortById() const;
0077   void sortByTriggerId() const;
0078   void sort() {}
0079 
0080   class PrecisionItem {
0081   public:
0082     PrecisionItem() { mId = mElId = 0; }
0083     PrecisionItem(uint32_t fId, uint32_t fElId) : mId(fId), mElId(fElId) {}
0084     uint32_t mId;
0085     uint32_t mElId;
0086 
0087     COND_SERIALIZABLE;
0088   };
0089   class TriggerItem {
0090   public:
0091     TriggerItem() { mElId = mTrigId = 0; }
0092     TriggerItem(uint32_t fTrigId, uint32_t fElId) : mTrigId(fTrigId), mElId(fElId) {}
0093     uint32_t mTrigId;
0094     uint32_t mElId;
0095 
0096     COND_SERIALIZABLE;
0097   };
0098 
0099 protected:
0100   const PrecisionItem* findById(unsigned long fId) const;
0101   const PrecisionItem* findPByElId(unsigned long fElId) const;
0102   const TriggerItem* findTByElId(unsigned long fElId) const;
0103   const TriggerItem* findByTrigId(unsigned long fTrigId) const;
0104 
0105   std::vector<PrecisionItem> mPItems;
0106   std::vector<TriggerItem> mTItems;
0107 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
0108   mutable std::atomic<std::vector<const PrecisionItem*>*> mPItemsById COND_TRANSIENT;
0109   mutable std::atomic<std::vector<const TriggerItem*>*> mTItemsByTrigId COND_TRANSIENT;
0110 #else
0111   mutable std::vector<const PrecisionItem*>* mPItemsById COND_TRANSIENT;
0112   mutable std::vector<const TriggerItem*>* mTItemsByTrigId COND_TRANSIENT;
0113 #endif
0114 
0115   COND_SERIALIZABLE;
0116 };
0117 
0118 #endif