File indexing completed on 2024-04-06 11:59:31
0001 #include "CalibTracker/SiPixelConnectivity/interface/PixelBarrelLinkMaker.h"
0002 #include "DataFormats/SiPixelDetId/interface/PixelModuleName.h"
0003 #include "DataFormats/TrackerCommon/interface/PixelBarrelName.h"
0004 #include "CondFormats/SiPixelObjects/interface/PixelROC.h"
0005
0006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0007
0008 #include <ostream>
0009 using namespace std;
0010 using namespace sipixelobjects;
0011
0012 bool PixelBarrelLinkMaker::Order::operator()(const Item& u1, const Item& u2) const {
0013 const PixelBarrelName& n1 = *u1.name;
0014 const PixelBarrelName& n2 = *u2.name;
0015
0016 bool res = false;
0017
0018 if (n1.layerName() < n2.layerName())
0019 res = true;
0020 else if (n1.layerName() > n2.layerName())
0021 res = false;
0022 else if (n1.ladderName() < n2.ladderName())
0023 res = true;
0024 else if (n1.ladderName() > n2.ladderName())
0025 res = false;
0026 else if (abs(n1.moduleName()) < abs(n2.moduleName()))
0027 res = true;
0028 else if (abs(n1.moduleName()) > abs(n2.moduleName()))
0029 res = false;
0030 else if (u1.rocIds.min() < u2.rocIds.min())
0031 res = true;
0032 else if (u1.rocIds.min() > u2.rocIds.min())
0033 res = false;
0034
0035 return res;
0036 }
0037
0038 PixelBarrelLinkMaker::Links PixelBarrelLinkMaker::links(const Names& n, const DetUnits& u) const {
0039 Links result;
0040 typedef Names::const_iterator CIN;
0041
0042
0043
0044
0045
0046
0047 vector<Item> linkItems;
0048 typedef vector<Item>::const_iterator CIU;
0049
0050 for (unsigned int idx = 0; idx < n.size(); idx++) {
0051 Item item;
0052 PixelBarrelName* b = dynamic_cast<PixelBarrelName*>(n[idx]);
0053 uint32_t d = u[idx];
0054 item.name = b;
0055 item.unit = d;
0056
0057 if (b->isHalfModule()) {
0058 item.rocIds = Range(0, 7);
0059 linkItems.push_back(item);
0060 } else if (b->layerName() <= 2) {
0061 item.rocIds = Range(0, 7);
0062 linkItems.push_back(item);
0063 item.rocIds = Range(8, 15);
0064 linkItems.push_back(item);
0065 } else {
0066 item.rocIds = Range(0, 15);
0067 linkItems.push_back(item);
0068 }
0069 }
0070
0071
0072
0073
0074
0075 Order myLess;
0076 sort(linkItems.begin(), linkItems.end(), myLess);
0077
0078
0079
0080
0081 ostringstream str;
0082 for (CIU it = linkItems.begin(); it != linkItems.end(); it++) {
0083 str << (*it).name->name() << " r=" << (*it).rocIds << endl;
0084 }
0085 LogDebug(" sorted BARREL links: ") << str.str();
0086
0087
0088
0089
0090 int idLink = 0;
0091 result.reserve(linkItems.size());
0092 for (CIU it = linkItems.begin(); it != linkItems.end(); it++) {
0093 PixelFEDLink::ROCs rocs;
0094 PixelFEDLink link(++idLink);
0095 int idRoc = 0;
0096 for (int id = (*it).rocIds.min(); id <= (*it).rocIds.max(); id++) {
0097 idRoc++;
0098 rocs.push_back(PixelROC(it->unit, id, idRoc));
0099 }
0100 link.add(rocs);
0101 result.push_back(link);
0102 }
0103
0104 return result;
0105 }