CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 {}
22 
24  etaMin(id.etaMin),etaMax(id.etaMax),phiMin(id.phiMin),phiMax(id.phiMax),subSys(id.subSys)
25 {}
26 
28 
29 bool CaloCellId::operator==(const CaloCellId& id) const {
30 
31  return (etaMin == id.etaMin && etaMax == id.etaMax && phiMin == id.phiMin && phiMax == id.phiMax && subSys == id.subSys) ? true : false ;
32 
33 }
34 
35 bool CaloCellId::isInCell(double thisEta, double thisPhi){
36 
37  double myPhi = thisPhi;
38 
39  bool itIs = false;
40  if ( myPhi < -1.*CLHEP::pi ) { myPhi = myPhi+CLHEP::twopi; }
41  else if ( myPhi > CLHEP::pi ) { myPhi = myPhi-CLHEP::twopi; }
42  if ( thisEta >= etaMin && thisEta < etaMax && myPhi >= phiMin && myPhi < phiMax ) { itIs = true; }
43  return itIs;
44 
45 }
46 
48 
49  double etaAve = 0.5*(etaMax+etaMin);
50  double theta = 2.*std::atan(std::exp(-1.*etaAve));
51  return theta;
52 
53 }
54 
55 std::ostream& operator<<(std::ostream& os, const CaloCellId& id) {
56  os << "Eta range = ["
57  << std::fixed << std::setw(7) << std::setfill(' ') << std::setprecision(4) << id.getEtaMin() << ","
58  << std::fixed << std::setw(7) << std::setfill(' ') << std::setprecision(4) << id.getEtaMax() << "], Phi range = ["
59  << std::fixed << std::setw(7) << std::setfill(' ') << std::setprecision(4) << id.getPhiMin() << ","
60  << std::fixed << std::setw(7) << std::setfill(' ') << std::setprecision(4) << id.getPhiMax() << "], subsystem = " << id.getSubSys();
61  return os;
62 }
63 
64 
double getThetaCell()
Definition: CaloCellId.cc:47
bool operator==(const CaloCellId &) const
Definition: CaloCellId.cc:29
Geom::Theta< T > theta() const
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:188
const Double_t pi
CaloCellId(double theEtaMin, double theEtaMax, double thePhiMin, double thePhiMax, System theSubSys)
Definition: CaloCellId.cc:19
virtual ~CaloCellId()
Definition: CaloCellId.cc:27
bool isInCell(double thisEta, double thisPhi)
Definition: CaloCellId.cc:35
double phiMin
Definition: CaloCellId.h:40
System subSys
Definition: CaloCellId.h:42
double phiMax
Definition: CaloCellId.h:41
volatile std::atomic< bool > shutdown_flag false
double etaMax
Definition: CaloCellId.h:39
double etaMin
Definition: CaloCellId.h:38