CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_4/src/SimDataFormats/EcalTestBeam/src/HodoscopeDetId.cc

Go to the documentation of this file.
00001 #include "SimDataFormats/EcalTestBeam/interface/HodoscopeDetId.h"
00002 #include "FWCore/Utilities/interface/Exception.h"
00003 
00004 #include <iostream>
00005 HodoscopeDetId::HodoscopeDetId() : 
00006    CaloTowerDetId() 
00007 {
00008 }
00009 
00010 HodoscopeDetId::HodoscopeDetId( uint32_t rawid ) : 
00011    CaloTowerDetId( rawid ) 
00012 {
00013 }
00014 
00015 int 
00016 HodoscopeDetId::planeId() const 
00017 {
00018    return ieta() ; 
00019 }
00020 
00021 int 
00022 HodoscopeDetId::fibrId() const 
00023 { 
00024    return iphi() ; 
00025 }
00026 
00027 HodoscopeDetId::HodoscopeDetId( int iPlane ,
00028                                 int iFibr    ) 
00029    : CaloTowerDetId( iPlane, iFibr )
00030 {
00031    if( !validDetId( iPlane, iFibr ) )
00032    {
00033       throw cms::Exception("InvalidDetId") 
00034          << "HodoscopeDetId:  Cannot create object.  Indices out of bounds.";
00035    }
00036 }
00037   
00038 HodoscopeDetId::HodoscopeDetId( const DetId& gen ) :
00039    CaloTowerDetId( gen )
00040 {
00041    if( !validDetId( planeId(), fibrId() ) )
00042    {
00043       throw cms::Exception("InvalidDetId") 
00044          << "HodoscopeDetId:  Cannot create object.  Indices out of bounds.";
00045    }
00046 }
00047 
00048 bool 
00049 HodoscopeDetId::validDetId( int iPlane ,
00050                             int iFibr   ) 
00051 {
00052    return !( iPlane < MIN_PLANE || 
00053              iPlane > MAX_PLANE ||
00054              iFibr  < MIN_FIBR  ||
00055              iFibr  > MAX_FIBR     ) ;
00056 }
00057 
00058 std::ostream& operator<<(std::ostream& s,const HodoscopeDetId& id) 
00059 {
00060    return s << "(Plane " << id.planeId() << ", fiber " << id.fibrId() << ')';
00061 }
00062