CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PixelEndcapLinkMaker.cc
Go to the documentation of this file.
6 #include <ostream>
7 
8 using namespace std;
9 using namespace sipixelobjects;
10 
12  (const Item &u1, const Item& u2) const
13 {
14  bool res = true;
15  const PixelEndcapName & n1 = *u1.name;
16  const PixelEndcapName & n2 = *u2.name;
17 
18  if (n1.halfCylinder() < n2.halfCylinder() ) res = true;
19  else if(n1.halfCylinder() > n2.halfCylinder() ) res = false;
20  else if (n1.diskName() < n2.diskName() ) res = true;
21  else if (n1.diskName() > n2.diskName() ) res = false;
22  else if (n1.bladeName() < n2.bladeName() ) res = true;
23  else if (n1.bladeName() > n2.bladeName() ) res = false;
24  else if (n1.pannelName() < n2.pannelName() ) res = true;
25  else if (n1.pannelName() > n2.pannelName() ) res = false;
26  else if (n1.plaquetteName() < n2.plaquetteName() ) res = true;
27  else if (n1.plaquetteName() > n2.plaquetteName() ) 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  // split names to links
41  //
42  vector<Item> linkItems;
43  typedef vector<Item>::const_iterator CIU;
44 
45 
46  for(unsigned int idx = 0; idx < n.size(); idx++) {
47  Item item;
48  PixelEndcapName * e = dynamic_cast<PixelEndcapName * >(n[idx]);
49  uint32_t d = u[idx];
50  item.name = e;
51  item.unit = d;
52  Range rocIds(-1,-1);
54  switch (type) {
55  case(PixelModuleName::v1x2) : { rocIds = Range(0,1); break; }
56  case(PixelModuleName::v1x5) : { rocIds = Range(0,4); break; }
57  case(PixelModuleName::v2x3) : { rocIds = Range(0,5); break; }
58  case(PixelModuleName::v2x4) : { rocIds = Range(0,7); break; }
59  case(PixelModuleName::v2x5) : { rocIds = Range(0,9); break; }
60  default:
61  edm::LogError("PixelEndcapLinkMaker")<< " *** UNEXPECTED roc: " << e->name() ;
62  };
63  item.rocIds = rocIds;
64  linkItems.push_back(item);
65  }
66  //
67  // sort names to get the order as in links
68  //
69 
70  sort( linkItems.begin(), linkItems.end(), Order() );
71 
72  //
73  // DEBUG
74  //
75  ostringstream str;
76  for (CIU it = linkItems.begin(); it != linkItems.end(); it++) {
77  str << (*it).name->name() <<" r="<< (*it).rocIds << endl;
78  }
79  LogDebug(" sorted ENDCAP links: ") << str.str();
80 
81  result.reserve(36);
82  int lastPannelId = -1;
83  int idLink = 0;
84  int idRoc = 0;
85  PixelFEDLink link(idLink); // dummy object, id=0
86 
87  for (CIU it = linkItems.begin(); it != linkItems.end(); it++) {
88  PixelFEDLink::ROCs rocs;
89  int pannelId = it->name->pannelName();
90 
91  if ( pannelId != lastPannelId ) {
92  lastPannelId = pannelId;
93  if (idLink > 0) result.push_back(link);
94  idRoc = 0;
95  link = PixelFEDLink(++idLink); // real link, to be filled
96  }
97 
98  for (int id = (*it).rocIds.min(); id <= (*it).rocIds.max(); id++) {
99  ++idRoc;
100  rocs.push_back( PixelROC( it->unit, id, idRoc ) );
101  }
102 
103  link.add( rocs);
104  }
105 
106  if (idLink > 0) result.push_back(link);
107  return result;
108 }
109 
110 
111 
#define LogDebug(id)
int plaquetteName() const
plaquetteId (in pannel)
type
Definition: HCALResponse.h:21
const PixelEndcapName * name
PixelFEDCabling::Links Links
tuple d
Definition: ztail.py:151
int bladeName() const
blade id
std::vector< uint32_t > DetUnits
std::vector< PixelModuleName * > Names
tuple result
Definition: query.py:137
PixelRecoRange< float > Range
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
virtual PixelModuleName::ModuleType moduleType() const
module Type
virtual std::string name() const
from base class
int pannelName() const
pannel id
int diskName() const
disk id
HalfCylinder halfCylinder() const
Links links(const Names &n, const DetUnits &u) const