File indexing completed on 2024-04-06 12:32:12
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "Validation/EventGenerator/interface/CaloCellId.h"
0010
0011 #include "CLHEP/Units/defs.h"
0012 #include "CLHEP/Units/PhysicalConstants.h"
0013 #include "CLHEP/Units/SystemOfUnits.h"
0014
0015 #include <iostream>
0016 #include <iomanip>
0017 #include <cmath>
0018
0019 CaloCellId::CaloCellId(double theEtaMin, double theEtaMax, double thePhiMin, double thePhiMax, System theSubSys)
0020 : etaMin(theEtaMin), etaMax(theEtaMax), phiMin(thePhiMin), phiMax(thePhiMax), subSys(theSubSys) {}
0021
0022 CaloCellId::CaloCellId(const CaloCellId& id)
0023 : etaMin(id.etaMin), etaMax(id.etaMax), phiMin(id.phiMin), phiMax(id.phiMax), subSys(id.subSys) {}
0024
0025 CaloCellId::~CaloCellId() {}
0026
0027 bool CaloCellId::operator==(const CaloCellId& id) const {
0028 return (etaMin == id.etaMin && etaMax == id.etaMax && phiMin == id.phiMin && phiMax == id.phiMax &&
0029 subSys == id.subSys)
0030 ? true
0031 : false;
0032 }
0033
0034 bool CaloCellId::isInCell(double thisEta, double thisPhi) {
0035 double myPhi = thisPhi;
0036
0037 bool itIs = false;
0038 if (myPhi < -1. * CLHEP::pi) {
0039 myPhi = myPhi + CLHEP::twopi;
0040 } else if (myPhi > CLHEP::pi) {
0041 myPhi = myPhi - CLHEP::twopi;
0042 }
0043 if (thisEta >= etaMin && thisEta < etaMax && myPhi >= phiMin && myPhi < phiMax) {
0044 itIs = true;
0045 }
0046 return itIs;
0047 }
0048
0049 double CaloCellId::getThetaCell() {
0050 double etaAve = 0.5 * (etaMax + etaMin);
0051 double theta = 2. * std::atan(std::exp(-1. * etaAve));
0052 return theta;
0053 }
0054
0055 std::ostream& operator<<(std::ostream& os, const CaloCellId& id) {
0056 os << "Eta range = [" << std::fixed << std::setw(7) << std::setfill(' ') << std::setprecision(4) << id.getEtaMin()
0057 << "," << std::fixed << std::setw(7) << std::setfill(' ') << std::setprecision(4) << id.getEtaMax()
0058 << "], Phi range = [" << std::fixed << std::setw(7) << std::setfill(' ') << std::setprecision(4) << id.getPhiMin()
0059 << "," << std::fixed << std::setw(7) << std::setfill(' ') << std::setprecision(4) << id.getPhiMax()
0060 << "], subsystem = " << id.getSubSys();
0061 return os;
0062 }