CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_8_patch3/src/L1TriggerConfig/DTTPGConfig/src/DTConfigTraco.cc

Go to the documentation of this file.
00001 //-------------------------------------------------
00002 //
00003 //   Class: DTConfigTraco
00004 //
00005 //   Description: Configurable parameters and constants for Level1 Mu DT Trigger - TRACO chip
00006 //
00007 //
00008 //   Author List:
00009 //   S.Vanini
00010 //   Modifications:
00011 //   April,10th 2008: set TRACO parameters from string
00012 //-----------------------------------------------------------------------
00013 
00014 //-----------------------
00015 // This Class's Header --
00016 //-----------------------
00017 #include "L1TriggerConfig/DTTPGConfig/interface/DTConfigTraco.h"
00018 
00019 //---------------
00020 // C++ Headers --
00021 //---------------
00022 #include <cstdlib>
00023 #include <string>
00024 #include <iostream>
00025 #include <fstream>
00026 #include <stdio.h>
00027 #include <stdlib.h>
00028 #include <math.h>
00029 #include <iomanip>
00030                
00031 //-------------------------------
00032 // Collaborating Class Headers --
00033 //-------------------------------
00034 
00035 #include "FWCore/Utilities/interface/Exception.h"
00036 
00037 //----------------
00038 // Constructors --
00039 //----------------
00040 DTConfigTraco::DTConfigTraco(const edm::ParameterSet& ps) { 
00041 
00042   setDefaults(ps);
00043 
00044 }
00045 
00046 DTConfigTraco::DTConfigTraco(int debugTRACO, unsigned short int * buffer) {
00047 
00048         m_debug = debugTRACO;
00049 
00050         // check if this is a TRACO configuration string
00051         if (buffer[2]!=0x15){
00052                 throw cms::Exception("DTTPG") << "===> ConfigTraco constructor : not a TRACO string!" << std::endl;
00053         }
00054 
00055         // decode
00056     unsigned short int memory_traco[38];
00057 
00058     for(int i=0;i<38;i++){
00059         memory_traco[i] = buffer[i+5];
00060         //std::cout << hex << memory_traco[i];
00061     }
00062     int btic = memory_traco[0] & 0x3f ;
00063     int rad = ( ( memory_traco[0] & 0xc0 ) >> 6 ) | ( ( memory_traco[1] & 0x7 ) << 2 ) ;
00064     int dd = ( memory_traco[1] & 0xf8 ) >> 3 ;
00065     int fprgcomp = memory_traco[2] & 0x3 ;
00066     int sprgcomp = memory_traco[3] & 0x3 ;
00067     int fhism = ( memory_traco[2] & 0x4 ) != 0 ;
00068     int fhtprf = ( memory_traco[2] & 0x8 ) != 0 ;
00069     int fslmsk = ( memory_traco[2] & 0x10 ) != 0 ;
00070     int fltmsk = ( memory_traco[2] & 0x20 ) != 0 ;
00071     int fhtmsk = ( memory_traco[2] & 0x40 ) != 0 ;
00072     int shism = ( memory_traco[3] & 0x4 ) != 0 ;
00073     int shtprf = ( memory_traco[3] & 0x8 ) != 0 ;
00074     int sslmsk = ( memory_traco[3] & 0x10 ) != 0 ;
00075     int sltmsk = ( memory_traco[3] & 0x20 ) != 0 ;
00076     int shtmsk = ( memory_traco[3] & 0x40 ) != 0 ;
00077     int reusei = ( memory_traco[2] & 0x80 ) != 0 ;
00078     int reuseo = ( memory_traco[3] & 0x80 ) != 0 ;
00079     int ltf = ( memory_traco[4] & 1 ) != 0 ;
00080     int lts = ( memory_traco[4] & 2 ) != 0 ;
00081     int prgdel = ( memory_traco[4] & 0x1c ) >> 2 ;
00082     int snapcor = ( memory_traco[4] & 0xe0 ) >> 5 ;
00083     int trgenb[16];
00084     for(int it=0; it<2; it++)
00085     {
00086         trgenb[0+it*8] = memory_traco[5+it] & 0x01; 
00087         trgenb[1+it*8] = (memory_traco[5+it] >> 1 ) & 0x01;
00088         trgenb[2+it*8] = (memory_traco[5+it] >> 1 ) & 0x01;
00089         trgenb[3+it*8] = (memory_traco[5+it] >> 1 ) & 0x01;
00090         trgenb[4+it*8] = (memory_traco[5+it] >> 1 ) & 0x01;
00091         trgenb[5+it*8] = (memory_traco[5+it] >> 1 ) & 0x01;
00092         trgenb[6+it*8] = (memory_traco[5+it] >> 1 ) & 0x01;
00093         trgenb[7+it*8] = (memory_traco[5+it] >> 1 ) & 0x01;
00094     }                   
00095     int trgadel = memory_traco[7] & 0x3 ;
00096     int ibtioff = ( memory_traco[7] & 0xfc ) >> 2 ;
00097     int kprgcom = ( memory_traco[8] & 0xff ) ;
00098     int testmode = ( memory_traco[9] & 1 ) != 0 ;
00099     int starttest = ( memory_traco[9] & 2 ) != 0 ;
00100     int prvsignmux = ( memory_traco[9] & 4 ) != 0 ;
00101     int lth = ( memory_traco[9] & 8 ) != 0 ;
00102 
00103     if(debug()==1)
00104     { 
00105         std::cout  << "btic=" << btic
00106               << " rad=" << rad
00107               << " dd=" << dd
00108               << " fprgcomp=" << fprgcomp
00109               << " sprgcomp=" << sprgcomp
00110               << " fhism=" << fhism
00111               << " fhtprf=" << fhtprf
00112               << " fslmsk=" << fslmsk
00113               << " fltmsk=" << fltmsk
00114               << " fhtmsk=" <<  fhtmsk
00115               << " shism=" <<  shism
00116               << " shtprf=" <<  shtprf
00117               << " sslmsk=" <<  sslmsk
00118               << " sltmsk=" <<  sltmsk
00119               << " shtmsk=" <<  shtmsk
00120               << " reusei=" <<  reusei
00121               << " reuseo=" <<  reuseo
00122               << " ltf=" <<  ltf
00123               << " lts=" <<  lts
00124               << " prgdel=" <<  prgdel
00125               << " snapcor=" <<  snapcor
00126               << " trgenb="; 
00127                 for(int t=0; t<16; t++)
00128                         std::cout << trgenb[t] << " ";
00129               std::cout << " trgadel=" <<  trgadel
00130               << " ibtioff=" <<  ibtioff
00131               << " kprgcom=" <<  kprgcom
00132               << " testmode=" <<  testmode
00133               << " starttest=" <<  starttest
00134               << " prvsignmux=" <<  prvsignmux
00135               << " lth=" <<  lth << std::endl;
00136 
00137         }
00138 
00139         // set parameters
00140         setBTIC(btic);
00141         setKRAD(rad);
00142         setDD(dd);
00143         setTcKToll(0,fprgcomp);
00144         setTcKToll(1,sprgcomp);
00145         setSortKascend(0,fhism);
00146         setSortKascend(1,shism);
00147         setPrefHtrig(0,fhtprf);
00148         setPrefHtrig(1,shtprf);
00149         setPrefInner(0,fslmsk);
00150         setPrefInner(1,sslmsk);
00151         setSingleLflag(0,fltmsk);
00152         setSingleLflag(1,sltmsk);
00153         setSingleHflag(0,fhtmsk);
00154         setSingleHflag(1,shtmsk);
00155         setTcReuse(0,reusei);
00156         setTcReuse(1,reuseo);
00157         setSingleLenab(0,ltf);
00158         setSingleLenab(1,ltf);
00159         setTcBxLts(lts);
00160         setIBTIOFF(ibtioff);
00161         setBendingAngleCut(kprgcom);
00162         setLVALIDIFH(lth);
00163         for(int t=0; t<16; t++)
00164                 setUsedBti(t+1,trgenb[t]);
00165         
00166         // the following are not relevant for simulation
00167         // prgdel, snapcor, trgadel, testmode, starttest, prvsignmux
00168 }
00169 
00170 //--------------
00171 // Destructor --
00172 //--------------
00173 DTConfigTraco::~DTConfigTraco() {}
00174 
00175 //--------------
00176 // Operations --
00177 //--------------
00178 
00179 void
00180 DTConfigTraco::setDefaults(const edm::ParameterSet& ps) {
00181 
00182   // Debug flag 
00183   m_debug = ps.getUntrackedParameter<int>("Debug");
00184 
00185   // KRAD traco parameter
00186   m_krad = ps.getParameter<int>("KRAD");
00187 
00188   // BTIC traco parameter
00189   m_btic = ps.getParameter<int>("BTIC");
00190  
00191   // DD traco parameter: this is fixed
00192   m_dd = ps.getParameter<int>("DD");
00193 
00194   // recycling of TRACO cand. in inner/outer SL : REUSEI/REUSEO
00195   m_reusei = ps.getParameter<int>("REUSEI");
00196   m_reuseo = ps.getParameter<int>("REUSEO");
00197 
00198   // single HTRIG enabling on first/second tracks F(S)HTMSK
00199   m_fhtmsk = ps.getParameter<int>("FHTMSK");
00200   m_shtmsk = ps.getParameter<int>("SHTMSK");
00201 
00202   // single LTRIG enabling on first/second tracks: F(S)LTMSK
00203   m_fltmsk = ps.getParameter<int>("FLTMSK");
00204   m_sltmsk = ps.getParameter<int>("SLTMSK");
00205 
00206   // preference to inner on first/second tracks: F(S)SLMSK
00207   m_fslmsk = ps.getParameter<int>("FSLMSK");
00208   m_sslmsk = ps.getParameter<int>("SSLMSK");
00209 
00210   // preference to HTRIG on first/second tracks: F(S)HTPRF
00211   m_fhtprf = ps.getParameter<int>("FHTPRF");
00212   m_shtprf = ps.getParameter<int>("SHTPRF");
00213 
00214   // ascend. order for K sorting first/second tracks: F(S)HISM
00215   m_fhism = ps.getParameter<int>("FHISM");
00216   m_shism = ps.getParameter<int>("SHISM");
00217 
00218   // K tollerance for correlation in TRACO: F(S)PRGCOMP
00219   m_fprgcomp = ps.getParameter<int>("FPRGCOMP");
00220   m_sprgcomp = ps.getParameter<int>("SPRGCOMP");
00221 
00222   // suppr. of LTRIG in 4 BX before HTRIG: LTS
00223   m_lts = ps.getParameter<int>("LTS");
00224 
00225   // single LTRIG accept enabling on first/second tracks LTF
00226   m_ltf = ps.getParameter<int>("LTF");
00227 
00228   // Connected bti in traco: bti mask
00229   for(int b=0; b<16; b++)
00230   {
00231         std::string label = "TRGENB";
00232         char p0 = (b/10)+'0';
00233         char p1 = (b%10)+'0';
00234         if ( p0 != '0' )
00235                 label = label + p0;
00236         label = label + p1;
00237         
00238         m_trgenb.set(b,ps.getParameter<int>(label));
00239   }
00240 
00241   // IBTIOFF traco parameter
00242   m_ibtioff = ps.getParameter<int>("IBTIOFF");
00243 
00244   // bending angle cut for all stations and triggers : KPRGCOM
00245   m_kprgcom = ps.getParameter<int>("KPRGCOM");
00246  
00247   // flag for Low validation parameter
00248   m_lvalidifh =  ps.getParameter<int>("LVALIDIFH");
00249 }
00250 
00251 void 
00252 DTConfigTraco::print() const {
00253   std::cout << "******************************************************************************" << std::endl;
00254   std::cout << "*              DTTrigger configuration : TRACO chips                                 *" << std::endl;
00255   std::cout << "******************************************************************************" << std::endl;
00256   std::cout << "*                                                                            *" << std::endl;
00257   std::cout << "Debug flag : " << debug()  << std::endl;
00258   std::cout << "KRAD traco parameter : " << KRAD() << std::endl;
00259   std::cout << "BTIC traco parameter : " << BTIC() << std::endl;
00260   std::cout << "DD traco parameter : " << DD() << std::endl;
00261   std::cout << "REUSEI, REUSEO : " << TcReuse(0) << ", " << TcReuse(1) << std::endl;
00262   std::cout << "FHTMSK, SHTMSK : " << singleHflag(0) << ", " << singleHflag(1) << std::endl;
00263   std::cout << "FLTMSK, SLTMSK: " << singleLflag(0) << ", " << singleLflag(1) << std::endl;
00264   std::cout << "FSLMSK, SSLMSK : " << prefInner(0) << ", " << prefInner(1) << std::endl;
00265   std::cout << "FHTPRF, SHTPRF : " << prefHtrig(0) << ", " << prefHtrig(1) << std::endl;
00266   std::cout << "FHISM, SHISM : " << sortKascend(0) << ", " << sortKascend(1) << std::endl;
00267   std::cout << "FPRGCOMP, SPRGCOMP : " << TcKToll(0) << ", " << TcKToll(1) << std::endl;
00268   std::cout << "LTS : " << TcBxLts() << std::endl;
00269   std::cout << "LTF : " << singleLenab(0) << std::endl;
00270   std::cout << "Connected bti in traco - bti mask : ";
00271   for(int b=1; b<=16; b++)
00272         std::cout << usedBti(b) << " "; 
00273   std::cout << std::endl;
00274   std::cout << "IBTIOFF : " << IBTIOFF() << std::endl;
00275   std::cout << "bending angle cut : " << BendingAngleCut() << std::endl;
00276   std::cout << "flag for Low validation parameter : " << LVALIDIFH() << std::endl;
00277   std::cout << "******************************************************************************" << std::endl;
00278 
00279 }