Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-11-18 03:07:25

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 std::ostream& reco::operator<<(std::ostream& out, const PFCluster& cluster) {
0064   if (!out)
0065     return out;
0066 
0067   const math::XYZPoint& pos = cluster.position();
0068   const PFCluster::REPPoint& posrep = cluster.positionREP();
0069   const std::vector<reco::PFRecHitFraction>& fracs = cluster.recHitFractions();
0070 
0071   out << "PFcluster "
0072       << ", layer: " << cluster.layer() << "\tE = " << cluster.energy() << "\tXYZ: " << pos.X() << "," << pos.Y() << ","
0073       << pos.Z() << " | "
0074       << "\tREP: " << posrep.Rho() << "," << posrep.Eta() << "," << posrep.Phi() << " | " << fracs.size() << " rechits";
0075 
0076   for (unsigned i = 0; i < fracs.size(); i++) {
0077     // PFRecHit is not available, print the detID
0078     if (!fracs[i].recHitRef().isAvailable())
0079       out << cluster.printHitAndFraction(i) << ", ";
0080     else
0081       out << fracs[i] << ", ";
0082   }
0083 
0084   return out;
0085 }