test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PackedGenParticle.h
Go to the documentation of this file.
1 #ifndef __AnalysisDataFormats_PackedGenParticle_h__
2 #define __AnalysisDataFormats_PackedGenParticle_h__
3 
14 /* #include "DataFormats/Math/interface/PtEtaPhiMass.h" */
15 
16 namespace pat {
18  public:
29 
30  typedef unsigned int index;
31 
34  : p4_(0,0,0,0), p4c_(0,0,0,0), vertex_(0,0,0), pdgId_(0), charge_(0), unpacked_(false) { }
36  : p4_(c.pt(), c.eta(), c.phi(), c.mass()), p4c_(p4_), vertex_(0,0,0), pdgId_(c.pdgId()), charge_(c.charge()), mother_(c.motherRef(0)), unpacked_(true) { pack(); }
38  : p4_(c.pt(), c.eta(), c.phi(), c.mass()), p4c_(p4_), vertex_(0,0,0), pdgId_(c.pdgId()), charge_(c.charge()), mother_(mother), unpacked_(true) { pack(); }
39 
40 
42  virtual ~PackedGenParticle();
44  virtual const_iterator begin() const;
46  virtual const_iterator end() const;
48  virtual iterator begin();
50  virtual iterator end();
52  virtual size_t numberOfDaughters() const;
54  virtual const reco::Candidate * daughter( size_type ) const;
56  virtual size_t numberOfMothers() const;
58  virtual const reco::Candidate * mother( size_type ) const;
60  virtual reco::Candidate * daughter( size_type );
62  virtual reco::Candidate * daughter(const std::string& s );
64  virtual const reco::Candidate * daughter(const std::string& s ) const;
67  virtual size_t numberOfSourceCandidatePtrs() const {return 0;}
71  return reco::CandidatePtr();
72  }
73 
75  virtual int charge() const {
76  return charge_;
77  }
79  virtual void setCharge( int charge) {charge_=charge;}
81  virtual int threeCharge() const {return charge()*3;}
83  virtual void setThreeCharge( int threecharge) {}
85  virtual const LorentzVector & p4() const { if (!unpacked_) unpack(); return p4c_; }
87  virtual const PolarLorentzVector & polarP4() const { if (!unpacked_) unpack(); return p4_; }
89  virtual Vector momentum() const { if (!unpacked_) unpack(); return p4c_.Vect(); }
92  virtual Vector boostToCM() const { if (!unpacked_) unpack(); return p4c_.BoostToCM(); }
94  virtual double p() const { if (!unpacked_) unpack(); return p4c_.P(); }
96  virtual double energy() const { if (!unpacked_) unpack(); return p4c_.E(); }
98  virtual double et() const { if (!unpacked_) unpack(); return p4_.Et(); }
100  virtual float mass() const { if (!unpacked_) unpack(); return p4_.M(); }
102  virtual float massSqr() const { if (!unpacked_) unpack(); return p4_.M()*p4_.M(); }
103 
105  virtual double mt() const { if (!unpacked_) unpack(); return p4_.Mt(); }
107  virtual double mtSqr() const { if (!unpacked_) unpack(); return p4_.Mt2(); }
109  virtual double px() const { if (!unpacked_) unpack(); return p4c_.Px(); }
111  virtual double py() const { if (!unpacked_) unpack(); return p4c_.Py(); }
113  virtual double pz() const { if (!unpacked_) unpack(); return p4c_.Pz(); }
115  virtual float pt() const { if (!unpacked_) unpack(); return p4_.Pt();}
117  virtual float phi() const { if (!unpacked_) unpack(); return p4_.Phi(); }
119  virtual double theta() const { if (!unpacked_) unpack(); return p4_.Theta(); }
121  virtual float eta() const { if (!unpacked_) unpack(); return p4_.Eta(); }
123  virtual double rapidity() const { if (!unpacked_) unpack(); return p4_.Rapidity(); }
125  virtual double y() const { if (!unpacked_) unpack(); return p4_.Rapidity(); }
127  virtual void setP4( const LorentzVector & p4 ) {
128  unpack(); // changing px,py,pz changes also mapping between dxy,dz and x,y,z
129  p4_ = PolarLorentzVector(p4.Pt(), p4.Eta(), p4.Phi(), p4.M());
130  pack();
131  }
133  virtual void setP4( const PolarLorentzVector & p4 ) {
134  unpack(); // changing px,py,pz changes also mapping between dxy,dz and x,y,z
135  p4_ = p4;
136  pack();
137  }
139  virtual void setMass( double m ) {
140  if (!unpacked_) unpack();
141  p4_ = PolarLorentzVector(p4_.Pt(), p4_.Eta(), p4_.Phi(), m);
142  pack();
143  }
144  virtual void setPz( double pz ) {
145  unpack(); // changing px,py,pz changes also mapping between dxy,dz and x,y,z
146  p4c_ = LorentzVector(p4c_.Px(), p4c_.Py(), pz, p4c_.E());
147  p4_ = PolarLorentzVector(p4c_.Pt(), p4c_.Eta(), p4c_.Phi(), p4c_.M());
148  pack();
149  }
151  virtual const Point & vertex() const { return vertex_; }//{ if (fromPV_) return Point(0,0,0); else return Point(0,0,100); }
153  virtual double vx() const { return vertex_.X(); }//{ return 0; }
155  virtual double vy() const { return vertex_.Y(); }//{ return 0; }
157  virtual double vz() const { return vertex_.Z(); }//{ if (fromPV_) return 0; else return 100; }
159  virtual void setVertex( const Point & vertex ) { vertex_ = vertex; }
160 
161  enum PVAssoc { NoPV=0, PVLoose=1, PVTight=2, PVUsedInFit=3 } ;
162 
163 
165  virtual float dxy() const { unpack(); return dxy_; }
167  virtual float dz() const { unpack(); return dz_; }
169  virtual float dxy(const Point &p) const ;
171  virtual float dz(const Point &p) const ;
172 
173 
175  virtual int pdgId() const { return pdgId_; }
176  // set PDG identifier
177  virtual void setPdgId( int pdgId ) { pdgId_ = pdgId; }
179  virtual int status() const { return 1; } /*FIXME*/
181  virtual void setStatus( int status ) {} /*FIXME*/
183  static const unsigned int longLivedTag = 0; /*FIXME*/
185  virtual void setLongLived() {} /*FIXME*/
187  virtual bool longLived() const;
189  static const unsigned int massConstraintTag = 0; /*FIXME*/
191  virtual void setMassConstraint() {} /*FIXME*/
193  virtual bool massConstraint() const;
194 
196  virtual PackedGenParticle * clone() const {
197  return new PackedGenParticle( *this );
198  }
199 
201  virtual double vertexChi2() const;
208  virtual double vertexNdof() const;
210  virtual double vertexNormalizedChi2() const;
212  virtual double vertexCovariance(int i, int j) const;
216  virtual void fillVertexCovariance(CovarianceMatrix & v) const;
219  virtual bool hasMasterClone() const;
222  virtual const reco::CandidateBaseRef & masterClone() const;
225  virtual bool hasMasterClonePtr() const;
228 
229  virtual const reco::CandidatePtr & masterClonePtr() const;
230 
232  template<typename Ref>
233  Ref masterRef() const { return masterClone().template castTo<Ref>(); }
235 
236  /* template<typename T> T get() const { */
237  /* if ( hasMasterClone() ) return masterClone()->get<T>(); */
238  /* else return reco::get<T>( * this ); */
239  /* } */
240  /* /// get a component */
241  /* template<typename T, typename Tag> T get() const { */
242  /* if ( hasMasterClone() ) return masterClone()->get<T, Tag>(); */
243  /* else return reco::get<T, Tag>( * this ); */
244  /* } */
245  /* /// get a component */
246  /* template<typename T> T get( size_type i ) const { */
247  /* if ( hasMasterClone() ) return masterClone()->get<T>( i ); */
248  /* else return reco::get<T>( * this, i ); */
249  /* } */
250  /* /// get a component */
251  /* template<typename T, typename Tag> T get( size_type i ) const { */
252  /* if ( hasMasterClone() ) return masterClone()->get<T, Tag>( i ); */
253  /* else return reco::get<T, Tag>( * this, i ); */
254  /* } */
255  /* /// number of components */
256  /* template<typename T> size_type numberOf() const { */
257  /* if ( hasMasterClone() ) return masterClone()->numberOf<T>(); */
258  /* else return reco::numberOf<T>( * this ); */
259  /* } */
260  /* /// number of components */
261  /* template<typename T, typename Tag> size_type numberOf() const { */
262  /* if ( hasMasterClone() ) return masterClone()->numberOf<T, Tag>(); */
263  /* else return reco::numberOf<T, Tag>( * this ); */
264  /* } */
265 
266  /* template<typename S> */
267  /* struct daughter_iterator { */
268  /* typedef boost::filter_iterator<S, const_iterator> type; */
269  /* }; */
270 
271  /* template<typename S> */
272  /* typename daughter_iterator<S>::type beginFilter( const S & s ) const { */
273  /* return boost::make_filter_iterator(s, begin(), end()); */
274  /* } */
275  /* template<typename S> */
276  /* typename daughter_iterator<S>::type endFilter( const S & s ) const { */
277  /* return boost::make_filter_iterator(s, end(), end()); */
278  /* } */
279 
280 
281  virtual bool isElectron() const;
282  virtual bool isMuon() const;
283  virtual bool isStandAloneMuon() const;
284  virtual bool isGlobalMuon() const;
285  virtual bool isTrackerMuon() const;
286  virtual bool isCaloMuon() const;
287  virtual bool isPhoton() const;
288  virtual bool isConvertedPhoton() const;
289  virtual bool isJet() const;
290 
291  protected:
293  void pack(bool unpackAfterwards=true) ;
294  void unpack() const ;
295 
300  mutable Point vertex_;
301  mutable float dxy_, dz_, dphi_;
303  int pdgId_;
305  int8_t charge_;
308  // is the momentum p4 unpacked
309  mutable bool unpacked_;
310 
312  virtual bool overlap( const reco::Candidate & ) const;
313  template<typename, typename, typename> friend struct component;
314  friend class ::OverlapChecker;
315  friend class ShallowCloneCandidate;
317 
318  private:
319  // const iterator implementation
321  // iterator implementation
323  };
324 
325  typedef std::vector<pat::PackedGenParticle> PackedGenParticleCollection;
328 }
329 
330 #endif
virtual PackedGenParticle * clone() const
returns a clone of the Candidate object
virtual double vx() const
x coordinate of vertex position
reco::candidate::iterator_imp_specific< daughters > iterator_imp_specific
virtual void setStatus(int status)
set status word
int i
Definition: DBlmapReader.cc:9
virtual double pz() const
z coordinate of momentum vector
Point vertex_
vertex position
virtual Vector boostToCM() const
edm::Ref< pat::PackedGenParticleCollection > PackedGenParticleRef
virtual void fillVertexCovariance(CovarianceMatrix &v) const
fill SMatrix
static const unsigned int longLivedTag
long lived flag
CovarianceMatrix vertexCovariance() const
return SMatrix
virtual size_t numberOfMothers() const
number of mothers
math::XYZVector Vector
point in the space
Definition: Candidate.h:47
friend class ShallowCloneCandidate
size_t size_type
Definition: Candidate.h:34
virtual void setVertex(const Point &vertex)
set vertex
virtual double et() const
transverse energy
candidate::const_iterator const_iterator
Definition: Candidate.h:35
virtual double vertexNdof() const
virtual int threeCharge() const
electric charge
int pdgId_
PDG identifier.
virtual void setP4(const PolarLorentzVector &p4)
set 4-momentum
virtual void setP4(const LorentzVector &p4)
set 4-momentum
virtual double vy() const
y coordinate of vertex position
virtual int status() const
status word
virtual bool isTrackerMuon() const
virtual reco::CandidatePtr sourceCandidatePtr(size_type i) const
virtual bool isJet() const
virtual ~PackedGenParticle()
destructor
virtual const reco::Candidate * daughter(size_type) const
return daughter at a given position (throws an exception)
friend class ShallowClonePtrCandidate
virtual double mtSqr() const
transverse mass squared
virtual size_t numberOfSourceCandidatePtrs() const
PackedGenParticle()
default constructor
virtual bool isElectron() const
get a component
virtual double theta() const
momentum polar angle
virtual bool isPhoton() const
PolarLorentzVector p4_
the four vector
void pack(bool unpackAfterwards=true)
virtual Vector momentum() const
spatial momentum vector
math::XYZPoint Point
point in the space
virtual double vertexNormalizedChi2() const
chi-squared divided by n.d.o.f.
virtual double p() const
magnitude of momentum vector
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:25
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
virtual void setLongLived()
set long lived flag
PackedGenParticle(const reco::GenParticle &c)
virtual void setThreeCharge(int threecharge)
set electric charge
virtual void setPz(double pz)
reco::GenParticleRef mother_
Ref to first mother.
virtual void setMassConstraint()
set mass constraint flag
virtual bool isMuon() const
virtual const Point & vertex() const
vertex position
virtual bool longLived() const
is long lived?
math::XYZVector Vector
point in the space
virtual const reco::CandidateBaseRef & masterClone() const
virtual double vertexChi2() const
chi-squares
virtual float mass() const
mass
virtual size_t numberOfDaughters() const
number of daughters
math::XYZPoint Point
virtual const LorentzVector & p4() const
four-momentum Lorentz vecto r
virtual bool isStandAloneMuon() const
int j
Definition: DBlmapReader.cc:9
virtual const reco::CandidatePtr & masterClonePtr() const
virtual const_iterator end() const
last daughter const_iterator
virtual float massSqr() const
mass squared
virtual double mt() const
transverse mass
virtual bool hasMasterClonePtr() const
virtual float eta() const
momentum pseudorapidity
PackedGenParticle(const reco::GenParticle &c, const edm::Ref< reco::GenParticleCollection > &mother)
virtual void setPdgId(int pdgId)
virtual double y() const
rapidity
static const unsigned int massConstraintTag
do mass constraint flag
virtual int pdgId() const
PDG identifier.
reco::CandidateCollection daughters
collection of daughter candidates
virtual bool overlap(const reco::Candidate &) const
check overlap with another Candidate
virtual const PolarLorentzVector & polarP4() const
four-momentum Lorentz vector
candidate::iterator iterator
Definition: Candidate.h:36
virtual bool hasMasterClone() const
edm::Ptr< Candidate > CandidatePtr
persistent reference to an object in a collection of Candidate objects
Definition: CandidateFwd.h:25
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
std::vector< pat::PackedGenParticle > PackedGenParticleCollection
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:41
virtual double energy() const
energy
virtual bool isCaloMuon() const
virtual bool isGlobalMuon() const
virtual const reco::Candidate * mother(size_type) const
return mother at a given position (throws an exception)
virtual double rapidity() const
rapidity
virtual int charge() const
electric charge
virtual bool isConvertedPhoton() const
virtual float pt() const
transverse momentum
virtual const_iterator begin() const
first daughter const_iterator
math::XYZPoint Point
point in the space
Definition: Candidate.h:45
virtual bool massConstraint() const
do mass constraint?
virtual void setCharge(int charge)
set electric charge
virtual double py() const
y coordinate of momentum vector
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
volatile std::atomic< bool > shutdown_flag false
virtual void setMass(double m)
set particle mass
reco::candidate::const_iterator_imp_specific< daughters > const_iterator_imp_specific
virtual double px() const
x coordinate of momentum vector
Ref masterRef() const
cast master clone reference to a concrete type
edm::RefVector< pat::PackedGenParticleCollection > PackedGenParticleRefVector
virtual float dz() const
dz with respect to the PV ref
virtual float phi() const
momentum azimuthal angle
virtual float dxy() const
dxy with respect to the PV ref
math::XYZTLorentzVector LorentzVector
Lorentz vector.
virtual double vz() const
z coordinate of vertex position
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: Candidate.h:43