CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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) :
11  crate(crt),
12  card(crd),
13  cardSummary(0) {
14  UCTGeometry g;
15  regions.reserve(2*g.getNRegions());
16  for(uint32_t rgn = 0; rgn < g.getNRegions(); rgn++) {
17  // Negative eta side
18  regions.push_back(new UCTRegion(crate, card, true, rgn));
19  // Positive eta side
20  regions.push_back(new UCTRegion(crate, card, false, rgn));
21  }
22 }
23 
24 UCTCard::~UCTCard() {
25  for(uint32_t i = 0; i < regions.size(); i++) {
26  if(regions[i] != 0) delete regions[i];
27  }
28 }
29 
30 bool UCTCard::process() {
31  cardSummary = 0;
32  for(uint32_t i = 0; i < regions.size(); i++) {
33  if(regions[i] != 0) regions[i]->process();
34  cardSummary += regions[i]->et();
35  }
36  return true;
37 }
38 
39 bool UCTCard::clearEvent() {
40  cardSummary = 0;
41  for(uint32_t i = 0; i < regions.size(); i++) {
42  if(!regions[i]->clearEvent()) 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 = abs(t.first);
50  uint32_t absCaloPhi = abs(t.second);
51  bool negativeEta = false;
52  if(t.first < 0) negativeEta = true;
53  uint32_t i = g.getRegion(absCaloEta, absCaloPhi) * 2;
54  if(!negativeEta) i++;
55  if(i > regions.size()) {
56  LOG_ERROR << "UCTCard: Incorrect region requested -- bailing" << std::endl;
57  exit(1);
58  }
59  return regions[i]->setECALData(t, ecalFG, ecalET);
60 }
61 
62 bool UCTCard::setHCALData(UCTTowerIndex t, uint32_t hcalFB, uint32_t hcalET) {
63  UCTGeometry g;
64  uint32_t absCaloEta = abs(t.first);
65  uint32_t absCaloPhi = abs(t.second);
66  bool negativeEta = false;
67  if(t.first < 0) negativeEta = true;
68  uint32_t i = g.getRegion(absCaloEta, absCaloPhi) * 2;
69  if(!negativeEta) i++;
70  if(i > regions.size()) {
71  LOG_ERROR << "UCTCard: Incorrect region requested -- bailing" << std::endl;
72  exit(1);
73  }
74  return regions[i]->setHCALData(t, hcalFB, hcalET);
75 }
76 
77 const UCTRegion* UCTCard::getRegion(UCTRegionIndex r) const {
78  UCTGeometry g;
79  UCTTowerIndex t = g.getUCTTowerIndex(r);
80  uint32_t absCaloEta = std::abs(t.first);
81  uint32_t absCaloPhi = std::abs(t.second);
82  bool negativeEta = false;
83  if(t.first < 0) negativeEta = true;
84  return getRegion(negativeEta, absCaloEta, absCaloPhi);
85 }
86 
87 const UCTRegion* UCTCard::getRegion(bool nE, uint32_t cEta, uint32_t cPhi) const {
88  UCTGeometry g;
89  uint32_t i = g.getRegion(cEta, cPhi) * 2;
90  if(!nE) i++;
91  if(i > regions.size()) {
92  LOG_ERROR << "UCTCard: Incorrect region requested -- bailing" << std::endl;
93  exit(1);
94  }
95  return regions[i];
96 }
97 
98 std::ostream& operator<<(std::ostream& os, const UCTCard& c) {
99  if(c.cardSummary > 0)
100  os << "UCTCard: card = " << c.card << "; Summary = " << c.cardSummary << std::endl;
101  return os;
102 }
int i
Definition: DBlmapReader.cc:9
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
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:41