CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/CondFormats/RPCObjects/src/FebConnectorSpec.cc

Go to the documentation of this file.
00001 #include "CondFormats/RPCObjects/interface/FebConnectorSpec.h"
00002 #include "CondFormats/RPCObjects/interface/DBSpecToDetUnit.h"
00003 #include "DataFormats/MuonDetId/interface/RPCDetId.h"
00004 #include <sstream>
00005 
00006 FebConnectorSpec::FebConnectorSpec(
00007     int num, const ChamberLocationSpec & chamber, const FebLocationSpec & feb)
00008   : theLinkBoardInputNum(num),
00009     theChamber(chamber),
00010     theFeb(feb),
00011     theAlgo(0),
00012     theRawId(0)
00013 { }
00014 
00015 const ChamberStripSpec FebConnectorSpec::strip( int pinNumber) const
00016 {
00017   int nStrips=theAlgo/10000;
00018   int firstChamberStrip=(theAlgo-10000*nStrips)/100;
00019   int pinAlgo=theAlgo-10000*nStrips-100*firstChamberStrip;
00020   int slope=1;
00021   if (pinAlgo > 3) {
00022     pinAlgo=pinAlgo-4;
00023     slope=-1;
00024   }
00025   bool valid=true;
00026   if (pinNumber < pinAlgo) valid=false;
00027   if (!pinAlgo && (pinNumber < 2)) valid=false;
00028   if (pinAlgo && (pinNumber > pinAlgo+nStrips-1)) valid=false;
00029   if (!pinAlgo && (pinNumber > nStrips+2 || pinNumber == 9)) valid=false;
00030   int chamberStripNumber=-1;
00031   if (valid) {
00032     if (pinAlgo !=0) chamberStripNumber=firstChamberStrip+slope*(pinNumber-pinAlgo);
00033     else if (pinNumber < 9) chamberStripNumber=firstChamberStrip+slope*(pinNumber-2);
00034     else chamberStripNumber=firstChamberStrip+slope*(pinNumber-3);
00035   }
00036   ChamberStripSpec aStrip={pinNumber,chamberStripNumber,0};
00037   return aStrip;
00038 }
00039 
00040 const int FebConnectorSpec::chamberStripNum(int istrip) const {
00041   int nStrips = theAlgo/10000;
00042   if (istrip<0 || istrip>nStrips-1) return 0;
00043   int firstChamberStrip=(theAlgo-10000*nStrips)/100;
00044   int pinAlgo=theAlgo-10000*nStrips-100*firstChamberStrip;
00045   int theStrip=firstChamberStrip+istrip;
00046   if (pinAlgo>3) theStrip=firstChamberStrip-istrip;
00047   return theStrip;
00048 }
00049 
00050 const int FebConnectorSpec::cablePinNum(int istrip) const {
00051   int nStrips = theAlgo/10000;
00052   if (istrip<0 || istrip>nStrips-1) return 0;
00053   int pinAlgo=theAlgo%100;
00054   if (pinAlgo>3) pinAlgo=pinAlgo-4;
00055   bool holeatpin9=(pinAlgo==0 && istrip>6);
00056   int thePin = istrip+pinAlgo+holeatpin9+2*(pinAlgo==0);
00057   return thePin;
00058 }
00059 
00060 const uint32_t & FebConnectorSpec::rawId() const
00061 {
00062   DBSpecToDetUnit toDU;
00063   if (!theRawId)  theRawId = toDU(theChamber, theFeb);
00064   return theRawId;
00065 }
00066 
00067 
00068 std::string FebConnectorSpec::print(int depth) const
00069 {
00070   std::ostringstream str;
00071   str << "FebConnectorSpec in LinkBoardNum ="<<linkBoardInputNum()
00072       <<" rawId: " << rawId() <<std::endl;
00073   RPCDetId aDet(rawId());
00074   str<<aDet<<std::endl;
00075   str << theChamber.print(depth)<< std::endl << theFeb.print(depth) ;
00076   depth--;
00077   if (depth >=0) {
00078     int nStrips=theAlgo/10000;
00079     for (int istrip=0; istrip<nStrips; istrip++) {
00080       ChamberStripSpec aStrip={cablePinNum(istrip),chamberStripNum(istrip),cmsStripNum(istrip)};
00081       str << aStrip.print(depth); 
00082     }
00083   }
00084   return str.str();
00085 }