CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
35  Constituent dau = daughterPtr (i);
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 
85 bool reco::TrackJet::overlap(const Candidate & dummy) const {
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 }
int i
Definition: DBlmapReader.cc:9
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:160
Base class for all types of Jets.
Definition: Jet.h:20
bool isAvailable() const
Definition: Ptr.h:259
TrackJet()
Default constructor.
Definition: TrackJet.cc:8
std::vector< Constituent > Constituents
Definition: Jet.h:23
key_type key() const
Accessor for product key.
Definition: Ref.h:264
ProductID id() const
Accessor for product ID.
Definition: Ref.h:258
tuple result
Definition: mps_fire.py:95
virtual std::string print() const
Print object.
virtual std::string print() const
Print object.
Definition: TrackJet.cc:90
void setPrimaryVertex(const reco::VertexRef &vtx)
set associated primary vertex
Definition: TrackJet.cc:80
#define end
Definition: vmac.h:37
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:244
Jets made out of tracks.
Definition: TrackJet.h:27
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:169
tuple tracks
Definition: testEve_cfg.py:39
virtual bool overlap(const Candidate &dummy) const
Polymorphic overlap.
Definition: TrackJet.cc:85
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:37
#define begin
Definition: vmac.h:30
math::XYZPoint Point
point in the space
Definition: Candidate.h:41
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
virtual TrackJet * clone() const
Polymorphic clone.
Definition: TrackJet.cc:28
void resetCharge()
calculate and set the charge by adding up the constituting track charges
Definition: TrackJet.cc:66