CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/CondFormats/SiPixelObjects/src/PixelFEDLink.cc

Go to the documentation of this file.
00001 #include "CondFormats/SiPixelObjects/interface/PixelFEDLink.h"
00002 #include "DataFormats/SiPixelDetId/interface/PixelBarrelName.h"
00003 #include "DataFormats/SiPixelDetId/interface/PixelEndcapName.h"
00004 #include "DataFormats/DetId/interface/DetId.h"
00005 
00006 
00007 #include <sstream>
00008 
00009 using namespace std;
00010 using namespace sipixelobjects;
00011 
00012 void PixelFEDLink::addItem(const PixelROC & roc)
00013 {
00014   // INFO roc numbering vs vector has offset=1
00015   if(roc.idInLink() > theROCs.size() ) theROCs.resize(roc.idInLink());
00016   theROCs[roc.idInLink()-1] = roc;
00017 }
00018 
00019 bool PixelFEDLink::checkRocNumbering() const
00020 {
00021   bool result = true;
00022   unsigned int idx_expected = 0;
00023   typedef ROCs::const_iterator CIR;
00024   for (CIR it = theROCs.begin(); it != theROCs.end(); it++) {
00025     idx_expected++;
00026     if (idx_expected != (*it).idInLink() ) {
00027       result = false;
00028       cout << "** PixelFEDLink, idInLink in ROC, expected: "
00029            << idx_expected <<" has: "<<(*it).idInLink() << endl;
00030     }
00031   }
00032   return result;
00033 }
00034 
00035 void PixelFEDLink::add(const ROCs & rocs)
00036 {
00037   theROCs.insert( theROCs.end(), rocs.begin(), rocs.end() );
00038 }
00039 
00040 string PixelFEDLink::print(int depth) const
00041 {
00042   ostringstream out;
00043   // if (id() < 0) return  out.str(); // id() >= 0, since it returns an unsigned
00044 
00045   if (depth-- >=0 ) {
00046     if(id()<10) out <<"  LNK:  "<<id(); else  out <<"  LNK: "<<id();
00047     if (depth==0) out << printForMap();
00048     else { 
00049       out << endl;
00050       typedef ROCs::const_iterator CIR;
00051       for (CIR ir = theROCs.begin(); ir != theROCs.end(); ir++) out<< (ir)->print(depth); 
00052       out <<"#  total number of ROCs: "<< numberOfROCs() << endl;
00053     }
00054   }
00055   return out.str();
00056 
00057 }
00058 
00059 string PixelFEDLink::printForMap() const 
00060 {
00061   typedef ROCs::const_iterator CIR;
00062   ostringstream out;
00063 
00064 // barrel
00065 {
00066   int minroc = 9999;
00067   int maxroc = -1;
00068   bool first = true;
00069   PixelBarrelName prev;
00070   for (CIR ir = theROCs.begin(); ir < theROCs.end(); ir++) {
00071     DetId detid = DetId(ir->rawId());
00072     bool barrel = PixelModuleName::isBarrel(detid.rawId()); if (!barrel) continue;
00073     PixelBarrelName curr( detid);
00074     if (first) prev = curr; 
00075 
00076     int idRoc = ir->idInDetUnit();
00077     if (curr==prev) {
00078       minroc = min(idRoc, minroc);
00079       maxroc = max(idRoc, maxroc);
00080     }
00081 
00082     if ( !(curr==prev) ) {
00083     out <<"    MOD: "<< prev.name() <<" ROC: "<< minroc<<", "<<maxroc<< std::endl;
00084       prev = curr;
00085       maxroc = minroc = idRoc;
00086  //     minroc = idRoc;
00087  //     maxroc = idRoc;
00088     }
00089 
00090     if ( ir==theROCs.end()-1) {
00091     out <<"    MOD: "<< curr.name() <<" ROC: "<< minroc<<", "<<maxroc<< std::endl;
00092     }
00093   }
00094 }
00095 
00096 // same for endcpap
00097 {
00098   bool first = true;
00099   PixelEndcapName prev;
00100   for (CIR ir = theROCs.begin(); ir < theROCs.end(); ir++) {
00101     DetId detid = DetId(ir->rawId());
00102     bool barrel = PixelModuleName::isBarrel(detid.rawId()); if (barrel) continue;
00103     PixelEndcapName tmp( detid);
00104     PixelEndcapName curr( tmp.halfCylinder(), tmp.diskName(), tmp.bladeName(), tmp.pannelName() );
00105     if (first) prev = curr;
00106     if ( !(curr==prev) ) out <<"    MOD: "<< prev.name() << std::endl;
00107     if ( ir==theROCs.end()-1) out <<"    MOD: "<< curr.name() << std::endl;
00108   }
00109 }
00110   return out.str();
00111 }
00112