Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:31:04

0001 //-------------------------------------------------
0002 //
0003 //   Class: DTConfigTraco
0004 //
0005 //   Description: Configurable parameters and constants for Level1 Mu DT Trigger - TRACO chip
0006 //
0007 //
0008 //   Author List:
0009 //   S.Vanini
0010 //   Modifications:
0011 //   April,10th 2008: set TRACO parameters from string
0012 //-----------------------------------------------------------------------
0013 
0014 //-----------------------
0015 // This Class's Header --
0016 //-----------------------
0017 #include "L1TriggerConfig/DTTPGConfig/interface/DTConfigTraco.h"
0018 
0019 //---------------
0020 // C++ Headers --
0021 //---------------
0022 #include <cstdlib>
0023 #include <string>
0024 #include <iostream>
0025 #include <fstream>
0026 #include <cstdio>
0027 #include <cstdlib>
0028 #include <cmath>
0029 #include <iomanip>
0030 
0031 //-------------------------------
0032 // Collaborating Class Headers --
0033 //-------------------------------
0034 
0035 #include "FWCore/Utilities/interface/Exception.h"
0036 
0037 //----------------
0038 // Constructors --
0039 //----------------
0040 DTConfigTraco::DTConfigTraco(const edm::ParameterSet& ps) { setDefaults(ps); }
0041 
0042 DTConfigTraco::DTConfigTraco(int debugTRACO, unsigned short int* buffer) {
0043   m_debug = debugTRACO;
0044 
0045   // check if this is a TRACO configuration string
0046   if (buffer[2] != 0x15) {
0047     throw cms::Exception("DTTPG") << "===> ConfigTraco constructor : not a TRACO string!" << std::endl;
0048   }
0049 
0050   // decode
0051   unsigned short int memory_traco[38];
0052 
0053   for (int i = 0; i < 38; i++) {
0054     memory_traco[i] = buffer[i + 5];
0055     //std::cout << hex << memory_traco[i];
0056   }
0057   int btic = memory_traco[0] & 0x3f;
0058   int rad = ((memory_traco[0] & 0xc0) >> 6) | ((memory_traco[1] & 0x7) << 2);
0059   int dd = (memory_traco[1] & 0xf8) >> 3;
0060   int fprgcomp = memory_traco[2] & 0x3;
0061   int sprgcomp = memory_traco[3] & 0x3;
0062   int fhism = (memory_traco[2] & 0x4) != 0;
0063   int fhtprf = (memory_traco[2] & 0x8) != 0;
0064   int fslmsk = (memory_traco[2] & 0x10) != 0;
0065   int fltmsk = (memory_traco[2] & 0x20) != 0;
0066   int fhtmsk = (memory_traco[2] & 0x40) != 0;
0067   int shism = (memory_traco[3] & 0x4) != 0;
0068   int shtprf = (memory_traco[3] & 0x8) != 0;
0069   int sslmsk = (memory_traco[3] & 0x10) != 0;
0070   int sltmsk = (memory_traco[3] & 0x20) != 0;
0071   int shtmsk = (memory_traco[3] & 0x40) != 0;
0072   int reusei = (memory_traco[2] & 0x80) != 0;
0073   int reuseo = (memory_traco[3] & 0x80) != 0;
0074   int ltf = (memory_traco[4] & 1) != 0;
0075   int lts = (memory_traco[4] & 2) != 0;
0076   int prgdel = (memory_traco[4] & 0x1c) >> 2;
0077   int snapcor = (memory_traco[4] & 0xe0) >> 5;
0078   int trgenb[16];
0079   for (int it = 0; it < 2; it++) {
0080     trgenb[0 + it * 8] = memory_traco[5 + it] & 0x01;
0081     trgenb[1 + it * 8] = (memory_traco[5 + it] >> 1) & 0x01;
0082     trgenb[2 + it * 8] = (memory_traco[5 + it] >> 1) & 0x01;
0083     trgenb[3 + it * 8] = (memory_traco[5 + it] >> 1) & 0x01;
0084     trgenb[4 + it * 8] = (memory_traco[5 + it] >> 1) & 0x01;
0085     trgenb[5 + it * 8] = (memory_traco[5 + it] >> 1) & 0x01;
0086     trgenb[6 + it * 8] = (memory_traco[5 + it] >> 1) & 0x01;
0087     trgenb[7 + it * 8] = (memory_traco[5 + it] >> 1) & 0x01;
0088   }
0089   int trgadel = memory_traco[7] & 0x3;
0090   int ibtioff = (memory_traco[7] & 0xfc) >> 2;
0091   int kprgcom = (memory_traco[8] & 0xff);
0092   int testmode = (memory_traco[9] & 1) != 0;
0093   int starttest = (memory_traco[9] & 2) != 0;
0094   int prvsignmux = (memory_traco[9] & 4) != 0;
0095   int lth = (memory_traco[9] & 8) != 0;
0096 
0097   if (debug() == 1) {
0098     std::cout << "btic=" << btic << " rad=" << rad << " dd=" << dd << " fprgcomp=" << fprgcomp
0099               << " sprgcomp=" << sprgcomp << " fhism=" << fhism << " fhtprf=" << fhtprf << " fslmsk=" << fslmsk
0100               << " fltmsk=" << fltmsk << " fhtmsk=" << fhtmsk << " shism=" << shism << " shtprf=" << shtprf
0101               << " sslmsk=" << sslmsk << " sltmsk=" << sltmsk << " shtmsk=" << shtmsk << " reusei=" << reusei
0102               << " reuseo=" << reuseo << " ltf=" << ltf << " lts=" << lts << " prgdel=" << prgdel
0103               << " snapcor=" << snapcor << " trgenb=";
0104     for (int t = 0; t < 16; t++)
0105       std::cout << trgenb[t] << " ";
0106     std::cout << " trgadel=" << trgadel << " ibtioff=" << ibtioff << " kprgcom=" << kprgcom << " testmode=" << testmode
0107               << " starttest=" << starttest << " prvsignmux=" << prvsignmux << " lth=" << lth << std::endl;
0108   }
0109 
0110   // set parameters
0111   setBTIC(btic);
0112   setKRAD(rad);
0113   setDD(dd);
0114   setTcKToll(0, fprgcomp);
0115   setTcKToll(1, sprgcomp);
0116   setSortKascend(0, fhism);
0117   setSortKascend(1, shism);
0118   setPrefHtrig(0, fhtprf);
0119   setPrefHtrig(1, shtprf);
0120   setPrefInner(0, fslmsk);
0121   setPrefInner(1, sslmsk);
0122   setSingleLflag(0, fltmsk);
0123   setSingleLflag(1, sltmsk);
0124   setSingleHflag(0, fhtmsk);
0125   setSingleHflag(1, shtmsk);
0126   setTcReuse(0, reusei);
0127   setTcReuse(1, reuseo);
0128   setSingleLenab(0, ltf);
0129   setSingleLenab(1, ltf);
0130   setTcBxLts(lts);
0131   setIBTIOFF(ibtioff);
0132   setBendingAngleCut(kprgcom);
0133   setLVALIDIFH(lth);
0134   for (int t = 0; t < 16; t++)
0135     setUsedBti(t + 1, trgenb[t]);
0136 
0137   // the following are not relevant for simulation
0138   // prgdel, snapcor, trgadel, testmode, starttest, prvsignmux
0139 }
0140 
0141 //--------------
0142 // Destructor --
0143 //--------------
0144 DTConfigTraco::~DTConfigTraco() {}
0145 
0146 //--------------
0147 // Operations --
0148 //--------------
0149 
0150 void DTConfigTraco::setDefaults(const edm::ParameterSet& ps) {
0151   // Debug flag
0152   m_debug = ps.getUntrackedParameter<int>("Debug");
0153 
0154   // KRAD traco parameter
0155   m_krad = ps.getParameter<int>("KRAD");
0156 
0157   // BTIC traco parameter
0158   m_btic = ps.getParameter<int>("BTIC");
0159 
0160   // DD traco parameter: this is fixed
0161   m_dd = ps.getParameter<int>("DD");
0162 
0163   // recycling of TRACO cand. in inner/outer SL : REUSEI/REUSEO
0164   m_reusei = ps.getParameter<int>("REUSEI");
0165   m_reuseo = ps.getParameter<int>("REUSEO");
0166 
0167   // single HTRIG enabling on first/second tracks F(S)HTMSK
0168   m_fhtmsk = ps.getParameter<int>("FHTMSK");
0169   m_shtmsk = ps.getParameter<int>("SHTMSK");
0170 
0171   // single LTRIG enabling on first/second tracks: F(S)LTMSK
0172   m_fltmsk = ps.getParameter<int>("FLTMSK");
0173   m_sltmsk = ps.getParameter<int>("SLTMSK");
0174 
0175   // preference to inner on first/second tracks: F(S)SLMSK
0176   m_fslmsk = ps.getParameter<int>("FSLMSK");
0177   m_sslmsk = ps.getParameter<int>("SSLMSK");
0178 
0179   // preference to HTRIG on first/second tracks: F(S)HTPRF
0180   m_fhtprf = ps.getParameter<int>("FHTPRF");
0181   m_shtprf = ps.getParameter<int>("SHTPRF");
0182 
0183   // ascend. order for K sorting first/second tracks: F(S)HISM
0184   m_fhism = ps.getParameter<int>("FHISM");
0185   m_shism = ps.getParameter<int>("SHISM");
0186 
0187   // K tollerance for correlation in TRACO: F(S)PRGCOMP
0188   m_fprgcomp = ps.getParameter<int>("FPRGCOMP");
0189   m_sprgcomp = ps.getParameter<int>("SPRGCOMP");
0190 
0191   // suppr. of LTRIG in 4 BX before HTRIG: LTS
0192   m_lts = ps.getParameter<int>("LTS");
0193 
0194   // single LTRIG accept enabling on first/second tracks LTF
0195   m_ltf = ps.getParameter<int>("LTF");
0196 
0197   // Connected bti in traco: bti mask
0198   for (int b = 0; b < 16; b++) {
0199     std::string label = "TRGENB";
0200     char p0 = (b / 10) + '0';
0201     char p1 = (b % 10) + '0';
0202     if (p0 != '0')
0203       label = label + p0;
0204     label = label + p1;
0205 
0206     m_trgenb.set(b, ps.getParameter<int>(label));
0207   }
0208 
0209   // IBTIOFF traco parameter
0210   m_ibtioff = ps.getParameter<int>("IBTIOFF");
0211 
0212   // bending angle cut for all stations and triggers : KPRGCOM
0213   m_kprgcom = ps.getParameter<int>("KPRGCOM");
0214 
0215   // flag for Low validation parameter
0216   m_lvalidifh = ps.getParameter<int>("LVALIDIFH");
0217 }
0218 
0219 void DTConfigTraco::print() const {
0220   std::cout << "******************************************************************************" << std::endl;
0221   std::cout << "*              DTTrigger configuration : TRACO chips                                 *" << std::endl;
0222   std::cout << "******************************************************************************" << std::endl;
0223   std::cout << "*                                                                            *" << std::endl;
0224   std::cout << "Debug flag : " << debug() << std::endl;
0225   std::cout << "KRAD traco parameter : " << KRAD() << std::endl;
0226   std::cout << "BTIC traco parameter : " << BTIC() << std::endl;
0227   std::cout << "DD traco parameter : " << DD() << std::endl;
0228   std::cout << "REUSEI, REUSEO : " << TcReuse(0) << ", " << TcReuse(1) << std::endl;
0229   std::cout << "FHTMSK, SHTMSK : " << singleHflag(0) << ", " << singleHflag(1) << std::endl;
0230   std::cout << "FLTMSK, SLTMSK: " << singleLflag(0) << ", " << singleLflag(1) << std::endl;
0231   std::cout << "FSLMSK, SSLMSK : " << prefInner(0) << ", " << prefInner(1) << std::endl;
0232   std::cout << "FHTPRF, SHTPRF : " << prefHtrig(0) << ", " << prefHtrig(1) << std::endl;
0233   std::cout << "FHISM, SHISM : " << sortKascend(0) << ", " << sortKascend(1) << std::endl;
0234   std::cout << "FPRGCOMP, SPRGCOMP : " << TcKToll(0) << ", " << TcKToll(1) << std::endl;
0235   std::cout << "LTS : " << TcBxLts() << std::endl;
0236   std::cout << "LTF : " << singleLenab(0) << std::endl;
0237   std::cout << "Connected bti in traco - bti mask : ";
0238   for (int b = 1; b <= 16; b++)
0239     std::cout << usedBti(b) << " ";
0240   std::cout << std::endl;
0241   std::cout << "IBTIOFF : " << IBTIOFF() << std::endl;
0242   std::cout << "bending angle cut : " << BendingAngleCut() << std::endl;
0243   std::cout << "flag for Low validation parameter : " << LVALIDIFH() << std::endl;
0244   std::cout << "******************************************************************************" << std::endl;
0245 }