CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch1/src/DataFormats/ParticleFlowReco/src/PFCluster.cc

Go to the documentation of this file.
00001 #include "DataFormats/ParticleFlowReco/interface/PFCluster.h"
00002 #include "DataFormats/ParticleFlowReco/interface/PFRecHit.h"
00003 
00004 using namespace std;
00005 using namespace reco;
00006 
00007 
00008 int    PFCluster::depthCorMode_ = 0;
00009 double PFCluster::depthCorA_ = 0.89;
00010 double PFCluster::depthCorB_ = 7.3;
00011 double PFCluster::depthCorAp_ = 0.89;
00012 double PFCluster::depthCorBp_ = 4.0;
00013 
00014 unsigned PFCluster::instanceCounter_ = 0;
00015 
00016 PFCluster::PFCluster(PFLayer::Layer layer, double energy,
00017                      double x, double y, double z ) : 
00018   CaloCluster( energy, 
00019                math::XYZPoint(x,y,z), 
00020                PFLayer::toCaloID(layer),
00021                CaloCluster::particleFlow ),
00022   posrep_( position_.Rho(), position_.Eta(), position_.Phi() ),
00023   color_(2)
00024 {  }
00025   
00026 
00027 void PFCluster::reset() {
00028   
00029   energy_ = 0;
00030   position_ *= 0;
00031   posrep_ *= 0;
00032   
00033   rechits_.clear();
00034 
00035   CaloCluster::reset();
00036   
00037 }
00038 
00039 
00040 void PFCluster::addRecHitFraction( const reco::PFRecHitFraction& frac ) {
00041 
00042   rechits_.push_back( frac );
00043 
00044   addHitAndFraction( frac.recHitRef()->detId(), 
00045                      frac.fraction() );
00046 }
00047 
00048 
00049 double PFCluster::getDepthCorrection(double energy, bool isBelowPS,
00050                                      bool isHadron)
00051 {
00052   double corrA = depthCorA_;
00053   double corrB = depthCorB_;
00054   if (isBelowPS) {
00055     corrA = depthCorAp_;
00056     corrB = depthCorBp_;
00057   }
00058   double depth = 0;
00059   switch(isHadron) {
00060   case 0: // e/gamma
00061     depth = corrA*(corrB + log(energy)); 
00062     break;
00063   case 1: // hadrons
00064     depth = corrA;
00065     break;
00066   default:
00067     assert(0);
00068     //     edm::LogError("PFCluster") << "unknown function for depth correction!"
00069     //                         << std::endl;
00070   }
00071   return depth;
00072 }
00073 
00074 void PFCluster::setLayer( PFLayer::Layer layer) {
00075   // cout<<"calling PFCluster::setLayer "<<layer<<endl;
00076   caloID_ = PFLayer::toCaloID( layer );
00077   // cout<<"done "<<caloID_<<endl;
00078 }
00079 
00080 
00081 PFLayer::Layer  PFCluster::layer() const {
00082   
00083   // cout<<"calling PFCluster::layer "<<caloID()<<" "<<PFLayer::fromCaloID( caloID() )<<endl;
00084   return PFLayer::fromCaloID( caloID() );
00085 }     
00086 
00087 
00088 PFCluster& PFCluster::operator=(const PFCluster& other) {
00089 
00090   CaloCluster::operator=(other); 
00091   rechits_ = other.rechits_;
00092   energy_ = other.energy_;
00093   position_ = other.position_;
00094   posrep_ = other.posrep_;
00095   color_ = other.color_;
00096 
00097   return *this;
00098 }
00099 
00100 
00101 std::ostream& reco::operator<<(std::ostream& out, 
00102                                const PFCluster& cluster) {
00103   
00104   if(!out) return out;
00105   
00106   const math::XYZPoint&  pos = cluster.position();
00107   const PFCluster::REPPoint&  posrep = cluster.positionREP();
00108   const std::vector< reco::PFRecHitFraction >& fracs = 
00109     cluster.recHitFractions();
00110   
00111   out<<"PFcluster "
00112      <<", layer: "<<cluster.layer()
00113      <<"\tE = "<<cluster.energy()
00114      <<"\tXYZ: "
00115      <<pos.X()<<","<<pos.Y()<<","<<pos.Z()<<" | "
00116      <<"\tREP: "
00117      <<posrep.Rho()<<","<<posrep.Eta()<<","<<posrep.Phi()<<" | "
00118      <<fracs.size()<<" rechits";
00119   
00120   for(unsigned i=0; i<fracs.size(); i++) {
00121     // PFRecHit is not available, print the detID
00122     if( !fracs[i].recHitRef().isAvailable() )
00123       out<<cluster.printHitAndFraction(i)<<", ";
00124     else 
00125       out<<fracs[i]<<", ";
00126   }
00127   
00128   return out;
00129 }