CMS 3D CMS Logo

TrackJet.cc
Go to the documentation of this file.
1 
3 
6 
8 
9 reco::TrackJet::TrackJet(const LorentzVector& fP4, const Point& fVertex) : reco::Jet(fP4, fVertex) {}
10 
11 reco::TrackJet::TrackJet(const LorentzVector& fP4, const Point& fVertex, const Jet::Constituents& fConstituents)
12  : reco::Jet(fP4, fVertex, fConstituents) {
13  this->resetCharge();
14 }
15 
16 reco::TrackJet* reco::TrackJet::clone() const { return new reco::TrackJet(*this); }
17 
19  Constituent dau = daughterPtr(i);
20  // check the daughter to be ok
21  if (dau.isNonnull() && dau.isAvailable()) {
22  // convert to concrete candidate type
23  const RecoChargedRefCandidate* trkCand = dynamic_cast<const RecoChargedRefCandidate*>(dau.get());
24  // check the candidate is of the right type
25  if (trkCand) {
26  // check the track link in the recochargedcandidate to be there
27  if (trkCand->track().get()) {
28  // ok, return pointer to the originating track
29  return edm::Ptr<reco::Track>(trkCand->track().id(), trkCand->track().get(), trkCand->track().key());
30  } else {
31  throw cms::Exception("TrackRef unavailable") << "TrackJet consituent track not in the event.";
32  }
33  } else {
34  throw cms::Exception("Invalid Constituent") << "TrackJet constituent is not of RecoChargedRefCandidate type";
35  }
36  // otherwise return empty ptr
37  } else {
38  return edm::Ptr<reco::Track>();
39  }
40 }
41 
42 std::vector<edm::Ptr<reco::Track> > reco::TrackJet::tracks() const {
43  std::vector<edm::Ptr<reco::Track> > result;
44  for (unsigned i = 0; i < numberOfDaughters(); i++)
45  result.push_back(track(i));
46  return result;
47 }
48 
51  for (reco::Candidate::const_iterator ida = this->begin(); ida != this->end(); ++ida) {
52  charge += ida->charge();
53  }
54  this->setCharge(charge);
55 }
56 
57 const reco::VertexRef reco::TrackJet::primaryVertex() const { return vtx_; }
58 
60 
61 bool reco::TrackJet::overlap(const Candidate& dummy) const { return false; }
62 
64  std::ostringstream out;
65  out << Jet::print() // generic jet info
66  << " TrackJet specific:" << std::endl;
67  if (primaryVertex().get()) {
68  out << " Associated PV:"
69  << " x=" << primaryVertex()->x() << " y=" << primaryVertex()->y() << " z=" << primaryVertex()->z() << std::endl;
70  } else {
71  out << " Associated PV not available on the event" << std::endl;
72  }
73  std::vector<edm::Ptr<reco::Track> > thetracks = tracks();
74  for (unsigned i = 0; i < thetracks.size(); i++) {
75  if (thetracks[i].get()) {
76  out << " #" << i << " px=" << thetracks[i]->px() << " py=" << thetracks[i]->py()
77  << " pz=" << thetracks[i]->pz() << " eta=" << thetracks[i]->eta() << " phi=" << thetracks[i]->phi()
78  << std::endl;
79  } else {
80  out << " #" << i << " track is not available in the event" << std::endl;
81  }
82  }
83  return out.str();
84 }
ProductID id() const
Accessor for product ID.
Definition: Ref.h:244
TrackJet()
Default constructor.
Definition: TrackJet.cc:7
std::vector< Constituent > Constituents
Definition: Jet.h:23
ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE constexpr float charge(ConstView const &tracks, int32_t i)
Definition: TracksSoA.h:73
bool isAvailable() const
Definition: Ptr.h:234
key_type key() const
Accessor for product key.
Definition: Ref.h:250
std::string print() const override
Print object.
Definition: TrackJet.cc:63
Definition: Jet.py:1
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:148
virtual std::string print() const
Print object.
void setPrimaryVertex(const reco::VertexRef &vtx)
set associated primary vertex
Definition: TrackJet.cc:59
TrackJet * clone() const override
Polymorphic clone.
Definition: TrackJet.cc:16
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:141
Jets made out of tracks.
Definition: TrackJet.h:24
virtual edm::Ptr< reco::Track > track(size_t i) const
Return Ptr to the track costituent.
Definition: TrackJet.cc:18
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:36
fixed size matrix
Structure Point Contains parameters of Gaussian fits to DMRs.
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:232
primaryVertex
hltOfflineBeamSpot for HLTMON
int Charge
electric charge type
Definition: LeafCandidate.h:21
bool overlap(const Candidate &dummy) const override
Polymorphic overlap.
Definition: TrackJet.cc:61
std::vector< edm::Ptr< reco::Track > > tracks() const
Return pointers to all track costituents.
Definition: TrackJet.cc:42
const reco::VertexRef primaryVertex() const
get associated primary vertex
Definition: TrackJet.cc:57
void resetCharge()
calculate and set the charge by adding up the constituting track charges
Definition: TrackJet.cc:49