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 setHoEnergy( float eoRaw, float eoCorr ) {
00206 rawHoEnergy_ = eoRaw; hoERatio_= std::abs(eoRaw)<1.e-6 ? 1.0 : eoCorr/eoRaw;}
00207
00209 double hoEnergy() const { return hoERatio_*rawHoEnergy_;}
00210
00212 double rawHoEnergy() const { return rawHoEnergy_;}
00213
00215 void setGsfElectronRef (const reco::GsfElectronRef & ref);
00216
00217 void setSuperClusterRef (const reco::SuperClusterRef& scRef);
00218
00220 reco::SuperClusterRef superClusterRef() const;
00221
00223 void setPhotonRef(const reco::PhotonRef& phRef);
00224
00226 reco::PhotonRef photonRef() const;
00227
00229 void setPFPhotonExtraRef(const reco::PFCandidatePhotonExtraRef& ref);
00230
00232 reco::PFCandidatePhotonExtraRef photonExtraRef() const;
00233
00234
00236 void setPs1Energy( float e1 ) {ps1Energy_ = e1;}
00237
00239 double pS1Energy() const { return ps1Energy_;}
00240
00242 void setPs2Energy( float e2 ) {ps2Energy_ = e2;}
00243
00245 double pS2Energy() const { return ps2Energy_;}
00246
00248 void rescaleMomentum( double rescaleFactor );
00249
00251 void setFlag(Flags theFlag, bool value);
00252
00254 bool flag(Flags theFlag) const;
00255
00257 void setDeltaP(double dp ) {deltaP_ = dp;}
00258
00260 double deltaP() const { return deltaP_;}
00261
00262
00263
00269
00270
00271 void set_mva_e_pi( float mva ){ mva_e_pi_=mva;}
00272
00274 float mva_e_pi() const { return mva_e_pi_;}
00275
00276
00278 void set_mva_e_mu( float mva ) { mva_e_mu_=mva;}
00279
00281 float mva_e_mu() const { return mva_e_mu_;}
00282
00284 void set_mva_pi_mu( float mva ) { mva_pi_mu_=mva;}
00285
00287 float mva_pi_mu() const { return mva_pi_mu_;}
00288
00289
00291 void set_mva_nothing_gamma( float mva ) { mva_nothing_gamma_=mva;}
00292
00294 float mva_nothing_gamma() const { return mva_nothing_gamma_;}
00295
00297 void set_mva_nothing_nh( float mva ) { mva_nothing_nh_=mva;}
00298
00300 float mva_nothing_nh() const { return mva_nothing_nh_;}
00301
00302
00304 void set_mva_gamma_nh( float mva ) { mva_gamma_nh_=mva;}
00305
00307 float mva_gamma_nh() const { return mva_gamma_nh_;}
00308
00310 void setPositionAtECALEntrance(const math::XYZPointF& pos) {
00311 positionAtECALEntrance_ = pos;
00312 }
00313
00315 void setPFElectronExtraRef(const reco::PFCandidateElectronExtraRef& ref);
00316
00318 const math::XYZPointF& positionAtECALEntrance() const {
00319 return positionAtECALEntrance_;
00320 }
00321
00324 virtual ParticleType particleId() const { return translatePdgIdToType(pdgId_);}
00325
00326
00328
00329
00330
00332
00333
00334
00336 typedef std::pair<reco::PFBlockRef, unsigned> ElementInBlock;
00337 typedef std::vector< ElementInBlock > ElementsInBlocks;
00338
00339 typedef edm::RefVector<reco::PFBlockCollection> Blocks;
00340 typedef std::vector<unsigned> Elements;
00341
00342 const ElementsInBlocks& elementsInBlocks() const {
00343
00344 if (elementsInBlocks_.size()!=blocksStorage_.size())
00345 {
00346 elementsInBlocks_.resize(blocksStorage_.size());
00347 for(unsigned int icopy=0;icopy!=blocksStorage_.size();++icopy)
00348 elementsInBlocks_[icopy]=std::make_pair(blocksStorage_[icopy],elementsStorage_[icopy]);
00349 }
00350 return elementsInBlocks_;
00351 }
00352
00353
00354
00355 static const float bigMva_;
00356
00357 friend std::ostream& operator<<( std::ostream& out,
00358 const PFCandidate& c );
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368 void setVertexSource( PFVertexType vt) { vertexType_=vt; if (vertexType_!=kCandVertex) vertex_=Point(0.,0.,0.);}
00369
00370 virtual void setVertex( math::XYZPoint p) {
00371 vertex_=p; vertexType_ = kCandVertex;
00372 }
00373
00374 virtual const Point & vertex() const;
00375 virtual double vx() const {return vertex().x();}
00376 virtual double vy() const {return vertex().y();}
00377 virtual double vz() const {return vertex().z();}
00378
00379 private:
00381 virtual bool overlap( const Candidate & ) const;
00382
00383 void setFlag(unsigned shift, unsigned flag, bool value);
00384
00385 bool flag(unsigned shift, unsigned flag) const;
00386
00387
00388 mutable ElementsInBlocks elementsInBlocks_;
00389 Blocks blocksStorage_;
00390 Elements elementsStorage_;
00391
00393
00394 PFCandidatePtr sourcePtr_;
00395
00396
00398 float ecalERatio_;
00399
00401 float hcalERatio_;
00402
00404 float hoERatio_;
00405
00407 float rawEcalEnergy_;
00408
00410 float rawHcalEnergy_;
00411
00413 float rawHoEnergy_;
00414
00416 float ps1Energy_;
00417
00419 float ps2Energy_;
00420
00422 unsigned flags_;
00423
00425 float deltaP_;
00426
00427 PFVertexType vertexType_;
00428
00430 float mva_e_pi_;
00431
00433 float mva_e_mu_;
00434
00436 float mva_pi_mu_;
00437
00439 float mva_nothing_gamma_;
00440
00442 float mva_nothing_nh_;
00443
00445 float mva_gamma_nh_;
00446
00448 math::XYZPointF positionAtECALEntrance_;
00449
00450
00451
00452 void storeRefInfo(unsigned int iMask, unsigned int iBit, bool iIsValid,
00453 const edm::RefCore& iCore, size_t iKey,
00454 const edm::EDProductGetter*);
00455 bool getRefInfo(unsigned int iMask, unsigned int iBit,
00456 edm::ProductID& oProdID, size_t& oIndex, size_t& aIndex ) const;
00457
00458
00459 const edm::EDProductGetter* getter_;
00460 unsigned short storedRefsBitPattern_;
00461 std::vector<unsigned long long> refsInfo_;
00462 std::vector<const void *> refsCollectionCache_;
00463
00464 };
00465
00467 struct PFParticleIdTag { };
00468
00471
00472
00475 GET_CANDIDATE_COMPONENT( PFCandidate, PFCandidate::ParticleType, particleId, PFParticleIdTag );
00476
00477 std::ostream& operator<<( std::ostream& out, const PFCandidate& c );
00478
00479
00480 }
00481
00482 #endif