Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:04:36

0001 #ifndef DataFormats_L1TParticleFlow_PFJet_h
0002 #define DataFormats_L1TParticleFlow_PFJet_h
0003 
0004 #include <vector>
0005 #include "DataFormats/L1Trigger/interface/L1Candidate.h"
0006 #include "DataFormats/L1TParticleFlow/interface/PFCandidate.h"
0007 #include "DataFormats/Common/interface/Ptr.h"
0008 
0009 namespace l1t {
0010 
0011   class PFJet : public L1Candidate {
0012   public:
0013     /// constituent information. note that this is not going to be available in the hardware!
0014     typedef std::vector<edm::Ptr<l1t::PFCandidate>> Constituents;
0015 
0016     PFJet() {}
0017     PFJet(float pt, float eta, float phi, float mass = 0, int hwpt = 0, int hweta = 0, int hwphi = 0)
0018         : L1Candidate(PolarLorentzVector(pt, eta, phi, mass), hwpt, hweta, hwphi, /*hwQuality=*/0), rawPt_(pt) {}
0019 
0020     PFJet(const LorentzVector& p4, int hwpt = 0, int hweta = 0, int hwphi = 0)
0021         : L1Candidate(p4, hwpt, hweta, hwphi, /*hwQuality=*/0), rawPt_(p4.Pt()) {}
0022 
0023     // change the pt (but doesn't change the raw pt)
0024     void calibratePt(float newpt);
0025 
0026     // return the raw pT()
0027     float rawPt() const { return rawPt_; }
0028 
0029     /// constituent information. note that this is not going to be available in the hardware!
0030     const Constituents& constituents() const { return constituents_; }
0031     /// adds a candidate to this cluster; note that this only records the information, it's up to you to also set the 4-vector appropriately
0032     void addConstituent(const edm::Ptr<l1t::PFCandidate>& cand) { constituents_.emplace_back(cand); }
0033 
0034     // candidate interface
0035     size_t numberOfDaughters() const override { return constituents_.size(); }
0036     const reco::Candidate* daughter(size_type i) const override { return constituents_[i].get(); }
0037     using reco::LeafCandidate::daughter;  // avoid hiding the base
0038     edm::Ptr<l1t::PFCandidate> daughterPtr(size_type i) const { return constituents_[i]; }
0039 
0040     // Get and set the encodedJet_ bits. The Jet is encoded in 128 bits as a 2-element array of uint64_t
0041     // We store encodings both for Correlator internal usage and for Global Trigger
0042     enum class HWEncoding { CT, GT };
0043     typedef std::array<uint64_t, 2> PackedJet;
0044     const PackedJet& encodedJet(const HWEncoding encoding = HWEncoding::GT) const {
0045       return encodedJet_[static_cast<int>(encoding)];
0046     }
0047     void setEncodedJet(const HWEncoding encoding, const PackedJet jet) {
0048       encodedJet_[static_cast<int>(encoding)] = jet;
0049     }
0050 
0051     // Accessors to HW objects with ap_* types from encoded words
0052     const PackedJet& getHWJetGT() const { return encodedJet(HWEncoding::GT); }
0053     const PackedJet& getHWJetCT() const { return encodedJet(HWEncoding::CT); }
0054 
0055   private:
0056     float rawPt_;
0057     Constituents constituents_;
0058     std::array<PackedJet, 2> encodedJet_ = {{{{0, 0}}, {{0, 0}}}};
0059   };
0060 
0061   typedef std::vector<l1t::PFJet> PFJetCollection;
0062   typedef edm::Ref<l1t::PFJetCollection> PFJetRef;
0063   typedef std::vector<l1t::PFJetRef> PFJetVectorRef;
0064 }  // namespace l1t
0065 #endif