Go to the documentation of this file.00001 #include "RecoParticleFlow/PFClusterTools/interface/SpaceVoxel.h"
00002 #include <iostream>
00003 #include "RecoParticleFlow/PFClusterTools/interface/ToString.h"
00004 using namespace pftools;
00005
00006 SpaceVoxel::SpaceVoxel(double etaBegin, double etaEnd, double phiBegin,
00007 double phiEnd, double energyBegin, double energyEnd, bool ecalValid, bool hcalValid) :
00008 myEtaMin(etaBegin), myEtaMax(etaEnd), myPhiMin(phiBegin), myPhiMax(phiEnd),
00009 myEnergyMin(energyBegin), myEnergyMax(energyEnd),
00010 ecalValid_(ecalValid), hcalValid_(hcalValid) {
00011 if (!ecalValid_ && !hcalValid_) {
00012
00013 std::cout << __PRETTY_FUNCTION__
00014 << ": WARNING! Constructed with both ecalValid and hcalValid = false!"
00015 << std::endl;
00016 }
00017 }
00018
00019 SpaceVoxel::~SpaceVoxel() {
00020 }
00021
00022 bool SpaceVoxel::contains(const double& eta, const double& phi,
00023 const double& energy) const {
00024 if (containsEta(eta) && containsPhi(phi) && containsEnergy(energy))
00025 return true;
00026 return false;
00027 }
00028
00029 bool SpaceVoxel::contains(const double& eta, const double& phi,
00030 const double& energy, const bool& ecalValid, const bool& hcalValid) const {
00031 if (contains(eta, phi, energy) && ecalValid == ecalValid_ && hcalValid
00032 == hcalValid_)
00033 return true;
00034 return false;
00035 }
00036
00037 bool SpaceVoxel::containsEta(const double& eta) const {
00038 if (myEtaMin == myEtaMax)
00039 return true;
00040 if (eta < myEtaMax && eta >= myEtaMin)
00041 return true;
00042
00043 return false;
00044 }
00045
00046 bool SpaceVoxel::containsPhi(const double& phi) const {
00047 if (myPhiMin == myPhiMax)
00048 return true;
00049 if (phi < myPhiMax && phi >= myPhiMin)
00050 return true;
00051
00052 return false;
00053
00054 }
00055
00056 bool SpaceVoxel::containsEnergy(const double& energy) const {
00057 if (myEnergyMin == myEnergyMax)
00058 return true;
00059 if (energy < myEnergyMax && energy >= myEnergyMin)
00060 return true;
00061
00062 return false;
00063 }
00064
00065 void SpaceVoxel::print(std::ostream& s) const {
00066 s << "SpaceVoxel: ";
00067 if (ecalValid_)
00068 s << "E";
00069 if (hcalValid_)
00070 s << "H, ";
00071 s << "eta: ["<< myEtaMin << ", "<< myEtaMax << "]\t phi: ["<< myPhiMin
00072 << ". "<< myPhiMax << "]\t energy: ["<< myEnergyMin<< ", "
00073 << myEnergyMax << "]";
00074 }
00075
00076 void SpaceVoxel::getName(std::string& s) const {
00077 s.append("SpaceVoxel: ");
00078 if (ecalValid_)
00079 s.append("E");
00080 if (hcalValid_)
00081 s.append("H");
00082 s.append(", eta: [");
00083 s.append(toString(myEtaMin));
00084 s.append(", ");
00085 s.append(toString(myEtaMax));
00086 s.append("] phi: [");
00087 s.append(toString(myPhiMin));
00088 s.append(", ");
00089 s.append(toString(myPhiMax));
00090 s.append("], en: [");
00091 s.append(toString(myEnergyMin));
00092 s.append(", ");
00093 s.append(toString(myEnergyMax));
00094 s.append("]");
00095 }
00096
00097 bool SpaceVoxel::operator()(const SpaceVoxel& sv1, const SpaceVoxel& sv2) {
00098 if(sv1.minEnergy() < sv2.maxEnergy())
00099 return true;
00100
00101 return false;
00102 }
00103
00104 bool SpaceVoxel::operator()(const SpaceVoxelPtr& svp1, const SpaceVoxelPtr& svp2) {
00105 SpaceVoxel sv1 = *svp1;
00106 SpaceVoxel sv2 = *svp2;
00107 if(sv1.minEnergy() < sv2.maxEnergy())
00108 return true;
00109
00110 return false;
00111 }
00112
00113 std::ostream& pftools::operator<<(std::ostream& s, const pftools::SpaceVoxel& sv) {
00114 sv.print(s);
00115 return s;
00116 }