CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 Item &u1, const Item& u2) const
14 {
15  const PixelBarrelName & n1 = *u1.name;
16  const PixelBarrelName & n2 = *u2.name;
17 
18  bool res = false;
19 
20  if ( n1.layerName() < n2.layerName() ) res = true;
21  else if ( n1.layerName() > n2.layerName() ) res = false;
22  else if ( n1.ladderName() < n2.ladderName() ) res = true;
23  else if ( n1.ladderName() > n2.ladderName() ) res = false;
24  else if ( abs(n1.moduleName()) < abs(n2.moduleName()) ) res = true;
25  else if ( abs(n1.moduleName()) > abs(n2.moduleName()) ) res = false;
26  else if ( u1.rocIds.min() < u2.rocIds.min() ) res = true;
27  else if ( u1.rocIds.min() > u2.rocIds.min() ) res = false;
28 
29  return res;
30 }
31 
33  const Names & n, const DetUnits & u) const
34 {
35 
36  Links result;
37  typedef Names::const_iterator CIN;
38 
39  //
40  // construct link items from names.
41  // the item is equivalent to name for layer=3.
42  // for layer=1,2 each module has 2 links
43  //
44  vector<Item> linkItems;
45  typedef vector<Item>::const_iterator CIU;
46 
47  for(unsigned int idx = 0; idx < n.size(); idx++) {
48  Item item;
49  PixelBarrelName * b = dynamic_cast<PixelBarrelName * >(n[idx]);
50  uint32_t d = u[idx];
51  item.name = b;
52  item.unit = d;
53 
54  if ( b->isHalfModule()) {
55  item.rocIds = Range(0,7); // half modules
56  linkItems.push_back(item);
57  } else if(b->layerName() <= 2) {
58  item.rocIds = Range(0,7); // first link for modules in Layer=1,2
59  linkItems.push_back(item);
60  item.rocIds = Range(8,15); // second link for modules in Layer=1,2
61  linkItems.push_back(item);
62  } else {
63  item.rocIds = Range(0,15); // one module per link
64  linkItems.push_back(item);
65  }
66  }
67 
68 
69 
70  //
71  // sort link items to get the order as in links
72  //
73 
74  Order myLess;
75  sort( linkItems.begin(), linkItems.end(), myLess );
76 
77  //
78  // DEBUG
79  //
80  ostringstream str;
81  for (CIU it = linkItems.begin(); it != linkItems.end(); it++) {
82  str << (*it).name->name() <<" r="<< (*it).rocIds << endl;
83  }
84  LogDebug(" sorted BARREL links: ") << str.str();
85 
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++) {
93  PixelFEDLink::ROCs rocs;
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 }
#define LogDebug(id)
std::vector< uint32_t > DetUnits
const PixelBarrelName * name
int moduleName() const
module id (index in z)
PixelRecoRange< float > Range
Links links(const Names &n, const DetUnits &u) const
tuple result
Definition: mps_fire.py:95
PixelFEDCabling::Links Links
tuple d
Definition: ztail.py:151
bool isHalfModule() const
full or half module
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int ladderName() const
ladder id (index in phi)
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
int layerName() const
layer id
double b
Definition: hdecay.h:120
std::vector< PixelModuleName * > Names