CMS 3D CMS Logo

CaloCellId.cc
Go to the documentation of this file.
1 /* class CaloCellId
2  *
3  * Simple eta-phi cell identifier, mimic calorimetric tower structure
4  * phi is stored in radians
5  *
6  *
7  */
8 
10 
11 #include "CLHEP/Units/defs.h"
12 #include "CLHEP/Units/PhysicalConstants.h"
13 #include "CLHEP/Units/SystemOfUnits.h"
14 
15 #include <iostream>
16 #include <iomanip>
17 #include <cmath>
18 
19 CaloCellId::CaloCellId(double theEtaMin, double theEtaMax, double thePhiMin, double thePhiMax, System theSubSys)
20  : etaMin(theEtaMin), etaMax(theEtaMax), phiMin(thePhiMin), phiMax(thePhiMax), subSys(theSubSys) {}
21 
23  : etaMin(id.etaMin), etaMax(id.etaMax), phiMin(id.phiMin), phiMax(id.phiMax), subSys(id.subSys) {}
24 
26 
27 bool CaloCellId::operator==(const CaloCellId& id) const {
28  return (etaMin == id.etaMin && etaMax == id.etaMax && phiMin == id.phiMin && phiMax == id.phiMax &&
29  subSys == id.subSys)
30  ? true
31  : false;
32 }
33 
34 bool CaloCellId::isInCell(double thisEta, double thisPhi) {
35  double myPhi = thisPhi;
36 
37  bool itIs = false;
38  if (myPhi < -1. * CLHEP::pi) {
39  myPhi = myPhi + CLHEP::twopi;
40  } else if (myPhi > CLHEP::pi) {
41  myPhi = myPhi - CLHEP::twopi;
42  }
43  if (thisEta >= etaMin && thisEta < etaMax && myPhi >= phiMin && myPhi < phiMax) {
44  itIs = true;
45  }
46  return itIs;
47 }
48 
50  double etaAve = 0.5 * (etaMax + etaMin);
51  double theta = 2. * std::atan(std::exp(-1. * etaAve));
52  return theta;
53 }
54 
55 std::ostream& operator<<(std::ostream& os, const CaloCellId& id) {
56  os << "Eta range = [" << std::fixed << std::setw(7) << std::setfill(' ') << std::setprecision(4) << id.getEtaMin()
57  << "," << std::fixed << std::setw(7) << std::setfill(' ') << std::setprecision(4) << id.getEtaMax()
58  << "], Phi range = [" << std::fixed << std::setw(7) << std::setfill(' ') << std::setprecision(4) << id.getPhiMin()
59  << "," << std::fixed << std::setw(7) << std::setfill(' ') << std::setprecision(4) << id.getPhiMax()
60  << "], subsystem = " << id.getSubSys();
61  return os;
62 }
double getThetaCell()
Definition: CaloCellId.cc:49
std::ostream & operator<<(std::ostream &os, const CaloCellId &id)
Definition: CaloCellId.cc:55
bool operator==(const CaloCellId &) const
Definition: CaloCellId.cc:27
Geom::Theta< T > theta() const
const Double_t pi
CaloCellId(double theEtaMin, double theEtaMax, double thePhiMin, double thePhiMax, System theSubSys)
Definition: CaloCellId.cc:19
virtual ~CaloCellId()
Definition: CaloCellId.cc:25
bool isInCell(double thisEta, double thisPhi)
Definition: CaloCellId.cc:34
double phiMin
Definition: CaloCellId.h:37
System subSys
Definition: CaloCellId.h:39
double phiMax
Definition: CaloCellId.h:38
double etaMax
Definition: CaloCellId.h:36
double etaMin
Definition: CaloCellId.h:35