Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:54:17

0001 #include "DataFormats/ParticleFlowReco/interface/PFBlockElementTrack.h"
0002 #include "DataFormats/ParticleFlowReco/interface/PFRecTrack.h"
0003 #include "DataFormats/Common/interface/Ref.h"
0004 #include "DataFormats/TrackReco/interface/Track.h"
0005 #include "DataFormats/ParticleFlowReco/interface/PFTrajectoryPoint.h"
0006 
0007 #include <iomanip>
0008 
0009 using namespace reco;
0010 using namespace std;
0011 
0012 PFBlockElementTrack::PFBlockElementTrack(const PFRecTrackRef& ref)
0013     : PFBlockElement(TRACK), trackRefPF_(ref), trackRef_(ref->trackRef()), trackType_(0) {
0014   if (ref.isNull())
0015     throw cms::Exception("NullRef") << " PFBlockElementTrack constructed from a null reference to PFRecTrack.";
0016 
0017   const reco::PFTrajectoryPoint& atECAL = ref->extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance);
0018 
0019   if (atECAL.isValid())
0020     positionAtECALEntrance_.SetCoordinates(atECAL.position().x(), atECAL.position().y(), atECAL.position().z());
0021   // if the position at ecal entrance is invalid,
0022   // positionAtECALEntrance_ is initialized by default to 0,0,0
0023 
0024   setTrackType(DEFAULT, true);
0025 }
0026 
0027 void PFBlockElementTrack::Dump(ostream& out, const char* tab) const {
0028   if (!out)
0029     return;
0030 
0031   if (!trackRef_.isNull()) {
0032     double charge = trackRef_->charge();
0033     double pt = trackRef_->pt();
0034     double p = trackRef_->p();
0035     string s = "  at vertex";
0036     double tracketa = trackRef_->eta();
0037     double trackphi = trackRef_->phi();
0038 
0039     // COLIN
0040     // the following lines rely on the presence of the PFRecTrack,
0041     // which for most people is not there (PFRecTracks are transient)
0042     // commented these lines out to remove the spurious error message
0043     // for the missing PFRecTrack product
0044     //     const reco::PFTrajectoryPoint& atECAL
0045     //       = trackRefPF_->extrapolatedPoint( reco::PFTrajectoryPoint::ECALShowerMax );
0046     //     // check if  reach ecal Shower max
0047     //     if( atECAL.isValid() ) {
0048     //       s = "  at ECAL shower max";
0049     //       tracketa = atECAL.position().Eta();
0050     //       trackphi = atECAL.position().Phi();
0051     //     }
0052 
0053     out << setprecision(0);
0054     out << tab << setw(7) << "charge=" << setw(3) << charge;
0055     out << setprecision(3);
0056     out << setiosflags(ios::right);
0057     out << setiosflags(ios::fixed);
0058     out << ", pT =" << setw(7) << pt;
0059     out << ", p =" << setw(7) << p;
0060     out << " (eta,phi)= (";
0061     out << tracketa << ",";
0062     out << trackphi << ")" << s;
0063 
0064     out << resetiosflags(ios::right | ios::fixed);
0065   }
0066 }