CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GenericParticle.cc
Go to the documentation of this file.
1 //
2 //
3 
5 
6 
8 
9 
11 GenericParticle::GenericParticle() :
12  PATObject<reco::RecoCandidate>()
13 {
14 }
15 
16 
19  PATObject<reco::RecoCandidate>()
20 {
21  fillInFrom(cand);
22 }
23 
24 
27  PATObject<reco::RecoCandidate>()
28 {
29  fillInFrom(*cand);
30  refToOrig_ = edm::Ptr<reco::Candidate>(cand.id(), cand.get(), cand.key()); // correct RefToBase=>Ptr conversion
31 }
32 
35  PATObject<reco::RecoCandidate>()
36 {
37  fillInFrom(*cand);
38  refToOrig_ = cand;
39 }
40 
41 
42 
45 }
46 
47 // ====== SETTERS =====
50  trackRef_ = ref;
51  if (embed) embedTrack(); else track_.clear();
52 }
53 
56  trackRefs_ = refs;
57  if (embed) embedTracks(); else tracks_.clear();
58 }
59 
62  standaloneTrackRef_ = ref;
63  if (embed) embedStandalone(); else standaloneTrack_.clear();
64 }
65 
68  combinedTrackRef_ = ref;
69  if (embed) embedCombined(); else combinedTrack_.clear();
70 }
71 
74  gsfTrackRef_ = ref;
75  if (embed) embedGsfTrack(); else gsfTrack_.clear();
76 }
77 
80  superClusterRef_ = ref;
81  if (embed) embedSuperCluster(); else superCluster_.clear();
82 }
83 
86  caloTowerRef_ = ref;
87  if (embed) {
88  embedCaloTower();
89  } else if (!caloTower_.empty()) {
91  }
92 }
93 
94 
95 // ========== EMBEDDER METHODS
98  track_.clear();
99  if (trackRef_.isNonnull()) track_.push_back(*trackRef_); // import
100  trackRef_ = reco::TrackRef(); // clear, to save space (zeroes compress better)
101 }
104  tracks_.clear();
105  tracks_.reserve(trackRefs_.size());
107  if (it->isNonnull()) tracks_.push_back(**it); // embed track
108  }
109  trackRefs_ = reco::TrackRefVector(); // clear, to save space
110 }
113  standaloneTrack_.clear();
115  standaloneTrackRef_ = reco::TrackRef(); // clear, to save space (zeroes compress better)
116 }
119  combinedTrack_.clear();
120  if (combinedTrackRef_.isNonnull()) combinedTrack_.push_back(*combinedTrackRef_); // import
121  combinedTrackRef_ = reco::TrackRef(); // clear, to save space (zeroes compress better)
122 }
125  gsfTrack_.clear();
126  if (gsfTrackRef_.isNonnull()) gsfTrack_.push_back(*gsfTrackRef_); // import
127  gsfTrackRef_ = reco::GsfTrackRef(); // clear, to save space (zeroes compress better)
128 }
129 
132  superCluster_.clear();
133  if (superClusterRef_.isNonnull()) superCluster_.push_back(*superClusterRef_); // import
134  superClusterRef_ = reco::SuperClusterRef(); // clear, to save space (zeroes compress better)
135 }
140  caloTowerRef_ = CaloTowerRef(); // clear, to save space (zeroes compress better)
141 }
142 
143 
145  // first, kinematics & status
146  setCharge(cand.charge());
147  setP4(cand.polarP4());
148  setVertex(cand.vertex());
149  setPdgId(cand.pdgId());
150  setStatus(cand.status());
151  // then RECO part, if available
152  const reco::RecoCandidate *rc = dynamic_cast<const reco::RecoCandidate *>(&cand);
153  if (rc != 0) {
154  setTrack(rc->track());
155  setGsfTrack(rc->gsfTrack());
156  setStandAloneMuon(rc->standAloneMuon());
157  setCombinedMuon(rc->combinedMuon());
158  setSuperCluster(rc->superCluster());
159  setCaloTower(rc->caloTower());
160  size_t ntracks = rc->numberOfTracks();
161  if (ntracks > 0) {
163  for (size_t i = 0; i < ntracks; ++i) {
164  tracks.push_back(rc->track(i));
165  }
166  setTracks(tracks);
167  }
168  }
169 }
170 
171 bool GenericParticle::overlap( const reco::Candidate &cand ) const {
172  const reco::RecoCandidate *rc = dynamic_cast<const reco::RecoCandidate *>(&cand);
173  if (rc != 0) {
174  if (rc->track().isNonnull() && (track() == rc->track())) return true;
175  if (rc->gsfTrack().isNonnull() && (gsfTrack() == rc->gsfTrack())) return true;
176  if (rc->standAloneMuon().isNonnull() && (standAloneMuon() == rc->standAloneMuon())) return true;
177  if (rc->combinedMuon().isNonnull() && (combinedMuon() == rc->combinedMuon())) return true;
178  if (rc->superCluster().isNonnull() && (superCluster() == rc->superCluster())) return true;
179  if (rc->caloTower().isNonnull() && (caloTower() == rc->caloTower())) return true;
180  }
181  const GenericParticle *rc2 = dynamic_cast<const GenericParticle *>(&cand);
182  if (rc2 != 0) {
183  if (rc2->track().isNonnull() && (track() == rc2->track())) return true;
184  if (rc2->gsfTrack().isNonnull() && (gsfTrack() == rc2->gsfTrack())) return true;
185  if (rc2->standAloneMuon().isNonnull() && (standAloneMuon() == rc2->standAloneMuon())) return true;
186  if (rc2->combinedMuon().isNonnull() && (combinedMuon() == rc2->combinedMuon())) return true;
187  if (rc2->superCluster().isNonnull() && (superCluster() == rc2->superCluster())) return true;
188  if (rc2->caloTower().isNonnull() && (caloTower() == rc2->caloTower())) return true;
189  }
190  return false;
191 }
edm::Ref< GsfTrackCollection > GsfTrackRef
persistent reference to a GsfTrack
Definition: GsfTrackFwd.h:13
virtual reco::GsfTrackRef gsfTrack() const
reference to a GsfTrack
value_type const * get() const
Definition: RefToBase.h:213
int i
Definition: DBlmapReader.cc:9
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
CaloTowerCollection caloTower_
reco::TrackRef standaloneTrackRef_
virtual reco::TrackRef combinedMuon() const
virtual bool overlap(const Candidate &) const
reco::TrackCollection combinedTrack_
reco::TrackCollection track_
virtual void setCharge(Charge q)
set electric charge
void fillInFrom(const reco::Candidate &cand)
virtual void setStatus(int status)
set status word
virtual int status() const =0
status word
void swap(SortedCollection &other)
void push_back(T const &t)
virtual void setP4(const LorentzVector &p4)
set 4-momentum
void embedTrack()
embeds the master track instead of keeping a reference to it
reco::TrackRef trackRef_
virtual reco::TrackRef standAloneMuon() const
reference to a stand-alone muon Track
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:249
edm::RefVector< TrackCollection > TrackRefVector
vector of reference to Track in the same collection
Definition: TrackFwd.h:25
virtual const PolarLorentzVector & polarP4() const =0
four-momentum Lorentz vector
edm::Ref< SuperClusterCollection > SuperClusterRef
reference to an object in a collection of SuperCluster objects
ProductID id() const
Definition: RefToBase.h:221
GenericParticle()
default constructor
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:244
virtual void setCombinedMuon(const reco::TrackRef &ref, bool embed=false)
sets combined muon track reference (or even embed it into the object)
#define embed
Definition: AMPTWrapper.h:178
virtual reco::TrackRef track() const
reference to a Track
Analysis-level Generic Particle class (e.g. for hadron or muon not fully reconstructed) ...
reco::TrackCollection standaloneTrack_
void embedStandalone()
embeds the stand-alone track instead of keeping a reference to it
reco::SuperClusterCollection superCluster_
virtual reco::TrackRef standAloneMuon() const
size_t key() const
Definition: RefToBase.h:229
virtual CaloTowerRef caloTower() const
reference to a CaloTower
reco::GsfTrackRef gsfTrackRef_
reco::SuperClusterRef superClusterRef_
virtual CaloTowerRef caloTower() const
virtual const Point & vertex() const =0
vertex position
virtual int charge() const =0
electric charge
virtual reco::TrackRef track() const
virtual void setGsfTrack(const reco::GsfTrackRef &ref, bool embed=false)
sets gsf track reference (or even embed it into the object)
virtual void setVertex(const Point &vertex)
set vertex
virtual void setCaloTower(const CaloTowerRef &ref, bool embed=false)
sets calotower reference (or even embed it into the object)
virtual void setTracks(const reco::TrackRefVector &refs, bool embed=false)
sets multiple track references (or even embed the tracks into the object - whatch out for disk size i...
void embedGsfTrack()
embeds the gsf track instead of keeping a reference to it
void embedSuperCluster()
embeds the supercluster instead of keeping a reference to it
virtual int pdgId() const =0
PDG identifier.
virtual void setStandAloneMuon(const reco::TrackRef &ref, bool embed=false)
sets stand-alone muon track reference (or even embed it into the object)
reco::TrackCollection tracks_
void embedTracks()
embeds the other tracks instead of keeping references
reco::GsfTrackCollection gsfTrack_
virtual ~GenericParticle()
destructor
tuple tracks
Definition: testEve_cfg.py:39
virtual reco::GsfTrackRef gsfTrack() const
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:19
reco::TrackRefVector trackRefs_
CaloTowerRef caloTowerRef_
reco::TrackRef combinedTrackRef_
edm::SortedCollection< CaloTower > CaloTowerCollection
Definition: CaloTowerFwd.h:15
virtual void setPdgId(int pdgId)
void push_back(value_type const &ref)
Add a Ref&lt;C, T&gt; to the RefVector.
Definition: RefVector.h:64
size_type size() const
Size of the RefVector.
Definition: RefVector.h:89
Templated PAT object container.
Definition: PATObject.h:41
void embedCaloTower()
embeds the calotower instead of keeping a reference to it
virtual reco::SuperClusterRef superCluster() const
edm::Ref< CaloTowerCollection > CaloTowerRef
Definition: CaloTowerFwd.h:16
void embedCombined()
embeds the combined track instead of keeping a reference to it
virtual void setTrack(const reco::TrackRef &ref, bool embed=false)
sets master track reference (or even embed it into the object)
edm::Ptr< reco::Candidate > refToOrig_
Definition: PATObject.h:407
virtual reco::SuperClusterRef superCluster() const
reference to a SuperCluster
virtual void setSuperCluster(const reco::SuperClusterRef &ref, bool embed=false)
sets supercluster reference (or even embed it into the object)
virtual reco::TrackRef combinedMuon() const
reference to a stand-alone muon Track