CMS 3D CMS Logo

PixelEndcapLinkMaker.cc
Go to the documentation of this file.
6 #include <ostream>
7 
8 using namespace std;
9 using namespace sipixelobjects;
10 
12  bool res = true;
13  const PixelEndcapName& n1 = *u1.name;
14  const PixelEndcapName& n2 = *u2.name;
15 
16  if (n1.halfCylinder() < n2.halfCylinder())
17  res = true;
18  else if (n1.halfCylinder() > n2.halfCylinder())
19  res = false;
20  else if (n1.diskName() < n2.diskName())
21  res = true;
22  else if (n1.diskName() > n2.diskName())
23  res = false;
24  else if (n1.bladeName() < n2.bladeName())
25  res = true;
26  else if (n1.bladeName() > n2.bladeName())
27  res = false;
28  else if (n1.pannelName() < n2.pannelName())
29  res = true;
30  else if (n1.pannelName() > n2.pannelName())
31  res = false;
32  else if (n1.plaquetteName() < n2.plaquetteName())
33  res = true;
34  else if (n1.plaquetteName() > n2.plaquetteName())
35  res = false;
36 
37  return res;
38 }
39 
41  Links result;
42  typedef Names::const_iterator CIN;
43 
44  //
45  // split names to links
46  //
47  vector<Item> linkItems;
48  typedef vector<Item>::const_iterator CIU;
49 
50  for (unsigned int idx = 0; idx < n.size(); idx++) {
51  Item item;
52  PixelEndcapName* e = dynamic_cast<PixelEndcapName*>(n[idx]);
53  uint32_t d = u[idx];
54  item.name = e;
55  item.unit = d;
56  Range rocIds(-1, -1);
58  switch (type) {
59  case (PixelModuleName::v1x2): {
60  rocIds = Range(0, 1);
61  break;
62  }
63  case (PixelModuleName::v1x5): {
64  rocIds = Range(0, 4);
65  break;
66  }
67  case (PixelModuleName::v2x3): {
68  rocIds = Range(0, 5);
69  break;
70  }
71  case (PixelModuleName::v2x4): {
72  rocIds = Range(0, 7);
73  break;
74  }
75  case (PixelModuleName::v2x5): {
76  rocIds = Range(0, 9);
77  break;
78  }
79  default:
80  edm::LogError("PixelEndcapLinkMaker") << " *** UNEXPECTED roc: " << e->name();
81  };
82  item.rocIds = rocIds;
83  linkItems.push_back(item);
84  }
85  //
86  // sort names to get the order as in links
87  //
88 
89  sort(linkItems.begin(), linkItems.end(), Order());
90 
91  //
92  // DEBUG
93  //
94  ostringstream str;
95  for (CIU it = linkItems.begin(); it != linkItems.end(); it++) {
96  str << (*it).name->name() << " r=" << (*it).rocIds << endl;
97  }
98  LogDebug(" sorted ENDCAP links: ") << str.str();
99 
100  result.reserve(36);
101  int lastPannelId = -1;
102  int idLink = 0;
103  int idRoc = 0;
104  PixelFEDLink link(idLink); // dummy object, id=0
105 
106  for (CIU it = linkItems.begin(); it != linkItems.end(); it++) {
108  int pannelId = it->name->pannelName();
109 
110  if (pannelId != lastPannelId) {
111  lastPannelId = pannelId;
112  if (idLink > 0)
113  result.push_back(link);
114  idRoc = 0;
115  link = PixelFEDLink(++idLink); // real link, to be filled
116  }
117 
118  for (int id = (*it).rocIds.min(); id <= (*it).rocIds.max(); id++) {
119  ++idRoc;
120  rocs.push_back(PixelROC(it->unit, id, idRoc));
121  }
122 
123  link.add(rocs);
124  }
125 
126  if (idLink > 0)
127  result.push_back(link);
128  return result;
129 }
#define LogDebug(id)
int plaquetteName() const
plaquetteId (in pannel)
type
Definition: HCALResponse.h:21
const PixelEndcapName * name
PixelRecoRange< float > Range
PixelFEDCabling::Links Links
std::vector< PixelModuleName * > Names
Definition: Electron.h:6
std::string name() const override
from base class
int bladeName() const
blade id
std::vector< uint32_t > DetUnits
d
Definition: ztail.py:151
PixelModuleName::ModuleType moduleType() const override
module Type
int pannelName() const
pannel id
int diskName() const
disk id
HalfCylinder halfCylinder() const
#define str(s)
Links links(const Names &n, const DetUnits &u) const
bool operator()(const Item &, const Item &) const