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  * $Date: 2010/05/25 16:50:51 $
7  * $Revision: 1.1 $
8  *
9  */
10 
12 
13 #include "CLHEP/Units/defs.h"
14 #include "CLHEP/Units/PhysicalConstants.h"
15 #include "CLHEP/Units/SystemOfUnits.h"
16 
17 #include <iostream>
18 #include <iomanip>
19 #include <cmath>
20 
21 CaloCellId::CaloCellId( double theEtaMin, double theEtaMax, double thePhiMin, double thePhiMax, System theSubSys ):
22  etaMin(theEtaMin),etaMax(theEtaMax),phiMin(thePhiMin),phiMax(thePhiMax),subSys(theSubSys)
23 {}
24 
26  etaMin(id.etaMin),etaMax(id.etaMax),phiMin(id.phiMin),phiMax(id.phiMax),subSys(id.subSys)
27 {}
28 
30 
31 bool CaloCellId::operator==(const CaloCellId& id) const {
32 
33  return (etaMin == id.etaMin && etaMax == id.etaMax && phiMin == id.phiMin && phiMax == id.phiMax && subSys == id.subSys) ? true : false ;
34 
35 }
36 
37 bool CaloCellId::isInCell(double thisEta, double thisPhi){
38 
39  double myPhi = thisPhi;
40 
41  bool itIs = false;
42  if ( myPhi < -1.*CLHEP::pi ) { myPhi = myPhi+CLHEP::twopi; }
43  else if ( myPhi > CLHEP::pi ) { myPhi = myPhi-CLHEP::twopi; }
44  if ( thisEta >= etaMin && thisEta < etaMax && myPhi >= phiMin && myPhi < phiMax ) { itIs = true; }
45  return itIs;
46 
47 }
48 
50 
51  double etaAve = 0.5*(etaMax+etaMin);
52  double theta = 2.*std::atan(std::exp(-1.*etaAve));
53  return theta;
54 
55 }
56 
57 std::ostream& operator<<(std::ostream& os, const CaloCellId& id) {
58  os << "Eta range = ["
59  << std::fixed << std::setw(7) << std::setfill(' ') << std::setprecision(4) << id.getEtaMin() << ","
60  << std::fixed << std::setw(7) << std::setfill(' ') << std::setprecision(4) << id.getEtaMax() << "], Phi range = ["
61  << std::fixed << std::setw(7) << std::setfill(' ') << std::setprecision(4) << id.getPhiMin() << ","
62  << std::fixed << std::setw(7) << std::setfill(' ') << std::setprecision(4) << id.getPhiMax() << "], subsystem = " << id.getSubSys();
63  return os;
64 }
65 
66 
double getThetaCell()
Definition: CaloCellId.cc:49
bool operator==(const CaloCellId &) const
Definition: CaloCellId.cc:31
Geom::Theta< T > theta() const
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
CaloCellId(double theEtaMin, double theEtaMax, double thePhiMin, double thePhiMax, System theSubSys)
Definition: CaloCellId.cc:21
virtual ~CaloCellId()
Definition: CaloCellId.cc:29
bool isInCell(double thisEta, double thisPhi)
Definition: CaloCellId.cc:37
double phiMin
Definition: CaloCellId.h:42
System subSys
Definition: CaloCellId.h:44
double phiMax
Definition: CaloCellId.h:43
double pi
double etaMax
Definition: CaloCellId.h:41
double etaMin
Definition: CaloCellId.h:40