CMS 3D CMS Logo

EcalTrigTowerDetId.cc

Go to the documentation of this file.
00001 #include "DataFormats/EcalDetId/interface/EcalTrigTowerDetId.h"
00002 #include "FWCore/Utilities/interface/Exception.h"
00003 
00004 
00005 EcalTrigTowerDetId::EcalTrigTowerDetId() {
00006 }
00007   
00008   
00009 EcalTrigTowerDetId::EcalTrigTowerDetId(uint32_t rawid) : DetId(rawid) {
00010 }
00011 
00012 EcalTrigTowerDetId::EcalTrigTowerDetId(int zside, EcalSubdetector subDet, int i, int j, int mode)
00013   : DetId(Ecal,EcalTriggerTower) 
00014 {
00015   int tower_i=0;
00016   int tower_j=0;
00017 
00018   if (mode == SUBDETIJMODE)
00019     {
00020       tower_i=i;
00021       tower_j=j;
00022     }
00023   else if (mode == SUBDETDCCTTMODE)
00024     {
00025       throw cms::Exception("InvalidDetId") << "EcalTriggerTowerDetId:  Cannot create object. SUBDETDCCTTMODE not yet implemented.";   
00026     }
00027   else
00028     throw cms::Exception("InvalidDetId") << "EcalTriggerTowerDetId:  Cannot create object.  Unknown mode for (int, EcalSubdetector, int, int) constructor.";
00029   
00030   if (tower_i > MAX_I || tower_i < MIN_I  || tower_j > MAX_J || tower_j < MIN_J)
00031     throw cms::Exception("InvalidDetId") << "EcalTriggerTowerDetId:  Cannot create object.  Indexes out of bounds.";
00032   
00033   id_|= ((zside>0)?(0x8000):(0x0)) | ((subDet == EcalBarrel)?(0x4000):(0x0)) | (tower_i<<7) | (tower_j & 0x7F);
00034 
00035 }
00036   
00037 EcalTrigTowerDetId::EcalTrigTowerDetId(const DetId& gen) 
00038 {
00039   if (!gen.null() && ( gen.det()!=Ecal || gen.subdetId()!=EcalTriggerTower )) {
00040     throw cms::Exception("InvalidDetId");  }
00041   id_=gen.rawId();
00042 }
00043   
00044 EcalTrigTowerDetId& EcalTrigTowerDetId::operator=(const DetId& gen) {
00045   if (!gen.null() && ( gen.det()!=Ecal || gen.subdetId()!=EcalTriggerTower )) {
00046     throw cms::Exception("InvalidDetId");
00047   }
00048   id_=gen.rawId();
00049   return *this;
00050 }
00051 
00052 //New SM numbering scheme. Avoids discontinuity in phi crossing \eta=0  
00053 int EcalTrigTowerDetId::iDCC() const 
00054 {
00055   if ( subDet() == EcalBarrel )
00056     {
00057       //Correction since iphi is uniformized with HB convention 
00058       int iphi_simple = iphi() + 2 ;
00059       if (iphi_simple > 72 ) iphi_simple = iphi_simple % 72;
00060       int id = ( iphi_simple - 1 ) / kEBTowersInPhi + 1;
00061       if ( zside() < 0 ) id += 18;
00062       return id;
00063     }
00064   else
00065     throw cms::Exception("MethodNotImplemented") << "EcalTriggerTowerDetId: iDCC not yet implemented";
00066 }
00067 
00068 int EcalTrigTowerDetId::iTT() const 
00069 {
00070   if ( subDet() == EcalBarrel )
00071     {
00072       int ie = ietaAbs() -1;
00073       int ip;
00074       int iphi_simple = iphi() + 2 ;
00075       if (iphi_simple > 72 )  iphi_simple = iphi_simple % 72;
00076       if (zside() < 0) {
00077         ip = (( iphi_simple -1 ) % kEBTowersInPhi ) + 1;
00078       } else {
00079         ip = kEBTowersInPhi - ((iphi_simple -1 ) % kEBTowersInPhi );
00080       }
00081       
00082       return (ie * kEBTowersInPhi) + ip;
00083     }
00084   else
00085     throw cms::Exception("MethodNotImplemented") << "EcalTriggerTowerDetId: iTT not yet implemented";
00086 }
00087 
00088 int EcalTrigTowerDetId::iquadrant() const
00089 {
00090   if ( subDet() == EcalEndcap )
00091     return int((iphi()-1)/kEETowersInPhiPerQuadrant)+1;
00092   else
00093     throw cms::Exception("MethodNotApplicable") << "EcalTriggerTowerDetId: iquadrant not applicable";
00094 }  
00095 
00096 int EcalTrigTowerDetId::hashedIndex() const 
00097 {
00098   return (iDCC()-1) * kEBTowersPerSM + iTT() - 1;
00099 }
00100 
00101 
00102 std::ostream& operator<<(std::ostream& s,const EcalTrigTowerDetId& id) {
00103   return s << "(EcalTT subDet " << ((id.subDet()==EcalBarrel)?("Barrel"):("Endcap")) 
00104            <<  " iz " << ((id.zside()>0)?("+ "):("- ")) << " ieta " 
00105            << id.ietaAbs() << " iphi " << id.iphi() << ')';
00106 }
00107 

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