CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_1/src/DataFormats/L1GlobalCaloTrigger/src/L1GctInternEtSum.cc

Go to the documentation of this file.
00001 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctInternEtSum.h"
00002 #include <stdint.h>
00003 
00004 
00005 L1GctInternEtSum::L1GctInternEtSum() {
00006 
00007 }
00008 
00009 
00011 L1GctInternEtSum::L1GctInternEtSum(uint16_t capBlock,
00012                                    uint16_t capIndex,
00013                                    int16_t bx,
00014                                    uint32_t et,
00015                                    uint8_t oflow) :
00016   type_(null),
00017   capBlock_(capBlock),
00018   capIndex_(capIndex),
00019   bx_(bx),
00020   data_(0)
00021 {
00022   this->setEt(et);
00023   this->setOflow(oflow);
00024 }
00025 
00026 
00028 L1GctInternEtSum::~L1GctInternEtSum() {
00029 
00030 }
00031 
00032 L1GctInternEtSum L1GctInternEtSum::fromJetTotEt(const uint16_t capBlock,
00033                                                 const uint16_t capIndex,
00034                                                 const int16_t bx,
00035                                                 const uint32_t data) {
00036   L1GctInternEtSum s;
00037   s.setEt(data & kTotEtOrHtMaxValue);
00038   s.setOflow((data>>kTotEtOrHtNBits)&0x1);
00039   s.setCapBlock(capBlock);
00040   s.setCapIndex(capIndex);
00041   s.setBx(bx);
00042   s.setType(jet_tot_et);
00043   return s;
00044 }
00045 
00046 L1GctInternEtSum L1GctInternEtSum::fromJetTotHt(const uint16_t capBlock,
00047                                                 const uint16_t capIndex,
00048                                                 const int16_t bx,
00049                                                 const uint32_t data) {
00050   L1GctInternEtSum s;
00051   uint32_t word=data>>16;
00052   s.setEt(word & kTotEtOrHtMaxValue);
00053   s.setOflow((word>>kTotEtOrHtNBits)&0x1);
00054   s.setCapBlock(capBlock);
00055   s.setCapIndex(capIndex);
00056   s.setBx(bx);
00057   s.setType(jet_tot_ht);
00058   return s;
00059 }
00060 
00061 L1GctInternEtSum L1GctInternEtSum::fromJetMissEt(const uint16_t capBlock,
00062                                                  const uint16_t capIndex,
00063                                                  const int16_t bx,
00064                                                  const uint32_t data) {
00065   L1GctInternEtSum s;
00066   s.setEt(data & kJetMissEtMaxValue);
00067   s.setOflow((data>>kJetMissEtNBits) & 0x1);
00068   s.setCapBlock(capBlock);
00069   s.setCapIndex(capIndex);
00070   s.setBx(bx);
00071   s.setType(jet_miss_et);
00072   return s;
00073 }
00074 
00075 
00076 L1GctInternEtSum L1GctInternEtSum::fromTotalEtOrHt(const uint16_t capBlock,
00077                                                    const uint16_t capIndex,
00078                                                    const int16_t bx,
00079                                                    const uint32_t data) {
00080   L1GctInternEtSum s;
00081   s.setEt(data & kTotEtOrHtMaxValue);
00082   s.setOflow((data>>kTotEtOrHtNBits) & 0x1);
00083   s.setCapBlock(capBlock);
00084   s.setCapIndex(capIndex);
00085   s.setBx(bx);
00086   s.setType(total_et_or_ht);
00087   return s;
00088 }
00089 
00090 L1GctInternEtSum L1GctInternEtSum::fromMissEtxOrEty(const uint16_t capBlock,
00091                                                     const uint16_t capIndex,
00092                                                     const int16_t bx,
00093                                                     const uint32_t data) {
00094   L1GctInternEtSum s;
00095   s.setEt(data & kMissExOrEyNBits);
00096   s.setOflow(0); // No over flow bit at the moment
00097   s.setCapBlock(capBlock);
00098   s.setCapIndex(capIndex);
00099   s.setBx(bx);
00100   s.setType(miss_etx_or_ety);
00101   return s;
00102 }
00103 
00104 
00106 
00107 L1GctInternEtSum L1GctInternEtSum::fromEmulatorJetTotEt(unsigned totEt, bool overFlow, int16_t bx) {
00108   L1GctInternEtSum s;
00109   s.setEt(totEt & kTotEtOrHtMaxValue);
00110   if (overFlow || (totEt > kTotEtOrHtMaxValue)) s.setOflow(0x1);
00111   s.setBx(bx);
00112   s.setType(jet_tot_et);
00113   return s;
00114 }
00115 
00116 L1GctInternEtSum L1GctInternEtSum::fromEmulatorJetTotHt(unsigned totHt, bool overFlow, int16_t bx) {
00117   L1GctInternEtSum s;
00118   s.setEt(totHt & kTotEtOrHtMaxValue);
00119   if (overFlow || (totHt > kTotEtOrHtMaxValue)) s.setOflow(0x1);
00120   s.setBx(bx);
00121   s.setType(jet_tot_ht);
00122   return s;
00123 }
00124   
00125 L1GctInternEtSum L1GctInternEtSum::fromEmulatorJetMissEt(int missEtxOrEty, bool overFlow, int16_t bx) {
00126   L1GctInternEtSum s;
00127   s.setEt(missEtxOrEty & kJetMissEtMaxValue);
00128   if (overFlow || (missEtxOrEty >= kJetMissEtOFlowBit/2) || (missEtxOrEty < -kJetMissEtOFlowBit/2)) s.setOflow(0x1);
00129   s.setBx(bx);
00130   s.setType(jet_miss_et);
00131   return s;
00132 }
00133   
00134 L1GctInternEtSum L1GctInternEtSum::fromEmulatorTotalEtOrHt(unsigned totEtOrHt, bool overFlow, int16_t bx) {
00135   L1GctInternEtSum s;
00136   s.setEt(totEtOrHt & kTotEtOrHtMaxValue);
00137   if (overFlow || (totEtOrHt > kTotEtOrHtMaxValue)) s.setOflow(0x1);
00138   s.setBx(bx);
00139   s.setType(total_et_or_ht);
00140   return s;
00141 }
00142 
00143 L1GctInternEtSum L1GctInternEtSum::fromEmulatorMissEtxOrEty(int missEtxOrEty, bool overFlow, int16_t bx) {
00144   L1GctInternEtSum s;
00145   s.setEt(missEtxOrEty & kMissExOrEyMaxValue);
00146   if (overFlow || (missEtxOrEty >= kMissExOrEyOFlowBit/2) || (missEtxOrEty < -kMissExOrEyOFlowBit/2)) s.setOflow(0x1);
00147   s.setBx(bx);
00148   s.setType(miss_etx_or_ety);
00149   return s;
00150 }
00151 
00153 bool L1GctInternEtSum::operator==(const L1GctInternEtSum& c) const {
00154   return ( data_ == c.raw() && bx_ == c.bx() );
00155 }
00156 
00157 
00159 void L1GctInternEtSum::setValue(uint32_t val) {
00160   data_ &= 0x80000000;
00161   data_ |= val & 0x7ffffff;
00162 }
00163 
00165 void L1GctInternEtSum::setEt(uint32_t et) {
00166   setValue(et);
00167 }
00168 
00170 void L1GctInternEtSum::setCount(uint32_t count) {
00171   setValue(count);
00172 }
00173 
00175 void L1GctInternEtSum::setOflow(uint8_t oflow) {
00176   data_ &= 0x7ffffff;
00177   data_ |= (oflow & 0x1)<<31;
00178 }
00179 
00181 std::ostream& operator<<(std::ostream& s, const L1GctInternEtSum& c) 
00182 {
00183   s << "L1GctInternEtSum : ";
00184 
00185   if (c.type()==L1GctInternEtSum::jet_miss_et){
00186     s << " type=jet_miss_et";
00187   } else if (c.type()==L1GctInternEtSum::jet_tot_et){
00188     s << " type=jet_tot_et";
00189   } else if (c.type()==L1GctInternEtSum::jet_tot_ht){
00190     s << " type=jet_tot_ht";
00191   } else if (c.type()==L1GctInternEtSum::total_et_or_ht){
00192     s << " type=total_et_or_ht";
00193   } else if (c.type()==L1GctInternEtSum::miss_etx_or_ety){
00194     s << " type=miss_etx_or_ety";
00195   }
00196 
00197   if (c.empty()) { 
00198     s << " empty!"; 
00199   } else {
00200     s << " mag=" << c.et();
00201     if (c.oflow()) { s << " overflow set"; }
00202   }
00203 
00204   s << " cap block=" << std::hex << c.capBlock(); 
00205   s << " index=" << std::dec << c.capIndex(); 
00206   s << " BX=" << c.bx(); 
00207 
00208   return s; 
00209 }