Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-03-26 02:43:38

0001 #ifndef L1Trigger_L1TTrackMatch_L1TrackJetEmulationProducer_HH
0002 #define L1Trigger_L1TTrackMatch_L1TrackJetEmulationProducer_HH
0003 #include <iostream>
0004 #include <fstream>
0005 #include <cmath>
0006 #include <cstdlib>
0007 #include <string>
0008 #include <cstdlib>
0009 #include "DataFormats/L1Trigger/interface/TkJetWord.h"
0010 
0011 //For precision studies
0012 const int PT_EXTRABITS = 0;
0013 const int ETA_EXTRABITS = 0;
0014 const int PHI_EXTRABITS = 0;
0015 const int Z0_EXTRABITS = 0;
0016 
0017 typedef ap_ufixed<16 + PT_EXTRABITS, 11, AP_TRN, AP_SAT> pt_intern;
0018 typedef ap_int<14 + ETA_EXTRABITS> glbeta_intern;
0019 typedef ap_int<14 + PHI_EXTRABITS> glbphi_intern;
0020 typedef ap_int<10 + Z0_EXTRABITS> z0_intern;  // 40cm / 0.1
0021 
0022 namespace convert {
0023   const int INTPHI_PI = 720;
0024   const int INTPHI_TWOPI = 2 * INTPHI_PI;
0025   static const float INTPT_LSB_POW = pow(2.0, -5 - PT_EXTRABITS);
0026   static const float INTPT_LSB = INTPT_LSB_POW;
0027   static const float ETA_LSB_POW = pow(2.0, -1 * ETA_EXTRABITS);
0028   static const float ETA_LSB = M_PI / pow(2.0, 12) * ETA_LSB_POW;
0029   static const float PHI_LSB_POW = pow(2.0, -1 * PHI_EXTRABITS);
0030   static const float PHI_LSB = M_PI / pow(2.0, 12) * PHI_LSB_POW;
0031   static const float Z0_LSB_POW = pow(2.0, -1 * Z0_EXTRABITS);
0032   static const float Z0_LSB = 0.05 * Z0_LSB_POW;
0033   inline float floatPt(pt_intern pt) { return pt.to_float(); }
0034   inline int intPt(pt_intern pt) { return (ap_ufixed<18 + PT_EXTRABITS, 13 + PT_EXTRABITS>(pt)).to_int(); }
0035   inline float floatEta(glbeta_intern eta) { return eta.to_float() * ETA_LSB; }
0036   inline float floatPhi(glbphi_intern phi) { return phi.to_float() * PHI_LSB; }
0037   inline float floatZ0(z0_intern z0) { return z0.to_float() * Z0_LSB; }
0038 
0039   inline pt_intern makePt(int pt) { return ap_ufixed<18 + PT_EXTRABITS, 13 + PT_EXTRABITS>(pt); }
0040   inline pt_intern makePtFromFloat(float pt) { return pt_intern(INTPT_LSB_POW * round(pt / INTPT_LSB_POW)); }
0041   inline z0_intern makeZ0(float z0) { return z0_intern(round(z0 / Z0_LSB)); }
0042 
0043   inline ap_uint<pt_intern::width> ptToInt(pt_intern pt) {
0044     // note: this can be synthethized, e.g. when pT is used as intex in a LUT
0045     ap_uint<pt_intern::width> ret = 0;
0046     ret(pt_intern::width - 1, 0) = pt(pt_intern::width - 1, 0);
0047     return ret;
0048   }
0049 
0050   inline glbeta_intern makeGlbEta(float eta) { return round(eta / ETA_LSB); }
0051   inline glbeta_intern makeGlbEtaRoundEven(float eta) {
0052     glbeta_intern ghweta = round(eta / ETA_LSB);
0053     return (ghweta % 2) ? glbeta_intern(ghweta + 1) : ghweta;
0054   }
0055 
0056   inline glbphi_intern makeGlbPhi(float phi) { return round(phi / PHI_LSB); }
0057 
0058 };  // namespace convert
0059 
0060 //Each individual box in the eta and phi dimension.
0061 //  Also used to store final cluster data for each zbin.
0062 struct TrackJetEmulationEtaPhiBin {
0063   pt_intern pTtot;
0064   l1t::TkJetWord::nt_t ntracks;
0065   l1t::TkJetWord::nx_t nxtracks;
0066   bool used;
0067   glbphi_intern phi;  //average phi value (halfway b/t min and max)
0068   glbeta_intern eta;  //average eta value
0069 };
0070 
0071 //store important information for plots
0072 struct TrackJetEmulationMaxZBin {
0073   int znum;    //Numbered from 0 to nzbins (16, 32, or 64) in order
0074   int nclust;  //number of clusters in this bin
0075   z0_intern zbincenter;
0076   TrackJetEmulationEtaPhiBin *clusters;  //list of all the clusters in this bin
0077   pt_intern ht;                          //sum of all cluster pTs--only the zbin with the maximum ht is stored
0078 };
0079 #endif