CMS 3D CMS Logo

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 using namespace std;
00009 using namespace sipixelobjects;
00010 
00011 PixelROC::PixelROC(uint32_t du, int idDU, int idLk)
00012   : theDetUnit(du), theIdDU(idDU), theIdLk(idLk), theFrameConverter(0)
00013 { }
00014 
00015 PixelROC::PixelROC(const PixelROC & o)
00016   : theDetUnit(o.theDetUnit), theIdDU(o.theIdDU), theIdLk(o.theIdLk),theFrameConverter(0)
00017 {
00018   if(o.theFrameConverter) theFrameConverter = o.theFrameConverter->clone();
00019 }
00020 
00021 PixelROC::~PixelROC() 
00022 {
00023   delete theFrameConverter;
00024 }
00025 
00026 GlobalPixel PixelROC::toGlobal(const LocalPixel & loc) const 
00027 {
00028   GlobalPixel result;
00029   if (!theFrameConverter) initFrameConversion();
00030   result.col    = theFrameConverter->collumn().convert(loc.rocCol());
00031   result.row    = theFrameConverter->row().convert(loc.rocRow());
00032   return result;
00033 }
00034 
00035 
00036 LocalPixel PixelROC::toLocal( const GlobalPixel& glo) const
00037 {
00038   if (!theFrameConverter) initFrameConversion();
00039   int rocRow = theFrameConverter->row().inverse(glo.row);
00040   int rocCol = theFrameConverter->collumn().inverse(glo.col);
00041 
00042   LocalPixel::RocRowCol rocRowCol = {rocRow, rocCol};
00043   return LocalPixel(rocRowCol);
00044 }
00045 
00046 void PixelROC::initFrameConversion() const
00047 {
00048   if ( PixelModuleName::isBarrel(theDetUnit) ) {
00049     PixelBarrelName barrelName(theDetUnit); 
00050     theFrameConverter = new FrameConversion(barrelName, theIdDU);
00051   } else {
00052     PixelEndcapName endcapName(theDetUnit);
00053     theFrameConverter = new FrameConversion(endcapName, theIdDU); 
00054   }
00055 }
00056 
00057 string PixelROC::print(int depth) const
00058 {
00059   if (!theFrameConverter) initFrameConversion();
00060 
00061   ostringstream out;
00062   bool barrel = PixelModuleName::isBarrel(theDetUnit);
00063   DetId detId(theDetUnit);
00064   if (depth-- >=0 ) {
00065     out <<"======== PixelROC ";
00066     out <<" unit: ";
00067     if (barrel) out << PixelBarrelName(detId).name();
00068     else        out << PixelEndcapName(detId).name(); 
00069     out <<" ("<<theDetUnit<<")"
00070         <<" idInDU: "<<theIdDU
00071         <<" idInLk: "<<theIdLk
00072 //        <<" frame: "<<theRowOffset<<","<<theRowSlopeSign<<","<<theColOffset<<","<<theColSlopeSign
00073 //        <<" frame: "<<*theFrameConverter
00074         <<endl;
00075   }
00076   return out.str();
00077 }
00078 

Generated on Tue Jun 9 17:26:46 2009 for CMSSW by  doxygen 1.5.4