Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
#include "DataFormats/L1THGCal/interface/HGCalTower.h"
#include "FWCore/Utilities/interface/EDMException.h"

using l1t::HGCalTower;
using l1t::L1Candidate;

HGCalTower::HGCalTower(double etEm,
                       double etHad,
                       double eta,
                       double phi,
                       uint32_t id,
                       int hwpt,
                       int hweta,
                       int hwphi,
                       int qual,
                       int hwEtEm,
                       int hwEtHad,
                       int hwEtRatio)
    : L1Candidate(PolarLorentzVector(etEm + etHad, eta, phi, 0.), hwpt, hweta, hwphi, qual),
      etEm_(etEm),
      etHad_(etHad),
      id_(id),
      hwEtEm_(hwEtEm),
      hwEtHad_(hwEtHad),
      hwEtRatio_(hwEtRatio) {}

HGCalTower::~HGCalTower() {}

void HGCalTower::addEtEm(double et) {
  etEm_ += et;
  addEt(et);
}

void HGCalTower::addEtHad(double et) {
  etHad_ += et;
  addEt(et);
}

void HGCalTower::addEt(double et) { this->setP4(PolarLorentzVector(this->pt() + et, this->eta(), this->phi(), 0.)); }

const HGCalTower& HGCalTower::operator+=(const HGCalTower& tower) {
  // NOTE: assume same eta and phi -> need an explicit check on the ID
  if (id().rawId() != tower.id().rawId()) {
    throw edm::Exception(edm::errors::StdException, "StdException")
        << "HGCalTower: adding to this tower with ID: " << id().rawId()
        << " one with different ID: " << tower.id().rawId() << std::endl;
  }
  addEt(tower.pt());
  etEm_ += tower.etEm();
  etHad_ += tower.etHad();

  return *this;
}