Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:22:34

0001 #include <iostream>
0002 #include <cstdlib>
0003 #include <cstdint>
0004 
0005 #include "UCTCrate.hh"
0006 #include "UCTCard.hh"
0007 #include "UCTGeometry.hh"
0008 #include "UCTLogging.hh"
0009 
0010 UCTCrate::UCTCrate(uint32_t crt, int fwv) : crate(crt), crateSummary(0), fwVersion(fwv) {
0011   UCTGeometry g;
0012   for (uint32_t card = 0; card < g.getNCards(); card++) {
0013     cards.push_back(new UCTCard(crate, card, fwVersion));
0014   }
0015 }
0016 
0017 UCTCrate::~UCTCrate() {
0018   for (uint32_t i = 0; i < cards.size(); i++) {
0019     if (cards[i] != nullptr)
0020       delete cards[i];
0021   }
0022 }
0023 
0024 bool UCTCrate::process() {
0025   crateSummary = 0;
0026   for (uint32_t i = 0; i < cards.size(); i++) {
0027     if (cards[i] != nullptr) {
0028       cards[i]->process();
0029       crateSummary += cards[i]->et();
0030     }
0031   }
0032   return true;
0033 }
0034 
0035 bool UCTCrate::clearEvent() {
0036   crateSummary = 0;
0037   for (uint32_t i = 0; i < cards.size(); i++) {
0038     if (!cards[i]->clearEvent())
0039       return false;
0040   }
0041   return true;
0042 }
0043 
0044 bool UCTCrate::setECALData(UCTTowerIndex t, bool ecalFG, uint32_t ecalET) {
0045   UCTGeometry g;
0046   uint32_t i = g.getCard(t.first, t.second);
0047   if (i > cards.size()) {
0048     LOG_ERROR << "UCTCrate: Incorrect (caloEta, caloPhi) -- bailing" << std::endl;
0049     exit(1);
0050   }
0051   return cards[i]->setECALData(t, ecalFG, ecalET);
0052 }
0053 
0054 bool UCTCrate::setHCALData(UCTTowerIndex t, uint32_t hcalFB, uint32_t hcalET) {
0055   UCTGeometry g;
0056   uint32_t i = g.getCard(t.first, t.second);
0057   if (i > cards.size()) {
0058     LOG_ERROR << "UCTCrate: Incorrect (caloEta, caloPhi) -- bailing" << std::endl;
0059     exit(1);
0060   }
0061   return cards[i]->setHCALData(t, hcalFB, hcalET);
0062 }
0063 
0064 const UCTCard* UCTCrate::getCard(UCTTowerIndex t) const {
0065   UCTGeometry g;
0066   uint32_t i = g.getCard(t.first, t.second);
0067   if (i > cards.size()) {
0068     LOG_ERROR << "UCTCrate: Incorrect (caloEta, caloPhi) -- bailing" << std::endl;
0069     exit(1);
0070   }
0071   return cards[i];
0072 }
0073 
0074 std::ostream& operator<<(std::ostream& os, const UCTCrate& cr) {
0075   if (cr.crateSummary > 0)
0076     os << "UCTCrate: crate = " << cr.crate << "; Summary = " << cr.crateSummary << std::endl;
0077   return os;
0078 }