CMS 3D CMS Logo

ESDetId.cc

Go to the documentation of this file.
00001 #include "DataFormats/EcalDetId/interface/ESDetId.h"
00002 #include "FWCore/Utilities/interface/Exception.h"
00003 
00004 ESDetId::ESDetId() : DetId() {
00005 }
00006   
00007 ESDetId::ESDetId(uint32_t rawid) : DetId(rawid) {
00008 }
00009   
00010 ESDetId::ESDetId(int strip, int ixs, int iys, int plane, int iz) : DetId(Ecal,EcalPreshower) {
00011   if ( !validDetId( strip, ixs, iys, plane, iz) )
00012     throw cms::Exception("InvalidDetId") << "ESDetId:  Cannot create object.  Indexes out of bounds \n" 
00013                                          << " strip = " << strip << " x = " << ixs << " y = " << iys << "\n" 
00014                                          << " plane = " << plane << " z = " << iz;
00015 
00016    id_ |=
00017     (strip&0x3F) |
00018     ((ixs&0x3F)<<6) |
00019     ((iys&0x3F)<<12) |
00020     (((plane-1)&0x1)<<18) |
00021     ((iz>0)?(1<<19):(0));
00022 }
00023   
00024 ESDetId::ESDetId(const DetId& gen) {
00025   if (!gen.null() && ( gen.det()!=Ecal || gen.subdetId()!=EcalPreshower )) {
00026     throw cms::Exception("InvalidDetId");
00027   }
00028   id_=gen.rawId();
00029 }
00030 
00031 bool ESDetId::validDetId(int istrip, int ixs, int iys, int iplane, int iz) {
00032 
00033   bool valid = true;
00034   if ((istrip<ISTRIP_MIN) || (istrip > ISTRIP_MAX) ||
00035       (ixs<IX_MIN) || (ixs > IX_MAX) ||
00036       (iys<IY_MIN) || (iys > IY_MAX) ||
00037       (abs(iz)) != 1 ||
00038       (iplane != 1 && iplane != 2)) { valid = false; }
00039   return valid;
00040 
00041 }
00042   
00043 ESDetId& ESDetId::operator=(const DetId& gen) {
00044   if (!gen.null() && ( gen.det()!=Ecal || gen.subdetId()!=EcalPreshower )) {
00045     throw cms::Exception("InvalidDetId");
00046   }
00047   id_=gen.rawId();
00048   return *this;
00049 }
00050   
00051 int ESDetId::hashedIndex() const {
00052   // TODO: more efficient index!
00053   return id_&0xFFFFFF;
00054 }
00055   
00056 std::ostream& operator<<(std::ostream& s,const ESDetId& id) {
00057   return s << "(ES z=" << id.zside() << "  plane " << id.plane() << " " <<
00058     id.six() << ':' << id.siy() << " " << id.strip() << ')';
00059 }

Generated on Tue Jun 9 17:30:41 2009 for CMSSW by  doxygen 1.5.4