CMS 3D CMS Logo

PFBlockElementTrack.cc

Go to the documentation of this file.
00001 #include "DataFormats/ParticleFlowReco/interface/PFBlockElementTrack.h"
00002 #include "DataFormats/ParticleFlowReco/interface/PFRecTrack.h"
00003 #include "DataFormats/Common/interface/Ref.h" 
00004 #include "DataFormats/TrackReco/interface/Track.h"
00005 #include "DataFormats/ParticleFlowReco/interface/PFTrajectoryPoint.h"
00006 
00007 #include <iomanip>
00008 
00009 using namespace reco;
00010 using namespace std;
00011 
00012 
00013 PFBlockElementTrack::PFBlockElementTrack(const PFRecTrackRef& ref) : 
00014   PFBlockElement( TRACK ),
00015   trackRefPF_( ref ), 
00016   trackRef_( ref->trackRef() ),
00017   trackType_(0) {
00018   
00019 
00020   if( ref.isNull() ) 
00021     throw cms::Exception("NullRef")<<" PFBlockElementTrack constructed from a null reference to PFRecTrack.";
00022   
00023   const reco::PFTrajectoryPoint& atECAL 
00024     = ref->extrapolatedPoint( reco::PFTrajectoryPoint::ECALEntrance );
00025 
00026   if( atECAL.isValid() ) 
00027     positionAtECALEntrance_.SetCoordinates( atECAL.position().x(),
00028                                             atECAL.position().y(),
00029                                             atECAL.position().z() );
00030   // if the position at ecal entrance is invalid, 
00031   // positionAtECALEntrance_ is initialized by default to 0,0,0
00032 
00033   setTrackType( DEFAULT, true );      
00034 } 
00035 
00036 
00037 void PFBlockElementTrack::Dump(ostream& out, 
00038                                const char* tab ) const {
00039   
00040   if(! out ) return;
00041   
00042   if( !trackRef_.isNull() ) {
00043     
00044     double charge = trackRef_->charge();
00045     double pt = trackRef_->pt();
00046     double p = trackRef_->p();
00047     string s = "  at vertex";
00048     double tracketa = trackRef_->eta();
00049     double trackphi = trackRef_->phi();
00050 
00051     // COLIN
00052     // the following lines rely on the presence of the PFRecTrack, 
00053     // which for most people is not there (PFRecTracks are transient) 
00054     // commented these lines out to remove the spurious error message
00055     // for the missing PFRecTrack product
00056     //     const reco::PFTrajectoryPoint& atECAL 
00057     //       = trackRefPF_->extrapolatedPoint( reco::PFTrajectoryPoint::ECALShowerMax );
00058     //     // check if  reach ecal Shower max 
00059     //     if( atECAL.isValid() ) { 
00060     //       s = "  at ECAL shower max";  
00061     //       tracketa = atECAL.position().Eta();
00062     //       trackphi = atECAL.position().Phi();
00063     //     }
00064     
00065     out<<setprecision(0);
00066     out<<tab<<setw(7)<<"charge="<<setw(3)<<charge;
00067     out<<setprecision(3);
00068     out<<setiosflags(ios::right);
00069     out<<setiosflags(ios::fixed);
00070     out<<", pT ="<<setw(7)<<pt;
00071     out<<", p ="<<setw(7)<<p;
00072     out<<" (eta,phi)= (";
00073     out<<tracketa<<",";
00074     out<<trackphi<<")" << s;
00075     
00076     out<<resetiosflags(ios::right|ios::fixed);  
00077   }
00078 }

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