CMS 3D CMS Logo

PFCluster.cc

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

Generated on Tue Jun 9 17:31:23 2009 for CMSSW by  doxygen 1.5.4