Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
#include "DataFormats/ParticleFlowReco/interface/PFSuperCluster.h"
#include "DataFormats/GeometryVector/interface/Pi.h"
#include "DataFormats/Common/interface/PtrVector.h"

using namespace std;
using namespace reco;

PFSuperCluster::PFSuperCluster(const edm::PtrVector<reco::PFCluster>& clusters) : clusters_(clusters) {}

void PFSuperCluster::reset() {
  PFCluster::reset();
  clusters_.clear();
}

PFSuperCluster& PFSuperCluster::operator=(const PFSuperCluster& other) {
  PFCluster::operator=((PFCluster)other);
  clusters_ = other.clusters_;

  return *this;
}

std::ostream& reco::operator<<(std::ostream& out, const PFSuperCluster& cluster) {
  if (!out)
    return out;

  const math::XYZPoint& pos = cluster.position();
  const PFCluster::REPPoint& posrep = cluster.positionREP();
  const std::vector<reco::PFRecHitFraction>& fracs = cluster.recHitFractions();

  out << "PFSuperCluster "
      << ", clusters: " << cluster.clusters().size() << ", layer: " << cluster.layer() << "\tE = " << cluster.energy()
      << "\tXYZ: " << pos.X() << "," << pos.Y() << "," << pos.Z() << " | "
      << "\tREP: " << posrep.Rho() << "," << posrep.Eta() << "," << posrep.Phi() << " | " << fracs.size() << " rechits";

  for (unsigned i = 0; i < fracs.size(); i++) {
    // PFRecHit is not available, print the detID
    if (!fracs[i].recHitRef().isAvailable())
      out << cluster.printHitAndFraction(i) << ", ";
    else
      out << fracs[i] << ", ";
  }

  return out;
}