CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/DataFormats/ParticleFlowCandidate/interface/PFCandidate.h

Go to the documentation of this file.
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/EgammaReco/interface/SuperClusterFwd.h"
00022 #include "DataFormats/ParticleFlowReco/interface/PFDisplacedVertexFwd.h"
00023 #include "DataFormats/EgammaCandidates/interface/ConversionFwd.h"
00024 #include "DataFormats/Candidate/interface/VertexCompositeCandidate.h"
00025 // to be removed
00026 #include "DataFormats/VertexReco/interface/NuclearInteractionFwd.h"
00027 namespace reco {
00034   class PFCandidate : public CompositeCandidate {
00035 
00036   public:
00037     
00039     enum ParticleType {
00040       X=0,     // undefined
00041       h,       // charged hadron
00042       e,       // electron 
00043       mu,      // muon 
00044       gamma,   // photon
00045       h0,      // neutral hadron
00046       h_HF,        // HF tower identified as a hadron
00047       egamma_HF    // HF tower identified as an EM particle
00048     };
00049 
00050     enum Flags {
00051       NORMAL=0,
00052       E_PHI_SMODULES,
00053       E_ETA_0,
00054       E_ETA_MODULES,
00055       E_BARREL_ENDCAP,
00056       E_PRESHOWER_EDGE,
00057       E_PRESHOWER,
00058       E_ENDCAP_EDGE,
00059       H_ETA_0,
00060       H_BARREL_ENDCAP,
00061       H_ENDCAP_VFCAL,
00062       H_VFCAL_EDGE,  
00063       T_TO_DISP,
00064       T_FROM_DISP,
00065       T_FROM_V0,
00066       T_FROM_GAMMACONV,
00067       GAMMA_TO_GAMMACONV
00068     };
00069     
00070 
00071 
00073     PFCandidate();
00074 
00076     PFCandidate( const PFCandidatePtr& sourcePtr );
00077     
00078     /*     PFCandidate( Charge q,  */
00079     /*                  const LorentzVector & p4,  */
00080     /*                  ParticleType particleId,  */
00081     /*                  reco::PFBlockRef blockRef ); */
00082     PFCandidate( Charge q, 
00083                  const LorentzVector & p4, 
00084                  ParticleType particleId );
00085 
00087     virtual ~PFCandidate() {}
00088 
00090     virtual PFCandidate * clone() const;
00091 
00092 
00093     /*    /// set source ref */
00094     /*     void setSourceRef(const PFCandidateRef& ref) { sourceRef_ = ref; } */
00095 
00096     /*     size_type numberOfSourceCandidateRefs() const {return 1;} */
00097 
00098     /*     CandidateBaseRef sourceCandidateRef( size_type i ) const { */
00099     /*       return  CandidateBaseRef(sourceRef_); */
00100     /*     } */
00101 
00102     //using reco::Candidate::setSourceCandidatePtr;
00103     void setSourceCandidatePtr(const PFCandidatePtr& ptr) { sourcePtr_ = ptr; }
00104 
00105     size_t numberOfSourceCandidatePtrs() const { 
00106       return 1;
00107     }
00108     
00109     CandidatePtr sourceCandidatePtr( size_type i ) const {
00110       return sourcePtr_;
00111     }
00112 
00116     int  translateTypeToPdgId( ParticleType type ) const;
00117 
00119     void setParticleType( ParticleType type ); 
00120 
00121     
00123     /*     void addElement( const reco::PFBlockElement* element ); */
00124     
00126     void addElementInBlock( const reco::PFBlockRef& blockref,
00127                             unsigned elementIndex );
00128 
00130     void setTrackRef(const reco::TrackRef& ref);
00131 
00134     reco::TrackRef trackRef() const { return trackRef_; }
00135 
00137     void setGsfTrackRef(const reco::GsfTrackRef& ref);   
00138 
00141     reco::GsfTrackRef gsfTrackRef() const { return gsfTrackRef_; }     
00142 
00144     void setMuonRef(const reco::MuonRef& ref);
00145 
00148     reco::MuonRef muonRef() const { return muonRef_; }    
00149 
00151     void setDisplacedVertexRef(const reco::PFDisplacedVertexRef& ref, Flags flag);
00152 
00155     reco::PFDisplacedVertexRef displacedVertexRef(Flags type) const { 
00156       if (type == T_TO_DISP) return displacedVertexDaughterRef_; 
00157       else if (type == T_FROM_DISP) return displacedVertexMotherRef_; 
00158       return reco::PFDisplacedVertexRef();
00159     }
00160 
00162     void setConversionRef(const reco::ConversionRef& ref);
00163 
00165     reco::ConversionRef conversionRef() const { return conversionRef_; }
00166 
00168     void setV0Ref(const reco::VertexCompositeCandidateRef& ref);
00169 
00171     reco::VertexCompositeCandidateRef v0Ref() const { return v0Ref_; }
00172 
00174     reco::GsfElectronRef gsfElectronRef() const {return gsfElectronRef_;} 
00175 
00177     reco::SuperClusterRef superClusterRef() const {return superClusterRef_;} 
00178 
00180     reco::PFCandidateElectronExtraRef electronExtraRef() const {return pfElectronExtraRef_;}
00181 
00183     void setEcalEnergy( float ee ) {ecalEnergy_ = ee;}
00184 
00186     double ecalEnergy() const { return ecalEnergy_;}
00187     
00189     void setHcalEnergy( float eh ) {hcalEnergy_ = eh;}
00190 
00192     double hcalEnergy() const { return hcalEnergy_;}
00193 
00195     void setRawEcalEnergy( float ee ) {rawEcalEnergy_ = ee;}
00196 
00198     double rawEcalEnergy() const { return rawEcalEnergy_;}
00199     
00201     void setRawHcalEnergy( float eh ) {rawHcalEnergy_ = eh;}
00202 
00204     void setGsfElectronRef (const reco::GsfElectronRef & ref) {gsfElectronRef_ = ref; }
00205 
00207     double rawHcalEnergy() const { return rawHcalEnergy_;}
00208 
00210     void setPs1Energy( float e1 ) {ps1Energy_ = e1;}
00211 
00213     double pS1Energy() const { return ps1Energy_;}
00214 
00216     void setPs2Energy( float e2 ) {ps2Energy_ = e2;}
00217 
00219     double pS2Energy() const { return ps2Energy_;}
00220 
00222     void rescaleMomentum( double rescaleFactor );
00223 
00225     void setFlag(Flags theFlag, bool value);
00226     
00228     bool flag(Flags theFlag) const;
00229 
00231     void setDeltaP(double dp ) {deltaP_ = dp;}
00232 
00234     double deltaP() const { return deltaP_;}
00235     
00236 
00242     void set_mva_e_pi( float mva ) { mva_e_pi_ = mva; } 
00243     
00245     float mva_e_pi() const { return mva_e_pi_;}
00246 
00247     
00249     void set_mva_e_mu( float mva ) { mva_e_mu_ = mva; } 
00250     
00252     float mva_e_mu() const { return mva_e_mu_;}
00253 
00254 
00256     void set_mva_pi_mu( float mva ) { mva_pi_mu_ = mva; } 
00257 
00259     float mva_pi_mu() const { return mva_pi_mu_;}
00260     
00261 
00263     void set_mva_nothing_gamma( float mva ) { mva_nothing_gamma_ = mva; } 
00264 
00266     float mva_nothing_gamma() const { return mva_nothing_gamma_;}
00267 
00268 
00270     void set_mva_nothing_nh( float mva ) { mva_nothing_nh_ = mva; } 
00271 
00273     float mva_nothing_nh() const { return mva_nothing_nh_;}
00274 
00275 
00277     void set_mva_gamma_nh( float mva ) { mva_gamma_nh_ = mva; } 
00278 
00280     float mva_gamma_nh() const { return mva_gamma_nh_;}
00281 
00283     void setPositionAtECALEntrance(const math::XYZPointF& pos) {
00284       positionAtECALEntrance_ = pos;
00285     } 
00286     
00288     void setPFElectronExtraRef(const reco::PFCandidateElectronExtraRef& ref) {
00289       pfElectronExtraRef_=ref ;
00290     }
00291 
00293     const math::XYZPointF& positionAtECALEntrance() const {
00294       return positionAtECALEntrance_;
00295     }
00296     
00299     virtual  ParticleType particleId() const { return particleId_;}
00300 
00301     
00303     /*     const std::vector<unsigned>& elementIndices() const {  */
00304     /*       return elementIndices_; */
00305     /*     } */
00307     /*     const edm::OwnVector< reco::PFBlockElement >& elements() const  */
00308     /*       {return elements_;} */
00309 
00311     typedef std::pair<reco::PFBlockRef, unsigned> ElementInBlock;
00312 
00313     typedef std::vector< ElementInBlock > ElementsInBlocks;
00314     const ElementsInBlocks& elementsInBlocks() const { 
00315       return elementsInBlocks_;
00316     }
00317     
00318   
00319 
00320     static const float bigMva_;
00321 
00322     friend std::ostream& operator<<( std::ostream& out, 
00323                                      const PFCandidate& c );
00324   
00325   private:
00327     virtual bool overlap( const Candidate & ) const;
00328 
00329     void setFlag(unsigned shift, unsigned flag, bool value);
00330 
00331     bool flag(unsigned shift, unsigned flag) const;
00332    
00334     ParticleType  particleId_; 
00335     
00336   
00337     ElementsInBlocks elementsInBlocks_;
00338 
00340     /*     PFCandidateRef sourceRef_; */
00341     PFCandidatePtr sourcePtr_;
00342 
00343     reco::TrackRef trackRef_;
00344     
00345     reco::GsfTrackRef gsfTrackRef_;  
00346 
00347     reco::MuonRef  muonRef_;
00348 
00349     // unused data member only here for backward compatibility
00350     reco::NuclearInteractionRef nuclearRef_;
00351 
00352     // unused data member only here for backward compatibility
00353     reco::ConversionRef conversionRef_;
00354 
00356     float       ecalEnergy_;
00357 
00359     float       hcalEnergy_;
00360 
00362     float       rawEcalEnergy_;
00363 
00365     float       rawHcalEnergy_;
00366 
00368     float       ps1Energy_;
00369 
00371     float       ps2Energy_;
00372 
00374     unsigned    flags_;
00375 
00377     double      deltaP_;
00378 
00380     float       mva_e_pi_;
00381 
00383     float       mva_e_mu_;
00384 
00386     float       mva_pi_mu_;
00387     
00389     float       mva_nothing_gamma_;
00390 
00392     float       mva_nothing_nh_;
00393 
00395     float       mva_gamma_nh_;
00396 
00398     math::XYZPointF   positionAtECALEntrance_;
00399 
00400 
00402     reco::PFDisplacedVertexRef displacedVertexMotherRef_;
00403 
00405     reco::PFDisplacedVertexRef displacedVertexDaughterRef_;
00406 
00407 
00408     // Reference to a mother V0
00409     reco::VertexCompositeCandidateRef v0Ref_;
00410 
00411     // Reference to the corresponding GsfElectron if any
00412     reco::GsfElectronRef gsfElectronRef_;
00413 
00414     // Reference to the corresponding SuperCluster if any
00415     reco::SuperClusterRef superClusterRef_;
00416 
00417     // Reference to the PFCandidateElectronExtra
00418     reco::PFCandidateElectronExtraRef pfElectronExtraRef_;
00419   };
00420 
00422   struct PFParticleIdTag { };
00423 
00426   /*   GET_DEFAULT_CANDIDATE_COMPONENT( PFCandidate, PFBlockRef, block ); */
00427 
00430   GET_CANDIDATE_COMPONENT( PFCandidate, PFCandidate::ParticleType, particleId, PFParticleIdTag );
00431 
00432   std::ostream& operator<<( std::ostream& out, const PFCandidate& c );
00433 }
00434 
00435 #endif