CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch1/src/DataFormats/EcalDigi/interface/EcalTrigPrimCompactColl.h

Go to the documentation of this file.
00001 #ifndef ECALTRIGPRIMCOMPACTCOLL_H
00002 #define ECALTRIGPRIMCOMPACTCOLL_H
00003 
00004 #include <vector>
00005 #include <inttypes.h>
00006 #include "FWCore/Utilities/interface/Exception.h"
00007 
00008 #include "DataFormats/EcalDigi/interface/EcalTriggerPrimitiveDigi.h"
00009 #include "DataFormats/Common/interface/SortedCollection.h"
00010 typedef edm::SortedCollection<EcalTriggerPrimitiveDigi> EcalTrigPrimDigiCollection;
00011 
00027 class EcalTrigPrimCompactColl {
00028 
00029 private:
00030   static const int nPhiBins = 72;
00031   static const int nEtaBins = 56;
00032   static const int nBins = nPhiBins*nEtaBins;
00033 
00034 private:
00035   static size_t index(int ieta, int iphi){
00036     size_t r = unsigned(((ieta<0) ? (ieta+28) : (ieta+27))*nPhiBins + (iphi -1));
00037     if(r >= (unsigned)nBins) throw cms::Exception("Invalid argument") << "Trigger tower index (" << ieta << "," << iphi << ") are out of range";
00038     return r;
00039   }
00040   
00041 public:
00042   EcalTrigPrimCompactColl(): formatVers_(0), data_(nBins){};
00043   
00045   void setValue(int ieta, int iphi, uint16_t sample){ data_[index(ieta, iphi)] = sample;}
00046 
00048 
00049   uint16_t raw(int ieta, int iphi) const { return data_[index(ieta, iphi)]; }
00050   uint16_t raw(const EcalTrigTowerDetId& ttId) const { return raw(ttId.ieta(), ttId.iphi()); }
00052 
00054 
00055   int compressedEt(int ieta, int iphi) const { return raw(ieta, iphi)&0xFF; }
00056   int compressedEt(const EcalTrigTowerDetId& ttId) const { return compressedEt(ttId.ieta(), ttId.iphi()); }
00058 
00060 
00061   bool fineGrain(int ieta, int iphi) const { return (raw(ieta, iphi)&0x100)!=0; }
00062   bool fineGrain(const EcalTrigTowerDetId& ttId) const { return fineGrain(ttId.ieta(), ttId.iphi()); }
00064 
00066 
00067   int ttFlag(int ieta, int iphi) const { return (raw(ieta, iphi)>>9)&0x7; }
00068   int ttFlag(const EcalTrigTowerDetId& ttId) const { return ttFlag(ttId.ieta(), ttId.iphi()); }
00070 
00072 
00073 
00074 
00075   int sFGVB(int ieta, int iphi) const { return (raw(ieta, iphi) >>12) & 0x1; }
00076   int sFGVB(const EcalTrigTowerDetId& ttId) const { return sFGVB(ttId.ieta(), ttId.iphi()); }
00078   
00080 
00081 
00082 
00083 
00084 
00085   int l1aSpike(int ieta, int iphi) const { return sFGVB(ieta, iphi); }
00086   int l1aSpike(const EcalTrigTowerDetId& ttId) const { return sFGVB(ttId); }
00088   
00089   void toEcalTrigPrimDigiCollection(EcalTrigPrimDigiCollection& dest) const;
00090   
00091  private:
00092   int16_t formatVers_;
00093   std::vector<uint16_t> data_;
00094 };
00095 
00096 #endif //ECALTRIGPRIMCOMPACTCOLL_H not defined