CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
UCTCard.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <cstdlib>
3 #include <cstdint>
4 
5 #include "UCTCard.hh"
6 #include "UCTRegion.hh"
7 #include "UCTGeometry.hh"
8 #include "UCTLogging.hh"
9 
10 UCTCard::UCTCard(uint32_t crt, uint32_t crd, int fwv) : crate(crt), card(crd), cardSummary(0), fwVersion(fwv) {
11  UCTGeometry g;
12  regions.reserve(2 * g.getNRegions());
13  for (uint32_t rgn = 0; rgn < g.getNRegions(); rgn++) {
14  // Negative eta side
15  regions.push_back(new UCTRegion(crate, card, true, rgn, fwVersion));
16  // Positive eta side
17  regions.push_back(new UCTRegion(crate, card, false, rgn, fwVersion));
18  }
19 }
20 
21 UCTCard::~UCTCard() {
22  for (uint32_t i = 0; i < regions.size(); i++) {
23  if (regions[i] != nullptr)
24  delete regions[i];
25  }
26 }
27 
28 bool UCTCard::process() {
29  cardSummary = 0;
30  for (uint32_t i = 0; i < regions.size(); i++) {
31  if (regions[i] != nullptr)
32  regions[i]->process();
33  cardSummary += regions[i]->et();
34  }
35  return true;
36 }
37 
38 bool UCTCard::clearEvent() {
39  cardSummary = 0;
40  for (uint32_t i = 0; i < regions.size(); i++) {
41  if (!regions[i]->clearEvent())
42  return false;
43  }
44  return true;
45 }
46 
47 bool UCTCard::setECALData(UCTTowerIndex t, bool ecalFG, uint32_t ecalET) {
48  UCTGeometry g;
49  uint32_t absCaloEta = std::abs(t.first);
50  uint32_t absCaloPhi = std::abs(t.second);
51  bool negativeEta = false;
52  if (t.first < 0)
53  negativeEta = true;
54  uint32_t i = g.getRegion(absCaloEta, absCaloPhi) * 2;
55  if (!negativeEta)
56  i++;
57  if (i > regions.size()) {
58  LOG_ERROR << "UCTCard: Incorrect region requested -- bailing" << std::endl;
59  exit(1);
60  }
61  return regions[i]->setECALData(t, ecalFG, ecalET);
62 }
63 
64 bool UCTCard::setHCALData(UCTTowerIndex t, uint32_t hcalFB, uint32_t hcalET) {
65  UCTGeometry g;
66  uint32_t absCaloEta = std::abs(t.first);
67  uint32_t absCaloPhi = std::abs(t.second);
68  bool negativeEta = false;
69  if (t.first < 0)
70  negativeEta = true;
71  uint32_t i = g.getRegion(absCaloEta, absCaloPhi) * 2;
72  if (!negativeEta)
73  i++;
74  if (i > regions.size()) {
75  LOG_ERROR << "UCTCard: Incorrect region requested -- bailing" << std::endl;
76  exit(1);
77  }
78  return regions[i]->setHCALData(t, hcalFB, hcalET);
79 }
80 
81 const UCTRegion* UCTCard::getRegion(UCTRegionIndex r) const {
82  UCTGeometry g;
83  UCTTowerIndex t = g.getUCTTowerIndex(r);
84  uint32_t absCaloEta = std::abs(t.first);
85  uint32_t absCaloPhi = std::abs(t.second);
86  bool negativeEta = false;
87  if (t.first < 0)
88  negativeEta = true;
89  return getRegion(negativeEta, absCaloEta, absCaloPhi);
90 }
91 
92 const UCTRegion* UCTCard::getRegion(bool nE, uint32_t cEta, uint32_t cPhi) const {
93  UCTGeometry g;
94  uint32_t i = g.getRegion(cEta, cPhi) * 2;
95  if (!nE)
96  i++;
97  if (i > regions.size()) {
98  LOG_ERROR << "UCTCard: Incorrect region requested -- bailing" << std::endl;
99  exit(1);
100  }
101  return regions[i];
102 }
103 
104 std::ostream& operator<<(std::ostream& os, const UCTCard& c) {
105  if (c.cardSummary > 0)
106  os << "UCTCard: card = " << c.card << "; Summary = " << c.cardSummary << std::endl;
107  return os;
108 }
const edm::EventSetup & c
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:167
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
tuple process
Definition: LaserDQM_cfg.py:3
#define LOG_ERROR
Definition: CSCDQM_Logger.h:40