CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
PixelFEDLink.cc
Go to the documentation of this file.
5 
6 #include <sstream>
7 
8 using namespace std;
9 using namespace sipixelobjects;
10 
11 void PixelFEDLink::addItem(const PixelROC& roc) {
12  // INFO roc numbering vs vector has offset=1
13  if (roc.idInLink() > theROCs.size())
14  theROCs.resize(roc.idInLink());
15  theROCs[roc.idInLink() - 1] = roc;
16 }
17 
18 bool PixelFEDLink::checkRocNumbering() const {
19  bool result = true;
20  unsigned int idx_expected = 0;
21  typedef ROCs::const_iterator CIR;
22  for (CIR it = theROCs.begin(); it != theROCs.end(); it++) {
23  idx_expected++;
24  if (idx_expected != (*it).idInLink()) {
25  result = false;
26  cout << "** PixelFEDLink, idInLink in ROC, expected: " << idx_expected << " has: " << (*it).idInLink() << endl;
27  }
28  }
29  return result;
30 }
31 
32 void PixelFEDLink::add(const ROCs& rocs) { theROCs.insert(theROCs.end(), rocs.begin(), rocs.end()); }
33 
34 string PixelFEDLink::print(int depth) const {
35  ostringstream out;
36  // if (id() < 0) return out.str(); // id() >= 0, since it returns an unsigned
37 
38  if (depth-- >= 0) {
39  if (id() < 10)
40  out << " LNK: " << id();
41  else
42  out << " LNK: " << id();
43  if (depth == 0)
44  out << printForMap();
45  else {
46  out << endl;
47  typedef ROCs::const_iterator CIR;
48  for (CIR ir = theROCs.begin(); ir != theROCs.end(); ir++)
49  out << (ir)->print(depth);
50  out << "# total number of ROCs: " << numberOfROCs() << endl;
51  }
52  }
53  return out.str();
54 }
55 
56 string PixelFEDLink::printForMap() const {
57  typedef ROCs::const_iterator CIR;
58  ostringstream out;
59 
60  // barrel
61  {
62  int minroc = 9999;
63  int maxroc = -1;
64  bool first = true;
65  PixelBarrelName prev;
66  for (CIR ir = theROCs.begin(); ir < theROCs.end(); ir++) {
67  DetId detid = DetId(ir->rawId());
68  bool barrel = PixelModuleName::isBarrel(detid.rawId());
69  if (!barrel)
70  continue;
71  PixelBarrelName curr(detid);
72  if (first)
73  prev = curr;
74 
75  int idRoc = ir->idInDetUnit();
76  if (curr == prev) {
77  minroc = min(idRoc, minroc);
78  maxroc = max(idRoc, maxroc);
79  }
80 
81  if (!(curr == prev)) {
82  out << " MOD: " << prev.name() << " ROC: " << minroc << ", " << maxroc << std::endl;
83  prev = curr;
84  maxroc = minroc = idRoc;
85  // minroc = idRoc;
86  // maxroc = idRoc;
87  }
88 
89  if (ir == theROCs.end() - 1) {
90  out << " MOD: " << curr.name() << " ROC: " << minroc << ", " << maxroc << std::endl;
91  }
92  }
93  }
94 
95  // same for endcpap
96  {
97  bool first = true;
98  PixelEndcapName prev;
99  for (CIR ir = theROCs.begin(); ir < theROCs.end(); ir++) {
100  DetId detid = DetId(ir->rawId());
101  bool barrel = PixelModuleName::isBarrel(detid.rawId());
102  if (barrel)
103  continue;
104  PixelEndcapName tmp(detid);
105  PixelEndcapName curr(tmp.halfCylinder(), tmp.diskName(), tmp.bladeName(), tmp.pannelName());
106  if (first)
107  prev = curr;
108  if (!(curr == prev))
109  out << " MOD: " << prev.name() << std::endl;
110  if (ir == theROCs.end() - 1)
111  out << " MOD: " << curr.name() << std::endl;
112  }
113  }
114  return out.str();
115 }
uint16_t *__restrict__ id
unsigned int idInLink() const
id of this ROC in parent Link.
Definition: PixelROC.h:40
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
tuple result
Definition: mps_fire.py:311
int bladeName() const
blade id
std::string name() const override
from base class
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
T min(T a, T b)
Definition: MathUtil.h:58
virtual bool isBarrel() const
true for barrel modules
Definition: DetId.h:17
void add(std::map< std::string, TH1 * > &h, TH1 *hist)
std::string name() const override
from base class
int pannelName() const
pannel id
tuple cout
Definition: gather_cfg.py:144
int diskName() const
disk id
HalfCylinder halfCylinder() const
tmp
align.sh
Definition: createJobs.py:716