test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PFBlockElementTrack.cc
Go to the documentation of this file.
6 
7 #include <iomanip>
8 
9 using namespace reco;
10 using namespace std;
11 
12 
14  PFBlockElement( TRACK ),
15  trackRefPF_( ref ),
16  trackRef_( ref->trackRef() ),
17  trackType_(0) {
18 
19 
20  if( ref.isNull() )
21  throw cms::Exception("NullRef")<<" PFBlockElementTrack constructed from a null reference to PFRecTrack.";
22 
23  const reco::PFTrajectoryPoint& atECAL
24  = ref->extrapolatedPoint( reco::PFTrajectoryPoint::ECALEntrance );
25 
26  if( atECAL.isValid() )
27  positionAtECALEntrance_.SetCoordinates( atECAL.position().x(),
28  atECAL.position().y(),
29  atECAL.position().z() );
30  // if the position at ecal entrance is invalid,
31  // positionAtECALEntrance_ is initialized by default to 0,0,0
32 
33  setTrackType( DEFAULT, true );
34 }
35 
36 
38  const char* tab ) const {
39 
40  if(! out ) return;
41 
42  if( !trackRef_.isNull() ) {
43 
44  double charge = trackRef_->charge();
45  double pt = trackRef_->pt();
46  double p = trackRef_->p();
47  string s = " at vertex";
48  double tracketa = trackRef_->eta();
49  double trackphi = trackRef_->phi();
50 
51  // COLIN
52  // the following lines rely on the presence of the PFRecTrack,
53  // which for most people is not there (PFRecTracks are transient)
54  // commented these lines out to remove the spurious error message
55  // for the missing PFRecTrack product
56  // const reco::PFTrajectoryPoint& atECAL
57  // = trackRefPF_->extrapolatedPoint( reco::PFTrajectoryPoint::ECALShowerMax );
58  // // check if reach ecal Shower max
59  // if( atECAL.isValid() ) {
60  // s = " at ECAL shower max";
61  // tracketa = atECAL.position().Eta();
62  // trackphi = atECAL.position().Phi();
63  // }
64 
65  out<<setprecision(0);
66  out<<tab<<setw(7)<<"charge="<<setw(3)<<charge;
67  out<<setprecision(3);
68  out<<setiosflags(ios::right);
69  out<<setiosflags(ios::fixed);
70  out<<", pT ="<<setw(7)<<pt;
71  out<<", p ="<<setw(7)<<p;
72  out<<" (eta,phi)= (";
73  out<<tracketa<<",";
74  out<<trackphi<<")" << s;
75 
76  out<<resetiosflags(ios::right|ios::fixed);
77  }
78 }
Abstract base class for a PFBlock element (track, cluster...)
void Dump(std::ostream &out=std::cout, const char *tab=" ") const
print the object inside the element
const math::XYZPoint & position() const
cartesian position (x, y, z)
reco::TrackRef trackRef_
reference to the corresponding track
bool isNull() const
Checks for null.
Definition: Ref.h:249
bool isValid() const
is this point valid ?
virtual void setTrackType(TrackType trType, bool value)
the trackType
A PFTrack holds several trajectory points, which basically contain the position and momentum of a tra...
math::XYZPointF positionAtECALEntrance_
position at ECAL entrance