CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SpaceVoxel.cc
Go to the documentation of this file.
2 #include <iostream>
4 using namespace pftools;
5 
6 SpaceVoxel::SpaceVoxel(double etaBegin, double etaEnd, double phiBegin,
7  double phiEnd, double energyBegin, double energyEnd, bool ecalValid, bool hcalValid) :
8  myEtaMin(etaBegin), myEtaMax(etaEnd), myPhiMin(phiBegin), myPhiMax(phiEnd),
9  myEnergyMin(energyBegin), myEnergyMax(energyEnd),
10  ecalValid_(ecalValid), hcalValid_(hcalValid) {
11  if (!ecalValid_ && !hcalValid_) {
12  //erm, it has to be valid for one of them at least!
13  std::cout << __PRETTY_FUNCTION__
14  << ": WARNING! Constructed with both ecalValid and hcalValid = false!"
15  << std::endl;
16  }
17 }
18 
20 }
21 
22 bool SpaceVoxel::contains(const double& eta, const double& phi,
23  const double& energy) const {
24  if (containsEta(eta) && containsPhi(phi) && containsEnergy(energy))
25  return true;
26  return false;
27 }
28 
29 bool SpaceVoxel::contains(const double& eta, const double& phi,
30  const double& energy, const bool& ecalValid, const bool& hcalValid) const {
31  if (contains(eta, phi, energy) && ecalValid == ecalValid_ && hcalValid
32  == hcalValid_)
33  return true;
34  return false;
35 }
36 
37 bool SpaceVoxel::containsEta(const double& eta) const {
38  if (myEtaMin == myEtaMax)
39  return true;
40  if (eta < myEtaMax && eta >= myEtaMin)
41  return true;
42  //::cout << "\teta fails!\n";
43  return false;
44 }
45 
46 bool SpaceVoxel::containsPhi(const double& phi) const {
47  if (myPhiMin == myPhiMax)
48  return true;
49  if (phi < myPhiMax && phi >= myPhiMin)
50  return true;
51  //std::cout << "\tphi fails!\n";
52  return false;
53 
54 }
55 
56 bool SpaceVoxel::containsEnergy(const double& energy) const {
57  if (myEnergyMin == myEnergyMax)
58  return true;
59  if (energy < myEnergyMax && energy >= myEnergyMin)
60  return true;
61  //std::cout << "\tenergy fails!: input " << energy << " not in " << myEnergyMin << ", " << myEnergyMax <<"\n";
62  return false;
63 }
64 
65 void SpaceVoxel::print(std::ostream& s) const {
66  s << "SpaceVoxel: ";
67  if (ecalValid_)
68  s << "E";
69  if (hcalValid_)
70  s << "H, ";
71  s << "eta: ["<< myEtaMin << ", "<< myEtaMax << "]\t phi: ["<< myPhiMin
72  << ". "<< myPhiMax << "]\t energy: ["<< myEnergyMin<< ", "
73  << myEnergyMax << "]";
74 }
75 
77  s.append("SpaceVoxel: ");
78  if (ecalValid_)
79  s.append("E");
80  if (hcalValid_)
81  s.append("H");
82  s.append(", eta: [");
83  s.append(toString(myEtaMin));
84  s.append(", ");
85  s.append(toString(myEtaMax));
86  s.append("] phi: [");
87  s.append(toString(myPhiMin));
88  s.append(", ");
89  s.append(toString(myPhiMax));
90  s.append("], en: [");
91  s.append(toString(myEnergyMin));
92  s.append(", ");
93  s.append(toString(myEnergyMax));
94  s.append("]");
95 }
96 
97 bool SpaceVoxel::operator()(const SpaceVoxel& sv1, const SpaceVoxel& sv2) {
98  if(sv1.minEnergy() < sv2.maxEnergy())
99  return true;
100 
101  return false;
102 }
103 
104 bool SpaceVoxel::operator()(const SpaceVoxelPtr& svp1, const SpaceVoxelPtr& svp2) {
105  SpaceVoxel sv1 = *svp1;
106  SpaceVoxel sv2 = *svp2;
107  if(sv1.minEnergy() < sv2.maxEnergy())
108  return true;
109 
110  return false;
111 }
112 
113 std::ostream& pftools::operator<<(std::ostream& s, const pftools::SpaceVoxel& sv) {
114  sv.print(s);
115  return s;
116 }
bool operator()(const SpaceVoxel &sv1, const SpaceVoxel &sv2)
Definition: SpaceVoxel.cc:97
virtual bool containsPhi(const double &phi) const
Definition: SpaceVoxel.cc:46
A multi-dimensional volume element to subdivide the detector into different calibration regions...
Definition: SpaceVoxel.h:15
T eta() const
SpaceVoxel(double etaBegin=0, double etaEnd=0, double phiBegin=0, double phiEnd=0, double energyBegin=0, double energyEnd=0, bool ecalValid=true, bool hcalValid=true)
Definition: SpaceVoxel.cc:6
void print(std::ostream &s) const
Definition: SpaceVoxel.cc:65
void getName(std::string &s) const
Definition: SpaceVoxel.cc:76
virtual ~SpaceVoxel()
Definition: SpaceVoxel.cc:19
std::string toString(const std::pair< T, T > &aT)
Definition: CaloEllipse.h:72
double maxEnergy() const
Definition: SpaceVoxel.h:47
virtual bool containsEta(const double &eta) const
Definition: SpaceVoxel.cc:37
double minEnergy() const
Definition: SpaceVoxel.h:43
tuple cout
Definition: gather_cfg.py:121
std::ostream & operator<<(std::ostream &s, const Calibratable &calib_)
Definition: Calibratable.cc:6
virtual bool contains(const double &eta, const double &phi, const double &energy) const
Definition: SpaceVoxel.cc:22
virtual bool containsEnergy(const double &energy) const
Definition: SpaceVoxel.cc:56
boost::shared_ptr< SpaceVoxel > SpaceVoxelPtr
Definition: SpaceVoxel.h:89
Definition: DDAxes.h:10