CMS 3D CMS Logo

GenericParticle.cc
Go to the documentation of this file.
1 //
2 //
3 
5 
7 
9 GenericParticle::GenericParticle() : PATObject<reco::RecoCandidate>() {}
10 
13 
15 GenericParticle::GenericParticle(const edm::RefToBase<Candidate> &cand) : PATObject<reco::RecoCandidate>() {
16  fillInFrom(*cand);
17  refToOrig_ = edm::Ptr<reco::Candidate>(cand.id(), cand.get(), cand.key()); // correct RefToBase=>Ptr conversion
18 }
19 
21 GenericParticle::GenericParticle(const edm::Ptr<Candidate> &cand) : PATObject<reco::RecoCandidate>() {
22  fillInFrom(*cand);
23  refToOrig_ = cand;
24 }
25 
28 
29 // ====== SETTERS =====
32  trackRef_ = ref;
33  if (embed)
34  embedTrack();
35  else
36  track_.clear();
37 }
38 
41  trackRefs_ = refs;
42  if (embed)
43  embedTracks();
44  else
45  tracks_.clear();
46 }
47 
50  standaloneTrackRef_ = ref;
51  if (embed)
53  else
54  standaloneTrack_.clear();
55 }
56 
59  combinedTrackRef_ = ref;
60  if (embed)
61  embedCombined();
62  else
63  combinedTrack_.clear();
64 }
65 
68  gsfTrackRef_ = ref;
69  if (embed)
70  embedGsfTrack();
71  else
72  gsfTrack_.clear();
73 }
74 
77  superClusterRef_ = ref;
78  if (embed)
80  else
81  superCluster_.clear();
82 }
83 
86  caloTowerRef_ = ref;
87  if (embed) {
89  } else if (!caloTower_.empty()) {
91  }
92 }
93 
94 // ========== EMBEDDER METHODS
97  track_.clear();
98  if (trackRef_.isNonnull())
99  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())
108  tracks_.push_back(**it); // embed track
109  }
110  trackRefs_ = reco::TrackRefVector(); // clear, to save space
111 }
114  standaloneTrack_.clear();
116  standaloneTrack_.push_back(*standaloneTrackRef_); // import
117  standaloneTrackRef_ = reco::TrackRef(); // clear, to save space (zeroes compress better)
118 }
121  combinedTrack_.clear();
123  combinedTrack_.push_back(*combinedTrackRef_); // import
124  combinedTrackRef_ = reco::TrackRef(); // clear, to save space (zeroes compress better)
125 }
128  gsfTrack_.clear();
129  if (gsfTrackRef_.isNonnull())
130  gsfTrack_.push_back(*gsfTrackRef_); // import
131  gsfTrackRef_ = reco::GsfTrackRef(); // clear, to save space (zeroes compress better)
132 }
133 
136  superCluster_.clear();
138  superCluster_.push_back(*superClusterRef_); // import
139  superClusterRef_ = reco::SuperClusterRef(); // clear, to save space (zeroes compress better)
140 }
143  if (!caloTower_.empty())
145  if (caloTowerRef_.isNonnull())
146  caloTower_.push_back(*caloTowerRef_); // import
147  caloTowerRef_ = CaloTowerRef(); // clear, to save space (zeroes compress better)
148 }
149 
151  // first, kinematics & status
152  setCharge(cand.charge());
153  setP4(cand.polarP4());
154  setVertex(cand.vertex());
155  setPdgId(cand.pdgId());
156  setStatus(cand.status());
157  // then RECO part, if available
158  const reco::RecoCandidate *rc = dynamic_cast<const reco::RecoCandidate *>(&cand);
159  if (rc != nullptr) {
160  setTrack(rc->track());
161  setGsfTrack(rc->gsfTrack());
162  setStandAloneMuon(rc->standAloneMuon());
163  setCombinedMuon(rc->combinedMuon());
164  setSuperCluster(rc->superCluster());
165  setCaloTower(rc->caloTower());
166  size_t ntracks = rc->numberOfTracks();
167  if (ntracks > 0) {
169  for (size_t i = 0; i < ntracks; ++i) {
170  tracks.push_back(rc->track(i));
171  }
172  setTracks(tracks);
173  }
174  }
175 }
176 
178  const reco::RecoCandidate *rc = dynamic_cast<const reco::RecoCandidate *>(&cand);
179  if (rc != nullptr) {
180  if (rc->track().isNonnull() && (track() == rc->track()))
181  return true;
182  if (rc->gsfTrack().isNonnull() && (gsfTrack() == rc->gsfTrack()))
183  return true;
184  if (rc->standAloneMuon().isNonnull() && (standAloneMuon() == rc->standAloneMuon()))
185  return true;
186  if (rc->combinedMuon().isNonnull() && (combinedMuon() == rc->combinedMuon()))
187  return true;
188  if (rc->superCluster().isNonnull() && (superCluster() == rc->superCluster()))
189  return true;
190  if (rc->caloTower().isNonnull() && (caloTower() == rc->caloTower()))
191  return true;
192  }
193  const GenericParticle *rc2 = dynamic_cast<const GenericParticle *>(&cand);
194  if (rc2 != nullptr) {
195  if (rc2->track().isNonnull() && (track() == rc2->track()))
196  return true;
197  if (rc2->gsfTrack().isNonnull() && (gsfTrack() == rc2->gsfTrack()))
198  return true;
199  if (rc2->standAloneMuon().isNonnull() && (standAloneMuon() == rc2->standAloneMuon()))
200  return true;
201  if (rc2->combinedMuon().isNonnull() && (combinedMuon() == rc2->combinedMuon()))
202  return true;
203  if (rc2->superCluster().isNonnull() && (superCluster() == rc2->superCluster()))
204  return true;
205  if (rc2->caloTower().isNonnull() && (caloTower() == rc2->caloTower()))
206  return true;
207  }
208  return false;
209 }
reco::LeafCandidate::setPdgId
void setPdgId(int pdgId) final
Definition: LeafCandidate.h:178
reco::GsfTrackRef
edm::Ref< GsfTrackCollection > GsfTrackRef
persistent reference to a GsfTrack
Definition: GsfTrackFwd.h:13
embed
#define embed
Definition: AMPTWrapper.h:188
PDWG_EXOHSCP_cff.tracks
tracks
Definition: PDWG_EXOHSCP_cff.py:28
mps_fire.i
i
Definition: mps_fire.py:428
pat::GenericParticle::combinedTrack_
reco::TrackCollection combinedTrack_
Definition: GenericParticle.h:292
configurableAnalysis::Candidate
char Candidate[]
Definition: modules.cc:20
pat::GenericParticle::setTrack
virtual void setTrack(const reco::TrackRef &ref, bool embed=false)
sets master track reference (or even embed it into the object)
Definition: GenericParticle.cc:31
pat::GenericParticle::track_
reco::TrackCollection track_
Definition: GenericParticle.h:292
pat::GenericParticle::standAloneMuon
reco::TrackRef standAloneMuon() const override
Definition: GenericParticle.h:80
pat::GenericParticle::standaloneTrackRef_
reco::TrackRef standaloneTrackRef_
Definition: GenericParticle.h:291
pat::GenericParticle::superClusterRef_
reco::SuperClusterRef superClusterRef_
Definition: GenericParticle.h:303
reco::RecoCandidate::combinedMuon
virtual reco::TrackRef combinedMuon() const
reference to a stand-alone muon Track
Definition: RecoCandidate.cc:23
pat::GenericParticle::caloTowerRef_
CaloTowerRef caloTowerRef_
Definition: GenericParticle.h:299
GenericParticle.h
pat::GenericParticle::embedSuperCluster
void embedSuperCluster()
embeds the supercluster instead of keeping a reference to it
Definition: GenericParticle.cc:135
edm::RefVector::begin
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:223
pat::GenericParticle::gsfTrack
reco::GsfTrackRef gsfTrack() const override
Definition: GenericParticle.h:75
reco::RecoCandidate::superCluster
virtual reco::SuperClusterRef superCluster() const
reference to a SuperCluster
Definition: RecoCandidate.cc:25
pat::GenericParticle::superCluster_
reco::SuperClusterCollection superCluster_
Definition: GenericParticle.h:304
reco::RecoCandidate::standAloneMuon
virtual reco::TrackRef standAloneMuon() const
reference to a stand-alone muon Track
Definition: RecoCandidate.cc:21
edm::RefVector< TrackCollection >
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
vertices_cff.ntracks
ntracks
Definition: vertices_cff.py:34
pat::GenericParticle::setCombinedMuon
virtual void setCombinedMuon(const reco::TrackRef &ref, bool embed=false)
sets combined muon track reference (or even embed it into the object)
Definition: GenericParticle.cc:58
pat::GenericParticle::embedGsfTrack
void embedGsfTrack()
embeds the gsf track instead of keeping a reference to it
Definition: GenericParticle.cc:127
edm::SortedCollection::push_back
void push_back(T const &t)
Definition: SortedCollection.h:188
reco::RecoCandidate::gsfTrack
virtual reco::GsfTrackRef gsfTrack() const
reference to a GsfTrack
Definition: RecoCandidate.cc:19
reco::TrackRefVector
edm::RefVector< TrackCollection > TrackRefVector
vector of reference to Track in the same collection
Definition: TrackFwd.h:29
pat::GenericParticle::combinedMuon
reco::TrackRef combinedMuon() const override
Definition: GenericParticle.h:85
reco::RecoCandidate::track
virtual reco::TrackRef track() const
reference to a Track
Definition: RecoCandidate.cc:13
edm::Ref< TrackCollection >
edm::RefVector::end
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:228
edm::SortedCollection::swap
void swap(SortedCollection &other)
Definition: SortedCollection.h:193
pat::PATObject< reco::RecoCandidate >::refToOrig_
edm::Ptr< reco::Candidate > refToOrig_
Definition: PATObject.h:460
CaloTowerCollection
edm::SortedCollection< CaloTower > CaloTowerCollection
Definition: CaloTowerDefs.h:16
pat::PATObject
Templated PAT object container.
Definition: PATObject.h:45
reco::SuperClusterRef
edm::Ref< SuperClusterCollection > SuperClusterRef
reference to an object in a collection of SuperCluster objects
Definition: SuperClusterFwd.h:15
pat::GenericParticle::setSuperCluster
virtual void setSuperCluster(const reco::SuperClusterRef &ref, bool embed=false)
sets supercluster reference (or even embed it into the object)
Definition: GenericParticle.cc:76
pat::GenericParticle::gsfTrack_
reco::GsfTrackCollection gsfTrack_
Definition: GenericParticle.h:296
reco::LeafCandidate::setVertex
void setVertex(const Point &vertex) override
set vertex
Definition: LeafCandidate.h:173
pat::GenericParticle::embedStandalone
void embedStandalone()
embeds the stand-alone track instead of keeping a reference to it
Definition: GenericParticle.cc:113
pat::GenericParticle::caloTower
CaloTowerRef caloTower() const override
Definition: GenericParticle.h:95
reco::TrackRef
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:20
pat::GenericParticle::embedCaloTower
void embedCaloTower()
embeds the calotower instead of keeping a reference to it
Definition: GenericParticle.cc:142
pat::GenericParticle
Analysis-level Generic Particle class (e.g. for hadron or muon not fully reconstructed)
Definition: GenericParticle.h:38
pat::GenericParticle::overlap
bool overlap(const Candidate &) const override
Definition: GenericParticle.cc:177
edm::Ref::isNonnull
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
pat::GenericParticle::setGsfTrack
virtual void setGsfTrack(const reco::GsfTrackRef &ref, bool embed=false)
sets gsf track reference (or even embed it into the object)
Definition: GenericParticle.cc:67
cand
Definition: decayParser.h:32
pat::GenericParticle::fillInFrom
void fillInFrom(const reco::Candidate &cand)
Definition: GenericParticle.cc:150
pat::GenericParticle::trackRef_
reco::TrackRef trackRef_
Definition: GenericParticle.h:291
reco::RecoCandidate::caloTower
virtual CaloTowerRef caloTower() const
reference to a CaloTower
Definition: RecoCandidate.cc:27
reco::RecoCandidate
Definition: RecoCandidate.h:20
pat::GenericParticle::~GenericParticle
~GenericParticle() override
destructor
Definition: GenericParticle.cc:27
reco::LeafCandidate::setStatus
void setStatus(int status) final
set status word
Definition: LeafCandidate.h:182
edm::Ptr< reco::Candidate >
reco::Candidate
Definition: Candidate.h:27
pat::GenericParticle::tracks_
reco::TrackCollection tracks_
Definition: GenericParticle.h:308
pat::GenericParticle::setTracks
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...
Definition: GenericParticle.cc:40
reco::LeafCandidate::setP4
void setP4(const LorentzVector &p4) final
set 4-momentum
Definition: LeafCandidate.h:158
pat::GenericParticle::standaloneTrack_
reco::TrackCollection standaloneTrack_
Definition: GenericParticle.h:292
pat::GenericParticle::embedCombined
void embedCombined()
embeds the combined track instead of keeping a reference to it
Definition: GenericParticle.cc:120
pat::GenericParticle::setCaloTower
virtual void setCaloTower(const CaloTowerRef &ref, bool embed=false)
sets calotower reference (or even embed it into the object)
Definition: GenericParticle.cc:85
edm::RefVectorIterator
Definition: EDProductfwd.h:33
reco::LeafCandidate::setCharge
void setCharge(Charge q) final
set electric charge
Definition: LeafCandidate.h:108
pat::GenericParticle::gsfTrackRef_
reco::GsfTrackRef gsfTrackRef_
Definition: GenericParticle.h:295
pat::GenericParticle::combinedTrackRef_
reco::TrackRef combinedTrackRef_
Definition: GenericParticle.h:291
pat::GenericParticle::track
reco::TrackRef track() const override
Definition: GenericParticle.h:62
edm::RefToBase< Candidate >
CaloTowerRef
edm::Ref< CaloTowerCollection > CaloTowerRef
Definition: CaloTowerDefs.h:17
pat::GenericParticle::embedTracks
void embedTracks()
embeds the other tracks instead of keeping references
Definition: GenericParticle.cc:103
pat::GenericParticle::setStandAloneMuon
virtual void setStandAloneMuon(const reco::TrackRef &ref, bool embed=false)
sets stand-alone muon track reference (or even embed it into the object)
Definition: GenericParticle.cc:49
pat::GenericParticle::superCluster
reco::SuperClusterRef superCluster() const override
Definition: GenericParticle.h:90
pat::GenericParticle::caloTower_
CaloTowerCollection caloTower_
Definition: GenericParticle.h:300
edm::RefVector::size
size_type size() const
Size of the RefVector.
Definition: RefVector.h:102
pat::GenericParticle::GenericParticle
GenericParticle()
default constructor
Definition: GenericParticle.cc:9
pat::GenericParticle::embedTrack
void embedTrack()
embeds the master track instead of keeping a reference to it
Definition: GenericParticle.cc:96
edm::SortedCollection::empty
bool empty() const
Definition: SortedCollection.h:210
pat::GenericParticle::trackRefs_
reco::TrackRefVector trackRefs_
Definition: GenericParticle.h:307