test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GenericParticle.h
Go to the documentation of this file.
1 //
2 //
3 
4 #ifndef DataFormats_PatCandidates_GenericParticle_h
5 #define DataFormats_PatCandidates_GenericParticle_h
6 
26 
27 // Define typedefs for convenience
28 namespace pat {
30  typedef std::vector<GenericParticle> GenericParticleCollection;
33 }
34 
35 
36 // Class definition
37 namespace pat {
38 
39 
40  class GenericParticle : public PATObject<reco::RecoCandidate> {
41 
42  public:
43 
47  GenericParticle(const reco::Candidate & aGenericParticle);
49  GenericParticle(const edm::RefToBase<reco::Candidate> & aGenericParticleRef);
51  GenericParticle(const edm::Ptr<reco::Candidate> & aGenericParticleRef);
53  virtual ~GenericParticle();
54 
56  virtual GenericParticle * clone() const { return new GenericParticle(*this); }
57 
62  virtual bool overlap( const Candidate & ) const ;
63 
66  virtual reco::TrackRef track() const { return track_.empty() ? trackRef_ : reco::TrackRef(&track_, 0); }
69  virtual reco::TrackRef track( size_t idx ) const {
70  if (idx >= numberOfTracks()) throw cms::Exception("Index out of bounds") << "Requested track " << idx << " out of " << numberOfTracks() << ".\n";
71  return (tracks_.empty() ? trackRefs_[idx] : reco::TrackRef(&tracks_, idx) );
72  }
74  virtual size_t numberOfTracks() const { return tracks_.empty() ? trackRefs_.size() : tracks_.size(); }
77  virtual reco::GsfTrackRef gsfTrack() const { return (gsfTrack_.empty() ? gsfTrackRef_ : reco::GsfTrackRef(&gsfTrack_, 0)); }
90 
92  virtual void setTrack(const reco::TrackRef &ref, bool embed=false) ;
94  virtual void setTracks(const reco::TrackRefVector &refs, bool embed=false) ;
96  virtual void setStandAloneMuon(const reco::TrackRef &ref, bool embed=false) ;
98  virtual void setCombinedMuon(const reco::TrackRef &ref, bool embed=false) ;
100  virtual void setGsfTrack(const reco::GsfTrackRef &ref, bool embed=false) ;
102  virtual void setSuperCluster(const reco::SuperClusterRef &ref, bool embed=false) ;
104  virtual void setCaloTower(const CaloTowerRef &ref, bool embed=false) ;
105 
107  void embedTrack() ;
109  void embedTracks() ;
111  void embedStandalone() ;
113  void embedCombined() ;
115  void embedGsfTrack() ;
117  void embedSuperCluster() ;
119  void embedCaloTower() ;
120 
122  float quality() { return quality_; }
124  void setQuality(float quality) { quality_ = quality; }
125 
126  //============ BEGIN ISOLATION BLOCK =====
130  if (key >= 0) {
131  //if (key >= isolations_.size()) throw cms::Excepton("Missing Data")
132  //<< "Isolation corresponding to key "
133  //<< key << " was not stored for this particle.";
134  if (size_t(key) >= isolations_.size()) return -1.0;
135  return isolations_[key];
136  } else switch (key) {
137  case pat::CaloIso:
138  //if (isolations_.size() <= pat::HcalIso) throw cms::Excepton("Missing Data")
139  //<< "CalIsoo Isolation was not stored for this particle.";
140  if (isolations_.size() <= pat::HcalIso) return -1.0;
142  default:
143  return -1.0;
144  //throw cms::Excepton("Missing Data") << "Isolation corresponding to key "
145  //<< key << " was not stored for this particle.";
146  }
147  }
152  float userIsolation(const std::string& key) const {
153  // remove leading namespace specifier
154  std::string prunedKey = ( key.find("pat::") == 0 ) ? std::string(key, 5) : key;
155  if ( prunedKey == "TrackIso" ) return userIsolation(pat::TrackIso);
156  if ( prunedKey == "EcalIso" ) return userIsolation(pat::EcalIso);
157  if ( prunedKey == "HcalIso" ) return userIsolation(pat::HcalIso);
158  if ( prunedKey == "PfAllParticleIso" ) return userIsolation(pat::PfAllParticleIso);
159  if ( prunedKey == "PfChargedHadronIso" ) return userIsolation(pat::PfChargedHadronIso);
160  if ( prunedKey == "PfNeutralHadronIso" ) return userIsolation(pat::PfNeutralHadronIso);
161  if ( prunedKey == "PfGammaIso" ) return userIsolation(pat::PfGammaIso);
162  if ( prunedKey == "User1Iso" ) return userIsolation(pat::User1Iso);
163  if ( prunedKey == "User2Iso" ) return userIsolation(pat::User2Iso);
164  if ( prunedKey == "User3Iso" ) return userIsolation(pat::User3Iso);
165  if ( prunedKey == "User4Iso" ) return userIsolation(pat::User4Iso);
166  if ( prunedKey == "User5Iso" ) return userIsolation(pat::User5Iso);
167  if ( prunedKey == "UserBaseIso" ) return userIsolation(pat::UserBaseIso);
168  if ( prunedKey == "CaloIso" ) return userIsolation(pat::CaloIso);
169  //throw cms::Excepton("Missing Data")
170  //<< "Isolation corresponding to key "
171  //<< key << " was not stored for this particle.";
172  return -1.0;
173  }
177  if (key >= 0) {
178  if (size_t(key) >= isolations_.size()) isolations_.resize(key+1, -1.0);
179  isolations_[key] = value;
180  } else {
181  throw cms::Exception("Illegal Argument") <<
182  "The key for which you're setting isolation does not correspond " <<
183  "to an individual isolation but to the sum of more independent isolations " <<
184  "(e.g. Calo = Ecal + Hcal), so you can't SET the value, just GET it.\n" <<
185  "Please set up each component independly.\n";
186  }
187  }
188 
189  // ---- specific getters ----
192  float trackIso() const { return userIsolation(pat::TrackIso); }
196  float caloIso() const { return userIsolation(pat::CaloIso); }
199  float ecalIso() const { return userIsolation(pat::EcalIso); }
202  float hcalIso() const { return userIsolation(pat::HcalIso); }
203 
204  // ---- specific setters ----
206  void setTrackIso(float trackIso) { setIsolation(pat::TrackIso, trackIso); }
208  void setEcalIso(float caloIso) { setIsolation(pat::EcalIso, caloIso); }
210  void setHcalIso(float caloIso) { setIsolation(pat::HcalIso, caloIso); }
212  void setUserIso(float value, uint8_t index=0) { setIsolation(IsolationKeys(UserBaseIso + index), value); }
213 
214 
215  //============ BEGIN ISODEPOSIT BLOCK =====
218  for (IsoDepositPairs::const_iterator it = isoDeposits_.begin(), ed = isoDeposits_.end();
219  it != ed; ++it)
220  {
221  if (it->first == key) return & it->second;
222  }
223  return 0;
224  }
225 
228  IsoDepositPairs::iterator it = isoDeposits_.begin(), ed = isoDeposits_.end();
229  for (; it != ed; ++it) {
230  if (it->first == key) { it->second = dep; return; }
231  }
232  isoDeposits_.push_back(std::make_pair(key,dep));
233  }
234 
235  // ---- specific getters ----
236  const IsoDeposit * trackIsoDeposit() const { return isoDeposit(pat::TrackIso); }
237  const IsoDeposit * ecalIsoDeposit() const { return isoDeposit(pat::EcalIso ); }
238  const IsoDeposit * hcalIsoDeposit() const { return isoDeposit(pat::HcalIso ); }
239  const IsoDeposit * userIsoDeposit(uint8_t index=0) const { return isoDeposit(IsolationKeys(UserBaseIso + index)); }
240 
241  // ---- specific setters ----
245  void userIsoDeposit(const IsoDeposit &dep, uint8_t index=0) { setIsoDeposit(IsolationKeys(UserBaseIso + index), dep); }
246 
248  const pat::VertexAssociation * vertexAssociation(size_t index=0) const { return vtxAss_.size() > index ? & vtxAss_[index] : 0; }
250  const std::vector<pat::VertexAssociation> & vertexAssociations() const { return vtxAss_; }
252  void setVertexAssociation(const pat::VertexAssociation &assoc) { vtxAss_ = std::vector<pat::VertexAssociation>(1, assoc); }
254  void setVertexAssociations(const std::vector<pat::VertexAssociation> &assocs) { vtxAss_ = assocs; }
255  protected:
256  // Any sort of single tracks
259 
260  // GsfTrack
263 
264  // CaloTower
267 
268  // SuperCluster
271 
272  // Multiple tracks
275 
276  // information originally in external branches
277  // some quality variable
278  float quality_;
279 
280  // --- Isolation and IsoDeposit related datamebers ---
281  typedef std::vector<std::pair<IsolationKeys, pat::IsoDeposit> > IsoDepositPairs;
283  std::vector<float> isolations_;
284 
285  // --- Vertexing information
286  std::vector<pat::VertexAssociation> vtxAss_;
287 
288  void fillInFrom(const reco::Candidate &cand);
289 
290  };
291 
292 
293 }
294 
295 #endif
edm::Ref< GsfTrackCollection > GsfTrackRef
persistent reference to a GsfTrack
Definition: GsfTrackFwd.h:13
IsoDepositPairs isoDeposits_
CaloTowerCollection caloTower_
reco::TrackRef standaloneTrackRef_
virtual reco::TrackRef combinedMuon() const
void setIsolation(IsolationKeys key, float value)
virtual bool overlap(const Candidate &) const
void ecalIsoDeposit(const IsoDeposit &dep)
reco::TrackCollection combinedTrack_
reco::TrackCollection track_
void fillInFrom(const reco::Candidate &cand)
edm::Ref< GenericParticleCollection > GenericParticleRef
std::vector< GenericParticle > GenericParticleCollection
void trackIsoDeposit(const IsoDeposit &dep)
void setUserIso(float value, uint8_t index=0)
Sets user isolation variable index.
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
std::vector< float > isolations_
void embedTrack()
embeds the master track instead of keeping a reference to it
void hcalIsoDeposit(const IsoDeposit &dep)
reco::TrackRef trackRef_
const IsoDeposit * isoDeposit(IsolationKeys key) const
Returns the IsoDeposit associated with some key, or a null pointer if it is not available.
IsolationKeys
Enum defining isolation keys.
Definition: Isolation.h:9
void setHcalIso(float caloIso)
Sets hcal isolation variable.
edm::Ref< SuperClusterCollection > SuperClusterRef
reference to an object in a collection of SuperCluster objects
GenericParticle()
default constructor
float trackIso() const
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
void userIsoDeposit(const IsoDeposit &dep, uint8_t index=0)
float hcalIso() const
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_
float quality()
returns a user defined quality value, if set by the user to some meaningful value ...
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
virtual reco::TrackRef standAloneMuon() const
const IsoDeposit * trackIsoDeposit() const
reco::GsfTrackRef gsfTrackRef_
reco::SuperClusterRef superClusterRef_
std::vector< GsfTrack > GsfTrackCollection
collection of GsfTracks
Definition: GsfTrackFwd.h:9
virtual CaloTowerRef caloTower() const
virtual reco::TrackRef track(size_t idx) const
void setTrackIso(float trackIso)
Sets tracker isolation variable.
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)
const pat::VertexAssociation * vertexAssociation(size_t index=0) const
Vertex association (or associations, if any). Return null pointer if none has been set...
unsigned int index
Definition: LeafCandidate.h:31
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
virtual void setCaloTower(const CaloTowerRef &ref, bool embed=false)
sets calotower reference (or even embed it into the object)
edm::RefVector< GenericParticleCollection > GenericParticleRefVector
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...
std::vector< std::pair< IsolationKeys, pat::IsoDeposit > > IsoDepositPairs
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
float caloIso() const
virtual void setStandAloneMuon(const reco::TrackRef &ref, bool embed=false)
sets stand-alone muon track reference (or even embed it into the object)
unsigned int index
index type
Definition: Candidate.h:51
virtual size_t numberOfTracks() const
number of multiple tracks (not including the master one)
const IsoDeposit * ecalIsoDeposit() const
const IsoDeposit * userIsoDeposit(uint8_t index=0) const
reco::TrackCollection tracks_
void embedTracks()
embeds the other tracks instead of keeping references
reco::GsfTrackCollection gsfTrack_
Candidate()
default constructor
Definition: Candidate.h:54
virtual ~GenericParticle()
destructor
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
virtual reco::GsfTrackRef gsfTrack() const
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:20
reco::TrackRefVector trackRefs_
const IsoDeposit * hcalIsoDeposit() const
float userIsolation(IsolationKeys key) const
std::vector< pat::VertexAssociation > vtxAss_
virtual GenericParticle * clone() const
required reimplementation of the Candidate&#39;s clone method
CaloTowerRef caloTowerRef_
reco::TrackRef combinedTrackRef_
void setIsoDeposit(IsolationKeys key, const IsoDeposit &dep)
Sets the IsoDeposit associated with some key; if it is already existent, it is overwritten.
size_type size() const
Size of the RefVector.
Definition: RefVector.h:99
Analysis-level structure for vertex-related information.
Definition: Vertexing.h:26
Templated PAT object container.
Definition: PATObject.h:49
void embedCaloTower()
embeds the calotower instead of keeping a reference to it
virtual reco::SuperClusterRef superCluster() const
const std::vector< pat::VertexAssociation > & vertexAssociations() const
Vertex associations. Can be empty if it was not enabled in the config file.
float ecalIso() const
void setEcalIso(float caloIso)
Sets ecal isolation variable.
void setQuality(float quality)
sets a user defined quality value
edm::Ref< CaloTowerCollection > CaloTowerRef
Definition: CaloTowerFwd.h:16
void setVertexAssociations(const std::vector< pat::VertexAssociation > &assocs)
Set multiple vertex associations.
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)
void setVertexAssociation(const pat::VertexAssociation &assoc)
Set a single vertex association.
virtual void setSuperCluster(const reco::SuperClusterRef &ref, bool embed=false)
sets supercluster reference (or even embed it into the object)
float userIsolation(const std::string &key) const