File indexing completed on 2024-04-06 12:03:48
0001 #include "DataFormats/CaloRecHit/interface/CaloCluster.h"
0002
0003 #include <sstream>
0004 #include <iostream>
0005
0006 using namespace std;
0007 using namespace reco;
0008
0009 void CaloCluster::reset() {
0010 position_ = math::XYZPoint();
0011 energy_ = 0;
0012 hitsAndFractions_.clear();
0013 }
0014
0015 string CaloCluster::printHitAndFraction(unsigned i) const {
0016 ostringstream out;
0017 if (i >= hitsAndFractions().size())
0018 out << "out of range " << i;
0019 else
0020 out << "( " << hitsAndFractions()[i].first << ", " << hitsAndFractions()[i].second << " )";
0021 return out.str();
0022 }
0023
0024 std::ostream& reco::operator<<(std::ostream& out, const CaloCluster& cluster) {
0025 if (!out)
0026 return out;
0027
0028 const math::XYZPoint& pos = cluster.position();
0029
0030 out << "CaloCluster , algoID=" << cluster.algoID() << ", " << cluster.caloID() << ", E=" << cluster.energy();
0031 if (cluster.correctedEnergy() != -1.0) {
0032 out << ", E_corr=" << cluster.correctedEnergy();
0033 }
0034 out << ", eta,phi=" << pos.eta() << "," << pos.phi() << ", nhits=" << cluster.hitsAndFractions().size() << endl;
0035 for (unsigned i = 0; i < cluster.hitsAndFractions().size(); i++) {
0036 out << "" << cluster.printHitAndFraction(i) << ", ";
0037 }
0038
0039 return out;
0040 }