Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:54:17

0001 #include "DataFormats/ParticleFlowReco/interface/PFCluster.h"
0002 
0003 #include "Math/GenVector/etaMax.h"
0004 
0005 using namespace std;
0006 using namespace reco;
0007 
0008 const math::XYZPoint PFCluster::dummyVtx_(0, 0, 0);
0009 
0010 PFCluster::PFCluster(PFLayer::Layer layer, double energy, double x, double y, double z)
0011     : CaloCluster(energy, math::XYZPoint(x, y, z), PFLayer::toCaloID(layer), CaloCluster::particleFlow),
0012       posrep_(position_.Rho(), position_.Eta(), position_.Phi()),
0013       time_(-99.),
0014       depth_(0.),
0015       layer_(layer) {}
0016 
0017 void PFCluster::reset() {
0018   energy_ = 0;
0019   position_ *= 0;
0020   posrep_ *= 0;
0021   time_ = -99.;
0022   layer_ = PFLayer::NONE;
0023   rechits_.clear();
0024 
0025   CaloCluster::reset();
0026 }
0027 
0028 void PFCluster::resetHitsAndFractions() {
0029   rechits_.clear();
0030   hitsAndFractions_.clear();
0031 }
0032 
0033 void PFCluster::addRecHitFraction(const reco::PFRecHitFraction& frac) {
0034   rechits_.push_back(frac);
0035 
0036   addHitAndFraction(frac.recHitRef()->detId(), frac.fraction());
0037 }
0038 
0039 double PFCluster::getDepthCorrection(double energy, bool isBelowPS, bool isHadron) {
0040   double corrA = depthCorA_;
0041   double corrB = depthCorB_;
0042   if (isBelowPS) {
0043     corrA = depthCorAp_;
0044     corrB = depthCorBp_;
0045   }
0046   return isHadron ? corrA : corrA * (corrB + log(energy));
0047 }
0048 
0049 void PFCluster::setLayer(PFLayer::Layer layer) {
0050   // cout<<"calling PFCluster::setLayer "<<layer<<endl;
0051   layer_ = layer;
0052   caloID_ = PFLayer::toCaloID(layer);
0053   // cout<<"done "<<caloID_<<endl;
0054 }
0055 
0056 PFLayer::Layer PFCluster::layer() const {
0057   // cout<<"calling PFCluster::layer "<<caloID()<<" "<<PFLayer::fromCaloID( caloID() )<<endl;
0058   if (layer_ != PFLayer::NONE)
0059     return layer_;
0060   return PFLayer::fromCaloID(caloID());
0061 }
0062 
0063 PFCluster& PFCluster::operator=(const PFCluster& other) {
0064   CaloCluster::operator=(other);
0065   rechits_ = other.rechits_;
0066   energy_ = other.energy_;
0067   position_ = other.position_;
0068   posrep_ = other.posrep_;
0069 
0070   return *this;
0071 }
0072 
0073 std::ostream& reco::operator<<(std::ostream& out, const PFCluster& cluster) {
0074   if (!out)
0075     return out;
0076 
0077   const math::XYZPoint& pos = cluster.position();
0078   const PFCluster::REPPoint& posrep = cluster.positionREP();
0079   const std::vector<reco::PFRecHitFraction>& fracs = cluster.recHitFractions();
0080 
0081   out << "PFcluster "
0082       << ", layer: " << cluster.layer() << "\tE = " << cluster.energy() << "\tXYZ: " << pos.X() << "," << pos.Y() << ","
0083       << pos.Z() << " | "
0084       << "\tREP: " << posrep.Rho() << "," << posrep.Eta() << "," << posrep.Phi() << " | " << fracs.size() << " rechits";
0085 
0086   for (unsigned i = 0; i < fracs.size(); i++) {
0087     // PFRecHit is not available, print the detID
0088     if (!fracs[i].recHitRef().isAvailable())
0089       out << cluster.printHitAndFraction(i) << ", ";
0090     else
0091       out << fracs[i] << ", ";
0092   }
0093 
0094   return out;
0095 }