CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/CalibFormats/SiPixelObjects/src/PixelHdwAddress.cc

Go to the documentation of this file.
00001 //
00002 // 
00003 //
00004 //
00005 //
00006 
00007 #include "CalibFormats/SiPixelObjects/interface/PixelHdwAddress.h"
00008 #include <string>
00009 #include <cassert>
00010 #include <ostream>
00011 #include <iostream>
00012 
00013 using namespace pos;
00014 
00015 //====================================================================================
00016 PixelHdwAddress::PixelHdwAddress():
00017     mfec_(0),
00018     mfecchannel_(0),
00019     portaddress_(0),
00020     hubaddress_(0),
00021     rocid_(0),
00022     fednumber_(0),
00023     fedchannel_(0),
00024     fedrocnumber_(0)
00025 {}
00026 
00027 
00028 //====================================================================================
00029 PixelHdwAddress::PixelHdwAddress(int fecnumber, int mfec, int mfecchannel,
00030                                  int hubaddress, int portaddress, int rocid,
00031                                  int fednumber, int fedchannel, 
00032                                  int fedrocnumber):
00033     fecnumber_(fecnumber),
00034     mfec_(mfec),
00035     mfecchannel_(mfecchannel),
00036     portaddress_(portaddress),
00037     hubaddress_(hubaddress),
00038     rocid_(rocid),
00039     fednumber_(fednumber),
00040     fedchannel_(fedchannel),
00041     fedrocnumber_(fedrocnumber)
00042 {
00043     //std::cout << "Created PixelHdwAddress:"<<std::endl;
00044     //std::cout << *this << std::endl;
00045 }
00046 
00047 //====================================================================================
00048 std::ostream& pos::operator<<(std::ostream& s, const PixelHdwAddress& pixelroc){
00049 
00050     s<< "[PixelHdwAddress::operator<<]"           <<std::endl;
00051     s<< "fecnumber   :" << pixelroc.fecnumber_    <<std::endl;
00052     s<< "mfec        :" << pixelroc.mfec_         <<std::endl;
00053     s<< "mfecchannel :" << pixelroc.mfecchannel_  <<std::endl;
00054     s<< "portaddress :" << pixelroc.portaddress_  <<std::endl;
00055     s<< "hubaddress  :" << pixelroc.hubaddress_   <<std::endl;
00056     s<< "rocid       :" << pixelroc.rocid_        <<std::endl;
00057     s<< "fednumber   :" << pixelroc.fednumber_    <<std::endl;
00058     s<< "fedchannel  :" << pixelroc.fedchannel_   <<std::endl;
00059     s<< "fedrocnumber:" << pixelroc.fedrocnumber_ <<std::endl;
00060 
00061     return s;
00062 }
00063 
00064 //====================================================================================
00065 const PixelHdwAddress& PixelHdwAddress::operator=(const PixelHdwAddress& aROC){
00066     
00067     fecnumber_   = aROC.fecnumber_   ;
00068     mfec_        = aROC.mfec_        ;
00069     mfecchannel_ = aROC.mfecchannel_ ;
00070     portaddress_ = aROC.portaddress_ ;
00071     hubaddress_  = aROC.hubaddress_  ;
00072     rocid_       = aROC.rocid_       ;
00073     fednumber_   = aROC.fednumber_   ;
00074     fedchannel_  = aROC.fedchannel_  ;
00075     fedrocnumber_= aROC.fedrocnumber_;
00076 
00077     return *this;
00078 
00079 }
00080 
00081 //====================================================================================
00082 // Added by Dario
00083 void PixelHdwAddress::setAddress(std::string what, int value)
00084 {
00085     std::string mthn = "[PixelHdwAddress::setAddress()]\t\t\t    " ;
00086     if(        what == "fecnumber"   )
00087     {
00088       fecnumber_    =  value;
00089     } else if( what == "mfec"        ) { 
00090       mfec_         =  value ;
00091     } else if( what == "mfecchannel" ) {
00092       mfecchannel_  =  value ;
00093     } else if( what == "portaddress" ) {
00094       portaddress_  =  value ;
00095     } else if( what == "hubaddress"  ) {
00096       hubaddress_   =  value ;
00097     } else if( what == "rocid"       ) {
00098       rocid_        =  value ;
00099     } else if( what == "fednumber"   ) {
00100       fednumber_    =  value ;
00101     } else if( what == "fedchannel"  ) {
00102       fedchannel_   =  value ;
00103     } else if( what == "fedrocnumber") {
00104       fedrocnumber_ =  value ;
00105     } else {
00106       std::cout << __LINE__ << "]\t" << mthn << "Could not set a value for " << what 
00107                 << " (invalid keyword)" << std::endl ;
00108       assert(0) ;
00109     }
00110 }
00111 
00112 //====================================================================================
00113 void PixelHdwAddress::compare(std::string what, bool &changed, unsigned int newValue, unsigned int &oldValue)
00114 {
00115     std::string mthn = "[PixelHdwAddress::compare()]\t\t\t    " ;
00116     changed  = false ;
00117     oldValue = 0 ;
00118     
00119     if(         what == "fecnumber"   )
00120     {
00121       if( fecnumber_ != newValue)       {changed = true; oldValue = fecnumber_;    return ;}
00122     } else if(  what == "mfec"        ) { 
00123       if( mfec_          != newValue)   {changed = true; oldValue = mfec_;         return ;}
00124     } else if(  what == "mfecchannel" ) {
00125       if( mfecchannel_   != newValue)   {changed = true; oldValue = mfecchannel_;  return ;}
00126     } else if(  what == "portaddress" ) {
00127       if( portaddress_   != newValue)   {changed = true; oldValue = portaddress_;  return ;}
00128     } else if(  what == "hubaddress"  ) {
00129       if( hubaddress_    != newValue)   {changed = true; oldValue = hubaddress_;   return ;}
00130     } else if(  what == "rocid"       ) {
00131       if( rocid_         != newValue)   {changed = true; oldValue = rocid_;        return ;}
00132     } else if(  what == "fednumber"   ) {
00133       if( fednumber_     != newValue)   {changed = true; oldValue = fednumber_;    return ;}
00134     } else if(  what == "fedchannel"  ) {
00135       if( fedchannel_    != newValue)   {changed = true; oldValue = fedchannel_;   return ;}
00136     } else if(  what == "fedrocnumber") {
00137       if( fedrocnumber_  != newValue)   {changed = true; oldValue = fedrocnumber_; return ;}
00138     } else {
00139       std::cout << __LINE__ << "]\t" << mthn << "Could not compare value for " << what 
00140                 << " (invalid keyword)" << std::endl ;
00141       assert(0) ;
00142     }
00143 }
00144 
00145 //====================================================================================
00146 bool PixelHdwAddress::operator()(const PixelHdwAddress& roc1, const PixelHdwAddress& roc2) const{
00147 
00148   if (roc1.fednumber_  < roc2.fednumber_ ) return true;
00149   if (roc1.fednumber_  > roc2.fednumber_ ) return false;
00150   if (roc1.fedchannel_ < roc2.fedchannel_) return true;
00151   if (roc1.fedchannel_ > roc2.fedchannel_) return false;
00152 
00153   return (roc1.fedrocnumber_<roc2.fedrocnumber_);
00154 
00155 }