Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:26:32

0001 // This class header:
0002 #include "FastSimDataFormats/L1GlobalMuonTrigger/interface/SimpleL1MuGMTCand.h"
0003 
0004 // Fast Simulation headers
0005 #include "SimDataFormats/Track/interface/SimTrack.h"
0006 
0007 // The muon scales
0008 
0009 //CMSSW headers
0010 
0011 // STL headers
0012 #include <iomanip>
0013 
0014 SimpleL1MuGMTCand::SimpleL1MuGMTCand()
0015     : m_name("FastL1MuCand"),
0016       m_empty(true),
0017       m_phi(0),
0018       m_eta(31),
0019       m_pt(0),
0020       m_charge(0),
0021       m_quality(0),
0022       m_rank(0),
0023       m_smearedPt(0) {}
0024 
0025 SimpleL1MuGMTCand::SimpleL1MuGMTCand(const SimpleL1MuGMTCand& mu)
0026     : L1MuGMTExtendedCand::L1MuGMTExtendedCand(mu),
0027       m_name(mu.m_name),
0028       m_empty(mu.m_empty),
0029       m_phi(mu.m_phi),
0030       m_eta(mu.m_eta),
0031       m_pt(mu.m_pt),
0032       m_charge(mu.m_charge),
0033       m_quality(mu.m_quality),
0034       m_rank(mu.m_rank),
0035       m_smearedPt(mu.m_smearedPt) {
0036   setMomentum(mu.getMomentum());
0037   setQuality(m_quality & 7);
0038   setEtaPacked(m_eta & 63);
0039   setPhiPacked(m_phi & 255);
0040   setCharge(m_charge);
0041   setPtPacked(m_pt & 31);
0042 }
0043 
0044 SimpleL1MuGMTCand::SimpleL1MuGMTCand(const SimpleL1MuGMTCand* mu)
0045     : m_name(mu->m_name),
0046       m_empty(mu->m_empty),
0047       m_phi(mu->m_phi),
0048       m_eta(mu->m_eta),
0049       m_pt(mu->m_pt),
0050       m_charge(mu->m_charge),
0051       m_quality(mu->m_quality),
0052       m_rank(mu->m_rank),
0053       m_smearedPt(mu->m_smearedPt) {
0054   setMomentum(mu->getMomentum());
0055   setQuality(m_quality & 7);
0056   setEtaPacked(m_eta & 63);
0057   setPhiPacked(m_phi & 255);
0058   setCharge(m_charge);
0059   setPtPacked(m_pt & 31);
0060 }
0061 
0062 SimpleL1MuGMTCand::SimpleL1MuGMTCand(const SimTrack* p) {
0063   //  setMomentum(p->momentum());
0064   LorentzVector toBeRemoved(p->momentum().x(), p->momentum().y(), p->momentum().z(), p->momentum().t());
0065   setMomentum(toBeRemoved);
0066   m_name = "FastL1MuCand";
0067   m_empty = false;
0068   m_quality = 7;
0069   setQuality(m_quality);
0070   m_rank = 0;
0071   setEta(myMomentum.Eta());
0072   setPhi(myMomentum.Phi());
0073   setCharge(int(p->charge()));
0074   setPt(myMomentum.Pt());
0075   setBx(0);
0076   if (fabs(myMomentum.eta()) > 1.04)
0077     setFwdBit(1);
0078   else
0079     setFwdBit(0);
0080   setRPCBit(0);
0081 }
0082 
0083 SimpleL1MuGMTCand::SimpleL1MuGMTCand(const SimTrack* p,
0084                                      unsigned etaIndex,
0085                                      unsigned phiIndex,
0086                                      unsigned pTIndex,
0087                                      float etaValue,
0088                                      float phiValue,
0089                                      float pTValue) {
0090   //  setMomentum(p->momentum());
0091   LorentzVector toBeRemoved(p->momentum().x(), p->momentum().y(), p->momentum().z(), p->momentum().t());
0092   setMomentum(toBeRemoved);
0093   m_name = "FastL1MuCand";
0094   m_empty = false;
0095   m_quality = 7;
0096   setQuality(m_quality);
0097   m_rank = 0;
0098   m_phi = phiIndex;
0099   setPhiPacked(phiIndex);
0100   setPhiValue(phiValue);
0101   m_eta = etaIndex;
0102   setEtaPacked(etaIndex);
0103   setEtaValue(etaValue);
0104   setCharge(int(p->charge()));
0105   m_pt = pTIndex;
0106   setPtPacked(pTIndex);
0107   setPtValue(pTValue);
0108   m_smearedPt = myMomentum.Pt();
0109   setBx(0);
0110   if (fabs(etaValue) > 1.04)
0111     setFwdBit(1);
0112   else
0113     setFwdBit(0);
0114   setRPCBit(0);
0115 }
0116 
0117 SimpleL1MuGMTCand::~SimpleL1MuGMTCand() { reset(); }
0118 
0119 //
0120 void SimpleL1MuGMTCand::reset() {
0121   m_empty = true;
0122   m_phi = 0;
0123   m_eta = 31;
0124   m_pt = 0;
0125   m_charge = 0;
0126   m_quality = 0;
0127   m_rank = 0;
0128   m_smearedPt = 0;
0129 }
0130 
0131 //
0132 // set phi-value of muon candidate
0133 //
0134 void SimpleL1MuGMTCand::setPhi(float phi) {
0135   int index = 0;
0136   float mindiff = 1000.0;
0137 
0138   if (phi < 0.) {
0139     phi = 2 * M_PI + phi;
0140   }
0141   for (int i = 0; i < 144; i++) {
0142     float diff = fabs(SimpleL1MuGMTCand::phiScale[i] - phi);
0143     if (diff <= mindiff) {
0144       mindiff = diff;
0145       index = i;
0146     }
0147   }
0148 
0149   m_phi = index;
0150   setPhiPacked(m_phi & 255);
0151   setPhiValue(phiScale[m_phi]);
0152 }
0153 
0154 //
0155 // set eta-value of muon candidate
0156 //
0157 void SimpleL1MuGMTCand::setEta(float eta) {
0158   int index = 0;
0159   float mindiff = 1000.0;
0160 
0161   for (int i = 0; i < 63; i++) {
0162     float diff = fabs(SimpleL1MuGMTCand::etaScale[i] - eta);
0163     if (diff <= mindiff) {
0164       mindiff = diff;
0165       index = i;
0166     }
0167   }
0168 
0169   m_eta = index;
0170   setEtaPacked(m_eta & 63);
0171   setEtaValue(etaScale[m_eta]);
0172 }
0173 
0174 //
0175 // set pt (value!!) of muon candidate
0176 //
0177 void SimpleL1MuGMTCand::setPt(float pt) {
0178   int index = 0;
0179   m_smearedPt = pt;
0180 
0181   float mindiff = 1000.0;
0182 
0183   for (int i = 0; i < 32; i++) {
0184     float diff = fabs(SimpleL1MuGMTCand::ptScale[i] - pt);
0185     if (diff <= mindiff) {
0186       mindiff = diff;
0187       index = i;
0188     }
0189   }
0190 
0191   m_pt = index;
0192   setPtPacked(m_pt & 31);
0193   setPtValue(ptScale[m_pt]);
0194 }
0195 
0196 //
0197 // set charge and packed code of muon candidate
0198 //
0199 void SimpleL1MuGMTCand::setCharge(int charge) {
0200   m_charge = charge;
0201   setChargePacked(charge == 1 ? 0 : 1);
0202 }
0203 
0204 //
0205 // set generator particle of muon candidate
0206 //
0207 /*
0208 void SimpleL1MuGMTCand::setGenPart(const HepMC::GenParticle * rhp) {
0209 
0210    myGenParticle = rhp;
0211 }
0212 */
0213 
0214 //
0215 // Assignment operator
0216 //
0217 SimpleL1MuGMTCand& SimpleL1MuGMTCand::operator=(const SimpleL1MuGMTCand& cand) {
0218   if (this != &cand) {
0219     m_empty = cand.m_empty;
0220     m_phi = cand.m_phi;
0221     m_eta = cand.m_eta;
0222     m_pt = cand.m_pt;
0223     m_charge = cand.m_charge;
0224     m_quality = cand.m_quality;
0225     m_rank = cand.m_rank;
0226     m_smearedPt = cand.m_smearedPt;
0227   }
0228   return *this;
0229 }
0230 
0231 //
0232 // Assignment operator for SimTrack's
0233 //
0234 SimpleL1MuGMTCand* SimpleL1MuGMTCand::operator=(const SimTrack* p) {
0235   m_empty = false;
0236   setEta(p->momentum().eta());
0237   setPhi(p->momentum().phi());
0238   setCharge(int(p->charge()));
0239   setPt(std::sqrt(p->momentum().perp2()));
0240 
0241   return this;
0242 }
0243 
0244 //
0245 // Equal operator
0246 //
0247 bool SimpleL1MuGMTCand::operator==(const SimpleL1MuGMTCand& cand) const {
0248   if (m_empty != cand.m_empty)
0249     return false;
0250   if (m_phi != cand.m_phi)
0251     return false;
0252   if (m_eta != cand.m_eta)
0253     return false;
0254   if (m_pt != cand.m_pt)
0255     return false;
0256   if (m_charge != cand.m_charge)
0257     return false;
0258   if (m_quality != cand.m_quality)
0259     return false;
0260   if (m_rank != cand.m_rank)
0261     return false;
0262   return true;
0263 }
0264 
0265 //
0266 // Unequal operator
0267 //
0268 bool SimpleL1MuGMTCand::operator!=(const SimpleL1MuGMTCand& cand) const {
0269   if (m_empty != cand.m_empty)
0270     return true;
0271   if (m_phi != cand.m_phi)
0272     return true;
0273   if (m_eta != cand.m_eta)
0274     return true;
0275   if (m_pt != cand.m_pt)
0276     return true;
0277   if (m_charge != cand.m_charge)
0278     return true;
0279   if (m_quality != cand.m_quality)
0280     return true;
0281   if (m_rank != cand.m_rank)
0282     return true;
0283   return false;
0284 }
0285 
0286 //
0287 // print parameters of track candidate
0288 //
0289 void SimpleL1MuGMTCand::print() const {
0290   using namespace std;
0291 
0292   if (!empty()) {
0293     cout.setf(ios::showpoint);
0294     cout.setf(ios::right, ios::adjustfield);
0295     cout << setiosflags(ios::showpoint | ios::fixed) << "pt = " << setw(5) << setprecision(1) << ptValue() << " GeV  "
0296          << "charge = " << setw(2) << charge() << " "
0297          << "eta = " << setw(5) << setprecision(2) << etaValue() << "  "
0298          << "phi = " << setw(5) << setprecision(3) << phiValue() << " rad  "
0299          << "rank = " << setw(6) << rank() << endl;
0300   }
0301 }
0302 
0303 //
0304 // output stream operator for track candidate
0305 //
0306 std::ostream& operator<<(std::ostream& s, const SimpleL1MuGMTCand& id) {
0307   using namespace std;
0308 
0309   if (!id.empty()) {
0310     s << setiosflags(ios::showpoint | ios::fixed) << "pt = " << setw(5) << setprecision(1) << id.ptValue() << " GeV  "
0311       << "charge = " << setw(2) << id.charge() << " "
0312       << "eta = " << setw(5) << setprecision(2) << id.etaValue() << "  "
0313       << "phi = " << setw(5) << setprecision(3) << id.phiValue() << " rad  ";
0314   }
0315   return s;
0316 }
0317 
0318 //static
0319 
0320 // pt scale in GeV
0321 // low edges of pt bins
0322 const float SimpleL1MuGMTCand::ptScale[32] = {0.0,  0.0,  1.5,  2.0,  2.5,  3.0,  3.5,  4.0,   4.5,   5.0,  6.0,
0323                                               7.0,  8.0,  10.0, 12.0, 14.0, 16.0, 18.0, 20.0,  25.0,  30.0, 35.0,
0324                                               40.0, 45.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0, 120.0, 140.0};
0325 
0326 // eta scale
0327 const float SimpleL1MuGMTCand::etaScale[63] = {
0328     -2.40, -2.35, -2.30, -2.25, -2.20, -2.15, -2.10, -2.05, -2.00, -1.95, -1.90, -1.85, -1.80, -1.75, -1.70, -1.60,
0329     -1.50, -1.40, -1.30, -1.20, -1.10, -1.00, -0.90, -0.80, -0.70, -0.60, -0.50, -0.40, -0.30, -0.20, -0.10, 0.00,
0330     0.10,  0.20,  0.30,  0.40,  0.50,  0.60,  0.70,  0.80,  0.90,  1.00,  1.10,  1.20,  1.30,  1.40,  1.50,  1.60,
0331     1.70,  1.75,  1.80,  1.85,  1.90,  1.95,  2.00,  2.05,  2.10,  2.15,  2.20,  2.25,  2.30,  2.35,  2.40};
0332 
0333 // phi scale
0334 const float SimpleL1MuGMTCand::phiScale[144] = {
0335     0.0000, 0.0436, 0.0873, 0.1309, 0.1745, 0.2182, 0.2618, 0.3054, 0.3491, 0.3927, 0.4363, 0.4800, 0.5236, 0.5672,
0336     0.6109, 0.6545, 0.6981, 0.7418, 0.7854, 0.8290, 0.8727, 0.9163, 0.9599, 1.0036, 1.0472, 1.0908, 1.1345, 1.1781,
0337     1.2217, 1.2654, 1.3090, 1.3526, 1.3963, 1.4399, 1.4835, 1.5272, 1.5708, 1.6144, 1.6581, 1.7017, 1.7453, 1.7890,
0338     1.8326, 1.8762, 1.9199, 1.9635, 2.0071, 2.0508, 2.0944, 2.1380, 2.1817, 2.2253, 2.2689, 2.3126, 2.3562, 2.3998,
0339     2.4435, 2.4871, 2.5307, 2.5744, 2.6180, 2.6616, 2.7053, 2.7489, 2.7925, 2.8362, 2.8798, 2.9234, 2.9671, 3.0107,
0340     3.0543, 3.0980, 3.1416, 3.1852, 3.2289, 3.2725, 3.3161, 3.3598, 3.4034, 3.4470, 3.4907, 3.5343, 3.5779, 3.6216,
0341     3.6652, 3.7088, 3.7525, 3.7961, 3.8397, 3.8834, 3.9270, 3.9706, 4.0143, 4.0579, 4.1015, 4.1452, 4.1888, 4.2324,
0342     4.2761, 4.3197, 4.3633, 4.4070, 4.4506, 4.4942, 4.5379, 4.5815, 4.6251, 4.6688, 4.7124, 4.7560, 4.7997, 4.8433,
0343     4.8869, 4.9306, 4.9742, 5.0178, 5.0615, 5.1051, 5.1487, 5.1924, 5.2360, 5.2796, 5.3233, 5.3669, 5.4105, 5.4542,
0344     5.4978, 5.5414, 5.5851, 5.6287, 5.6723, 5.7160, 5.7596, 5.8032, 5.8469, 5.8905, 5.9341, 5.9778, 6.0214, 6.0650,
0345     6.1087, 6.1523, 6.1959, 6.2396};