CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch2/src/CondFormats/SiPixelObjects/src/PixelROC.cc

Go to the documentation of this file.
00001 #include "CondFormats/SiPixelObjects/interface/PixelROC.h"
00002 
00003 #include "DataFormats/SiPixelDetId/interface/PixelBarrelName.h"
00004 #include "DataFormats/SiPixelDetId/interface/PixelEndcapName.h"
00005 #include "DataFormats/DetId/interface/DetId.h"
00006 
00007 #include <sstream>
00008 #include <algorithm>
00009 using namespace std;
00010 using namespace sipixelobjects;
00011 
00012 PixelROC::PixelROC(uint32_t du, int idDU, int idLk)
00013   : theDetUnit(du), theIdDU(idDU), theIdLk(idLk), theFrameConverter(0)
00014 {}
00015 
00016 PixelROC::PixelROC(const PixelROC & o)
00017   : theDetUnit(o.theDetUnit), theIdDU(o.theIdDU), theIdLk(o.theIdLk),theFrameConverter(0)
00018 {
00019   if(o.theFrameConverter) theFrameConverter = o.theFrameConverter->clone();
00020 }
00021 
00022 PixelROC::~PixelROC() 
00023 {
00024   delete theFrameConverter;
00025 }
00026 
00027 const PixelROC&
00028 PixelROC::operator=(const PixelROC& iRHS)
00029 {
00030   PixelROC temp(iRHS);
00031   this->swap(temp);
00032   return *this;
00033 }
00034 
00035 void
00036 PixelROC::swap(PixelROC& iOther)
00037 {
00038   std::swap(theDetUnit,iOther.theDetUnit);
00039   std::swap(theIdDU,iOther.theIdDU);
00040   std::swap(theIdLk,iOther.theIdLk);
00041   std::swap(theFrameConverter,iOther.theFrameConverter);
00042 }
00043 
00044 GlobalPixel PixelROC::toGlobal(const LocalPixel & loc) const 
00045 {
00046   GlobalPixel result;
00047   if (!theFrameConverter) initFrameConversion();
00048   result.col    = theFrameConverter->collumn().convert(loc.rocCol());
00049   result.row    = theFrameConverter->row().convert(loc.rocRow());
00050   return result;
00051 }
00052 
00053 
00054 LocalPixel PixelROC::toLocal( const GlobalPixel& glo) const
00055 {
00056   if (!theFrameConverter) initFrameConversion();
00057   int rocRow = theFrameConverter->row().inverse(glo.row);
00058   int rocCol = theFrameConverter->collumn().inverse(glo.col);
00059 
00060   LocalPixel::RocRowCol rocRowCol = {rocRow, rocCol};
00061   return LocalPixel(rocRowCol);
00062 }
00063 
00064 void PixelROC::initFrameConversion() const
00065 {
00066   if ( PixelModuleName::isBarrel(theDetUnit) ) {
00067     PixelBarrelName barrelName(theDetUnit); 
00068     theFrameConverter = new FrameConversion(barrelName, theIdDU);
00069   } else {
00070     PixelEndcapName endcapName(theDetUnit);
00071     theFrameConverter = new FrameConversion(endcapName, theIdDU); 
00072   }
00073 }
00074 
00075 string PixelROC::print(int depth) const
00076 {
00077   if (!theFrameConverter) initFrameConversion();
00078 
00079   ostringstream out;
00080   bool barrel = PixelModuleName::isBarrel(theDetUnit);
00081   DetId detId(theDetUnit);
00082   if (depth-- >=0 ) {
00083     out <<"======== PixelROC ";
00084     out <<" unit: ";
00085     if (barrel) out << PixelBarrelName(detId).name();
00086     else        out << PixelEndcapName(detId).name(); 
00087     out <<" ("<<theDetUnit<<")"
00088         <<" idInDU: "<<theIdDU
00089         <<" idInLk: "<<theIdLk
00090 //        <<" frame: "<<theRowOffset<<","<<theRowSlopeSign<<","<<theColOffset<<","<<theColSlopeSign
00091 //        <<" frame: "<<*theFrameConverter
00092         <<endl;
00093   }
00094   return out.str();
00095 }
00096