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 // $Id: TrackJet.cc,v 1.2 2009/12/10 15:13:43 lowette Exp $
2 
4 
7 
8 
10  : reco::Jet()
11 {
12 }
13 
14 
15 reco::TrackJet::TrackJet(const LorentzVector & fP4, const Point & fVertex)
16  : reco::Jet(fP4, fVertex)
17 {
18 }
19 
20 
21 reco::TrackJet::TrackJet(const LorentzVector & fP4, const Point & fVertex, const Jet::Constituents & fConstituents)
22  : reco::Jet(fP4, fVertex, fConstituents)
23 {
24  this->resetCharge();
25 }
26 
27 
28 
30  return new reco::TrackJet(*this);
31 }
32 
33 
34 
36  Constituent dau = daughterPtr (i);
37  // check the daughter to be ok
38  if ( dau.isNonnull() && dau.isAvailable() ) {
39  // convert to concrete candidate type
40  const RecoChargedRefCandidate* trkCand = dynamic_cast <const RecoChargedRefCandidate*> (dau.get());
41  // check the candidate is of the right type
42  if (trkCand) {
43  // check the track link in the recochargedcandidate to be there
44  if (trkCand->track().get()) {
45  // ok, return pointer to the originating track
46  return edm::Ptr<reco::Track> ( trkCand->track().id(), trkCand->track().get(), trkCand->track().key() );
47  } else {
48  throw cms::Exception("TrackRef unavailable") << "TrackJet consituent track not in the event.";
49  }
50  } else {
51  throw cms::Exception("Invalid Constituent") << "TrackJet constituent is not of RecoChargedRefCandidate type";
52  }
53  // otherwise return empty ptr
54  } else {
55  return edm::Ptr<reco::Track>();
56  }
57 }
58 
59 
60 std::vector<edm::Ptr<reco::Track> > reco::TrackJet::tracks() const {
61  std::vector <edm::Ptr<reco::Track> > result;
62  for (unsigned i = 0; i < numberOfDaughters (); i++) result.push_back (track (i));
63  return result;
64 }
65 
66 
69  for ( reco::Candidate::const_iterator ida = this->begin(); ida != this->end(); ++ida ) {
70  charge += ida->charge();
71  }
72  this->setCharge(charge);
73 }
74 
75 
77  return vtx_;
78 }
79 
80 
82  vtx_ = vtx;
83 }
84 
85 
86 bool reco::TrackJet::overlap(const Candidate & dummy) const {
87  return false;
88 }
89 
90 
91 std::string reco::TrackJet::print() const {
92  std::ostringstream out;
93  out << Jet::print() // generic jet info
94  << " TrackJet specific:" << std::endl;
95  if (primaryVertex().get()) {
96  out << " Associated PV:"
97  << " x=" << primaryVertex()->x()
98  << " y=" << primaryVertex()->y()
99  << " z=" << primaryVertex()->z() << std::endl;
100  } else {
101  out << " Associated PV not available on the event" << std::endl;
102  }
103  std::vector<edm::Ptr<reco::Track> > thetracks = tracks();
104  for (unsigned i = 0; i < thetracks.size (); i++) {
105  if (thetracks[i].get ()) {
106  out << " #" << i
107  << " px=" << thetracks[i]->px()
108  << " py=" << thetracks[i]->py()
109  << " pz=" << thetracks[i]->pz()
110  << " eta=" << thetracks[i]->eta()
111  << " phi=" << thetracks[i]->phi() << std::endl;
112  }
113  else {
114  out << " #" << i << " track is not available in the event" << std::endl;
115  }
116  }
117  return out.str();
118 }
int i
Definition: DBlmapReader.cc:9
Base class for all types of Jets.
Definition: Jet.h:21
TrackJet()
Default constructor.
Definition: TrackJet.cc:9
std::vector< Constituent > Constituents
Definition: Jet.h:24
double charge(const std::vector< uint8_t > &Ampls)
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:152
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:143
tuple result
Definition: query.py:137
virtual std::string print() const
Print object.
Definition: TrackJet.cc:91
void setPrimaryVertex(const reco::VertexRef &vtx)
set associated primary vertex
Definition: TrackJet.cc:81
#define end
Definition: vmac.h:38
Jets made out of tracks.
Definition: TrackJet.h:28
tuple out
Definition: dbtoconf.py:99
tuple tracks
Definition: testEve_cfg.py:39
key_type key() const
Accessor for product key.
Definition: Ref.h:266
virtual bool overlap(const Candidate &dummy) const
Polymorphic overlap.
Definition: TrackJet.cc:86
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:38
#define begin
Definition: vmac.h:31
bool isAvailable() const
Definition: Ptr.h:158
math::XYZPoint Point
point in the space
Definition: Candidate.h:42
ProductID id() const
Accessor for product ID.
Definition: Ref.h:256
const reco::VertexRef primaryVertex() const
get associated primary vertex
Definition: TrackJet.cc:76
std::vector< edm::Ptr< reco::Track > > tracks() const
Return pointers to all track costituents.
Definition: TrackJet.cc:60
virtual std::string print() const
Print object.
Definition: Jet.cc:425
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:242
int Charge
electric charge type
Definition: LeafCandidate.h:23
virtual edm::Ptr< reco::Track > track(size_t i) const
Return Ptr to the track costituent.
Definition: TrackJet.cc:35
reco::TrackRef const & track() const
virtual TrackJet * clone() const
Polymorphic clone.
Definition: TrackJet.cc:29
void resetCharge()
calculate and set the charge by adding up the constituting track charges
Definition: TrackJet.cc:67