CMS 3D CMS Logo

UCTCard.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <stdlib.h>
3 #include <stdint.h>
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) :
11  crate(crt),
12  card(crd),
13  cardSummary(0),
14  fwVersion(fwv) {
15  UCTGeometry g;
16  regions.reserve(2*g.getNRegions());
17  for(uint32_t rgn = 0; rgn < g.getNRegions(); rgn++) {
18  // Negative eta side
19  regions.push_back(new UCTRegion(crate, card, true, rgn, fwVersion));
20  // Positive eta side
21  regions.push_back(new UCTRegion(crate, card, false, rgn, fwVersion));
22  }
23 }
24 
25 UCTCard::~UCTCard() {
26  for(uint32_t i = 0; i < regions.size(); i++) {
27  if(regions[i] != 0) delete regions[i];
28  }
29 }
30 
31 bool UCTCard::process() {
32  cardSummary = 0;
33  for(uint32_t i = 0; i < regions.size(); i++) {
34  if(regions[i] != 0) regions[i]->process();
35  cardSummary += regions[i]->et();
36  }
37  return true;
38 }
39 
40 bool UCTCard::clearEvent() {
41  cardSummary = 0;
42  for(uint32_t i = 0; i < regions.size(); i++) {
43  if(!regions[i]->clearEvent()) return false;
44  }
45  return true;
46 }
47 
48 bool UCTCard::setECALData(UCTTowerIndex t, bool ecalFG, uint32_t ecalET) {
49  UCTGeometry g;
50  uint32_t absCaloEta = std::abs(t.first);
51  uint32_t absCaloPhi = std::abs(t.second);
52  bool negativeEta = false;
53  if(t.first < 0) negativeEta = true;
54  uint32_t i = g.getRegion(absCaloEta, absCaloPhi) * 2;
55  if(!negativeEta) i++;
56  if(i > regions.size()) {
57  LOG_ERROR << "UCTCard: Incorrect region requested -- bailing" << std::endl;
58  exit(1);
59  }
60  return regions[i]->setECALData(t, ecalFG, ecalET);
61 }
62 
63 bool UCTCard::setHCALData(UCTTowerIndex t, uint32_t hcalFB, uint32_t hcalET) {
64  UCTGeometry g;
65  uint32_t absCaloEta = std::abs(t.first);
66  uint32_t absCaloPhi = std::abs(t.second);
67  bool negativeEta = false;
68  if(t.first < 0) negativeEta = true;
69  uint32_t i = g.getRegion(absCaloEta, absCaloPhi) * 2;
70  if(!negativeEta) i++;
71  if(i > regions.size()) {
72  LOG_ERROR << "UCTCard: Incorrect region requested -- bailing" << std::endl;
73  exit(1);
74  }
75  return regions[i]->setHCALData(t, hcalFB, hcalET);
76 }
77 
78 const UCTRegion* UCTCard::getRegion(UCTRegionIndex r) const {
79  UCTGeometry g;
80  UCTTowerIndex t = g.getUCTTowerIndex(r);
81  uint32_t absCaloEta = std::abs(t.first);
82  uint32_t absCaloPhi = std::abs(t.second);
83  bool negativeEta = false;
84  if(t.first < 0) negativeEta = true;
85  return getRegion(negativeEta, absCaloEta, absCaloPhi);
86 }
87 
88 const UCTRegion* UCTCard::getRegion(bool nE, uint32_t cEta, uint32_t cPhi) const {
89  UCTGeometry g;
90  uint32_t i = g.getRegion(cEta, cPhi) * 2;
91  if(!nE) i++;
92  if(i > regions.size()) {
93  LOG_ERROR << "UCTCard: Incorrect region requested -- bailing" << std::endl;
94  exit(1);
95  }
96  return regions[i];
97 }
98 
99 std::ostream& operator<<(std::ostream& os, const UCTCard& c) {
100  if(c.cardSummary > 0)
101  os << "UCTCard: card = " << c.card << "; Summary = " << c.cardSummary << std::endl;
102  return os;
103 }
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
std::ostream & operator<<(std::ostream &os, const UCTCard &c)
Definition: UCTCard.cc:99
#define LOG_ERROR
Definition: CSCDQM_Logger.h:41