Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:22:35

0001 #ifndef L1GObject_h
0002 #define L1GObject_h
0003 
0004 #include <iostream>
0005 
0006 #include <string>
0007 
0008 #include "DataFormats/Candidate/interface/LeafCandidate.h"
0009 #include "DataFormats/Math/interface/LorentzVector.h"
0010 
0011 /**
0012  * L1GObject represents a calorimeter global trigger object that
0013  * is made from global calorimeter quantities, total ET, missing ET.
0014  * These objects are created/filled while processing the calorimeter
0015  * trigger information at the card level.
0016  */
0017 
0018 class L1GObject : public reco::LeafCandidate {
0019 public:
0020   // Constructors
0021 
0022   //L1GObject() : myEt(0), myEta(999), myPhi(999), myName("L1GObject") {initialize();}
0023   L1GObject() {}
0024 
0025   L1GObject(unsigned int et, unsigned int eta, unsigned int phi)
0026       : myEt(et), myEta(eta), myPhi(phi), myName("L1GObject") {
0027     initialize();
0028   }
0029 
0030   L1GObject(unsigned int et, unsigned int eta, unsigned int phi, std::string name)
0031       : myEt(et), myEta(eta), myPhi(phi), myName(name) {
0032     initialize();
0033   }
0034 
0035   L1GObject(unsigned int packedObject, std::string name = "L1GObject") {
0036     myEt = (packedObject & 0xFFFF0000) >> 16;
0037     myEta = (packedObject & 0x0000FF00) >> 8;
0038     myPhi = (packedObject & 0x000000FF);
0039     myName = name;
0040     initialize();
0041   }
0042 
0043   unsigned int packedObject() {
0044     if (myEt > 0xFFFF)
0045       myEt = 0xFFFF;
0046     unsigned int etBits = (myEt << 16);
0047     if (myEta < 0xFF) {
0048       unsigned int etaBits = (myEta << 8);
0049       if (myPhi < 0xFF) {
0050         return (etBits + etaBits + myPhi);
0051       }
0052     }
0053     std::cerr << "L1GObject: Cannot pack content - fatal error: " << myEt << ", " << myEta << ", " << myPhi
0054               << std::endl;
0055     return (etBits);
0056   }
0057 
0058   L1GObject(const L1GObject& t) : reco::LeafCandidate::LeafCandidate() {
0059     myName = t.myName;
0060     myPhi = t.myPhi;
0061     myEta = t.myEta;
0062     myEt = t.myEt;
0063     associatedRegionEt_ = t.associatedRegionEt_;
0064     associatedJetPt_ = t.associatedJetPt_;
0065     ellIsolation_ = t.ellIsolation_;
0066     puLevel_ = t.puLevel_;
0067     tauVeto_ = t.tauVeto_;
0068     mipBit_ = t.mipBit_;
0069     initialize();
0070   }
0071 
0072   L1GObject& operator=(const L1GObject& t) {
0073     if (this != &t) {
0074       myName = t.myName;
0075       myPhi = t.myPhi;
0076       myEta = t.myEta;
0077       myEt = t.myEt;
0078       associatedRegionEt_ = t.associatedRegionEt_;
0079       associatedJetPt_ = t.associatedJetPt_;
0080       ellIsolation_ = t.ellIsolation_;
0081       puLevel_ = t.puLevel_;
0082       tauVeto_ = t.tauVeto_;
0083       mipBit_ = t.mipBit_;
0084       initialize();
0085     }
0086     return *this;
0087   }
0088 
0089   // Destructor
0090 
0091   ~L1GObject() override {}
0092 
0093   // Access functions
0094 
0095   std::string name() const { return myName; }
0096 
0097   bool empty() const { return false; }
0098 
0099   double ptValue() const { return myLSB * myEt; }
0100 
0101   double etaValue() const {
0102     if (myEta < 11) {
0103       return -etaValues[-(myEta - 10)];  // 0-10 are negative eta values
0104     } else if (myEta < 22) {
0105       return etaValues[myEta - 11];  // 11-21 are positive eta values
0106     }
0107     return 999.;
0108   }
0109 
0110   double phiValue() const {
0111     if (myPhi < 18)
0112       return phiValues[myPhi];
0113     else
0114       return 999.;
0115   }
0116 
0117   unsigned int ptCode() const { return myEt; }
0118 
0119   unsigned int etaIndex() const { return myEta; }
0120 
0121   unsigned int phiIndex() const { return myPhi; }
0122 
0123   // Operators required for sorting lists of these objects
0124 
0125   bool operator==(const L1GObject& t) const {
0126     if (myEt == t.myEt)
0127       return true;
0128     else
0129       return false;
0130   }
0131 
0132   bool operator<(const L1GObject& t) const {
0133     if (myEt < t.myEt)
0134       return true;
0135     else
0136       return false;
0137   }
0138 
0139   bool operator>(const L1GObject& t) const {
0140     if (myEt > t.myEt)
0141       return true;
0142     else
0143       return false;
0144   }
0145 
0146   bool operator<=(const L1GObject& t) const {
0147     if (myEt <= t.myEt)
0148       return true;
0149     else
0150       return false;
0151   }
0152 
0153   bool operator>=(const L1GObject& t) const {
0154     if (myEt >= t.myEt)
0155       return true;
0156     else
0157       return false;
0158   }
0159 
0160   friend std::ostream& operator<<(std::ostream& os, const L1GObject& t) {
0161     os << "L1GObject : Name = " << t.name() << "(Et, Eta, Phi) = (" << t.myEt << ", " << t.myEta << ", " << t.myPhi
0162        << ") (" << t.ptValue() << ", " << t.etaValue() << ", " << t.phiValue() << ")";
0163     return os;
0164   }
0165 
0166   void setEt(unsigned int et) { myEt = et; }
0167   void setEta(unsigned int eta) { myEta = eta; }
0168   void setPhi(unsigned int phi) { myPhi = phi; }
0169   void setName(std::string name) { myName = name; }
0170   void setLSB(double lsb) { myLSB = lsb; }
0171 
0172   void initialize() {
0173     for (unsigned int i = 0; i < 10; i++) {
0174       phiValues[i] = 2. * 3.1415927 * i / 18;
0175     }
0176     for (unsigned int j = 10; j < 18; j++) {
0177       phiValues[j] = -3.1415927 + 2. * 3.1415927 * (j - 9) / 18;
0178     }
0179     etaValues[0] = 0.174;  // HB and inner HE bins are 0.348 wide
0180     etaValues[1] = 0.522;
0181     etaValues[2] = 0.870;
0182     etaValues[3] = 1.218;
0183     etaValues[4] = 1.566;
0184     etaValues[5] = 1.956;  // Last two HE bins are 0.432 and 0.828 wide
0185     etaValues[6] = 2.586;
0186     etaValues[7] = 3.250;  // HF bins are 0.5 wide
0187     etaValues[8] = 3.750;
0188     etaValues[9] = 4.250;
0189     etaValues[10] = 4.750;
0190     myLSB = 1.0;
0191 
0192     // Initialize tuning parameters
0193     //associatedRegionEt = -1;
0194     //associatedJetPt = -1;
0195     //puLevel = -1;
0196 
0197     // Setup the reco::Candidate (physics) 4-vector
0198     math::PtEtaPhiMLorentzVector myP4(this->ptValue(), this->etaValue(), this->phiValue(), 0);
0199     this->setP4(myP4);
0200   }
0201 
0202   // Extra values for tuning UCT parameters - just public members, to
0203   // eventually be removed
0204   double associatedJetPt() const { return associatedJetPt_; }
0205   unsigned int puLevel() const { return puLevel_; }
0206   double associatedRegionEt() const { return associatedRegionEt_; }
0207   bool ellIsolation() const { return ellIsolation_; };
0208   bool tauVeto() const { return tauVeto_; }
0209   bool mipBit() const { return mipBit_; }
0210 
0211   double associatedJetPt_;
0212   unsigned int puLevel_;
0213   double associatedRegionEt_;
0214   bool ellIsolation_;
0215 
0216   // For the EG objects, don't require this to build the object, just embed it.
0217   bool tauVeto_;
0218   bool mipBit_;
0219 
0220 private:
0221   unsigned int myEt;
0222   unsigned int myEta;
0223   unsigned int myPhi;
0224   std::string myName;
0225 
0226   double myLSB;
0227   double etaValues[11];
0228   double phiValues[18];
0229 };
0230 
0231 #endif