CMS 3D CMS Logo

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