CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/DataFormats/CaloRecHit/src/CaloCluster.cc

Go to the documentation of this file.
00001 #include "DataFormats/CaloRecHit/interface/CaloCluster.h"
00002 
00003 
00004 #include <sstream>
00005 #include <iostream>
00006 
00007 using namespace std;
00008 using namespace reco;
00009 
00010 
00011 void CaloCluster::reset() {
00012   position_ = math::XYZPoint();
00013   energy_ = 0;
00014   hitsAndFractions_.clear();
00015 }
00016 
00017 string CaloCluster::printHitAndFraction(unsigned i) const {
00018   
00019   ostringstream out; 
00020   if( i>=hitsAndFractions().size() ) // i >= 0, since i is unsigned
00021     out<<"out of range "<<i; 
00022   else
00023     out<<"( "<<hitsAndFractions()[i].first
00024        <<", "<<hitsAndFractions()[i].second
00025        <<" )";
00026   return out.str();
00027 }
00028 
00029 
00030 std::ostream& reco::operator<<(std::ostream& out, 
00031                                const CaloCluster& cluster) {
00032   
00033   if(!out) return out;
00034 
00035   const math::XYZPoint&  pos = cluster.position();
00036 
00037   out<<"CaloCluster , algoID="<<cluster.algoID()
00038      <<", "<<cluster.caloID()    
00039      <<", E="<<cluster.energy()
00040      <<", eta,phi="<<pos.eta()<<","<<pos.phi()
00041      <<", nhits="<<cluster.hitsAndFractions().size()<<endl;
00042   for(unsigned i=0; i<cluster.hitsAndFractions().size(); i++ ) {
00043     out<<""<<cluster.printHitAndFraction(i)<<", ";
00044   }
00045 
00046   return out;
00047 }