Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-19 02:16:45

0001 #ifndef L1Trigger_TrackFindingTracklet_interface_Settings_h
0002 #define L1Trigger_TrackFindingTracklet_interface_Settings_h
0003 
0004 #include <iostream>
0005 #include <string>
0006 #include <array>
0007 #include <set>
0008 #include <cassert>
0009 #include <cmath>
0010 #include <unordered_map>
0011 #include <map>
0012 #include <vector>
0013 
0014 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0015 #include "FWCore/Utilities/interface/Exception.h"
0016 
0017 namespace tt {
0018   class Setup;
0019 }
0020 
0021 namespace trklet {
0022 
0023   constexpr unsigned int N_SECTOR = 9;  // # of phi sectors for L1TK processing
0024 
0025   constexpr int N_LAYER = 6;                 // # of barrel layers assumed
0026   constexpr int N_DISK = 5;                  // # of endcap disks assumed
0027   constexpr unsigned int N_PSLAYER = 3;      // # of barrel PS layers assumed
0028   constexpr unsigned int N_SEED = 12;        // # of tracklet+triplet seeds
0029   constexpr unsigned int N_SEED_PROMPT = 8;  // # of tracklet (prompt) seeds
0030 
0031   constexpr unsigned int N_DSS_MOD = 5;  // # of rings with 2S modules per disk
0032 
0033   constexpr unsigned int N_BENDBITS_PS = 3;  // Number of bend bits for PS modules
0034   constexpr unsigned int N_BENDBITS_2S = 4;  // Number of bend bits for 2S modules
0035 
0036   constexpr unsigned int NRINVBITS = 5;     //number of bit for rinv in bend match table
0037   constexpr unsigned int NFINERZBITS = 3;   //number of bit for r or z within a r/z bin
0038   constexpr unsigned int NFINEPHIBITS = 3;  //number of bits for phi within a vm bin
0039   constexpr unsigned int N_RZBITS = 3;      //number of bit for the r/z bins
0040   constexpr unsigned int N_PHIBITS = 3;     //number of bit for the phi bins
0041 
0042   constexpr unsigned int N_VMSTUBSMAX = 15;     // maximum number of stubs in VM bin
0043   constexpr unsigned int N_BITSMEMADDRESS = 7;  // Number of bits for address in memories
0044 
0045   constexpr double sixth = 1.0 / 6.0;  //Commonly used factor
0046   constexpr double third = 1.0 / 3.0;  //Commonly used factor
0047 
0048   constexpr double VMROUTERCUTZL2 = 50.0;      //Min L2 z for inner allstub
0049   constexpr double VMROUTERCUTZL1L3L5 = 95.0;  //Max z for inner barrel layers
0050   constexpr double VMROUTERCUTZL1 = 70.0;      //Max z for L1 barrel seeding
0051   constexpr double VMROUTERCUTRD1D3 = 55.0;    //Max r for disk seeds
0052 
0053   enum Seed { L1L2 = 0, L2L3, L3L4, L5L6, D1D2, D3D4, L1D1, L2D1, L2L3L4, L4L5L6, L2L3D1, D1D2L2 };
0054   enum LayerDisk { L1 = 0, L2, L3, L4, L5, L6, D1, D2, D3, D4, D5 };
0055 
0056   class Settings {
0057   public:
0058     Settings() {
0059       //Comment out to run tracklet-only algorithm
0060 #ifdef CMSSW_GIT_HASH
0061 #ifndef CMS_DICT_IMPL  // Don't print message if genreflex being run.
0062 #ifndef USEHYBRID
0063 #pragma message "USEHYBRID is undefined, so Hybrid L1 tracking disabled."
0064 #endif
0065 #endif
0066 #endif
0067     }
0068 
0069     ~Settings() = default;
0070 
0071     void passSetup(const tt::Setup* setup) { setup_ = setup; }
0072     const tt::Setup* setup() const { return setup_; }
0073 
0074     // processing & memory modules, wiring, etc.
0075     std::string const& fitPatternFile() const { return fitPatternFile_; }
0076     std::string const& processingModulesFile() const { return processingModulesFile_; }
0077     std::string const& memoryModulesFile() const { return memoryModulesFile_; }
0078     std::string const& wiresFile() const { return wiresFile_; }
0079     std::string const& tableTEDFile() const { return tableTEDFile_; }
0080     std::string const& tableTREFile() const { return tableTREFile_; }
0081 
0082     void setFitPatternFile(std::string fitPatternFileName) { fitPatternFile_ = fitPatternFileName; }
0083     void setProcessingModulesFile(std::string processingModulesFileName) {
0084       processingModulesFile_ = processingModulesFileName;
0085     }
0086     void setMemoryModulesFile(std::string memoryModulesFileName) { memoryModulesFile_ = memoryModulesFileName; }
0087     void setWiresFile(std::string wiresFileName) { wiresFile_ = wiresFileName; }
0088     void setTableTEDFile(std::string tableTEDFileName) { tableTEDFile_ = tableTEDFileName; }
0089     void setTableTREFile(std::string tableTREFileName) { tableTREFile_ = tableTREFileName; }
0090 
0091     unsigned int nzbitsstub(unsigned int layerdisk) const { return nzbitsstub_[layerdisk]; }
0092     unsigned int nphibitsstub(unsigned int layerdisk) const { return nphibitsstub_[layerdisk]; }
0093     unsigned int nrbitsstub(unsigned int layerdisk) const { return nrbitsstub_[layerdisk]; }
0094 
0095     unsigned int nrbitsprojderdisk() const { return nrbitsprojderdisk_; }
0096     unsigned int nbitsphiprojderL123() const { return nbitsphiprojderL123_; }
0097     unsigned int nbitsphiprojderL456() const { return nbitsphiprojderL456_; }
0098     unsigned int nbitszprojderL123() const { return nbitszprojderL123_; }
0099     unsigned int nbitszprojderL456() const { return nbitszprojderL456_; }
0100 
0101     unsigned int nbendbitsmedisk() const { return nbendbitsmedisk_; }
0102 
0103     bool useSeed(unsigned int iSeed) const { return useseeding_.find(iSeed) != useseeding_.end(); }
0104     unsigned int nbitsvmte(unsigned int inner, unsigned int iSeed) const {
0105       if (combined_) {
0106         return nbitsvmtecm_[inner][iSeed];
0107       }
0108       return nbitsvmte_[inner][iSeed];
0109     }
0110     unsigned int nvmte(unsigned int inner, unsigned int iSeed) const { return (1 << nbitsvmte(inner, iSeed)); }
0111 
0112     unsigned int nbitsvmme(unsigned int layerdisk) const { return nbitsvmme_[layerdisk]; }
0113     unsigned int nvmme(unsigned int layerdisk) const { return (1 << nbitsvmme_[layerdisk]); }
0114 
0115     unsigned int nbitsallstubs(unsigned int layerdisk) const { return nbitsallstubs_[layerdisk]; }
0116     unsigned int nallstubs(unsigned int layerdisk) const { return (1 << nbitsallstubs_[layerdisk]); }
0117 
0118     bool writeMonitorData(std::string module) const {
0119       if (writeMonitorData_.find(module) == writeMonitorData_.end()) {
0120         throw cms::Exception("BadConfig") << "Settings::writeMonitorData module = " << module << " not known";
0121       }
0122       return writeMonitorData_.at(module);
0123     }
0124 
0125     unsigned int maxStep(std::string module) const {
0126       if (maxstep_.find(module) == maxstep_.end()) {
0127         throw cms::Exception("BadConfig")
0128             << __FILE__ << " " << __LINE__ << " maxStep module = " << module << " not known";
0129       }
0130       return extended_ ? (maxstep_.at(module) + maxstepoffset_extended_) : (maxstep_.at(module) + maxstepoffset_);
0131     }
0132 
0133     double zlength() const { return zlength_; }
0134     double rmaxdisk() const { return rmaxdisk_; }
0135     double rmindisk() const { return rmindisk_; }
0136 
0137     double drmax() const { return rmaxdisk_ / deltarzfract_; }
0138     double dzmax() const { return zlength_ / deltarzfract_; }
0139 
0140     double half2SmoduleWidth() const { return half2SmoduleWidth_; }
0141 
0142     int nfinephi(unsigned int inner, unsigned int iSeed) const { return nfinephi_[inner][iSeed]; }
0143     double nphireg(unsigned int inner, unsigned int iSeed) const {
0144       if (combined_) {
0145         return nphiregcm_[inner][iSeed];
0146       }
0147       return nphireg_[inner][iSeed];
0148     }
0149     double lutwidthtab(unsigned int inner, unsigned int iSeed) const { return lutwidthtab_[inner][iSeed]; }
0150     double lutwidthtabextended(unsigned int inner, unsigned int iSeed) const {
0151       return lutwidthtabextended_[inner][iSeed];
0152     }
0153 
0154     unsigned int seedlayers(int inner, int seed) const {
0155       int layerdisk = seedlayers_[seed][inner];
0156       assert(layerdisk >= 0);
0157       return layerdisk;
0158     }
0159 
0160     unsigned int teunits(unsigned int iSeed) const { return teunits_[iSeed]; }
0161 
0162     unsigned int NTC(int seed) const { return ntc_[seed]; }
0163 
0164     unsigned int projlayers(unsigned int iSeed, unsigned int i) const { return projlayers_[iSeed][i]; }
0165     unsigned int projdisks(unsigned int iSeed, unsigned int i) const { return projdisks_[iSeed][i]; }
0166     double rphimatchcut(unsigned int iSeed, unsigned int ilayer) const { return rphimatchcut_[ilayer][iSeed]; }
0167     double zmatchcut(unsigned int iSeed, unsigned int ilayer) const { return zmatchcut_[ilayer][iSeed]; }
0168     double rphicutPS(unsigned int iSeed, unsigned int idisk) const { return rphicutPS_[idisk][iSeed]; }
0169     double rcutPS(unsigned int iSeed, unsigned int idisk) const { return rcutPS_[idisk][iSeed]; }
0170     double rphicut2S(unsigned int iSeed, unsigned int idisk) const { return rphicut2S_[idisk][iSeed]; }
0171     double rcut2S(unsigned int iSeed, unsigned int idisk) const { return rcut2S_[idisk][iSeed]; }
0172 
0173     double rmean(unsigned int iLayer) const { return irmean_[iLayer] * rmaxdisk_ / 4096; }
0174     double rmax(unsigned int iLayer) const { return rmean(iLayer) + drmax(); }
0175     double rmin(unsigned int iLayer) const { return rmean(iLayer) - drmax(); }
0176     double zmean(unsigned int iDisk) const { return izmean_[iDisk] * zlength_ / 2048; }
0177     double zmax(unsigned int iDisk) const { return zmean(iDisk) + dzmax(); }
0178     double zmin(unsigned int iDisk) const { return zmean(iDisk) - dzmax(); }
0179 
0180     double zmindisk(unsigned int iDisk) const { return zmean(iDisk) - zsepdisk_ / 2; }
0181     double zmaxdisk(unsigned int iDisk) const { return zmean(iDisk) + zsepdisk_ / 2; }
0182 
0183     double rDSSinner(unsigned int iBin) const {
0184       return rDSSinner_mod_[iBin / 2] + halfstrip_ * ((iBin % 2 == 0) ? -1 : 1);
0185     }
0186     double rDSSouter(unsigned int iBin) const {
0187       return rDSSouter_mod_[iBin / 2] + halfstrip_ * ((iBin % 2 == 0) ? -1 : 1);
0188     }
0189 
0190     unsigned int vmrlutzbits(unsigned int layerdisk) const { return vmrlutzbits_[layerdisk]; }
0191     unsigned int vmrlutrbits(unsigned int layerdisk) const { return vmrlutrbits_[layerdisk]; }
0192 
0193     bool printDebugKF() const { return printDebugKF_; }
0194     bool debugTracklet() const { return debugTracklet_; }
0195     bool writetrace() const { return writetrace_; }
0196 
0197     bool warnNoMem() const { return warnNoMem_; }
0198     bool warnNoDer() const { return warnNoDer_; }
0199 
0200     bool writeMem() const { return writeMem_; }
0201     bool writeTable() const { return writeTable_; }
0202     bool writeConfig() const { return writeConfig_; }
0203 
0204     std::string memPath() const { return memPath_; }
0205     std::string tablePath() const { return tablePath_; }
0206 
0207     bool writeVerilog() const { return writeVerilog_; }
0208     bool writeHLS() const { return writeHLS_; }
0209     bool writeInvTable() const { return writeInvTable_; }
0210     bool writeHLSInvTable() const { return writeHLSInvTable_; }
0211 
0212     unsigned int writememsect() const { return writememsect_; }
0213 
0214     bool enableTripletTables() const { return enableTripletTables_; }
0215     bool writeTripletTables() const { return writeTripletTables_; }
0216 
0217     bool writeoutReal() const { return writeoutReal_; }
0218 
0219     bool bookHistos() const { return bookHistos_; }
0220 
0221     double ptcut() const { return ptcut_; }
0222     double rinvcut() const { return 0.01 * c_ * bfield_ / ptcut_; }  //0.01 to convert to cm-1
0223 
0224     double c() const { return c_; }
0225 
0226     double rinvmax() const { return 0.01 * c_ * bfield_ / ptmin_; }
0227 
0228     int alphashift() const { return alphashift_; }
0229     int nbitsalpha() const { return nbitsalpha_; }
0230     int alphaBitsTable() const { return alphaBitsTable_; }
0231     int nrinvBitsTable() const { return nrinvBitsTable_; }
0232 
0233     unsigned int MEBinsBits() const { return MEBinsBits_; }
0234     unsigned int MEBins() const { return 1u << MEBinsBits_; }
0235     unsigned int MEBinsDisks() const { return MEBinsDisks_; }
0236     unsigned int maxStubsPerBin() const { return maxStubsPerBin_; }
0237 
0238     std::string geomext() const {
0239       std::string geo = extended_ ? "hourglassExtended" : "hourglass";
0240       if (combined_)
0241         geo += "Combined";
0242       return geo;
0243     }
0244 
0245     bool exactderivatives() const { return exactderivatives_; }
0246     bool exactderivativesforfloating() const { return exactderivativesforfloating_; }
0247     bool useapprox() const { return useapprox_; }
0248     bool usephicritapprox() const { return usephicritapprox_; }
0249 
0250     unsigned int minIndStubs() const { return minIndStubs_; }
0251     std::string removalType() const { return removalType_; }
0252     std::string mergeComparison() const { return mergeComparison_; }
0253     bool doKF() const { return doKF_; }
0254     bool doMultipleMatches() const { return doMultipleMatches_; }
0255     bool fakefit() const { return fakefit_; }
0256     void setFakefit(bool fakefit) { fakefit_ = fakefit; }
0257     bool storeTrackBuilderOutput() const { return storeTrackBuilderOutput_; }
0258     void setStoreTrackBuilderOutput(bool storeTrackBuilderOutput) {
0259       storeTrackBuilderOutput_ = storeTrackBuilderOutput;
0260     }
0261     void setRemovalType(std::string removalType) { removalType_ = removalType; }
0262     void setDoMultipleMatches(bool doMultipleMatches) { doMultipleMatches_ = doMultipleMatches; }
0263 
0264     // configurable
0265     unsigned int nHelixPar() const { return nHelixPar_; }
0266     void setNHelixPar(unsigned int nHelixPar) { nHelixPar_ = nHelixPar; }
0267 
0268     bool extended() const { return extended_; }
0269     void setExtended(bool extended) { extended_ = extended; }
0270     bool combined() const { return combined_; }
0271     void setCombined(bool combined) { combined_ = combined; }
0272     bool reduced() const { return reduced_; }
0273     void setReduced(bool reduced) { reduced_ = reduced; }
0274     bool inventStubs() const { return inventStubs_; }
0275     void setInventStubs(bool inventStubs) { inventStubs_ = inventStubs; }
0276 
0277     double bfield() const { return bfield_; }
0278     void setBfield(double bfield) { bfield_ = bfield; }
0279 
0280     unsigned int nStrips(bool isPSmodule) const { return isPSmodule ? nStrips_PS_ : nStrips_2S_; }
0281     void setNStrips_PS(unsigned int nStrips_PS) { nStrips_PS_ = nStrips_PS; }
0282     void setNStrips_2S(unsigned int nStrips_2S) { nStrips_2S_ = nStrips_2S; }
0283 
0284     double stripPitch(bool isPSmodule) const { return isPSmodule ? stripPitch_PS_ : stripPitch_2S_; }
0285     void setStripPitch_PS(double stripPitch_PS) { stripPitch_PS_ = stripPitch_PS; }
0286     void setStripPitch_2S(double stripPitch_2S) { stripPitch_2S_ = stripPitch_2S; }
0287 
0288     double sensorSpacing2S() const { return sensorSpacing_2S_; }
0289 
0290     double stripLength(bool isPSmodule) const { return isPSmodule ? stripLength_PS_ : stripLength_2S_; }
0291     void setStripLength_PS(double stripLength_PS) { stripLength_PS_ = stripLength_PS; }
0292     void setStripLength_2S(double stripLength_2S) { stripLength_2S_ = stripLength_2S; }
0293 
0294     //Following functions are used for duplicate removal
0295     //Function which returns the value corresponding to the overlap size for the overlap rinv bins in DR
0296     double rinvOverlapSize() const { return rinvOverlapSize_; }
0297     //Function which returns the value corresponding to the overlap size for the overlap phi bins in DR
0298     double phiOverlapSize() const { return phiOverlapSize_; }
0299     //Function which returns the value corresponding to the number of tracks that are compared to all the other tracks per rinv bin
0300     unsigned int numTracksComparedPerBin() const { return numTracksComparedPerBin_; }
0301     //Returns the rinv bin edges you need for duplicate removal bins
0302     const std::vector<double>& rinvBins() const { return rinvBins_; }
0303     //Returns the phi bin edges you need for duplicate removal bins
0304     const std::vector<double>& phiBins() const { return phiBins_; }
0305 
0306     std::string skimfile() const { return skimfile_; }
0307     void setSkimfile(std::string skimfile) { skimfile_ = skimfile; }
0308 
0309     unsigned int nbitstrackletindex() const { return nbitstrackletindex_; }
0310     void setNbitstrackletindex(unsigned int nbitstrackletindex) { nbitstrackletindex_ = nbitstrackletindex; }
0311 
0312     unsigned int nbitsitc() const { return nbitsitc_; }
0313     unsigned int nbitsseed() const { return (extended_ ? nbitsseedextended_ : nbitsseed_); }
0314     unsigned int nbitstcindex() const { return nbitsseed() + nbitsitc(); }
0315     void setNbitsitc(unsigned int nbitsitc) { nbitsitc_ = nbitsitc; }
0316     void setNbitsseed(unsigned int nbitsseed) { nbitsseed_ = nbitsseed; }
0317     void setNbitsseedextended(unsigned int nbitsseed) { nbitsseedextended_ = nbitsseed; }
0318 
0319     // Phi width of nonant including overlaps (at widest point).
0320     double dphisectorHG() const {
0321       //These values are used in the DTC emulation code.
0322       double rsectmin = 21.8;
0323       double rsectmax = 112.7;
0324       return 2 * M_PI / N_SECTOR + rinvmax() * std::max(rcrit_ - rsectmin, rsectmax - rcrit_);
0325     }
0326 
0327     double rcrit() const { return rcrit_; }
0328 
0329     double dphisector() const { return 2 * M_PI / N_SECTOR; }
0330 
0331     double phicritmin() const { return 0.5 * dphisectorHG() - M_PI / N_SECTOR; }
0332     double phicritmax() const { return dphisectorHG() - 0.5 * dphisectorHG() + M_PI / N_SECTOR; }
0333 
0334     double phicritminmc() const { return phicritmin() - dphicritmc_; }
0335     double phicritmaxmc() const { return phicritmax() + dphicritmc_; }
0336 
0337     // Stub digitization granularities
0338     double kphi() const { return dphisectorHG() / (1 << nphibitsstub(0)); }
0339     double kphi1() const { return dphisectorHG() / (1 << nphibitsstub(N_LAYER - 1)); }
0340     double kphi(unsigned int layerdisk) const { return dphisectorHG() / (1 << nphibitsstub(layerdisk)); }
0341 
0342     double kz() const { return 2.0 * zlength_ / (1 << nzbitsstub_[0]); }
0343     double kz(unsigned int layerdisk) const { return 2.0 * zlength_ / (1 << nzbitsstub_[layerdisk]); }
0344     double kr() const { return rmaxdisk_ / (1 << nrbitsstub_[N_LAYER]); }
0345     double krbarrel() const { return 2.0 * drmax() / (1 << nrbitsstub_[0]); }
0346 
0347     double maxrinv() const { return maxrinv_; }
0348     double maxd0() const { return maxd0_; }
0349     unsigned int nbitsd0() const { return nbitsd0_; }
0350 
0351     double kd0() const { return 2 * maxd0_ / (1 << nbitsd0_); }
0352 
0353     double rinvcutte() const { return 0.01 * c_ * bfield_ / ptcutte_; }  //0.01 to convert to cm-1
0354 
0355     double rmindiskvm() const { return rmindiskvm_; }
0356     double rmaxdiskvm() const { return rmaxdiskvm_; }
0357 
0358     double rmaxdiskl1overlapvm() const { return rmaxdiskl1overlapvm_; }
0359     double rmindiskl2overlapvm() const { return rmindiskl2overlapvm_; }
0360     double rmindiskl3overlapvm() const { return rmindiskl3overlapvm_; }
0361 
0362     double rPS2S() const { return rPS2S_; }
0363 
0364     double z0cut() const { return z0cut_; }
0365 
0366     double disp_z0cut() const { return disp_z0cut_; }
0367 
0368     unsigned int NLONGVMBITS() const { return NLONGVMBITS_; }
0369     unsigned int NLONGVMBINS() const { return (1 << NLONGVMBITS_); }
0370 
0371     unsigned int ntrackletmax() const { return ((1 << nbitstrackletindex_) - 1); }
0372 
0373     //Bits used to store track parameter in tracklet
0374     int nbitsrinv() const { return nbitsrinv_; }
0375     int nbitsphi0() const { return nbitsphi0_; }
0376     int nbitst() const { return nbitst_; }
0377     int nbitsz0() const { return nbitsz0_; }
0378 
0379     //track and tracklet parameters
0380     int rinv_shift() const { return rinv_shift_; }
0381     int phi0_shift() const { return phi0_shift_; }
0382     int t_shift() const { return t_shift_; }
0383     int z0_shift() const { return z0_shift_; }
0384 
0385     //projections are coarsened from global to stub precision
0386 
0387     //projection to R parameters
0388     int SS_phiL_shift() const { return SS_phiL_shift_; }
0389     int PS_zL_shift() const { return PS_zL_shift_; }
0390 
0391     int SS_phiderL_shift() const { return SS_phiderL_shift_; }
0392     int PS_zderL_shift() const { return PS_zderL_shift_; }
0393     int SS_zderL_shift() const { return SS_zderL_shift_; }
0394 
0395     //projection to Z parameters
0396     int SS_phiD_shift() const { return SS_phiD_shift_; }
0397     int PS_rD_shift() const { return PS_rD_shift_; }
0398 
0399     int SS_phiderD_shift() const { return SS_phiderD_shift_; }
0400     int PS_rderD_shift() const { return PS_rderD_shift_; }
0401 
0402     //numbers needed for matches & fit, unclear what they are.
0403     int phi0bitshift() const { return phi0bitshift_; }
0404     int phiderbitshift() const { return phiderbitshift_; }
0405     int zderbitshift() const { return zderbitshift_; }
0406 
0407     int phiresidbits() const { return phiresidbits_; }
0408     int zresidbits() const { return zresidbits_; }
0409     int rresidbits() const { return rresidbits_; }
0410 
0411     //Trackfit
0412     int fitrinvbitshift() const { return fitrinvbitshift_; }
0413     int fitphi0bitshift() const { return fitphi0bitshift_; }
0414     int fittbitshift() const { return fittbitshift_; }
0415     int fitz0bitshift() const { return fitz0bitshift_; }
0416 
0417     //r correction bits
0418     int rcorrbits() const { return rcorrbits_; }
0419 
0420     int chisqphifactbits() const { return chisqphifactbits_; }
0421     int chisqzfactbits() const { return chisqzfactbits_; }
0422 
0423     // Helix param digisation granularities
0424     //0.02 here is the maximum range in rinv values that can be represented
0425     double krinvpars() const {
0426       int shift = ceil(-log2(0.02 * rmaxdisk_ / ((1 << nbitsrinv_) * dphisectorHG())));
0427       return dphisectorHG() / rmaxdisk_ / (1 << shift);
0428     }
0429     double kphi0pars() const { return 2 * kphi1(); }
0430     double ktpars() const { return maxt_ / (1 << nbitst_); }
0431     double kz0pars() const { return kz(); }
0432     double kd0pars() const { return kd0(); }
0433 
0434     double kphider() const { return kphi() / kr() / 256; }
0435     double kphiderdisk() const { return kphi() / kr() / 128; }
0436     double kzder() const { return 1.0 / 64; }
0437     double krder() const { return 1.0 / 128; }
0438 
0439     //This is a 'historical accident' and should be fixed so that we don't
0440     //have the factor if 2
0441     double krprojshiftdisk() const { return 2 * kr(); }
0442 
0443     double benddecode(unsigned int ibend, unsigned int layerdisk, bool isPSmodule) const {
0444       if (layerdisk >= N_LAYER && (!isPSmodule))
0445         layerdisk += N_DISK;
0446       double bend = benddecode_[layerdisk][ibend];
0447       assert(bend < 99.0);
0448       return bend;
0449     }
0450 
0451     double bendcut(unsigned int ibend, unsigned int layerdisk, bool isPSmodule) const {
0452       if (layerdisk >= N_LAYER && (!isPSmodule))
0453         layerdisk += N_DISK;
0454       double bendcut = bendcut_[layerdisk][ibend];
0455       if (bendcut <= 0.0)
0456         std::cout << "bendcut : " << layerdisk << " " << ibend << " " << isPSmodule << std::endl;
0457       assert(bendcut > 0.0);
0458       return bendcut;
0459     }
0460 
0461     // DTC in given ATCA crate slot.
0462     std::string slotToDTCname(unsigned int slot) const { return slotToDTCname_.at(slot); }
0463 
0464     // Tracker layers read by given DTC.
0465     const std::vector<int>& dtcLayers(const std::string& dtcName) const {
0466       auto iter = dtclayers_.find(dtcName);
0467       assert(iter != dtclayers_.end());
0468       return iter->second;
0469     }
0470 
0471     double bendcutte(int ibend, int layerdisk, bool isPSmodule) const { return bendcut(ibend, layerdisk, isPSmodule); }
0472 
0473     double bendcutme(int ibend, int layerdisk, bool isPSmodule) const {
0474       //Should understand why larger cut needed in disks
0475       double fact = (layerdisk < N_LAYER) ? 1.0 : 1.8;
0476       return fact * bendcut(ibend, layerdisk, isPSmodule);
0477     }
0478 
0479     bool useCalcBendCuts = true;
0480 
0481     double bendcutTE(unsigned int seed, bool inner) const {
0482       if (inner) {
0483         return bendcutTE_[seed][0];
0484       } else {
0485         return bendcutTE_[seed][1];
0486       }
0487     }
0488 
0489     double bendcutME(unsigned int layerdisk, bool isPSmodule) const {
0490       if (layerdisk >= N_LAYER && (!isPSmodule))
0491         layerdisk += N_DISK;
0492 
0493       return bendcutME_[layerdisk];
0494     }
0495 
0496     //layers/disks used by each seed
0497     std::array<std::array<int, 3>, N_SEED> seedlayers() const { return seedlayers_; }
0498 
0499     //projection layers by seed index. For each seeding index (row) the list of layers that we consider projections to
0500     std::array<std::array<unsigned int, N_LAYER - 2>, N_SEED> projlayers() const { return projlayers_; }
0501 
0502     //projection disks by seed index. For each seeding index (row) the list of diks that we consider projections to
0503     std::array<std::array<unsigned int, N_DISK>, N_SEED> projdisks() const { return projdisks_; }
0504 
0505   private:
0506     const tt::Setup* setup_;
0507 
0508     std::string fitPatternFile_;
0509     std::string processingModulesFile_;
0510     std::string memoryModulesFile_;
0511     std::string wiresFile_;
0512     std::string tableTEDFile_;
0513     std::string tableTREFile_;
0514 
0515     double rcrit_{55.0};  // critical radius for the hourglass configuration
0516 
0517     double dphicritmc_{0.005};
0518 
0519     //fraction of full r and z range that stubs can be located within layer/disk
0520     double deltarzfract_{32.0};
0521 
0522     double maxt_{32.0};  //range in t that we must cover
0523 
0524     std::array<unsigned int, N_LAYER> irmean_{{851, 1269, 1784, 2347, 2936, 3697}};
0525     std::array<unsigned int, N_DISK> izmean_{{2239, 2645, 3163, 3782, 4523}};
0526 
0527     std::array<unsigned int, N_LAYER + N_DISK> nzbitsstub_{{12, 12, 12, 8, 8, 8, 7, 7, 7, 7, 7}};
0528     std::array<unsigned int, N_LAYER + N_DISK> nphibitsstub_{{14, 14, 14, 17, 17, 17, 14, 14, 14, 14, 14}};
0529     std::array<unsigned int, N_LAYER + N_DISK> nrbitsstub_{{7, 7, 7, 7, 7, 7, 12, 12, 12, 12, 12}};
0530 
0531     unsigned int nrbitsprojderdisk_{9};
0532     unsigned int nbitsphiprojderL123_{10};
0533     unsigned int nbitsphiprojderL456_{10};
0534     unsigned int nbitszprojderL123_{10};
0535     unsigned int nbitszprojderL456_{9};
0536 
0537     unsigned int nbendbitsmedisk_{4};  // Always 4 bits even for PS disk hits, for HLS compatibility
0538 
0539     std::set<unsigned int> useseeding_{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
0540 
0541     std::array<unsigned int, N_LAYER + N_DISK> nbitsallstubs_{{3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2}};
0542     std::array<unsigned int, N_LAYER + N_DISK> nbitsvmme_{{2, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2}};
0543     std::array<std::array<unsigned int, N_SEED>, 3> nbitsvmte_{
0544         {{{2, 2, 2, 2, 2, 2, 1, 1, 2, 2, 3, 2}},  // (3 = #stubs/triplet, only row 1+2 used for tracklet)
0545          {{3, 2, 3, 3, 2, 2, 2, 2, 3, 3, 2, 2}},
0546          {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1}}}};
0547 
0548     std::array<std::array<unsigned int, N_SEED>, 3> nbitsvmtecm_{
0549         {{{2, 2, 2, 2, 2, 2, 1, 1, 2, 2, 3, 2}},  // (3 = #stubs/triplet, only row 1+2 used for tracklet)
0550          {{3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2}},
0551          {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1}}}};
0552 
0553     // FIX: There should be 3 PS10G slots & 3 PS (5G) ones.
0554     // (Will change output files used by HLS).
0555     std::vector<std::string> slotToDTCname_{
0556         "PS10G_1", "PS10G_2", "PS10G_3", "PS10G_4", "PS_1", "PS_2", "2S_1", "2S_2", "2S_3", "2S_4", "2S_5", "2S_6"};
0557 
0558     std::map<std::string, std::vector<int> > dtclayers_{{"PS10G_1", {0, 6, 8, 10}},
0559                                                         {"PS10G_2", {0, 7, 9}},
0560                                                         {"PS10G_3", {1, 7}},
0561                                                         {"PS10G_4", {6, 8, 10}},
0562                                                         {"PS_1", {2, 7}},
0563                                                         {"PS_2", {2, 9}},
0564                                                         {"2S_1", {3, 4}},
0565                                                         {"2S_2", {4}},
0566                                                         {"2S_3", {5}},
0567                                                         {"2S_4", {5, 8}},
0568                                                         {"2S_5", {6, 9}},
0569                                                         {"2S_6", {7, 10}}};
0570 
0571     double rmindiskvm_{22.5};
0572     double rmaxdiskvm_{67.0};
0573 
0574     double rmaxdiskl1overlapvm_{45.0};
0575     double rmindiskl2overlapvm_{40.0};
0576     double rmindiskl3overlapvm_{50.0};
0577 
0578     double rPS2S_{60.0};
0579 
0580     double z0cut_{15.0};
0581 
0582     double disp_z0cut_{27.0};
0583 
0584     unsigned int NLONGVMBITS_{3};
0585 
0586     double zlength_{120.0};
0587     double rmaxdisk_{120.0};
0588     double rmindisk_{20.0};
0589 
0590     double zsepdisk_{1.5};  //cm
0591 
0592     double half2SmoduleWidth_{4.57};
0593 
0594     double maxrinv_{0.006};
0595     double maxd0_{10.0};
0596 
0597     unsigned int nbitsd0_{13};
0598 
0599     double ptmin_{2.0};  //minumim pt for tracks
0600 
0601     double ptcutte_{1.8};  //Minimum pt in TE
0602 
0603     // VALUE AUTOMATICALLY INCREASED FOR EXTENDED TRACKING BY PYTHON CFG
0604     unsigned int nbitstrackletindex_{7};  //Bits used to store the tracklet index
0605 
0606     unsigned int nbitsitc_{4};           //Bits used to store the iTC, a unique
0607                                          //identifier assigned to each TC within a sector
0608     unsigned int nbitsseed_{3};          //Bits used to store the seed number
0609     unsigned int nbitsseedextended_{4};  //Bits used to store the seed number
0610                                          //in the extended project
0611 
0612     //Bits used to store track parameter in tracklet
0613     int nbitsrinv_{14};
0614     int nbitsphi0_{18};
0615     int nbitst_{14};
0616     int nbitsz0_{10};
0617 
0618     //track and tracklet parameters
0619     int rinv_shift_{-8};  // Krinv = 2^shift * Kphi/Kr
0620     int phi0_shift_{1};   // Kphi0 = 2^shift * Kphi
0621     int t_shift_{-10};    // Kt    = 2^shift * Kz/Kr
0622     int z0_shift_{0};     // Kz0   = 2^shift * kz
0623 
0624     //projections are coarsened from global to stub precision
0625 
0626     //projection to R parameters
0627     int SS_phiL_shift_{0};
0628     int PS_zL_shift_{0};  // z projections have global precision in ITC
0629 
0630     int SS_phiderL_shift_{-5};
0631     int PS_zderL_shift_{-7};  // Kderz = 2^shift * Kz/Kr
0632     int SS_zderL_shift_{-7};
0633 
0634     //projection to Z parameters
0635     int SS_phiD_shift_{3};
0636     int PS_rD_shift_{1};  // a bug?! coarser by a factor of two then stubs??
0637 
0638     int SS_phiderD_shift_{-4};
0639     int PS_rderD_shift_{-6};  //Kderrdisk = 2^shift * Kr/Kz
0640 
0641     //numbers needed for matches & fit, unclear what they are.
0642     int phi0bitshift_{1};
0643     int phiderbitshift_{7};
0644     int zderbitshift_{6};
0645 
0646     int phiresidbits_{12};
0647     int zresidbits_{9};
0648     int rresidbits_{7};
0649 
0650     //Trackfit
0651     int fitrinvbitshift_{9};  //6 OK?
0652     int fitphi0bitshift_{6};  //4 OK?
0653     int fittbitshift_{10};    //4 OK? //lower number gives rounding problems
0654     int fitz0bitshift_{8};    //6 OK?
0655 
0656     //r correction bits
0657     int rcorrbits_{6};
0658 
0659     int chisqphifactbits_{14};
0660     int chisqzfactbits_{14};
0661 
0662     std::array<unsigned int, N_SEED> teunits_{{5, 2, 5, 3, 3, 2, 3, 2, 0, 0, 0, 0}};  //teunits used by seed
0663 
0664     std::array<unsigned int, N_LAYER + N_DISK> vmrlutzbits_{
0665         {7, 7, 7, 7, 7, 7, 3, 3, 3, 3, 3}};  // zbits used by LUT in VMR
0666     std::array<unsigned int, N_LAYER + N_DISK> vmrlutrbits_{
0667         {4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8}};  // rbits used by LUT in VMR
0668 
0669     std::array<std::array<unsigned int, N_SEED>, 3> nfinephi_{
0670         {{{2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2}},    //inner  (3 = #stubs/triplet, only row 1+2 used for tracklet)
0671          {{3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}},    //outer
0672          {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3}}}};  //outermost (triplets only)
0673 
0674     //These are the number of bits used for the VM regions in the TE by seedindex
0675     //FIXME not independed nbitsvmte
0676     std::array<std::array<unsigned int, N_SEED>, 3> nphireg_{
0677         {{{5, 4, 4, 4, 4, 4, 4, 3, 4, 4, 5, 4}},    //inner
0678          {{5, 4, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4}},    //outer
0679          {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4}}}};  //outermost (triplets only)
0680 
0681     //For combined modules
0682     std::array<std::array<unsigned int, N_SEED>, 3> nphiregcm_{
0683         {{{5, 4, 4, 4, 4, 4, 4, 3, 4, 4, 5, 4}},    //inner
0684          {{5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4}},    //outer
0685          {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4}}}};  //outermost (triplets only)
0686 
0687     // These are the number of bits to represent lutval for VM memories in TE
0688     std::array<std::array<unsigned int, N_SEED>, 3> lutwidthtab_{{{{10, 10, 10, 10, 10, 10, 10, 10, 0, 0, 11, 0}},
0689                                                                   {{6, 6, 6, 6, 10, 10, 10, 10, 0, 0, 6, 0}},
0690                                                                   {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 6}}}};
0691 
0692     // These are the number of bits to represent lutval for VM memories in TED
0693     // TO DO: tune lutwidthtabextended_ values
0694 
0695     /* std::array<std::array<unsigned int, N_SEED>, 3> lutwidthtabextended_{ */
0696     /*     {{{11, 11, 21, 21, 21, 21, 11, 11, 0, 0, 21, 0}}, */
0697     /*      {{6, 6, 6, 6, 10, 10, 10, 10, 0, 0, 6, 0}}, */
0698     /*      {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 6}}}}; */
0699 
0700     std::array<std::array<unsigned int, N_SEED>, 3> lutwidthtabextended_{
0701         {{{21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21}},
0702          {{21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21}},
0703          {{21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21}}}};
0704 
0705     //layers/disks used by each seed
0706     std::array<std::array<int, 3>, N_SEED> seedlayers_{{{{0, 1, -1}},   //L1L2
0707                                                         {{1, 2, -1}},   //1 L2L3
0708                                                         {{2, 3, -1}},   //2 L3L4
0709                                                         {{4, 5, -1}},   //3 L5L6
0710                                                         {{6, 7, -1}},   //4 D1D2
0711                                                         {{8, 9, -1}},   //5 D3D4
0712                                                         {{0, 6, -1}},   //6 L1D1
0713                                                         {{1, 6, -1}},   //7 L2D1
0714                                                         {{2, 3, 1}},    //8 L2L3L4
0715                                                         {{4, 5, 3}},    //9 L4L5L6
0716                                                         {{1, 2, 6}},    //10 L2L3D1
0717                                                         {{6, 7, 1}}}};  //11 D1D2L2
0718 
0719     //Number of tracklet calculators for the prompt seeding combinations
0720     std::array<unsigned int, N_SEED> ntc_{{12, 4, 4, 4, 4, 4, 8, 4, 0, 0, 0, 0}};
0721 
0722     //projection layers by seed index. For each seeding index (row) the list of layers that we consider projections to
0723     std::array<std::array<unsigned int, N_LAYER - 2>, N_SEED> projlayers_{{{{3, 4, 5, 6}},  //0 L1L2
0724                                                                            {{1, 4, 5, 6}},  //1 L2L3
0725                                                                            {{1, 2, 5, 6}},  //2 L3L4
0726                                                                            {{1, 2, 3, 4}},  //3 L5L6
0727                                                                            {{1, 2}},        //4 D1D2
0728                                                                            {{1}},           //5 D3D4
0729                                                                            {{}},            //6 L1D1
0730                                                                            {{1}},           //7 L2D1
0731                                                                            {{1, 5, 6}},     //8 L2L3L4
0732                                                                            {{1, 2, 3}},     //9 L4L5L6
0733                                                                            {{1}},           //10 L2L3D1
0734                                                                            {{1}}}};         //11 D1D2L2
0735 
0736     //projection disks by seed index. For each seeding index (row) the list of diks that we consider projections to
0737     std::array<std::array<unsigned int, N_DISK>, N_SEED> projdisks_{{{{1, 2, 3, 4}},  //0 L1L2
0738                                                                      {{1, 2, 3, 4}},  //1 L2L3
0739                                                                      {{1, 2}},        //2 L3L4
0740                                                                      {{}},            //3 L5L6
0741                                                                      {{3, 4, 5}},     //4 D1D2
0742                                                                      {{1, 2, 5}},     //5 D3D4
0743                                                                      {{2, 3, 4, 5}},  //6 L1D1
0744                                                                      {{2, 3, 4}},     //7 L2D1
0745                                                                      {{1, 2, 3}},     //8 L2L3L4
0746                                                                      {{}},            //9 L4L5L6
0747                                                                      {{2, 3, 4}},     //10 L2L3D1
0748                                                                      {{3, 4}}}};      //11 D1D2L2
0749 
0750     //rphi cuts for layers - the column is the seedindex
0751     std::array<std::array<double, N_SEED>, N_LAYER> rphimatchcut_{
0752         {{{0.0, 0.1, 0.07, 0.08, 0.07, 0.05, 0.0, 0.05, 0.08, 0.15, 0.125, 0.15}},  //Layer 1
0753          {{0.0, 0.0, 0.06, 0.08, 0.05, 0.0, 0.0, 0.0, 0.0, 0.1, 0.0, 0.0}},         //Layer 2
0754          {{0.1, 0.0, 0.0, 0.08, 0.0, 0.0, 0.0, 0.0, 0.0, 0.08, 0.0, 0.0}},          //Layer 3
0755          {{0.19, 0.19, 0.0, 0.05, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}},         //Layer 4
0756          {{0.4, 0.4, 0.08, 0.0, 0.0, 0.0, 0.0, 0.0, 0.08, 0.0, 0.0, 0.0}},          //Layer 5
0757          {{0.5, 0.0, 0.19, 0.0, 0.0, 0.0, 0.0, 0.0, 0.2, 0.0, 0.0, 0.0}}}};         //Layer 6
0758 
0759     //z cuts for layers - the column is the seedindex
0760     std::array<std::array<double, N_SEED>, N_LAYER> zmatchcut_{
0761         {{{0.0, 0.7, 5.5, 15.0, 1.5, 2.0, 0.0, 1.5, 1.0, 8.0, 1.0, 1.5}},   //Layer 1
0762          {{0.0, 0.0, 3.5, 15.0, 1.25, 0.0, 0.0, 0.0, 0.0, 7.0, 0.0, 0.0}},  //Layer 2
0763          {{0.7, 0.0, 0.0, 9.0, 0.0, 0.0, 0.0, 0.0, 0.0, 5.0, 0.0, 0.0}},    //Layer 3
0764          {{3.0, 3.0, 0.0, 7.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}},    //Layer 4
0765          {{3.0, 3.0, 8.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.5, 0.0, 0.0, 0.0}},    //Layer 5
0766          {{4.0, 0.0, 9.5, 0.0, 0.0, 0.0, 0.0, 0.0, 4.5, 0.0, 0.0, 0.0}}}};  //Layer 6
0767 
0768     //rphi cuts for PS modules in disks - the column is the seedindex
0769     std::array<std::array<double, N_SEED>, N_DISK> rphicutPS_{
0770         {{{0.2, 0.2, 0.0, 0.0, 0.0, 0.1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}},     //disk 1
0771          {{0.2, 0.2, 0.0, 0.0, 0.0, 0.1, 0.1, 0.1, 0.0, 0.0, 0.15, 0.0}},    //disk 2
0772          {{0.25, 0.2, 0.0, 0.0, 0.15, 0.0, 0.2, 0.15, 0.0, 0.0, 0.0, 0.2}},  //disk 3
0773          {{0.5, 0.2, 0.0, 0.0, 0.2, 0.0, 0.3, 0.5, 0.0, 0.0, 0.0, 0.0}},     //disk 4
0774          {{0.0, 0.0, 0.0, 0.0, 0.25, 0.1, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0}}}};  //disk 5
0775 
0776     //r cuts for PS modules in disks - the column is the seedindex
0777     std::array<std::array<double, N_SEED>, N_DISK> rcutPS_{
0778         {{{0.5, 0.5, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}},    //disk 1
0779          {{0.5, 0.5, 0.0, 0.0, 0.0, 0.5, 0.5, 0.5, 0.0, 0.0, 0.5, 0.0}},    //disk 2
0780          {{0.5, 0.5, 0.0, 0.0, 0.5, 0.0, 0.6, 0.8, 0.0, 0.0, 0.0, 0.4}},    //disk 3
0781          {{0.5, 0.5, 0.0, 0.0, 0.8, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0}},    //disk 4
0782          {{0.0, 0.0, 0.0, 0.0, 1.0, 0.5, 2.0, 0.0, 0.0, 0.0, 0.0, 0.0}}}};  //disk 5
0783 
0784     //rphi cuts for 2S modules in disks = the column is the seedindex
0785     std::array<std::array<double, N_SEED>, N_DISK> rphicut2S_{
0786         {{{0.5, 0.5, 0.8, 0.0, 0.0, 0.0, 0.0, 0.0, 0.2, 0.0, 0.0, 0.0}},    //disk 1
0787          {{0.5, 0.5, 0.8, 0.0, 0.0, 0.0, 0.5, 0.15, 0.3, 0.0, 0.68, 0.0}},  //disk 2
0788          {{0.5, 0.5, 0.0, 0.0, 0.15, 0.0, 0.2, 0.25, 0.0, 0.0, 0.8, 0.1}},  //disk 3
0789          {{0.5, 0.5, 0.0, 0.0, 0.2, 0.0, 0.25, 0.5, 0.0, 0.0, 0.6, 0.4}},   //disk 4
0790          {{0.0, 0.0, 0.0, 0.0, 0.4, 0.2, 0.4, 0.0, 0.0, 0.0, 0.0, 0.8}}}};  //disk 5
0791 
0792     //r cuts for 2S modules in disks -the column is the seedindex
0793     std::array<std::array<double, N_SEED>, N_DISK> rcut2S_{
0794         {{{3.8, 3.8, 3.8, 0.0, 0.0, 0.0, 0.0, 0.0, 3.0, 0.0, 0.0, 0.0}},    //disk 1
0795          {{3.8, 3.8, 3.8, 0.0, 0.0, 0.0, 3.8, 3.4, 3.0, 0.0, 3.0, 0.0}},    //disk 2
0796          {{3.6, 3.8, 0.0, 0.0, 3.6, 0.0, 3.6, 3.8, 0.0, 0.0, 3.8, 3.0}},    //disk 3
0797          {{3.6, 3.8, 0.0, 0.0, 3.6, 0.0, 3.5, 3.8, 0.0, 0.0, 3.0, 3.0}},    //disk 4
0798          {{0.0, 0.0, 0.0, 0.0, 3.6, 3.4, 3.7, 0.0, 0.0, 0.0, 0.0, 3.0}}}};  //disk 5
0799 
0800     //returns the mean bend (in strips at a 1.8 mm separation) for bendcode
0801     std::array<std::array<double, 16>, 16> benddecode_{
0802         {{{0.0, 0.5, 0.7, 0.8, 89.9, -1.0, -0.9, -0.8, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9}},  //L1 PS
0803          {{0.0, 0.7, 1.0, 1.5, 89.9, -1.5, -1.0, -0.7, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9}},  //L2 PS
0804          {{0.0, 1.0, 1.8, 2.2, 89.9, -2.2, -1.8, -1.0, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9}},  //L3 PS
0805          {{0.0, 0.7, 1.2, 1.8, 2.1, 2.6, 3.2, 3.5, 89.9, -3.5, -3.2, -2.6, -2.1, -1.8, -1.2, -0.7}},      //L4 2S
0806          {{0.0, 0.8, 1.2, 1.8, 2.2, 3.2, 4.1, 4.4, 89.9, -4.4, -4.1, -3.2, -2.2, -1.8, -1.2, -0.8}},      //L5 2S
0807          {{0.0, 0.9, 1.8, 2.8, 3.8, 4.5, 5.3, 5.9, 89.9, -5.9, -5.3, -4.5, -3.8, -2.8, -1.8, -0.9}},      //L6 2S
0808          {{0.0, 0.8, 1.2, 2.0, 89.9, -2.0, -1.2, -0.8, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9}},  //D1 PS
0809          {{0.0, 1.5, 1.8, 2.4, 89.9, -2.4, -1.8, -1.4, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9}},  //D2 PS
0810          {{0.0, 1.7, 2.0, 2.2, 89.9, -2.2, -2.0, -1.7, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9}},  //D3 PS
0811          {{0.0, 1.8, 2.0, 2.4, 89.9, -2.4, -2.0, -1.8, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9}},  //D4 PS
0812          {{0.0, 2.0, 2.2, 2.4, 89.9, -2.4, -2.0, -1.8, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9}},  //D5 PS
0813          {{0.0, 1.8, 2.3, 2.5, 3.0, 3.9, 4.5, 5.2, 89.9, -5.2, -4.5, -3.9, -3.0, -2.5, -2.3, -1.8}},      //D1 2S
0814          {{0.0, 2.0, 2.4, 2.9, 3.2, 4.0, 4.8, 5.2, 89.9, -5.2, -4.8, -4.0, -3.2, -2.9, -2.4, -2.0}},      //D2 2S
0815          {{0.0, 2.0, 2.4, 2.7, 3.6, 3.7, 4.4, 4.6, 89.9, -4.6, -4.4, -3.7, -3.6, -2.7, -2.4, -2.0}},      //D3 2S
0816          {{0.0, 2.0, 2.6, 3.2, 3.8, 4.0, 4.4, 4.4, 89.9, -4.4, -4.4, -4.0, -3.8, -3.2, -2.6, -2.0}},      //D4 2S
0817          {{0.0, 2.0, 3.2, 3.4, 3.9, 3.9, 4.4, 4.4, 89.9, -4.4, -4.4, -3.9, -3.9, -3.4, -3.2, -2.0}}}};    //D5 2S
0818 
0819     //returns the bend 'cut' (in strips at a 1.8 mm separation) for bendcode
0820     std::array<std::array<double, 16>, 16> bendcut_{
0821         {{{1.5, 1.2, 0.8, 0.8, 99.9, 0.8, 0.8, 1.2, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0}},  //L1 PS
0822          {{1.5, 1.3, 1.0, 1.0, 99.9, 1.0, 1.0, 1.3, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0}},  //L2 PS
0823          {{1.6, 1.5, 1.0, 1.0, 99.9, 1.0, 1.0, 1.5, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0}},  //L3 PS
0824          {{1.6, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 99.9, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}},          //L4 2S
0825          {{1.6, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 99.9, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}},          //L5 2S
0826          {{1.6, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 99.9, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}},          //L6 2S
0827          {{1.8, 1.6, 1.6, 1.6, 99.9, 1.6, 1.6, 1.6, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0}},  //D1 PS
0828          {{1.8, 1.6, 1.6, 1.6, 99.9, 1.6, 1.6, 1.6, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0}},  //D2 PS
0829          {{1.8, 1.6, 1.6, 1.6, 99.9, 1.6, 1.6, 1.6, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0}},  //D3 PS
0830          {{2.2, 1.6, 1.6, 1.6, 99.9, 1.6, 1.6, 1.6, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0}},  //D4 PS
0831          {{2.2, 1.6, 1.6, 1.6, 99.9, 1.6, 1.6, 1.6, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0}},  //D5 PS
0832          {{2.0, 1.2, 1.2, 1.2, 1.5, 1.5, 1.5, 1.5, 99.9, 1.5, 1.5, 1.5, 1.5, 1.2, 1.2, 1.2}},          //D1 2S
0833          {{2.0, 1.2, 1.2, 1.2, 1.5, 1.5, 1.5, 1.5, 99.9, 1.5, 1.5, 1.5, 1.5, 1.2, 1.2, 1.2}},          //D2 2S
0834          {{2.2, 1.5, 1.5, 1.5, 2.0, 2.0, 2.0, 2.0, 99.9, 2.0, 2.0, 2.0, 2.0, 1.5, 1.5, 1.5}},          //D3 2S
0835          {{2.5, 1.5, 1.5, 2.0, 2.0, 2.0, 2.0, 2.0, 99.9, 2.0, 2.0, 2.0, 2.0, 2.0, 1.5, 1.5}},          //D4 2S
0836          {{2.5, 1.5, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 99.9, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 1.5}}}};        //D5 2S
0837 
0838     double FEbendcut = sqrt(1 / 6.0);
0839 
0840     double bendcutTE_[N_SEED_PROMPT][2] = {{2.2 * FEbendcut, 2.5 * FEbendcut},   //L1L2
0841                                            {2.0 * FEbendcut, 2.0 * FEbendcut},   //L2L3
0842                                            {2.0 * FEbendcut, 2.6 * FEbendcut},   //L3L4
0843                                            {2.4 * FEbendcut, 2.4 * FEbendcut},   //L5L6
0844                                            {2.5 * FEbendcut, 2.2 * FEbendcut},   //D1D2 PS
0845                                            {2.0 * FEbendcut, 2.0 * FEbendcut},   //D3D4 PS
0846                                            {2.0 * FEbendcut, 2.4 * FEbendcut},   //L1D1 PS
0847                                            {2.2 * FEbendcut, 2.2 * FEbendcut}};  //L2D1 PS
0848 
0849     double bendcutME_[N_LAYER + 2 * N_DISK] = {2.0 * FEbendcut,   //0  L1
0850                                                2.5 * FEbendcut,   //1  L2
0851                                                2.0 * FEbendcut,   //2  L3
0852                                                2.5 * FEbendcut,   //3  L4
0853                                                2.2 * FEbendcut,   //4  L5
0854                                                2.3 * FEbendcut,   //5  L6
0855                                                4.0 * FEbendcut,   //6  D1 PS
0856                                                3.5 * FEbendcut,   //7  D2 PS
0857                                                3.5 * FEbendcut,   //8  D3 PS
0858                                                3.5 * FEbendcut,   //9  D4 PS
0859                                                2.7 * FEbendcut,   //10 D5 PS
0860                                                3.5 * FEbendcut,   //11 D1 2S
0861                                                3.4 * FEbendcut,   //12 D2 2S
0862                                                3.5 * FEbendcut,   //13 D3 2S
0863                                                3.7 * FEbendcut,   //14 D4 2S
0864                                                3.5 * FEbendcut};  //15 D5 2S
0865 
0866     // Offset to the maximum number of steps in each processing step:
0867     // Set to 0 (default) means standard truncation
0868     // Set to large value, e.g. 10000, to disable truncation
0869     unsigned int maxstepoffset_{0};
0870     // turn off truncation for displaced tracking (not implemented properly for displaced seeding)
0871     unsigned int maxstepoffset_extended_{10000};
0872 
0873     //Number of processing steps for one event (108=18TM*240MHz/40MHz)
0874 
0875     //IR should be set to 108 to match the FW for the summer chain, but ultimately should be at 156
0876     std::unordered_map<std::string, unsigned int> maxstep_{
0877         {"IR", 156},  //IR will run at a higher clock speed to handle
0878                       //input links running at 25 Gbits/s
0879         //Set to 108 to match firmware project 240 MHz clock
0880 
0881         {"VMR", 107},
0882         {"TE", 107},
0883         {"TC", 108},
0884         {"PR", 108},
0885         {"ME", 108},
0886         //NOTE: The MC is set to 108, but `mergedepth`
0887         //removes 3 iterations to emulate the delay
0888         //due to the HLS priority encoder
0889         {"MC", 108},
0890         {"TB", 108},
0891         {"MP", 108},
0892         {"TP", 108},
0893         {"TRE", 108},
0894         {"DR", 108}};  //Specifies how many tracks allowed per bin in DR
0895 
0896     // If set to true this creates txt files, which the ROOT macros in
0897     // https://github.com/cms-L1TK/TrackPerf/tree/master/PatternReco
0898     // can then use to study truncation of individual algo steps within tracklet chain.
0899     std::unordered_map<std::string, bool> writeMonitorData_{{"IL", false},
0900                                                             {"TE", false},
0901                                                             {"CT", false},
0902                                                             {"HitPattern", false},
0903                                                             {"ChiSq", false},
0904                                                             {"Seeds", false},
0905                                                             {"FT", false},
0906                                                             {"Residuals", false},
0907                                                             {"StubBend", false},
0908                                                             {"MC", false},
0909                                                             {"MP", false},
0910                                                             {"ME", false},
0911                                                             {"AP", false},
0912                                                             {"VMP", false},
0913                                                             {"TrackProjOcc", false},
0914                                                             {"TC", false},
0915                                                             {"Pars", false},
0916                                                             {"TPars", false},
0917                                                             {"TPD", false},
0918                                                             {"TrackletPars", false},
0919                                                             {"TED", false},
0920                                                             {"TP", false},
0921                                                             {"TRE", false},
0922                                                             {"VMR", false},
0923                                                             {"StubsLayer", false},
0924                                                             {"StubsLayerSector", false},
0925                                                             {"HitEff", false},
0926                                                             {"MatchEff", false},
0927                                                             {"IFit", false},
0928                                                             {"AS", false},
0929                                                             {"WriteEmptyProj", false}};
0930 
0931     std::array<double, N_DSS_MOD> rDSSinner_mod_{{68.9391, 78.7750, 85.4550, 96.3150, 102.3160}};
0932     std::array<double, N_DSS_MOD> rDSSouter_mod_{{66.4903, 76.7750, 84.4562, 94.9920, 102.3160}};
0933 
0934     //we want the center of the two strip positions in a module, not just the center of a module
0935     double halfstrip_{2.5};
0936 
0937     // various printouts for debugging and warnings
0938     bool printDebugKF_{false};   // if true print lots of debugging statements related to the KF fit
0939     bool debugTracklet_{false};  //Print detailed debug information about tracklet tracking
0940     bool writetrace_{false};     //Print out details about parsing configuration files
0941 
0942     bool warnNoMem_{false};  //If true will print out warnings about missing projection memories
0943     bool warnNoDer_{false};  //If true will print out warnings about missing track fit derivatives
0944 
0945     //--- These used to create files needed by HLS code.
0946     bool writeMem_{false};     //If true will print out content of memories (between algo steps) to files
0947     bool writeTable_{false};   //If true will print out content of LUTs to files
0948     bool writeConfig_{false};  //If true will print out the autogenerated configuration as files
0949     std::string memPath_{"../data/MemPrints/"};  //path for writing memories
0950     std::string tablePath_{"../data/LUTs/"};     //path for writing LUTs
0951 
0952     // Write various lookup tables and autogenerated code (from iMath)
0953     bool writeVerilog_{false};      //Write out auto-generated Verilog mudules used by TCs
0954     bool writeHLS_{false};          //Write out auto-generated HLS mudules used by TCs
0955     bool writeInvTable_{false};     //Write out tables of drinv and invt in tracklet calculator for Verilog module
0956     bool writeHLSInvTable_{false};  //Write out tables of drinv and invt in tracklet calculator for HLS module
0957 
0958     unsigned int writememsect_{3};  //writemem only for this sector (note that the files will have _4 extension)
0959 
0960     bool enableTripletTables_{false};  //Enable the application of the TED and
0961                                        //TRE tables; when this flag is false,
0962                                        //the tables will not be read from disk
0963     bool writeTripletTables_{false};   //Train and write the TED and TRE tables. N.B.: the tables
0964                                        //cannot be applied while they are being trained, i.e.,
0965                                        //this flag effectively turns off the cuts in
0966                                        //TrackletEngineDisplaced and TripletEngine
0967 
0968     bool writeoutReal_{false};
0969 
0970     //set to true/false to turn on/off histogram booking internal to the tracking (class "HistBase/HistImp", does nothing in central CMSSW)
0971     bool bookHistos_{false};
0972 
0973     // pt constants
0974     double ptcut_{1.91};  //Minimum pt cut
0975 
0976     // Parameters for bit sizes
0977     int alphashift_{12};
0978     int nbitsalpha_{4};      //bits used to store alpha
0979     int alphaBitsTable_{2};  //For number of bits in track derivative table
0980     int nrinvBitsTable_{3};  //number of bits for tabulating rinv dependence
0981 
0982     unsigned int MEBinsBits_{3};
0983     unsigned int MEBinsDisks_{8};      //on each side
0984     unsigned int maxStubsPerBin_{15};  //16 causes overflow!
0985 
0986     // Options for chisq fit
0987     bool exactderivatives_{false};
0988     bool exactderivativesforfloating_{true};  //only for the floating point
0989     bool useapprox_{true};          //use approximate postion based on integer representation for floating point
0990     bool usephicritapprox_{false};  //use floating point approximate version of phicrit cut if true
0991 
0992     // Duplicate Removal
0993     // "merge" (hybrid dup removal)
0994     // "ichi" (pairwise, keep track with best ichisq), "nstub" (pairwise, keep track with more stubs)
0995     // "grid" (TMTT-like removal), "" (no removal)
0996     unsigned int minIndStubs_{3};  // not used with merge removal
0997 
0998 #ifdef USEHYBRID
0999     // Duplicate track removal algo. VALUE HERE OVERRIDDEN BY PYTHON CFG
1000     std::string removalType_{"merge"};
1001     // "CompareBest" (recommended) Compares only the best stub in each track for each region (best = smallest phi residual)
1002     // and will merge the two tracks if stubs are shared in three or more regions
1003     // "CompareAll" Compares all stubs in a region, looking for matches, and will merge the two tracks if stubs are shared in three or more regions
1004     std::string mergeComparison_{"CompareBest"};
1005     bool doKF_{true};
1006 #else
1007     std::string removalType_{"ichi"};
1008     std::string mergeComparison_{""};
1009     bool doKF_{false};
1010 #endif
1011 
1012     // VALUE OVERRIDDEN BY PYTHON CFG
1013     // When false, match calculator does not save multiple matches, even when doKF=true.
1014     // This is a temporary fix for compatibilty with HLS. We will need to implement multiple match
1015     // printing in emulator eventually, possibly after CMSSW-integration inspired rewrites
1016     // Use false when generating HLS files, use true when doing full hybrid tracking
1017     bool doMultipleMatches_{true};
1018 
1019     // NEXT 2 VALUES OVERRIDDEN BY PYTHON CFG
1020     // if true, run a dummy fit, producing TTracks directly from output of tracklet pattern reco stage
1021     bool fakefit_{false};
1022     // if true, EDProducer fills additional bit & clock accurate TrackBuilder EDProduct
1023     bool storeTrackBuilderOutput_{false};
1024 
1025     // NEXT 3 VALUES OVERRIDDEN BY PYTHON CFG
1026     unsigned int nHelixPar_{4};  // 4 or 5 param helix fit
1027     bool extended_{false};       // turn on displaced tracking
1028     bool reduced_{false};        // use reduced (Summer Chain) config
1029     bool inventStubs_{false};    // invent seeding stub coordinates based on tracklet traj
1030 
1031     // Use combined TP (TE+TC) and MP (PR+ME+MC) configuration (with prompt tracking)
1032     bool combined_{false};
1033     // N.B. To use combined modules with extended tracking, edit
1034     // Tracklet_cfi.py to refer to *_hourglassExtendedCombined.dat,
1035     // but leave combined_=false.
1036 
1037     std::string skimfile_{""};  //if not empty events will be written out in ascii format to this file
1038 
1039     double bfield_{3.8112};  //B-field in T
1040     double c_{0.299792458};  //speed of light m/ns
1041 
1042     unsigned int nStrips_PS_{960};
1043     unsigned int nStrips_2S_{1016};
1044 
1045     double stripPitch_PS_{0.01};
1046     double stripPitch_2S_{0.009};
1047 
1048     double stripLength_PS_{0.1467};
1049     double stripLength_2S_{5.0250};
1050 
1051     // The DR binning below disabled, as doesn't match latest FW.
1052 
1053     //Following values are used for duplicate removal
1054     //Only one bin currently used.
1055     std::vector<double> rinvBins_{-rinvcut(), rinvcut()};
1056     std::vector<double> phiBins_{0, dphisectorHG()};
1057     //Overlap size for the overlap rinv bins in DR
1058     double rinvOverlapSize_{0.0004};
1059     //Overlap size for the overlap phi bins in DR
1060     double phiOverlapSize_{M_PI / 360};
1061     //The maximum number of tracks that are compared to all the other tracks per rinv bin
1062     int numTracksComparedPerBin_{9999};
1063 
1064     double sensorSpacing_2S_{0.18};
1065   };
1066 
1067   constexpr unsigned int N_TILTED_RINGS = 12;  // # of tilted rings per half-layer in TBPS layers
1068   constexpr std::array<unsigned int, N_PSLAYER> N_MOD_PLANK = {{7, 11, 15}};  // # of flat barrel modules/plank in TBPS
1069 
1070   constexpr unsigned int N_TRKLSEED = 7;  // # of tracklet seeds
1071   constexpr unsigned int N_PROJ = 4;      // # of projections (beyond stubs from tracklet seed)
1072 
1073   // chi2 fitting
1074   constexpr unsigned int N_FITPARAM = 4;  // # of fit parameters for chi2 fit
1075   constexpr unsigned int N_FITSTUB = 6;   // max # of number of stubs used
1076 
1077   constexpr unsigned int N_TRACKDER_PTBIN = 4;
1078   constexpr unsigned int N_TRACKDER_INDEX = 1000;
1079 
1080 }  // namespace trklet
1081 
1082 #endif