Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "L1TriggerConfig/DTTPGConfig/interface/DTConfigTSPhi.h"
00018
00019
00020
00021
00022 #include <iostream>
00023 #include <cstring>
00024
00025
00026
00027
00028
00029 #include "FWCore/Utilities/interface/Exception.h"
00030
00031
00032
00033
00034 DTConfigTSPhi::DTConfigTSPhi(const edm::ParameterSet& ps) {
00035
00036 setDefaults(ps);
00037 if (debug()) print();
00038 }
00039
00040 DTConfigTSPhi::DTConfigTSPhi(bool debugTS, unsigned short int tss_buffer[7][31], int ntss, unsigned short int tsm_buffer[9]) {
00041
00042 if (ntss == 0) {
00043 throw cms::Exception("DTTPG") << "DTConfigTSPhi::DTConfigTSPhi : ntss=" << ntss << std::endl
00044 << "configuration from CCB strings not possible " << std::endl
00045 << "if error occurs configuring from DB this is " << std::endl
00046 << "likely to be a DTCCBConfigRcd issue" << std::endl;
00047 }
00048
00049 m_debug = debugTS;
00050
00051 bool tstren[24];
00052 bool tsscgs2, tsscgs1, tsscce1, tsshte1, tssnoe1, carrytss;
00053 bool tsscce2, tsshte2, tssnoe2, tssccec, tsshtec, tssnoec;
00054 unsigned short tssgs1, tssgs2, tssmsk1, tssmsk2;
00055
00056 tsscgs2 = tsscgs1 = tsscce1 = tsshte1 = tssnoe1 = carrytss = 0;
00057 tsscce2 = tsshte2 = tssnoe2 = tssccec = tsshtec = tssnoec = 0;
00058 tssgs1 = tssgs2 = tssmsk1 = tssmsk2 = 0;
00059
00060 memset(tstren,true,24*sizeof(bool));
00061
00062
00063 for (int itss=0; itss<ntss; itss++) {
00064 unsigned short int memory_tss[27];
00065
00066 for(int ts=0;ts<27;ts++){
00067 memory_tss[ts] = tss_buffer[itss][ts+4];
00068
00069 }
00070
00071 tstren[itss*4] = !(memory_tss[1]&0x08);
00072 tstren[itss*4+1] = !(memory_tss[1]&0x80);
00073 tstren[itss*4+2] = !(memory_tss[2]&0x08);
00074 tstren[itss*4+3] = !(memory_tss[2]&0x80);
00075
00076 if(!itss) {
00077 tsscgs2 = !(memory_tss[0]&0x08);
00078 tssgs2 = memory_tss[0]&0x04 ? 0 : 1;
00079 tsscgs1 = !(memory_tss[0]&0x02);
00080 tssgs1 = memory_tss[0]&0x01 ? 0 : 1;
00081 tsscce1 = !(memory_tss[4]&0x04);
00082 tsshte1 = !(memory_tss[4]&0x02);
00083 tssnoe1 = !(memory_tss[4]&0x01);
00084 tsscce2 = !(memory_tss[3]&0x40);
00085 tsshte2 = !(memory_tss[3]&0x20);
00086 tssnoe2 = !(memory_tss[3]&0x10);
00087 tssccec = !(memory_tss[3]&0x04);
00088 tsshtec = !(memory_tss[3]&0x02);
00089 tssnoec = !(memory_tss[3]&0x01);
00090 carrytss= !(memory_tss[4]&0x40);
00091 tssmsk1 = memory_tss[4]&0x10 ? 132 : 312;
00092 tssmsk2 = memory_tss[4]&0x20 ? 132 : 312;
00093 }
00094 }
00095
00096
00097 unsigned short int memory_tsms[2], memory_tsmdu[2], memory_tsmdd[2];
00098
00099 for(int ts=0;ts<2;ts++){
00100 memory_tsms[ts] = tsm_buffer[ts+3];
00101 memory_tsmdu[ts] = tsm_buffer[ts+5];
00102 memory_tsmdd[ts] = tsm_buffer[ts+7];
00103
00104
00105 }
00106
00107 bool tsmcgs1 = true;
00108 unsigned short tsmgs1 = memory_tsms[1]&0x02 ? 0 : 1;
00109 bool tsmcgs2 = true;
00110 unsigned short tsmgs2 = 1;
00111 bool tsmcce1 = true;
00112 bool tsmhte1 = true;
00113 bool tsmnoe1 = true;
00114 bool tsmcce2 = true;
00115 bool tsmhte2 = true;
00116 bool tsmnoe2 = true;
00117 bool tsmccec = true;
00118 bool tsmhtec = true;
00119 bool tsmnoec = true;
00120 bool carrytsms = !(memory_tsms[1]&0x01);
00121 unsigned short tsmmsk1 = memory_tsms[1]&0x08 ? 321 : 312;
00122 unsigned short tsmmsk2 = tsmmsk1;
00123 bool tsmword[8];
00124 tsmword[0] = !((memory_tsmdu[0]&0x80)&&(memory_tsmdd[0]&0x80));
00125 tsmword[1] = !(memory_tsms[0]&0x01);
00126 tsmword[2] = !(memory_tsms[0]&0x02);
00127 tsmword[3] = !(memory_tsms[0]&0x04);
00128 tsmword[4] = !(memory_tsms[0]&0x08);
00129 tsmword[5] = !(memory_tsms[0]&0x10);
00130 tsmword[6] = !(memory_tsms[0]&0x20);
00131 tsmword[7] = !(memory_tsms[0]&0x40);
00132 bool carrytsmd = !((memory_tsmdu[0]&0x10)&&(memory_tsmdd[0]&0x10));
00133
00134 unsigned short tsmhsp = carrytss && carrytsms && carrytsmd;
00135
00136 if (debug()) {
00137 std::cout << "TSS :" << std::dec << std::endl << "tstren= " ;
00138 for (int i=0; i<24 ;i++) std::cout << tstren[i] << " ";
00139 std::cout << " tsscgs1=" << tsscgs1
00140 << " tssgs1=" << tssgs1
00141 << " tsscgs2=" << tsscgs2
00142 << " tssgs2=" << tssgs2
00143 << " tsscce1=" << tsscce1
00144 << " tsshte1=" << tsshte1
00145 << " tssnoe1=" << tssnoe1
00146 << " tsscce2=" << tsscce2
00147 << " tsshte2=" << tsshte2
00148 << " tssnoe2=" << tssnoe2
00149 << " tssccec=" << tssccec
00150 << " tsshtec=" << tsshtec
00151 << " tssnoec=" << tssnoec
00152 << " carrytss=" << carrytss
00153 << " tssmsk1=" << tssmsk1
00154 << " tssmsk2=" << tssmsk2 << std::endl;
00155
00156 std::cout << "TSM : "<< std::endl
00157 << "tsmcgs1=" << tsmcgs1
00158 << " tsmgs1=" << tsmgs1
00159 << " tsmcgs2=" << tsmcgs2
00160 << " tsmgs2=" << tsmgs2
00161 << " tsmcce1=" << tsmcce1
00162 << " tsmhte1=" << tsmhte1
00163 << " tsmnoe1=" << tsmnoe1
00164 << " tsmcce2=" << tsmcce2
00165 << " tsmhte2=" << tsmhte2
00166 << " tsmnoe2=" << tsmnoe2
00167 << " tsmccec=" << tsmccec
00168 << " tsmhtec=" << tsmhtec
00169 << " tsmnoec=" << tsmnoec
00170 << " tsmhsp=" << tsmhsp
00171 << " carrytsms=" << carrytsms
00172 << " carrytsmd=" << carrytsmd
00173 << " tsmword=";
00174 for (int i=0;i<8;i++) std::cout << tsmword[i] << " ";
00175 std::cout << " tsmmsk1=" << tsmmsk1
00176 << " tsmmsk2=" << tsmmsk2 << std::endl;
00177 }
00178
00179 setTssMasking(tssmsk1,1);
00180 setTssMasking(tssmsk2,2);
00181 setTssHtrigEna(tsshte1,1);
00182 setTssHtrigEna(tsshte2,2);
00183 setTssHtrigEnaCarry(tsshtec);
00184 setTssInOutEna(tssnoe1,1);
00185 setTssInOutEna(tssnoe2,2);
00186 setTssInOutEnaCarry(tssnoec);
00187 setTssCorrEna(tsscce1,1);
00188 setTssCorrEna(tsscce2,2);
00189 setTssCorrEnaCarry(tssccec);
00190 setTssGhost1Flag(tssgs1);
00191 setTssGhost2Flag(tssgs2);
00192 setTssGhost1Corr(tsscgs1);
00193 setTssGhost2Corr(tsscgs2);
00194
00195 setTsmMasking(tsmmsk1,1);
00196 setTsmMasking(tsmmsk2,2);
00197 setTsmHtrigEna(tsmhte1,1);
00198 setTsmHtrigEna(tsmhte2,2);
00199 setTsmHtrigEnaCarry(tsmhtec);
00200 setTsmInOutEna(tsmnoe1,1);
00201 setTsmInOutEna(tsmnoe2,2);
00202 setTsmInOutEnaCarry(tsmnoec);
00203 setTsmCorrEna(tsmcce1,1);
00204 setTsmCorrEna(tsmcce2,2);
00205 setTsmCorrEnaCarry(tsmccec);
00206 setTsmGhost1Flag(tsmgs1);
00207 setTsmGhost2Flag(tsmgs2);
00208 setTsmGhost1Corr(tsmcgs1);
00209 setTsmGhost2Corr(tsmcgs2);
00210 setTsmCarryFlag(tsmhsp);
00211
00212 for (int i=0;i<24;i++) setUsedTraco(i,tstren[i]);
00213 for (int i=0;i<8;i++) setTsmStatus(i,tsmword[i]);
00214
00215
00216 }
00217
00218
00219
00220
00221 DTConfigTSPhi::~DTConfigTSPhi() {}
00222
00223
00224
00225
00226
00227 void
00228 DTConfigTSPhi::setDefaults(const edm::ParameterSet& ps) {
00229
00230
00231 m_debug = ps.getUntrackedParameter<bool>("Debug");
00232
00233
00234 int mymsk = ps.getParameter<int>("TSSMSK1");
00235 if (checkMask(mymsk))
00236 m_tssmsk[0] = mymsk;
00237 else {
00238 throw cms::Exception("DTTPG") << "DTConfigTSPhi::setDefaults : TSSMSK1 not in correct form: " << mymsk << std::endl;
00239 }
00240
00241
00242 mymsk= ps.getParameter<int>("TSSMSK2");
00243 if (checkMask(mymsk))
00244 m_tssmsk[1] = mymsk;
00245 else {
00246 throw cms::Exception("DTTPG") << "DTConfigTSPhi::setDefaults : TSSMSK2 not in correct form: " << mymsk << std::endl;
00247 }
00248
00249
00250 m_tsshte[0] = ps.getParameter<bool>("TSSHTE1");
00251
00252
00253 m_tsshte[1] = ps.getParameter<bool>("TSSHTE2");
00254
00255
00256 m_tsshte[2] = ps.getParameter<bool>("TSSHTEC");
00257
00258
00259 m_tssnoe[0] = ps.getParameter<bool>("TSSNOE1");
00260
00261
00262 m_tssnoe[1] = ps.getParameter<bool>("TSSNOE2");
00263
00264
00265 m_tssnoe[2] = ps.getParameter<bool>("TSSNOEC");
00266
00267
00268 m_tsscce[0] = ps.getParameter<bool>("TSSCCE1");
00269
00270
00271 m_tsscce[1] = ps.getParameter<bool>("TSSCCE2");
00272
00273
00274 m_tsscce[2] = ps.getParameter<bool>("TSSCCEC");
00275
00276
00277 int mygs = ps.getParameter<int>("TSSGS1");
00278 if (mygs>=0 && mygs<3)
00279 m_tssgs1 = mygs;
00280 else {
00281 throw cms::Exception("DTTPG") << "DTConfigTSPhi::setDefaults : TSSGS1 value is not correct: " << mygs << std::endl;
00282 }
00283
00284
00285 mygs= ps.getParameter<int>("TSSGS2");
00286 if (mygs>=0 && mygs<5)
00287 m_tssgs2 = mygs;
00288 else {
00289 throw cms::Exception("DTTPG") << "DTConfigTSPhi::setDefaults : TSSGS2 value is not correct: " << mygs << std::endl;
00290 }
00291
00292
00293 m_tsscgs1 = ps.getParameter<bool>("TSSCGS1");
00294
00295
00296 m_tsscgs2 = ps.getParameter<bool>("TSSCGS2");
00297
00298
00299 mymsk = ps.getParameter<int>("TSMMSK1");
00300 if (checkMask(mymsk))
00301 m_tsmmsk[0] = mymsk;
00302 else {
00303 throw cms::Exception("DTTPG") << "DTConfigTSPhi::setDefaults : TSMMSK1 not in correct form: " << mymsk << std::endl;
00304 }
00305
00306
00307 mymsk= ps.getParameter<int>("TSMMSK2");
00308 if (checkMask(mymsk))
00309 m_tsmmsk[1] = mymsk;
00310 else {
00311 throw cms::Exception("DTTPG") << "DTConfigTSPhi::setDefaults : TSMMSK2 not in correct form: " << mymsk << std::endl;
00312 }
00313
00314
00315 m_tsmhte[0] = ps.getParameter<bool>("TSMHTE1");
00316
00317
00318 m_tsmhte[1] = ps.getParameter<bool>("TSMHTE2");
00319
00320
00321 m_tsmhte[2] = ps.getParameter<bool>("TSMHTEC");
00322
00323
00324 m_tsmnoe[0] = ps.getParameter<bool>("TSMNOE1");
00325
00326
00327 m_tsmnoe[1] = ps.getParameter<bool>("TSMNOE2");
00328
00329
00330 m_tsmnoe[2] = ps.getParameter<bool>("TSMNOEC");
00331
00332
00333 m_tsmcce[0] = ps.getParameter<bool>("TSMCCE1");
00334
00335
00336 m_tsmcce[1] = ps.getParameter<bool>("TSMCCE2");
00337
00338
00339 m_tsmcce[2] = ps.getParameter<bool>("TSMCCEC");
00340
00341
00342 mygs = ps.getParameter<int>("TSMGS1");
00343 if (mygs>=0 && mygs<3)
00344 m_tsmgs1 = mygs;
00345 else {
00346 throw cms::Exception("DTTPG") << "DTConfigTSPhi::setDefaults : TSMGS1 value is not correct: " << mygs << std::endl;
00347 }
00348
00349
00350 mygs= ps.getParameter<int>("TSMGS2");
00351 if (mygs>=0 && mygs<5)
00352 m_tsmgs2 = mygs;
00353 else {
00354 throw cms::Exception("DTTPG") << "DTConfigTSPhi::setDefaults : TSMGS2 value is not correct: " << mygs << std::endl;
00355 }
00356
00357
00358 m_tsmcgs1 = ps.getParameter<bool>("TSMCGS1");
00359
00360
00361 m_tsmcgs2 = ps.getParameter<bool>("TSMCGS2");
00362
00363
00364 int myhsp = ps.getParameter<int>("TSMHSP");
00365 if (myhsp>=0 && myhsp<3)
00366 m_tsmhsp = myhsp;
00367 else {
00368 throw cms::Exception("DTTPG") << "DTConfigTSPhi::setDefaults : TSMHSP value is not correct: " << myhsp << std::endl;
00369 }
00370
00371
00372 m_tsmword.one();
00373 int word = ps.getParameter<int>("TSMWORD");
00374 if (word<0 || word>255){
00375 throw cms::Exception("DTTPG") << "DTConfigTSPhi::setDefaults : TSMWORD value is not correct: " << word << std::endl;
00376 }
00377 for (int i=0;i<7;i++){
00378 short int bit = word%2;
00379 word /= 2;
00380 if (bit==0) m_tsmword.unset(i);
00381 }
00382
00384 m_tstren.one();
00385 for (int i=0;i<24;i++){
00386 std::stringstream os;
00387 os << "TSTREN" << i;
00388 if (ps.getParameter<bool>(os.str())== 0)
00389 m_tstren.unset(i);
00390 }
00391
00392 }
00393
00394 int
00395 DTConfigTSPhi::TSSinTSMD(int stat, int sect) {
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412 if( stat==1 ||
00413 stat==2 ||
00414 ( stat==4 && (sect==9 || sect==11 ||
00415 sect==10))) {
00416 m_ntsstsmd = 2;
00417 } else {
00418 m_ntsstsmd = 3;
00419 }
00420
00421 return (int)m_ntsstsmd;
00422
00423 }
00424
00425 void
00426 DTConfigTSPhi::print() const {
00427
00428 std::cout << "******************************************************************************" << std::endl;
00429 std::cout << "* DTTrigger configuration : TSPhi chips *" << std::endl;
00430 std::cout << "******************************************************************************" << std::endl << std::endl;
00431 std::cout << "Debug flag : " << debug() << std::endl;
00432 std::cout << " TSS Parameters:" << std::endl;
00433 std::cout << "TSSMSK 1/2:" << TssMasking(0) << " " << TssMasking(1) << std::endl;
00434 std::cout << "TSSHTE 1/2/carry :" << TssHtrigEna(0) << " " << TssHtrigEna(1) << " " << TssHtrigEnaCarry() << std::endl;
00435 std::cout << "TSSNOE 1/2/carry :" << TssInOutEna(0) << " " << TssInOutEna(1) << " " << TssInOutEnaCarry() << std::endl;
00436 std::cout << "TSSCCE 1/2/carry :" << TssCorrEna(0) << " " << TssCorrEna(1) << " " << TssCorrEnaCarry() << std::endl;
00437 std::cout << "TSSGS 1/2:" << TssGhost1Flag() << " " << TssGhost2Flag() << std::endl;
00438 std::cout << "TSSCGS 1/2:" << TssGhost1Corr() << " " << TssGhost2Corr() << std::endl;
00439 std::cout << " TSM Parameters:" << std::endl;
00440 std::cout << "TSMMSK 1/2:" << TsmMasking(0) << " " << TsmMasking(1) << std::endl;
00441 std::cout << "TSMHTE 1/2/carry :" << TsmHtrigEna(0) << " " << TsmHtrigEna(1) << " " << TsmHtrigEnaCarry() << std::endl;
00442 std::cout << "TSMNOE 1/2/carry :" << TsmInOutEna(0) << " " << TsmInOutEna(1) << " " << TsmInOutEnaCarry() << std::endl;
00443 std::cout << "TSMCCE 1/2/carry :" << TsmCorrEna(0) << " " << TsmCorrEna(1) << " " << TsmCorrEnaCarry() << std::endl;
00444 std::cout << "TSMGS 1/2:" << TsmGhost1Flag() << " " << TsmGhost2Flag() << std::endl;
00445 std::cout << "TSMCGS 1/2:" << TsmGhost1Corr() << " " << TsmGhost2Corr() << std::endl;
00446 std::cout << "TSMHSP :" << TsmGetCarryFlag() << std::endl;
00447 std::cout << "TSTREN[i] :";
00448 for (int i=1;i<25;i++) std::cout << usedTraco(i) << " ";
00449 std::cout << std::endl;
00450 std::cout << "TSMWORD :";
00451 TsmStatus().print();
00452 std::cout << std::endl;
00453
00454
00455 std::cout << "******************************************************************************" << std::endl;
00456
00457 }
00458
00459 void
00460 DTConfigTSPhi::setTssMasking(unsigned short tssmsk, int i) {
00461 if (checkMask(tssmsk))
00462 m_tssmsk[i-1] = tssmsk;
00463 else {
00464 throw cms::Exception("DTTPG") << "DTConfigTSPhi::setTssMasking : TSSMSK" << i << " not in correct form: " << tssmsk << std::endl;
00465 }
00466 }
00467
00468 void
00469 DTConfigTSPhi::setTsmMasking(unsigned short tsmmsk, int i) {
00470 if (checkMask(tsmmsk))
00471 m_tsmmsk[i-1] = tsmmsk;
00472 else {
00473 throw cms::Exception("DTTPG") << "DTConfigTSPhi::setTsmMasking : TSMMSK" << i << " not in correct form: " << tsmmsk << std::endl;
00474 }
00475 }
00476
00477 bool
00478 DTConfigTSPhi::checkMask(unsigned short msk){
00479
00480 bool hasone = false;
00481 bool hastwo = false;
00482 bool hasthree = false;
00483 for(int i=0;i<3;i++){
00484 int mynum = msk%10;
00485 switch (mynum){
00486 case 1:
00487 hasone = true;
00488 break;
00489 case 2:
00490 hastwo = true;
00491 break;
00492 case 3:
00493 hasthree =true;
00494 break;
00495 }
00496 msk /= 10;
00497 }
00498 if (hasone==true && hastwo==true && hasthree==true) return true;
00499 return false;
00500
00501 }
00502
00503