CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch2/src/CondFormats/EcalObjects/interface/EcalCondTowerObjectContainer.h

Go to the documentation of this file.
00001 #ifndef ECAL_CONDTOWER_OBJECT_CONTAINER_HH
00002 #define ECAL_CONDTOWER_OBJECT_CONTAINER_HH
00003 
00004 #include "DataFormats/EcalDetId/interface/EcalContainer.h"
00005 #include "DataFormats/EcalDetId/interface/EcalTrigTowerDetId.h"
00006 #include "DataFormats/EcalDetId/interface/EcalScDetId.h"
00007 
00008 
00009 #include <cstdio>
00010 
00011 template < typename T >
00012 class EcalCondTowerObjectContainer {
00013         public:
00014                 typedef T Item;
00015                 typedef Item value_type;
00016                 typedef EcalCondTowerObjectContainer<T> self;
00017                 typedef typename std::vector<Item> Items;
00018                 typedef typename std::vector<Item>::const_iterator const_iterator; 
00019                 typedef typename std::vector<Item>::iterator iterator;
00020 
00021                 EcalCondTowerObjectContainer() {
00022                   size_t ebsize=(size_t)EcalTrigTowerDetId::kEBTowersPerSM*18*2;
00023                   eb_.checkAndResize(ebsize);
00024                   size_t eesize=(size_t)632;
00025                   ee_.checkAndResize(eesize);
00026                 };
00027                 ~EcalCondTowerObjectContainer() {};
00028 
00029                 inline
00030                 const Items & barrelItems() const { return eb_.items(); };
00031 
00032                 inline
00033                 const Items & endcapItems() const { return ee_.items(); };
00034 
00035                 inline
00036                 const Item & barrel( size_t hashedIndex ) const {
00037                         return eb_.item(hashedIndex);
00038                 }
00039                 
00040                 inline
00041                 const Item & endcap( size_t hashedIndex ) const {
00042                         return ee_.item(hashedIndex);
00043                 }
00044 
00045                 inline void insert( std::pair<uint32_t, Item> const &a ) {
00046                   DetId id(a.first);
00047                   if( id.subdetId() == EcalBarrel || id.subdetId() == EcalTriggerTower )   { 
00048                     eb_.insert(a);
00049                   } else if(  id.subdetId() == EcalEndcap  ) { 
00050                     ee_.insert(a);
00051                   } else {
00052                     std::cout <<"*** ERROR it is not barrel nor endcap tower"<< std::endl;
00053                   }
00054                 }
00055                 
00056                 inline
00057                 const_iterator find( uint32_t rawId ) const {
00058                         DetId id(rawId);
00059                         if( id.subdetId() == EcalBarrel || id.subdetId() == EcalTriggerTower )   { 
00060                           const_iterator it = eb_.find(rawId);
00061                           if ( it != eb_.end() ) {
00062                             return it;
00063                           } else {
00064                             return ee_.end();
00065                           }
00066                         } else if(  id.subdetId() == EcalEndcap  ) { 
00067                           return ee_.find(rawId);
00068                         } else {
00069                           return ee_.end();
00070                         }
00071                 }
00072 
00073                 inline
00074                 const_iterator begin() const {
00075                         return eb_.begin();
00076                 }
00077 
00078                 inline
00079                 const_iterator end() const {
00080                         return ee_.end();
00081                 }
00082 
00083                 inline
00084                 void setValue(const uint32_t id, const Item &item) {
00085                         (*this)[id] = item;
00086                 }
00087 
00088                 inline
00089                 const self & getMap() const {
00090                         return *this;
00091                 }
00092 
00093                 inline
00094                 size_t size() const {
00095                         return eb_.size() + ee_.size();
00096                 }
00097                 // add coherent operator++, not needed now -- FIXME
00098 
00099                 inline
00100                 Item & operator[]( uint32_t rawId ) {
00101                         DetId id(rawId);
00102                         static Item dummy;
00103 
00104                         if( id.subdetId() == EcalBarrel || id.subdetId() == EcalTriggerTower )   { 
00105                           return eb_[rawId];
00106                         } else if(  id.subdetId() == EcalEndcap  ) { 
00107                           return ee_[rawId];
00108                         } else {
00109                           return dummy;
00110                         }
00111                 }
00112                 
00113                 inline
00114                 Item const & operator[]( uint32_t rawId ) const {
00115                         DetId id(rawId);
00116                         static Item dummy;
00117 
00118                         if( id.subdetId() == EcalBarrel || id.subdetId() == EcalTriggerTower )   { 
00119                           return eb_[rawId];
00120                         } else if(  id.subdetId() == EcalEndcap  ) { 
00121                           return ee_[rawId];
00122                         } else {
00123                           return dummy;
00124                         }
00125                 }
00126                 
00127         private:
00128                 EcalContainer< EcalTrigTowerDetId , Item > eb_;
00129                 EcalContainer< EcalScDetId , Item > ee_;
00130 };
00131 
00132 typedef EcalCondTowerObjectContainer<float> EcalTowerFloatCondObjectContainer;
00133 #endif