Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:14:50

0001 #ifndef EventFilter_EcalRawToDigi_interface_EcalRegionCabling_h
0002 #define EventFilter_EcalRawToDigi_interface_EcalRegionCabling_h
0003 
0004 #include "DataFormats/FEDRawData/interface/FEDNumbering.h"
0005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0006 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0007 #include "Geometry/EcalMapping/interface/ESElectronicsMapper.h"
0008 #include "Geometry/EcalMapping/interface/EcalElectronicsMapping.h"
0009 
0010 class EcalRegionCabling {
0011 public:
0012   EcalRegionCabling(edm::ParameterSet& conf, const EcalElectronicsMapping* m) : mapping_(m) {
0013     const edm::ParameterSet esMap = conf.getParameter<edm::ParameterSet>("esMapping");
0014     es_mapping_ = new ESElectronicsMapper(esMap);
0015   }
0016 
0017   ~EcalRegionCabling() {
0018     // this pointer is own by this object.
0019     delete es_mapping_;
0020   }
0021   const EcalElectronicsMapping* mapping() const { return mapping_; }
0022   const ESElectronicsMapper* es_mapping() const { return es_mapping_; }
0023 
0024   static uint32_t maxElementIndex() { return (FEDNumbering::MAXECALFEDID - FEDNumbering::MINECALFEDID + 1); }
0025   static uint32_t maxESElementIndex() {
0026     return (FEDNumbering::MAXPreShowerFEDID - FEDNumbering::MINPreShowerFEDID + 1);
0027   }
0028 
0029   static uint32_t elementIndex(const int FEDindex) {
0030     //do a test for the time being
0031     if (FEDindex > FEDNumbering::MAXECALFEDID || FEDindex < FEDNumbering::MINECALFEDID) {
0032       edm::LogError("IncorrectMapping") << "FEDindex: " << FEDindex
0033                                         << " is not between: " << (int)FEDNumbering::MINECALFEDID << " and "
0034                                         << (int)FEDNumbering::MAXECALFEDID;
0035       return 0;
0036     }
0037     uint32_t eI = FEDindex - FEDNumbering::MINECALFEDID;
0038     return eI;
0039   }
0040 
0041   static uint32_t esElementIndex(const int FEDindex) {
0042     //do a test for the time being
0043     if (FEDindex > FEDNumbering::MAXPreShowerFEDID || FEDindex < FEDNumbering::MINPreShowerFEDID) {
0044       edm::LogError("IncorrectMapping") << "FEDindex: " << FEDindex
0045                                         << " is not between: " << (int)FEDNumbering::MINPreShowerFEDID << " and "
0046                                         << (int)FEDNumbering::MAXPreShowerFEDID;
0047       return 0;
0048     }
0049     uint32_t eI = FEDindex - FEDNumbering::MINPreShowerFEDID;
0050     return eI;
0051   }
0052 
0053   static int fedIndex(const uint32_t index) {
0054     int fI = index + FEDNumbering::MINECALFEDID;
0055     return fI;
0056   }
0057 
0058   static int esFedIndex(const uint32_t index) {
0059     int fI = index + FEDNumbering::MINPreShowerFEDID;
0060     return fI;
0061   }
0062 
0063   uint32_t elementIndex(const double eta, const double phi) const {
0064     int FEDindex = mapping()->GetFED(eta, phi);
0065     return elementIndex(FEDindex);
0066   }
0067 
0068 private:
0069   const EcalElectronicsMapping* mapping_;
0070   const ESElectronicsMapper* es_mapping_;
0071 };
0072 
0073 #endif  // EventFilter_EcalRawToDigi_interface_EcalRegionCabling_h