Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-06-21 23:58:59

0001 /**
0002  * Project:
0003  * File name:  constants.h
0004  * Language:   C++
0005  *
0006  * *********************************************************************
0007  * Description:
0008  *
0009  *
0010  * To Do:
0011  *
0012  * Author: Jose Manuel Cela <josemanuel.cela@ciemat.es>
0013  *
0014  * *********************************************************************
0015  * Copyright (c) 2015-08-07 Jose Manuel Cela <josemanuel.cela@ciemat.es>
0016  *
0017  * For internal use, all rights reserved.
0018  * *********************************************************************
0019  */
0020 #ifndef L1Trigger_DTTriggerPhase2_constants_h
0021 #define L1Trigger_DTTriggerPhase2_constants_h
0022 #include <cstdint>
0023 
0024 // Compiler option to select program mode: PRUEBA_MEZCLADOR, PRUEBA_ANALIZADOR,
0025 // or NONE
0026 
0027 /* Quality of the trayectories:
0028    NOPATH => Not valid trayectory
0029    LOWQGHOST => 3h (multiple lateralities)
0030    LOWQ   => 3h
0031    HIGHQGHOST => 4h (multiple lateralities)
0032    HIGHQ  => 4h
0033    CLOWQ  => 3h + 2h/1h
0034    LOWLOWQ => 3h + 3h
0035    CHIGHQ => 4h + 2h/1h
0036    HIGHLOWQ => 4h + 3h
0037    HIGHHIGHQ => 4h + 4h
0038 */
0039 namespace cmsdt {
0040 
0041   // enum MP_QUALITY { NOPATH = 0, LOWQGHOST, LOWQ, HIGHQGHOST, HIGHQ, CLOWQ, LOWLOWQ, CHIGHQ, HIGHLOWQ, HIGHHIGHQ };
0042   enum MP_QUALITY { NOPATH = 0, LOWQ = 1, CLOWQ = 2, HIGHQ = 3, CHIGHQ = 4, LOWLOWQ = 6, HIGHLOWQ = 7, HIGHHIGHQ = 8 };
0043 
0044   // Tipos de lateralidad de traza de partícula al pasar por una celda
0045   enum LATERAL_CASES { LEFT = 0, RIGHT, NONE };
0046 
0047   enum RPC_QUALITY { NORPC = 0, RPC_TIME, RPC_ONLY, RPC_HIT, RPC_CONFIRM, RPC_ASSOCIATE };
0048 
0049   struct metaPrimitive {
0050     metaPrimitive(uint32_t id,
0051                   double t,
0052                   double pos,
0053                   double tan,
0054                   double ph,
0055                   double phb,
0056                   double ph_cmssw,
0057                   double phb_cmssw,
0058                   double chi,
0059                   int q,
0060                   int w1,
0061                   int t1,
0062                   int l1,
0063                   int w2,
0064                   int t2,
0065                   int l2,
0066                   int w3,
0067                   int t3,
0068                   int l3,
0069                   int w4,
0070                   int t4,
0071                   int l4,
0072                   int w5 = 0,
0073                   int t5 = -1,
0074                   int l5 = 0,
0075                   int w6 = 0,
0076                   int t6 = -1,
0077                   int l6 = 0,
0078                   int w7 = 0,
0079                   int t7 = -1,
0080                   int l7 = 0,
0081                   int w8 = 0,
0082                   int t8 = -1,
0083                   int l8 = 0,
0084                   int idx = 0,
0085                   int rpc = 0)
0086         : rawId(id),
0087           t0(t),
0088           x(pos),
0089           tanPhi(tan),
0090           phi(ph),
0091           phiB(phb),
0092           phi_cmssw(ph_cmssw),
0093           phiB_cmssw(phb_cmssw),
0094           chi2(chi),
0095           quality(q),
0096           wi1(w1),
0097           tdc1(t1),
0098           lat1(l1),
0099           wi2(w2),
0100           tdc2(t2),
0101           lat2(l2),
0102           wi3(w3),
0103           tdc3(t3),
0104           lat3(l3),
0105           wi4(w4),
0106           tdc4(t4),
0107           lat4(l4),
0108           wi5(w5),
0109           tdc5(t5),
0110           lat5(l5),
0111           wi6(w6),
0112           tdc6(t6),
0113           lat6(l6),
0114           wi7(w7),
0115           tdc7(t7),
0116           lat7(l7),
0117           wi8(w8),
0118           tdc8(t8),
0119           lat8(l8),
0120           index(idx),
0121           rpcFlag(rpc) {}
0122 
0123     uint32_t rawId;
0124     double t0;
0125     double x;
0126     double tanPhi;
0127     double phi;
0128     double phiB;
0129     double phi_cmssw;
0130     double phiB_cmssw;
0131     double chi2;
0132     int quality;
0133     int wi1;
0134     int tdc1;
0135     int lat1;
0136     int wi2;
0137     int tdc2;
0138     int lat2;
0139     int wi3;
0140     int tdc3;
0141     int lat3;
0142     int wi4;
0143     int tdc4;
0144     int lat4;
0145     int wi5;
0146     int tdc5;
0147     int lat5;
0148     int wi6;
0149     int tdc6;
0150     int lat6;
0151     int wi7;
0152     int tdc7;
0153     int lat7;
0154     int wi8;
0155     int tdc8;
0156     int lat8;
0157     int index;
0158     int rpcFlag = 0;
0159   };
0160   struct PARTIAL_LATQ_TYPE {
0161     bool latQValid;
0162     int bxValue;
0163   };
0164   struct LATQ_TYPE {
0165     bool valid;
0166     int bxValue;
0167     int invalidateHitIdx;
0168     MP_QUALITY quality;
0169   };
0170 
0171   enum algo { Standard = 0, PseudoBayes = 1, HoughTrans = 2 };
0172 
0173   enum scenario { MC = 0, DATA = 1, SLICE_TEST = 2 };
0174 
0175   /* En nanosegundos */
0176   constexpr int LHC_CLK_FREQ = 25;
0177 
0178   /* Adimensional */
0179   constexpr int MAX_BX_IDX = 3564;
0180 
0181   // In ns (maximum drift time inside the cell)
0182   constexpr float MAXDRIFT = 387;
0183   // In mm (cell dimmensions)
0184   constexpr int CELL_HEIGHT = 13;
0185   constexpr float CELL_SEMIHEIGHT = 6.5;
0186   constexpr int CELL_LENGTH = 42;
0187   constexpr int CELL_SEMILENGTH = 21;
0188   // In mm / ns (velocidad de deriva)
0189   constexpr float DRIFT_SPEED = 0.0542;
0190   // With 4 bits for the decimal part
0191   constexpr int DRIFT_SPEED_X4 = 889;  // 55.5 * 2 ** 4
0192 
0193   // distance between SLs, cm
0194   constexpr float VERT_PHI1_PHI3 = 23.5;
0195 
0196   // inverse of the distance between SLs, FW units
0197   constexpr int VERT_PHI1_PHI3_INV = 558;
0198 
0199   // distance between center of the chamber and each SL in mm, 2 bit precision for the decimal part
0200   constexpr int CH_CENTER_TO_MID_SL_X2 = 470;  // 117.5 * 2 ** 2
0201 
0202   /*
0203   This is the maximum value than internal time can take. This is because
0204   internal time is cyclical due to the limited size of the time counters and
0205   the limited value of the bunch crossing index.
0206   It should be, approximately, the LHC's clock frequency multiplied by the
0207   maximum BX index, plus an arbitrary amount for taking into account the
0208   muon traveling time and muon's signal drift time.
0209  */
0210   constexpr int MAX_VALUE_OF_TIME = (LHC_CLK_FREQ * MAX_BX_IDX + 5000);
0211 
0212   /*
0213  * Total BTI number and total channel number must be coordinated. One BTI
0214  * works over 10 channels, but 2 consecutive BTI's overlap many of their
0215  * channels.
0216  */
0217   constexpr int TOTAL_BTI = 100;         // Should be the same value as NUM_CH_PER_LAYER
0218   constexpr int NUM_CH_PER_LAYER = 100;  // Should be the same value as TOTAL_BTI
0219   constexpr int NUM_LAYERS = 4;
0220   constexpr int NUM_LATERALITIES = 16;
0221   constexpr int NUM_CELL_COMB = 3;
0222   constexpr int TOTAL_CHANNELS = (NUM_LAYERS * NUM_CH_PER_LAYER);
0223   constexpr int NUM_SUPERLAYERS = 3;
0224   constexpr float PHIRES_CONV = 65536. / 0.5;  // 17 bits, [-0.5, 0.5]
0225   constexpr float PHIBRES_CONV = 4096. / 2.;   // 13 bits, [-2, 2]
0226   constexpr int CHI2RES_CONV = 1000000;
0227   constexpr int TDCTIME_REDUCED_SIZE = 10;
0228   constexpr float ZRES_CONV = 65536. / 1500;
0229   constexpr float KRES_CONV = 65536. / 2;
0230 
0231   /*
0232  * Size of pre-mixer buffers for DTPrimitives
0233  *
0234  * As first approach, this value should be evaluated in order to allow storing
0235  * enough elements to avoid saturating its size. It will be dependent on the
0236  * noise level, the number of good data injected in the system, as well as on
0237  * the processing speed of the final analyzer.
0238  */
0239   constexpr int SIZE_SEEKT_BUFFER = 32;
0240 
0241   // Number of cells for a analysis block (BTI)
0242   constexpr int NUM_CELLS_PER_BLOCK = 10;
0243 
0244   /*
0245  * Number of entries for the payload inside DTPrimitive.
0246  * This value is also used in other code places to manage reading and writing
0247  * from/to files
0248  */
0249   constexpr int PAYLOAD_ENTRIES = 9;
0250 
0251   /*
0252    * Size of muon primitive 
0253    */
0254   constexpr int NUM_LAYERS_2SL = 8;
0255   constexpr double PHI_CONV = 0.5235988;
0256 
0257   constexpr int BX_SHIFT = 20;
0258   constexpr float Z_SHIFT_MB4 = -1.8;
0259   constexpr float Z_POS_SL = 11.75;
0260   constexpr double X_POS_L3 = 0.65;
0261   constexpr double X_POS_L4 = 1.95;
0262 
0263   /*
0264    * Analyzer precision constants
0265    */
0266   constexpr int DIV_SHR_BITS_T0 = 16;
0267   constexpr int DIV_SHR_BITS_POS = 21;
0268   constexpr int DIV_SHR_BITS_SLOPE = 21;
0269   constexpr int DIV_SHR_BITS_SLOPE_XHH = 18;
0270 
0271   constexpr int INCREASED_RES_T0 = 0;
0272   constexpr int INCREASED_RES_POS = 4;
0273   constexpr int INCREASED_RES_SLOPE = 12;
0274   constexpr int INCREASED_RES_SLOPE_XHH = 4;
0275 
0276   constexpr int INCREASED_RES_POS_POW = 16;
0277   constexpr int INCREASED_RES_SLOPE_POW = 4096;
0278 
0279   // Values to compute drift distances from drift times
0280   constexpr int DTDD_PREADD = 9;
0281   constexpr int DTDD_MULT = 445;
0282   constexpr int DTDD_SHIFTR_BITS = 13;
0283 
0284   /*
0285    * Local to global coordinates transformation
0286    */
0287 
0288   constexpr int X_SIZE = 18;
0289   constexpr int TANPSI_SIZE = 15;
0290   constexpr int PHI_SIZE = 17;   // (1 / 2 ** 17)
0291   constexpr int PHIB_SIZE = 11;  // (2 ** 2) / (2 ** 13)
0292 
0293   constexpr int PHI_LUT_ADDR_WIDTH = 12;
0294   constexpr int PHI_B_SHL_BITS = 7;
0295   constexpr int PHI_MULT_SHR_BITS = 10;
0296   constexpr int PHI_LUT_A_BITS = 12;
0297   constexpr int PHI_LUT_B_BITS = 20;
0298 
0299   constexpr int PHIB_LUT_ADDR_WIDTH = 9;
0300   constexpr int PHIB_B_SHL_BITS = 7;
0301   constexpr int PHIB_MULT_SHR_BITS = 10;
0302   constexpr int PHIB_LUT_A_BITS = 10;
0303   constexpr int PHIB_LUT_B_BITS = 16;
0304 
0305   constexpr int PHI_PHIB_RES_DIFF_BITS = 6;
0306 
0307 }  // namespace cmsdt
0308 
0309 #endif