Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:51:32

0001 #include "CondFormats/SiPixelObjects/interface/PixelFEDLink.h"
0002 #include "DataFormats/TrackerCommon/interface/PixelBarrelName.h"
0003 #include "DataFormats/TrackerCommon/interface/PixelEndcapName.h"
0004 #include "DataFormats/DetId/interface/DetId.h"
0005 
0006 #include <sstream>
0007 
0008 using namespace std;
0009 using namespace sipixelobjects;
0010 
0011 void PixelFEDLink::addItem(const PixelROC& roc) {
0012   // INFO roc numbering vs vector has offset=1
0013   if (roc.idInLink() > theROCs.size())
0014     theROCs.resize(roc.idInLink());
0015   theROCs[roc.idInLink() - 1] = roc;
0016 }
0017 
0018 bool PixelFEDLink::checkRocNumbering() const {
0019   bool result = true;
0020   unsigned int idx_expected = 0;
0021   typedef ROCs::const_iterator CIR;
0022   for (CIR it = theROCs.begin(); it != theROCs.end(); it++) {
0023     idx_expected++;
0024     if (idx_expected != (*it).idInLink()) {
0025       result = false;
0026       cout << "** PixelFEDLink, idInLink in ROC, expected: " << idx_expected << " has: " << (*it).idInLink() << endl;
0027     }
0028   }
0029   return result;
0030 }
0031 
0032 void PixelFEDLink::add(const ROCs& rocs) { theROCs.insert(theROCs.end(), rocs.begin(), rocs.end()); }
0033 
0034 string PixelFEDLink::print(int depth) const {
0035   ostringstream out;
0036   // if (id() < 0) return  out.str(); // id() >= 0, since it returns an unsigned
0037 
0038   if (depth-- >= 0) {
0039     if (id() < 10)
0040       out << "  LNK:  " << id();
0041     else
0042       out << "  LNK: " << id();
0043     if (depth == 0)
0044       out << printForMap();
0045     else {
0046       out << endl;
0047       typedef ROCs::const_iterator CIR;
0048       for (CIR ir = theROCs.begin(); ir != theROCs.end(); ir++)
0049         out << (ir)->print(depth);
0050       out << "#  total number of ROCs: " << numberOfROCs() << endl;
0051     }
0052   }
0053   return out.str();
0054 }
0055 
0056 string PixelFEDLink::printForMap() const {
0057   typedef ROCs::const_iterator CIR;
0058   ostringstream out;
0059 
0060   // barrel
0061   {
0062     int minroc = 9999;
0063     int maxroc = -1;
0064     bool first = true;
0065     PixelBarrelName prev;
0066     for (CIR ir = theROCs.begin(); ir < theROCs.end(); ir++) {
0067       DetId detid = DetId(ir->rawId());
0068       bool barrel = PixelModuleName::isBarrel(detid.rawId());
0069       if (!barrel)
0070         continue;
0071       PixelBarrelName curr(detid);
0072       if (first)
0073         prev = curr;
0074 
0075       int idRoc = ir->idInDetUnit();
0076       if (curr == prev) {
0077         minroc = min(idRoc, minroc);
0078         maxroc = max(idRoc, maxroc);
0079       }
0080 
0081       if (!(curr == prev)) {
0082         out << "    MOD: " << prev.name() << " ROC: " << minroc << ", " << maxroc << std::endl;
0083         prev = curr;
0084         maxroc = minroc = idRoc;
0085         //     minroc = idRoc;
0086         //     maxroc = idRoc;
0087       }
0088 
0089       if (ir == theROCs.end() - 1) {
0090         out << "    MOD: " << curr.name() << " ROC: " << minroc << ", " << maxroc << std::endl;
0091       }
0092     }
0093   }
0094 
0095   // same for endcpap
0096   {
0097     bool first = true;
0098     PixelEndcapName prev;
0099     for (CIR ir = theROCs.begin(); ir < theROCs.end(); ir++) {
0100       DetId detid = DetId(ir->rawId());
0101       bool barrel = PixelModuleName::isBarrel(detid.rawId());
0102       if (barrel)
0103         continue;
0104       PixelEndcapName tmp(detid);
0105       PixelEndcapName curr(tmp.halfCylinder(), tmp.diskName(), tmp.bladeName(), tmp.pannelName());
0106       if (first)
0107         prev = curr;
0108       if (!(curr == prev))
0109         out << "    MOD: " << prev.name() << std::endl;
0110       if (ir == theROCs.end() - 1)
0111         out << "    MOD: " << curr.name() << std::endl;
0112     }
0113   }
0114   return out.str();
0115 }