CMS 3D CMS Logo

TrackJet.cc
Go to the documentation of this file.
1 
3 
6 
7 
9  : reco::Jet()
10 {
11 }
12 
13 
14 reco::TrackJet::TrackJet(const LorentzVector & fP4, const Point & fVertex)
15  : reco::Jet(fP4, fVertex)
16 {
17 }
18 
19 
20 reco::TrackJet::TrackJet(const LorentzVector & fP4, const Point & fVertex, const Jet::Constituents & fConstituents)
21  : reco::Jet(fP4, fVertex, fConstituents)
22 {
23  this->resetCharge();
24 }
25 
26 
27 
29  return new reco::TrackJet(*this);
30 }
31 
32 
33 
36  // check the daughter to be ok
37  if ( dau.isNonnull() && dau.isAvailable() ) {
38  // convert to concrete candidate type
39  const RecoChargedRefCandidate* trkCand = dynamic_cast <const RecoChargedRefCandidate*> (dau.get());
40  // check the candidate is of the right type
41  if (trkCand) {
42  // check the track link in the recochargedcandidate to be there
43  if (trkCand->track().get()) {
44  // ok, return pointer to the originating track
45  return edm::Ptr<reco::Track> ( trkCand->track().id(), trkCand->track().get(), trkCand->track().key() );
46  } else {
47  throw cms::Exception("TrackRef unavailable") << "TrackJet consituent track not in the event.";
48  }
49  } else {
50  throw cms::Exception("Invalid Constituent") << "TrackJet constituent is not of RecoChargedRefCandidate type";
51  }
52  // otherwise return empty ptr
53  } else {
54  return edm::Ptr<reco::Track>();
55  }
56 }
57 
58 
59 std::vector<edm::Ptr<reco::Track> > reco::TrackJet::tracks() const {
60  std::vector <edm::Ptr<reco::Track> > result;
61  for (unsigned i = 0; i < numberOfDaughters (); i++) result.push_back (track (i));
62  return result;
63 }
64 
65 
68  for ( reco::Candidate::const_iterator ida = this->begin(); ida != this->end(); ++ida ) {
69  charge += ida->charge();
70  }
71  this->setCharge(charge);
72 }
73 
74 
76  return vtx_;
77 }
78 
79 
81  vtx_ = vtx;
82 }
83 
84 
86  return false;
87 }
88 
89 
91  std::ostringstream out;
92  out << Jet::print() // generic jet info
93  << " TrackJet specific:" << std::endl;
94  if (primaryVertex().get()) {
95  out << " Associated PV:"
96  << " x=" << primaryVertex()->x()
97  << " y=" << primaryVertex()->y()
98  << " z=" << primaryVertex()->z() << std::endl;
99  } else {
100  out << " Associated PV not available on the event" << std::endl;
101  }
102  std::vector<edm::Ptr<reco::Track> > thetracks = tracks();
103  for (unsigned i = 0; i < thetracks.size (); i++) {
104  if (thetracks[i].get ()) {
105  out << " #" << i
106  << " px=" << thetracks[i]->px()
107  << " py=" << thetracks[i]->py()
108  << " pz=" << thetracks[i]->pz()
109  << " eta=" << thetracks[i]->eta()
110  << " phi=" << thetracks[i]->phi() << std::endl;
111  }
112  else {
113  out << " #" << i << " track is not available in the event" << std::endl;
114  }
115  }
116  return out.str();
117 }
reco::VertexRef vtx_
Associated primary vertex.
Definition: TrackJet.h:69
TrackJet * clone() const override
Polymorphic clone.
Definition: TrackJet.cc:28
std::string print() const override
Print object.
Definition: TrackJet.cc:90
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:159
bool overlap(const Candidate &dummy) const override
Polymorphic overlap.
Definition: TrackJet.cc:85
bool isAvailable() const
Definition: Ptr.h:258
TrackJet()
Default constructor.
Definition: TrackJet.cc:8
std::vector< Constituent > Constituents
Definition: Jet.h:23
int charge() const final
electric charge
Definition: LeafCandidate.h:91
key_type key() const
Accessor for product key.
Definition: Ref.h:263
ProductID id() const
Accessor for product ID.
Definition: Ref.h:257
size_t numberOfDaughters() const override
number of daughters
daughters dau
collection of references to daughters
void setCharge(Charge q) final
set electric charge
Definition: LeafCandidate.h:93
virtual std::string print() const
Print object.
Definition: Jet.py:1
const_iterator end() const
last daughter const_iterator
Definition: Candidate.h:146
void setPrimaryVertex(const reco::VertexRef &vtx)
set associated primary vertex
Definition: TrackJet.cc:80
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:243
Jets made out of tracks.
Definition: TrackJet.h:27
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:168
virtual CandidatePtr daughterPtr(size_type i) const
reference to daughter at given position
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:37
fixed size matrix
Structure Point Contains parameters of Gaussian fits to DMRs.
Definition: DMRtrends.cc:55
const_iterator begin() const
first daughter const_iterator
Definition: Candidate.h:144
const reco::VertexRef primaryVertex() const
get associated primary vertex
Definition: TrackJet.cc:75
std::vector< edm::Ptr< reco::Track > > tracks() const
Return pointers to all track costituents.
Definition: TrackJet.cc:59
int Charge
electric charge type
Definition: LeafCandidate.h:21
virtual edm::Ptr< reco::Track > track(size_t i) const
Return Ptr to the track costituent.
Definition: TrackJet.cc:34
void resetCharge()
calculate and set the charge by adding up the constituting track charges
Definition: TrackJet.cc:66