00001 #ifndef ParticleFlowCandidate_PFCandidate_h
00002 #define ParticleFlowCandidate_PFCandidate_h
00003
00009 #include <iosfwd>
00010
00011 #include "DataFormats/Math/interface/Point3D.h"
00012
00013 #include "DataFormats/Candidate/interface/CompositeCandidate.h"
00014 #include "DataFormats/ParticleFlowReco/interface/PFBlockFwd.h"
00015 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00016 #include "DataFormats/GsfTrackReco/interface/GsfTrackFwd.h"
00017 #include "DataFormats/MuonReco/interface/MuonFwd.h"
00018 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h"
00019 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateElectronExtraFwd.h"
00020 #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h"
00021 #include "DataFormats/ParticleFlowReco/interface/PFDisplacedVertexFwd.h"
00022 #include "DataFormats/EgammaCandidates/interface/ConversionFwd.h"
00023 #include "DataFormats/Candidate/interface/VertexCompositeCandidate.h"
00024 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidatePhotonExtraFwd.h"
00025 #include "DataFormats/EgammaCandidates/interface/PhotonFwd.h"
00026 namespace reco {
00033 class PFCandidate : public CompositeCandidate {
00034
00035 public:
00036
00038 enum ParticleType {
00039 X=0,
00040 h,
00041 e,
00042 mu,
00043 gamma,
00044 h0,
00045 h_HF,
00046 egamma_HF
00047 };
00048
00049 enum Flags {
00050 NORMAL=0,
00051 E_PHI_SMODULES,
00052 E_ETA_0,
00053 E_ETA_MODULES,
00054 E_BARREL_ENDCAP,
00055 E_PRESHOWER_EDGE,
00056 E_PRESHOWER,
00057 E_ENDCAP_EDGE,
00058 H_ETA_0,
00059 H_BARREL_ENDCAP,
00060 H_ENDCAP_VFCAL,
00061 H_VFCAL_EDGE,
00062 T_TO_DISP,
00063 T_FROM_DISP,
00064 T_FROM_V0,
00065 T_FROM_GAMMACONV,
00066 GAMMA_TO_GAMMACONV
00067 };
00068
00069
00070 enum PFVertexType {
00071 kCandVertex=0,
00072 kTrkVertex=1,
00073 kComMuonVertex=2,
00074 kSAMuonVertex=3,
00075 kTrkMuonVertex=4,
00076 kGSFVertex=5
00077 };
00078
00079
00081 PFCandidate();
00082
00084 PFCandidate( const PFCandidatePtr& sourcePtr );
00085
00086
00087
00088
00089
00090 PFCandidate( Charge q,
00091 const LorentzVector & p4,
00092 ParticleType particleId );
00093
00095 virtual ~PFCandidate() {}
00096
00098 virtual PFCandidate * clone() const;
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111 void setSourceCandidatePtr(const PFCandidatePtr& ptr) { sourcePtr_ = ptr; }
00112
00113 size_t numberOfSourceCandidatePtrs() const {
00114 return 1;
00115 }
00116
00117 CandidatePtr sourceCandidatePtr( size_type i ) const {
00118 return sourcePtr_;
00119 }
00120
00124 int translateTypeToPdgId( ParticleType type ) const;
00125 ParticleType translatePdgIdToType(int pdgid) const;
00126
00128 void setParticleType( ParticleType type );
00129
00130
00132
00133
00135 void addElementInBlock( const reco::PFBlockRef& blockref,
00136 unsigned elementIndex );
00137
00139 void setTrackRef(const reco::TrackRef& ref);
00140
00143 reco::TrackRef trackRef() const;
00144
00146 void setGsfTrackRef(const reco::GsfTrackRef& ref);
00147
00150 reco::GsfTrackRef gsfTrackRef() const;
00151
00153 void setMuonRef(const reco::MuonRef& ref);
00154
00157 reco::MuonRef muonRef() const;
00158
00160 void setDisplacedVertexRef(const reco::PFDisplacedVertexRef& ref, Flags flag);
00161
00164 reco::PFDisplacedVertexRef displacedVertexRef(Flags type) const;
00165
00167 void setConversionRef(const reco::ConversionRef& ref);
00168
00170 reco::ConversionRef conversionRef() const;
00171
00173 void setV0Ref(const reco::VertexCompositeCandidateRef& ref);
00174
00176 reco::VertexCompositeCandidateRef v0Ref() const;
00177
00179 reco::GsfElectronRef gsfElectronRef() const;
00180
00182 reco::PFCandidateElectronExtraRef electronExtraRef() const;
00183
00185 void setEcalEnergy( float eeRaw, float eeCorr ) {
00186 rawEcalEnergy_ = eeRaw; ecalERatio_= std::abs(eeRaw)<1.e-6 ? 1.0 : eeCorr/eeRaw;}
00187
00189 double ecalEnergy() const { return ecalERatio_*rawEcalEnergy_;}
00190
00192 double rawEcalEnergy() const { return rawEcalEnergy_;}
00193
00195 void setHcalEnergy( float ehRaw, float ehCorr ) {
00196 rawHcalEnergy_ = ehRaw; hcalERatio_= std::abs(ehRaw)<1.e-6 ? 1.0 : ehCorr/ehRaw;}
00197
00199 double hcalEnergy() const { return hcalERatio_*rawHcalEnergy_;}
00200
00202 double rawHcalEnergy() const { return rawHcalEnergy_;}
00203
00205 void setGsfElectronRef (const reco::GsfElectronRef & ref);
00206
00207 void setSuperClusterRef (const reco::SuperClusterRef& scRef);
00208
00210 reco::SuperClusterRef superClusterRef() const;
00211
00213 void setPhotonRef(const reco::PhotonRef& phRef);
00214
00216 reco::PhotonRef photonRef() const;
00217
00219 void setPFPhotonExtraRef(const reco::PFCandidatePhotonExtraRef& ref);
00220
00222 reco::PFCandidatePhotonExtraRef photonExtraRef() const;
00223
00224
00226 void setPs1Energy( float e1 ) {ps1Energy_ = e1;}
00227
00229 double pS1Energy() const { return ps1Energy_;}
00230
00232 void setPs2Energy( float e2 ) {ps2Energy_ = e2;}
00233
00235 double pS2Energy() const { return ps2Energy_;}
00236
00238 void rescaleMomentum( double rescaleFactor );
00239
00241 void setFlag(Flags theFlag, bool value);
00242
00244 bool flag(Flags theFlag) const;
00245
00247 void setDeltaP(double dp ) {deltaP_ = dp;}
00248
00250 double deltaP() const { return deltaP_;}
00251
00252
00253
00259
00260
00261 void set_mva_e_pi( float mva ){ mva_e_pi_=mva;}
00262
00264 float mva_e_pi() const { return mva_e_pi_;}
00265
00266
00268 void set_mva_e_mu( float mva ) { mva_e_mu_=mva;}
00269
00271 float mva_e_mu() const { return mva_e_mu_;}
00272
00274 void set_mva_pi_mu( float mva ) { mva_pi_mu_=mva;}
00275
00277 float mva_pi_mu() const { return mva_pi_mu_;}
00278
00279
00281 void set_mva_nothing_gamma( float mva ) { mva_nothing_gamma_=mva;}
00282
00284 float mva_nothing_gamma() const { return mva_nothing_gamma_;}
00285
00287 void set_mva_nothing_nh( float mva ) { mva_nothing_nh_=mva;}
00288
00290 float mva_nothing_nh() const { return mva_nothing_nh_;}
00291
00292
00294 void set_mva_gamma_nh( float mva ) { mva_gamma_nh_=mva;}
00295
00297 float mva_gamma_nh() const { return mva_gamma_nh_;}
00298
00300 void setPositionAtECALEntrance(const math::XYZPointF& pos) {
00301 positionAtECALEntrance_ = pos;
00302 }
00303
00305 void setPFElectronExtraRef(const reco::PFCandidateElectronExtraRef& ref);
00306
00308 const math::XYZPointF& positionAtECALEntrance() const {
00309 return positionAtECALEntrance_;
00310 }
00311
00314 virtual ParticleType particleId() const { return translatePdgIdToType(pdgId_);}
00315
00316
00318
00319
00320
00322
00323
00324
00326 typedef std::pair<reco::PFBlockRef, unsigned> ElementInBlock;
00327 typedef std::vector< ElementInBlock > ElementsInBlocks;
00328
00329 typedef edm::RefVector<reco::PFBlockCollection> Blocks;
00330 typedef std::vector<unsigned> Elements;
00331
00332 const ElementsInBlocks& elementsInBlocks() const {
00333
00334 if (elementsInBlocks_.size()!=blocksStorage_.size())
00335 {
00336 elementsInBlocks_.resize(blocksStorage_.size());
00337 for(unsigned int icopy=0;icopy!=blocksStorage_.size();++icopy)
00338 elementsInBlocks_[icopy]=std::make_pair(blocksStorage_[icopy],elementsStorage_[icopy]);
00339 }
00340 return elementsInBlocks_;
00341 }
00342
00343
00344
00345 static const float bigMva_;
00346
00347 friend std::ostream& operator<<( std::ostream& out,
00348 const PFCandidate& c );
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358 void setVertexSource( PFVertexType vt) { vertexType_=vt; if (vertexType_!=kCandVertex) vertex_=Point(0.,0.,0.);}
00359
00360 virtual void setVertex( math::XYZPoint p) {
00361 vertex_=p; vertexType_ = kCandVertex;
00362 }
00363
00364 virtual const Point & vertex() const;
00365 virtual double vx() const {return vertex().x();}
00366 virtual double vy() const {return vertex().y();}
00367 virtual double vz() const {return vertex().z();}
00368
00369 private:
00371 virtual bool overlap( const Candidate & ) const;
00372
00373 void setFlag(unsigned shift, unsigned flag, bool value);
00374
00375 bool flag(unsigned shift, unsigned flag) const;
00376
00377
00378 mutable ElementsInBlocks elementsInBlocks_;
00379 Blocks blocksStorage_;
00380 Elements elementsStorage_;
00381
00383
00384 PFCandidatePtr sourcePtr_;
00385
00386
00388 float ecalERatio_;
00389
00391 float hcalERatio_;
00392
00394 float rawEcalEnergy_;
00395
00397 float rawHcalEnergy_;
00398
00400 float ps1Energy_;
00401
00403 float ps2Energy_;
00404
00406 unsigned flags_;
00407
00409 float deltaP_;
00410
00411 PFVertexType vertexType_;
00412
00414 float mva_e_pi_;
00415
00417 float mva_e_mu_;
00418
00420 float mva_pi_mu_;
00421
00423 float mva_nothing_gamma_;
00424
00426 float mva_nothing_nh_;
00427
00429 float mva_gamma_nh_;
00430
00432 math::XYZPointF positionAtECALEntrance_;
00433
00434
00435
00436 void storeRefInfo(unsigned int iMask, unsigned int iBit, bool iIsValid,
00437 const edm::RefCore& iCore, size_t iKey,
00438 const edm::EDProductGetter*);
00439 bool getRefInfo(unsigned int iMask, unsigned int iBit,
00440 edm::ProductID& oProdID, size_t& oIndex, size_t& aIndex ) const;
00441
00442
00443 const edm::EDProductGetter* getter_;
00444 unsigned short storedRefsBitPattern_;
00445 std::vector<unsigned long long> refsInfo_;
00446 std::vector<const void *> refsCollectionCache_;
00447
00448 };
00449
00451 struct PFParticleIdTag { };
00452
00455
00456
00459 GET_CANDIDATE_COMPONENT( PFCandidate, PFCandidate::ParticleType, particleId, PFParticleIdTag );
00460
00461 std::ostream& operator<<( std::ostream& out, const PFCandidate& c );
00462
00463
00464 }
00465
00466 #endif