CMS 3D CMS Logo

PixelBarrelLinkMaker.cc
Go to the documentation of this file.
5 
7 
8 #include <ostream>
9 using namespace std;
10 using namespace sipixelobjects;
11 
13  const PixelBarrelName& n1 = *u1.name;
14  const PixelBarrelName& n2 = *u2.name;
15 
16  bool res = false;
17 
18  if (n1.layerName() < n2.layerName())
19  res = true;
20  else if (n1.layerName() > n2.layerName())
21  res = false;
22  else if (n1.ladderName() < n2.ladderName())
23  res = true;
24  else if (n1.ladderName() > n2.ladderName())
25  res = false;
26  else if (abs(n1.moduleName()) < abs(n2.moduleName()))
27  res = true;
28  else if (abs(n1.moduleName()) > abs(n2.moduleName()))
29  res = false;
30  else if (u1.rocIds.min() < u2.rocIds.min())
31  res = true;
32  else if (u1.rocIds.min() > u2.rocIds.min())
33  res = false;
34 
35  return res;
36 }
37 
39  Links result;
40  typedef Names::const_iterator CIN;
41 
42  //
43  // construct link items from names.
44  // the item is equivalent to name for layer=3.
45  // for layer=1,2 each module has 2 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  PixelBarrelName* b = dynamic_cast<PixelBarrelName*>(n[idx]);
53  uint32_t d = u[idx];
54  item.name = b;
55  item.unit = d;
56 
57  if (b->isHalfModule()) {
58  item.rocIds = Range(0, 7); // half modules
59  linkItems.push_back(item);
60  } else if (b->layerName() <= 2) {
61  item.rocIds = Range(0, 7); // first link for modules in Layer=1,2
62  linkItems.push_back(item);
63  item.rocIds = Range(8, 15); // second link for modules in Layer=1,2
64  linkItems.push_back(item);
65  } else {
66  item.rocIds = Range(0, 15); // one module per link
67  linkItems.push_back(item);
68  }
69  }
70 
71  //
72  // sort link items to get the order as in links
73  //
74 
75  Order myLess;
76  sort(linkItems.begin(), linkItems.end(), myLess);
77 
78  //
79  // DEBUG
80  //
81  ostringstream str;
82  for (CIU it = linkItems.begin(); it != linkItems.end(); it++) {
83  str << (*it).name->name() << " r=" << (*it).rocIds << endl;
84  }
85  LogDebug(" sorted BARREL links: ") << str.str();
86 
87  //
88  // create corresponding PixelROC and link
89  //
90  int idLink = 0;
91  result.reserve(linkItems.size());
92  for (CIU it = linkItems.begin(); it != linkItems.end(); it++) {
94  PixelFEDLink link(++idLink);
95  int idRoc = 0;
96  for (int id = (*it).rocIds.min(); id <= (*it).rocIds.max(); id++) {
97  idRoc++;
98  rocs.push_back(PixelROC(it->unit, id, idRoc));
99  }
100  link.add(rocs);
101  result.push_back(link);
102  }
103 
104  return result;
105 }
std::vector< uint32_t > DetUnits
PixelRecoRange< float > Range
int moduleName() const
module id (index in z)
Links links(const Names &n, const DetUnits &u) const
Definition: Electron.h:6
PixelFEDCabling::Links Links
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
d
Definition: ztail.py:151
bool operator()(const Item &, const Item &) const
int layerName() const
layer id
double b
Definition: hdecay.h:120
int ladderName() const
ladder id (index in phi)
std::vector< PixelModuleName * > Names
#define str(s)
#define LogDebug(id)