Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:54:13

0001 #ifndef ParticleFlowCandidate_PFCandidateEGammaExtra_h
0002 #define ParticleFlowCandidate_PFCandidateEGammaExtra_h
0003 
0004 #include "DataFormats/TrackReco/interface/TrackFwd.h"
0005 #include "DataFormats/GsfTrackReco/interface/GsfTrackFwd.h"
0006 #include "DataFormats/Math/interface/LorentzVector.h"
0007 #include "DataFormats/EgammaReco/interface/SuperClusterFwd.h"
0008 #include "DataFormats/EgammaCandidates/interface/ConversionFwd.h"
0009 #include "DataFormats/ParticleFlowReco/interface/PFBlock.h"
0010 #include "DataFormats/ParticleFlowReco/interface/PFBlockFwd.h"
0011 #include "DataFormats/ParticleFlowReco/interface/PFBlockElementTrack.h"
0012 #include "DataFormats/ParticleFlowReco/interface/PFBlockElementCluster.h"
0013 
0014 #include <iosfwd>
0015 
0016 namespace reco {
0017   /** \class reco::PFCandidateEGammaExtra
0018  *
0019  * extra information on the photon/electron particle candidate from particle flow
0020  *
0021  */
0022   typedef std::pair<reco::PFBlockRef, unsigned> ElementInBlock;
0023   typedef std::vector<ElementInBlock> ElementsInBlocks;
0024 
0025   class PFCandidateEGammaExtra {
0026   public:
0027     enum StatusFlag {
0028       X = 0,                  // undefined
0029       Selected,               // selected
0030       ECALDrivenPreselected,  // ECAL-driven electron pre-selected
0031       MVASelected,            // Passed the internal particle-flow selection (mva selection)
0032       Rejected                // Rejected
0033     };
0034 
0035     // if you had a variable update NMvaVariables
0036     enum MvaVariable {
0037       MVA_FIRST = 0,
0038       MVA_LnPtGsf = MVA_FIRST,
0039       MVA_EtaGsf,
0040       MVA_SigmaPtOverPt,
0041       MVA_Fbrem,
0042       MVA_Chi2Gsf,
0043       MVA_NhitsKf,
0044       MVA_Chi2Kf,
0045       MVA_EtotOverPin,
0046       MVA_EseedOverPout,
0047       MVA_EbremOverDeltaP,
0048       MVA_DeltaEtaTrackCluster,
0049       MVA_LogSigmaEtaEta,
0050       MVA_HOverHE,
0051       MVA_LateBrem,
0052       MVA_FirstBrem,
0053       MVA_MVA,
0054       MVA_LAST
0055     };
0056 
0057     enum ElectronVetoes {
0058       kFailsMVA,
0059       kKFTracksOnGSFCluster,  // any number of additional tracks on GSF cluster
0060       kFailsTrackAndHCALIso,  // > 3 kfs on Gsf-cluster, bad h/e
0061       kKillAdditionalKFs,     // tracks with hcal linkbut good gsf etot/p_in
0062       kItIsAPion,             // bad H/P_in, H/H+E, and E_tot/P_in
0063       kCrazyEoverP,           // screwey track linking / weird GSFs
0064       kTooLargeAngle,         // angle between GSF and RSC centroid too large
0065       kN_EVETOS
0066     };
0067 
0068     enum PhotonVetoes {
0069       kFailsTrackIso,  // the photon fails tracker isolation
0070       kN_PHOVETOS
0071     };
0072 
0073   public:
0074     /// constructor
0075     PFCandidateEGammaExtra();
0076     /// constructor
0077     PFCandidateEGammaExtra(const GsfTrackRef&);
0078     /// destructor
0079     ~PFCandidateEGammaExtra() { ; }
0080 
0081     /// set gsftrack reference
0082     void setGsfTrackRef(const reco::GsfTrackRef& ref);
0083 
0084     /// set kf track reference
0085     void setKfTrackRef(const reco::TrackRef& ref);
0086 
0087     /// set gsf electron cluster ref
0088     void setGsfElectronClusterRef(const reco::PFBlockRef& blk, const reco::PFBlockElementCluster& ref) {
0089       eleGsfCluster_ = ElementInBlock(blk, ref.index());
0090     }
0091 
0092     /// return a reference to the corresponding GSF track
0093     reco::GsfTrackRef gsfTrackRef() const { return gsfTrackRef_; }
0094 
0095     /// return a reference to the corresponding KF track
0096     reco::TrackRef kfTrackRef() const { return kfTrackRef_; }
0097 
0098     /// return a reference to the electron cluster ref
0099     const ElementInBlock& gsfElectronClusterRef() const { return eleGsfCluster_; }
0100 
0101     /// return a reference to the corresponding supercluster
0102     reco::SuperClusterRef superClusterRef() const { return scRef_; }
0103 
0104     /// return a reference to the corresponding box supercluster
0105     reco::SuperClusterRef superClusterPFECALRef() const { return scPFECALRef_; }
0106 
0107     /// set reference to the corresponding supercluster
0108     void setSuperClusterRef(reco::SuperClusterRef sc) { scRef_ = sc; }
0109 
0110     /// set reference to the corresponding supercluster
0111     void setSuperClusterPFECALRef(reco::SuperClusterRef sc) { scPFECALRef_ = sc; }
0112 
0113     /// add Single Leg Conversion TrackRef
0114     void addSingleLegConvTrackRefMva(const std::pair<reco::TrackRef, float>& trackrefmva);
0115 
0116     /// return vector of Single Leg Conversion TrackRef from
0117     const std::vector<std::pair<reco::TrackRef, float> >& singleLegConvTrackRefMva() const { return assoSingleLeg_; }
0118 
0119     /// add Conversions from PF
0120     void addConversionRef(const reco::ConversionRef& convref);
0121 
0122     /// return Conversions from PF
0123     reco::ConversionRefVector conversionRef() const { return assoConversionsRef_; }
0124 
0125     /// add Conversions from PF
0126     void addSingleLegConversionRef(const reco::ConversionRef& convref);
0127 
0128     /// return Conversions from PF
0129     reco::ConversionRefVector singleLegConversionRef() const { return singleLegConversions_; }
0130 
0131     /// set LateBrem
0132     void setLateBrem(float val);
0133     /// set EarlyBrem
0134     void setEarlyBrem(float val);
0135 
0136     /// set the pout (not trivial to get from the GSF track)
0137     void setGsfTrackPout(const math::XYZTLorentzVector& pout);
0138 
0139     /// set the cluster energies. the Pout should be saved first
0140     void setClusterEnergies(const std::vector<float>& energies);
0141 
0142     /// set the sigmaetaeta
0143     void setSigmaEtaEta(float val);
0144 
0145     /// set the delta eta
0146     void setDeltaEta(float val);
0147 
0148     /// set the had energy. The cluster energies should be entered before
0149     void setHadEnergy(float val);
0150 
0151     /// set the result (mostly for debugging)
0152     void setMVA(float val);
0153 
0154     /// set status
0155     void setStatus(StatusFlag type, bool status = true);
0156 
0157     /// access to the status
0158     bool electronStatus(StatusFlag) const;
0159 
0160     /// access to the status
0161     int electronStatus() const { return status_; }
0162 
0163     /// access to mva variable status
0164     bool mvaStatus(MvaVariable flag) const;
0165 
0166     /// access to the mva variables
0167     const std::vector<float>& mvaVariables() const { return mvaVariables_; }
0168 
0169     /// access to any variable
0170     float mvaVariable(MvaVariable var) const;
0171 
0172     /// access to specific variables
0173     float hadEnergy() const { return hadEnergy_; }
0174     float sigmaEtaEta() const { return sigmaEtaEta_; }
0175 
0176     /// track counting for electrons and photons
0177     void addExtraNonConvTrack(const reco::PFBlockRef& blk, const reco::PFBlockElementTrack& tkref) {
0178       if (!tkref.trackType(reco::PFBlockElement::T_FROM_GAMMACONV)) {
0179         assoNonConvExtraTracks_.push_back(std::make_pair(blk, tkref.index()));
0180       }
0181     }
0182     const ElementsInBlocks& extraNonConvTracks() const { return assoNonConvExtraTracks_; }
0183 
0184   private:
0185     void setVariable(MvaVariable type, float var);
0186 
0187   private:
0188     /// Ref to the GSF track
0189     reco::GsfTrackRef gsfTrackRef_;
0190     /// Ref to the KF track
0191     reco::TrackRef kfTrackRef_;
0192     /// Ref to the electron gsf cluster;
0193     ElementInBlock eleGsfCluster_;
0194 
0195     /// Ref to (refined) supercluster
0196     reco::SuperClusterRef scRef_;
0197 
0198     /// Ref to PF-ECAL only supercluster
0199     reco::SuperClusterRef scPFECALRef_;
0200 
0201     ///  vector of TrackRef from Single Leg conversions and associated mva value
0202     std::vector<std::pair<reco::TrackRef, float> > assoSingleLeg_;
0203 
0204     // information for track matching
0205     ElementsInBlocks assoNonConvExtraTracks_;
0206 
0207     /// vector of ConversionRef from PF
0208     reco::ConversionRefVector assoConversionsRef_;
0209 
0210     //associated single leg conversions
0211     reco::ConversionRefVector singleLegConversions_;
0212 
0213     /// energy of individual clusters (corrected).
0214     /// The first cluster is the seed
0215     std::vector<float> clusterEnergies_;
0216 
0217     /// mva variables  -  transient !
0218     std::vector<float> mvaVariables_;
0219 
0220     /// status of  mva variables
0221     int mvaStatus_;
0222 
0223     /// Status of the electron
0224     int status_;
0225 
0226     /// Variables entering the MVA that should be saved
0227     math::XYZTLorentzVector pout_;
0228     float earlyBrem_;
0229     float lateBrem_;
0230     float sigmaEtaEta_;
0231     float hadEnergy_;
0232     float deltaEta_;
0233   };
0234 
0235   /// print the variables
0236   std::ostream& operator<<(std::ostream& out, const PFCandidateEGammaExtra& c);
0237 
0238 }  // namespace reco
0239 #endif