CMS 3D CMS Logo

EcalRegionCabling.h

Go to the documentation of this file.
00001 #ifndef EcalRegionCabling_H
00002 #define EcalRegionCabling_H
00003 
00004 #include "Geometry/EcalMapping/interface/EcalElectronicsMapping.h"
00005 #include "DataFormats/Common/interface/LazyGetter.h"
00006 #include "DataFormats/Common/interface/RefGetter.h"
00007 #include "DataFormats/EcalRecHit/interface/EcalRecHit.h"
00008 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00009 #include "DataFormats/FEDRawData/interface/FEDNumbering.h"
00010 
00011 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00012 
00013 class EcalRegionCabling {
00014  public:
00015   EcalRegionCabling(edm::ParameterSet & conf, const EcalElectronicsMapping * m): mapping_(m)
00016     {
00017     }
00018   
00019   ~EcalRegionCabling();
00020   const EcalElectronicsMapping * mapping() const  { return mapping_;} 
00021 
00022   template <class T>  void updateEcalRefGetterWithElementIndex(edm::RefGetter<T> & refgetter,
00023                                                                const edm::Handle< edm::LazyGetter<T> >& lazygetter,
00024                                                                const uint32_t index)const;
00025   template <class T>  void updateEcalRefGetterWithFedIndex(edm::RefGetter<T> & refgetter,
00026                                                                const edm::Handle< edm::LazyGetter<T> >& lazygetter,
00027                                                                const int index)const;
00028   
00029   template <class T> void updateEcalRefGetterWithEtaPhi(edm::RefGetter<T> & refgetter,
00030                                                         const edm::Handle< edm::LazyGetter<T> >& lazygetter,
00031                                                         const double eta,
00032                                                         const double phi)const;
00033   
00034   static uint32_t maxElementIndex() {return (FEDNumbering::getEcalFEDIds().second - FEDNumbering::getEcalFEDIds().first +1);}
00035 
00036   static uint32_t elementIndex(const int FEDindex) {
00037     //do a test for the time being
00038     if (FEDindex > FEDNumbering::getEcalFEDIds().second || FEDindex < FEDNumbering::getEcalFEDIds().first) {
00039       edm::LogError("EcalRegionCabling")<<"FEDindex: "<< FEDindex
00040                                         <<" is not between: "<<FEDNumbering::getEcalFEDIds().first
00041                                         <<" and "<<FEDNumbering::getEcalFEDIds().second;
00042       return 0;}
00043     uint32_t eI = FEDindex - FEDNumbering::getEcalFEDIds().first;
00044     return eI; }
00045   
00046   static int fedIndex(const uint32_t index){ 
00047     int fI = index+FEDNumbering::getEcalFEDIds().first; 
00048     return fI;}
00049     
00050 
00051     
00052   uint32_t elementIndex(const double eta, const double phi) const{
00053     int FEDindex = mapping()->GetFED(eta,phi);
00054     return elementIndex(FEDindex); }
00055 
00056  private:
00057   const EcalElectronicsMapping * mapping_;
00058 };
00059 
00060 
00061 template <class T> void EcalRegionCabling::updateEcalRefGetterWithElementIndex(edm::RefGetter<T> & refgetter, 
00062                                                                                const edm::Handle< edm::LazyGetter<T> >& lazygetter, 
00063                                                                                const uint32_t index)const{
00064   LogDebug("EcalRawToRecHit|Cabling")<<"updating a refgetter with element index: "<<index;
00065   refgetter.push_back(lazygetter, index);
00066 }
00067 
00068 
00069 template <class T> void EcalRegionCabling::updateEcalRefGetterWithFedIndex(edm::RefGetter<T> & refgetter, 
00070                                                                            const edm::Handle< edm::LazyGetter<T> >& lazygetter, 
00071                                                                            const int fedindex)const{
00072   LogDebug("EcalRawToRecHit|Cabling")<<"updating a refgetter with fed index: "<<fedindex;
00073   updateEcalRefGetterWithElementIndex(refgetter, lazygetter, elementIndex(fedindex));
00074 }
00075 
00076 
00077 template <class T> void EcalRegionCabling::updateEcalRefGetterWithEtaPhi(edm::RefGetter<T> & refgetter, 
00078                                                                          const edm::Handle< edm::LazyGetter<T> >& lazygetter, 
00079                                                                          const double eta,
00080                                                                          const double phi)const{
00081   int index = mapping()->GetFED(eta,phi);
00082   LogDebug("EcalRawToRecHit|Cabling")<<"updating a refgetter with eta: "<<eta<<" phi: "<<phi;
00083   updateEcalRefGetterWithFedIndex(refgetter, lazygetter, index);
00084 }
00085 
00086 #endif

Generated on Tue Jun 9 17:34:32 2009 for CMSSW by  doxygen 1.5.4