00001 #include "L1TriggerConfig/DTTPGConfigProducers/src/DTConfigDBProducer.h"
00002
00003 #include "DataFormats/MuonDetId/interface/DTChamberId.h"
00004 #include "DataFormats/MuonDetId/interface/DTSuperLayerId.h"
00005 #include "DataFormats/MuonDetId/interface/DTLayerId.h"
00006
00007 #include "CondFormats/DataRecord/interface/DTT0Rcd.h"
00008 #include "CondFormats/DTObjects/interface/DTCCBConfig.h"
00009 #include "CondFormats/DataRecord/interface/DTCCBConfigRcd.h"
00010 #include "CondFormats/DataRecord/interface/DTTPGParametersRcd.h"
00011 #include "CondFormats/DTObjects/interface/DTKeyedConfig.h"
00012 #include "CondFormats/DataRecord/interface/DTKeyedConfigListRcd.h"
00013 #include "CondFormats/DTObjects/interface/DTConfigAbstractHandler.h"
00014
00015 #include "L1TriggerConfig/DTTPGConfig/interface/DTConfigManagerRcd.h"
00016 #include "L1TriggerConfig/DTTPGConfigProducers/src/DTPosNegType.h"
00017
00018 #include "FWCore/Framework/interface/ESHandle.h"
00019 #include "FWCore/Utilities/interface/Exception.h"
00020 #include "FWCore/Framework/interface/MakerMacros.h"
00021 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00022
00023 #include <iostream>
00024 #include <iomanip>
00025
00026 using std::cout;
00027 using std::endl;
00028 using std::vector;
00029 using std::auto_ptr;
00030
00031
00032
00033
00034
00035 DTConfigDBProducer::DTConfigDBProducer(const edm::ParameterSet& p)
00036 {
00037
00038 setWhatProduced(this,&DTConfigDBProducer::produce);
00039
00040 cfgConfig = p.getParameter<bool>("cfgConfig");
00041
00042
00043 m_ps = p;
00044
00045
00046 m_debugDB = p.getParameter<bool>("debugDB");
00047 m_debugBti = p.getParameter<int>("debugBti");
00048 m_debugTraco = p.getParameter<int>("debugTraco");
00049 m_debugTSP = p.getParameter<bool>("debugTSP");
00050 m_debugTST = p.getParameter<bool>("debugTST");
00051 m_debugTU = p.getParameter<bool>("debugTU");
00052 m_debugSC = p.getParameter<bool>("debugSC");
00053 m_debugLUTs = p.getParameter<bool>("debugLUTs");
00054 m_debugPed = p.getParameter<bool>("debugPed");
00055
00056 m_UseT0 = p.getParameter<bool>("UseT0");
00057
00058 }
00059
00060
00061 DTConfigDBProducer::~DTConfigDBProducer()
00062 {
00063
00064 }
00065
00066
00067
00068
00069
00070
00071 std::auto_ptr<DTConfigManager> DTConfigDBProducer::produce(const DTConfigManagerRcd& iRecord)
00072 {
00073 using namespace edm;
00074
00075 std::auto_ptr<DTConfigManager> dtConfig = std::auto_ptr<DTConfigManager>( new DTConfigManager() );
00076 DTConfigManager & dttpgConfig = *(dtConfig.get());
00077
00078
00079 bool tracoLutsFromDB = m_ps.getParameter<bool>("TracoLutsFromDB");
00080 bool useBtiAcceptParam = m_ps.getParameter<bool>("UseBtiAcceptParam");
00081
00082
00083 dttpgConfig.setLutFromDB(tracoLutsFromDB);
00084 dttpgConfig.setUseAcceptParam(useBtiAcceptParam);
00085
00086
00087 edm::ParameterSet conf_ps = m_ps.getParameter<edm::ParameterSet>("DTTPGParameters");
00088 bool dttpgdebug = conf_ps.getUntrackedParameter<bool>("Debug");
00089 dttpgConfig.setDTTPGDebug(dttpgdebug);
00090
00091 int code;
00092 if(cfgConfig){
00093 dttpgConfig.setLutFromDB(false);
00094 configFromCfg(dttpgConfig);
00095 code = 2;
00096 } else{
00097 code = readDTCCBConfig(iRecord,dttpgConfig);
00098 readDBPedestalsConfig(iRecord,dttpgConfig);
00099
00100 if(code != -1 && checkDTCCBConfig(dttpgConfig) > 0)
00101 code=-1;
00102 }
00103
00104 if(code==-1) {
00105 dttpgConfig.setCCBConfigValidity(false);
00106 } else if(code==2) {
00107 LogVerbatim ("DTTPG") << "DTConfigDBProducer::produce : Trivial : " << endl
00108 << "configurations has been read from cfg" << endl;
00109 } else if(code==0) {
00110 LogVerbatim ("DTTPG") << "DTConfigDBProducer::produce : " << endl
00111 << "Configurations successfully read from OMDS" << endl;
00112 } else {
00113 LogProblem ("DTTPG") << "DTConfigDBProducer::produce : " << endl
00114 << "Wrong configuration return CODE" << endl;
00115 }
00116
00117 return dtConfig ;
00118 }
00119
00120 void DTConfigDBProducer::readDBPedestalsConfig(const DTConfigManagerRcd& iRecord,
00121 DTConfigManager & dttpgConfig){
00122
00123 edm::ESHandle<DTTPGParameters> dttpgParams;
00124 iRecord.getRecord<DTTPGParametersRcd>().get(dttpgParams);
00125
00126 DTConfigPedestals pedestals;
00127 pedestals.setDebug(m_debugPed);
00128
00129 if (m_UseT0) {
00130
00131 edm::ESHandle<DTT0> t0i;
00132 iRecord.getRecord<DTT0Rcd>().get(t0i);
00133
00134 pedestals.setUseT0(true);
00135 pedestals.setES(dttpgParams.product(),t0i.product());
00136
00137
00138 } else {
00139
00140 pedestals.setUseT0(false);
00141 pedestals.setES(dttpgParams.product());
00142
00143 }
00144
00145 dttpgConfig.setDTConfigPedestals(pedestals);
00146
00147 }
00148
00149 int DTConfigDBProducer::checkDTCCBConfig(DTConfigManager & dttpgConfig)
00150 {
00151
00152
00153
00154
00155
00156
00157
00158 int check_cfg_code = 0;
00159
00160
00161 for(int iwh=-2;iwh<=2;iwh++){
00162 for(int ise=1;ise<=12;ise++){
00163 for(int ist=1;ist<=4;ist++){
00164
00165 check_cfg_code = 0;
00166 DTChamberId chid(iwh,ist,ise);
00167
00168
00169 int nbti = dttpgConfig.getDTConfigBtiMap(chid).size();
00170 int ntraco = dttpgConfig.getDTConfigTracoMap(chid).size();
00171 int ntss = dttpgConfig.getDTConfigTSPhi(chid)->nValidTSS();
00172 int ntsm = dttpgConfig.getDTConfigTSPhi(chid)->nValidTSM();
00173
00174
00175 if((ist==1 && nbti!=168) ||
00176 (ist==2 && nbti!=192) ||
00177 (ist==3 && nbti!=224) ||
00178 (ist==4 && (ise==1||ise==2||ise==3||ise==5||ise==6||ise==7||ise==8||ise==12) && nbti!=192) ||
00179 (ist==4 && (ise==9||ise==11) && nbti!=96) ||
00180 (ist==4 && ise==10 && nbti!=128) ||
00181 (ist==4 && ise==4 && nbti!=160)){
00182 check_cfg_code = 1;
00183 return check_cfg_code;
00184 }
00185
00186
00187 if((ist==1 && ntraco!=13) ||
00188 (ist==2 && ntraco!=16) ||
00189 (ist==3 && ntraco!=20) ||
00190 (ist==4 && (ise==1||ise==2||ise==3||ise==5||ise==6||ise==7||ise==8||ise==12) && ntraco!=24) ||
00191 (ist==4 && (ise==9||ise==11) && ntraco!=12) ||
00192 (ist==4 && ise==10 && ntraco!=16) ||
00193 (ist==4 && ise==4 && ntraco!=20)){
00194 check_cfg_code = 2;
00195 return check_cfg_code;
00196 }
00197
00198
00199 if((ist==1 && ntss!=4) ||
00200 (ist==2 && ntss!=4) ||
00201 (ist==3 && ntss!=5) ||
00202 (ist==4 && (ise==1||ise==2||ise==3||ise==5||ise==6||ise==7||ise==8||ise==12) && ntss!=6) ||
00203 (ist==4 && (ise==9||ise==11) && ntss!=3) ||
00204 (ist==4 && ise==10 && ntss!=4) ||
00205 (ist==4 && ise==4 && ntss!=5) ){
00206 check_cfg_code = 3;
00207 return check_cfg_code;
00208 }
00209
00210
00211 if(ntsm!=1){
00212 check_cfg_code = 4;
00213 return check_cfg_code;
00214 }
00215
00216
00217
00218
00219
00220 }
00221 }
00222
00223
00224 for(int ise=13;ise<=14;ise++){
00225
00226 DTChamberId chid(iwh,4,ise);
00227
00228 int nbti = dttpgConfig.getDTConfigBtiMap(chid).size();
00229 int ntraco = dttpgConfig.getDTConfigTracoMap(chid).size();
00230 int ntss = dttpgConfig.getDTConfigTSPhi(chid)->nValidTSS();
00231 int ntsm = dttpgConfig.getDTConfigTSPhi(chid)->nValidTSM();
00232
00233 if((ise==13 && nbti != 160) ||
00234 (ise==14 && nbti != 128)){
00235 check_cfg_code = 1;
00236 return check_cfg_code;
00237 }
00238 if((ise==13 && ntraco != 20) ||
00239 (ise==14 && ntraco != 16)){
00240 check_cfg_code = 2;
00241 return check_cfg_code;
00242 }
00243 if((ise==13 && ntss != 5) ||
00244 (ise==14 && ntss != 4)) {
00245 check_cfg_code = 3;
00246 return check_cfg_code;
00247 }
00248 if(ntsm != 1){
00249 check_cfg_code = 4;
00250 return check_cfg_code;
00251 }
00252
00253
00254
00255
00256 }
00257
00258 }
00259
00260
00261 return check_cfg_code;
00262 }
00263
00264 int DTConfigDBProducer::readDTCCBConfig(const DTConfigManagerRcd & iRecord,
00265 DTConfigManager & dttpgConfig)
00266 {
00267 using namespace edm::eventsetup;
00268
00269
00270 dttpgConfig.setCCBConfigValidity(true);
00271
00272
00273 edm::ESHandle<DTCCBConfig> ccb_conf;
00274 iRecord.getRecord<DTCCBConfigRcd>().get(ccb_conf);
00275 int ndata = std::distance( ccb_conf->begin(), ccb_conf->end() );
00276
00277 DTConfigAbstractHandler* cfgCache = DTConfigAbstractHandler::getInstance();
00278 const DTKeyedConfigListRcd& keyRecord = iRecord.getRecord<DTKeyedConfigListRcd>();
00279
00280 if(m_debugDB)
00281 {
00282 cout << ccb_conf->version() << endl;
00283 cout << ndata << " data in the container" << endl;
00284 }
00285
00286 edm::ValidityInterval iov(iRecord.getRecord<DTCCBConfigRcd>().validityInterval() );
00287 unsigned int currValidityStart = iov.first().eventID().run();
00288 unsigned int currValidityEnd = iov.last( ).eventID().run();
00289
00290 if(m_debugDB)
00291 cout << "valid since run " << currValidityStart
00292 << " to run " << currValidityEnd << endl;
00293
00294
00295 if( ndata==0 ){
00296 return -1;
00297 }
00298
00299
00300 edm::ParameterSet conf_map = m_ps.getUntrackedParameter<edm::ParameterSet>("DTTPGMap");
00301
00302
00303 DTCCBConfig::ccb_config_map configKeys( ccb_conf->configKeyMap() );
00304 DTCCBConfig::ccb_config_iterator iter = configKeys.begin();
00305 DTCCBConfig::ccb_config_iterator iend = configKeys.end();
00306
00307
00308 if(ccb_conf->configKeyMap().size() != 250)
00309 return -1;
00310
00311
00312 while ( iter != iend ) {
00313
00314
00315 flagDBBti = false;
00316 flagDBTraco = false;
00317 flagDBTSS = false;
00318 flagDBTSM = false;
00319 flagDBLUTS = false;
00320
00321
00322 const DTCCBId& ccbId = iter->first;
00323 if(m_debugDB)
00324 cout << " Filling configuration for chamber : wh " << ccbId.wheelId << " st "
00325 << ccbId.stationId << " se "
00326 << ccbId.sectorId << " -> " << endl;
00327
00328
00329 int mbtype = DTPosNegType::getCT( ccbId.wheelId, ccbId.sectorId, ccbId.stationId );
00330 int posneg = DTPosNegType::getPN( ccbId.wheelId, ccbId.sectorId, ccbId.stationId );
00331 if(m_debugDB)
00332 cout << "Chamber type : " << mbtype
00333 << " posneg : " << posneg << endl;
00334 DTChamberId chambid(ccbId.wheelId, ccbId.stationId, ccbId.sectorId);
00335
00336
00337 const std::vector<int>& ccbConf = iter->second;
00338 std::vector<int>::const_iterator cfgIter = ccbConf.begin();
00339 std::vector<int>::const_iterator cfgIend = ccbConf.end();
00340
00341
00342 unsigned short int tss_buffer[7][31];
00343 unsigned short int tsm_buffer[9];
00344 int ntss=0;
00345
00346
00347 while ( cfgIter != cfgIend ) {
00348
00349 int id = *cfgIter++;
00350 if(m_debugDB)
00351 cout << " BRICK " << id << endl;
00352
00353
00354 std::vector<std::string> list;
00355 cfgCache->getData( keyRecord, id, list );
00356
00357
00358 std::vector<std::string>::const_iterator s_iter = list.begin();
00359 std::vector<std::string>::const_iterator s_iend = list.end();
00360 while ( s_iter != s_iend ) {
00361 if(m_debugDB)
00362 cout << " ----> " << *s_iter << endl;
00363
00364
00365 std::string str = *s_iter++;
00366 unsigned short int buffer[100];
00367 int c = 0;
00368 const char* cstr = str.c_str();
00369 const char* ptr = cstr + 2;
00370 const char* end = cstr + str.length();
00371 while ( ptr < end ) {
00372 char c1 = *ptr++;
00373 int i1 = 0;
00374 if ( ( c1 >= '0' ) && ( c1 <= '9' ) ) i1 = c1 - '0';
00375 if ( ( c1 >= 'a' ) && ( c1 <= 'f' ) ) i1 = 10 + c1 - 'a';
00376 if ( ( c1 >= 'A' ) && ( c1 <= 'F' ) ) i1 = 10 + c1 - 'A';
00377 char c2 = *ptr++;
00378 int i2 = 0;
00379 if ( ( c2 >= '0' ) && ( c2 <= '9' ) ) i2 = c2 - '0';
00380 if ( ( c2 >= 'a' ) && ( c2 <= 'f' ) ) i2 = 10 + c2 - 'a';
00381 if ( ( c2 >= 'A' ) && ( c2 <= 'F' ) ) i2 = 10 + c2 - 'A';
00382 buffer[c] = ( i1 * 16 ) + i2;
00383 c++;
00384 }
00385
00386
00387 if (buffer[2]==0x54){
00388 if(m_debugDB)
00389 cout << "BTI STRING found in DB" << endl;
00390
00391
00392 flagDBBti = true;
00393
00394
00395 int brd=buffer[3];
00396 int chip=buffer[4];
00397
00398 if (brd>7) {
00399 cout << "Not existing board ... " << brd << endl;
00400 return -1;
00401 }
00402 if (chip>31) {
00403 cout << "Not existing chip... " << chip << endl;
00404 return -1;
00405 }
00406
00407
00408 bool ThetaSL, PhiSL;
00409 PhiSL=false;
00410 ThetaSL=false;
00411 switch (mbtype) {
00412 case 1:
00413 if (brd==6 || brd==7) {
00414 ThetaSL=true;
00415 brd-=6;
00416 }
00417 else if ((brd<3 && chip<32) || (brd==3 && chip<8))
00418 PhiSL=true;
00419 break;
00420 case 2:
00421 if (brd==6 || brd==7) {
00422 ThetaSL=true;
00423 brd-=6;
00424 }
00425 else if (brd<4 && chip<32)
00426 PhiSL=true;
00427 break;
00428 case 3:
00429 if (brd==6 || brd==7) {
00430 ThetaSL=true;
00431 brd-=6;
00432 }
00433 else if (brd<5 && chip<32)
00434 PhiSL=true;
00435 break;
00436 case 4:
00437 if (brd<6 && chip<32)
00438 PhiSL=true;
00439 break;
00440 case 5:
00441 if (brd<3 && chip<32)
00442 PhiSL=true;
00443 break;
00444 case 6:
00445 if (brd<5 && chip<32)
00446 PhiSL=true;
00447 break;
00448 case 7:
00449 if (brd<4 && chip<32)
00450 PhiSL=true;
00451 break;
00452 }
00453 if (!PhiSL && !ThetaSL) {
00454 cout << "MB type " << mbtype << endl;
00455 cout << "Board " << brd << " chip " <<chip << endl;
00456 cout << "Not phi SL nor Theta SL" << endl;
00457 return -1;
00458 }
00459
00460
00461 int isl;
00462 int ibti;
00463 if (PhiSL) {
00464 if ((chip%8)<4)
00465 isl=1;
00466 else
00467 isl=3;
00468 ibti=brd*16+(int)(chip/8)*4+(chip%4);
00469 }
00470 else if (ThetaSL){
00471 isl=2;
00472 if ((chip%8)<4)
00473 ibti=brd*32+ chip-4*(int)(chip/8);
00474 else
00475 ibti=brd*32+ chip+12-4*(int)(chip/8);
00476 }
00477
00478
00479 DTConfigBti bticonf(m_debugBti,buffer);
00480
00481 dttpgConfig.setDTConfigBti(DTBtiId(chambid,isl,ibti+1),bticonf);
00482
00483 if(m_debugDB)
00484 cout << "Filling BTI config for chamber : wh " << chambid.wheel() <<
00485 ", st " << chambid.station() <<
00486 ", se " << chambid.sector() <<
00487 "... sl " << isl <<
00488 ", bti " << ibti+1 << endl;
00489 }
00490
00491
00492 if (buffer[2]==0x15){
00493 if(m_debugDB)
00494 cout << "TRACO STRING found in DB" << endl;
00495
00496 flagDBTraco = true;
00497
00498
00499 int traco_brd = buffer[3];
00500 int traco_chip = buffer[4];
00501 int itraco = traco_brd * 4 + traco_chip + 1;
00502 DTConfigTraco tracoconf(m_debugTraco,buffer);
00503 dttpgConfig.setDTConfigTraco(DTTracoId(chambid,itraco),tracoconf);
00504
00505 if(m_debugDB)
00506 cout << "Filling TRACO config for chamber : wh " << chambid.wheel() <<
00507 ", st " << chambid.station() <<
00508 ", se " << chambid.sector() <<
00509 ", board " << traco_brd <<
00510 ", chip " << traco_chip <<
00511 ", traco " << itraco << endl;
00512 }
00513
00514
00515
00516 if (buffer[2]==0x16){
00517 if(m_debugDB)
00518 cout << "TSS STRING found in DB" << endl;
00519
00520 flagDBTSS = true;
00521
00522 unsigned short int itss=buffer[3];
00523 for (int i=0;i<31;i++)
00524 tss_buffer[itss][i]=buffer[i];
00525 ntss++;
00526 }
00527
00528
00529 if (buffer[2]==0x17){
00530 if(m_debugDB)
00531 cout << "TSM STRING found in DB" << endl;
00532
00533
00534 flagDBTSM = true;
00535
00536 for (int i=0; i<9; i++)
00537 tsm_buffer[i]=buffer[i];
00538 }
00539
00540
00541 if (buffer[2]==0xA8){
00542 if(m_debugDB)
00543 cout << "LUT STRING found in DB" << endl;
00544
00545
00546 flagDBLUTS = true;
00547 DTConfigLUTs lutconf(m_debugLUTs,buffer);
00548
00549 dttpgConfig.setDTConfigLUTs(chambid,lutconf);
00550 }
00551
00552 }
00553 }
00554
00555
00556 if(flagDBTSM && flagDBTSS) {
00557 DTConfigTSPhi tsphiconf(m_debugTSP,tss_buffer,ntss,tsm_buffer);
00558 dttpgConfig.setDTConfigTSPhi(chambid,tsphiconf);
00559 }
00560
00561
00562 edm::ParameterSet conf_ps = m_ps.getParameter<edm::ParameterSet>("DTTPGParameters");
00563 edm::ParameterSet tups = conf_ps.getParameter<edm::ParameterSet>("TUParameters");
00564
00565
00566 DTConfigTSTheta tsthetaconf(tups.getParameter<edm::ParameterSet>("TSThetaParameters"));
00567 tsthetaconf.setDebug(m_debugTST);
00568 dttpgConfig.setDTConfigTSTheta(chambid,tsthetaconf);
00569
00570
00571 DTConfigSectColl sectcollconf(conf_ps.getParameter<edm::ParameterSet>("SectCollParameters"));
00572 sectcollconf.setDebug(m_debugSC);
00573 dttpgConfig.setDTConfigSectColl(DTSectCollId(chambid.wheel(),chambid.sector()),sectcollconf);
00574
00575
00576 DTConfigTrigUnit trigunitconf(tups);
00577 trigunitconf.setDebug(m_debugTU);
00578 dttpgConfig.setDTConfigTrigUnit(chambid,trigunitconf);
00579
00580 ++iter;
00581
00582
00583
00584
00585 if(!flagDBBti || !flagDBTraco || !flagDBTSS || !flagDBTSM ){
00586 return -1;
00587 }
00588 if(!flagDBLUTS && dttpgConfig.lutFromDB()==true){
00589 return -1;
00590 }
00591 }
00592
00593
00594 return 0;
00595 }
00596
00597 std::string DTConfigDBProducer::mapEntryName(const DTChamberId & chambid) const
00598 {
00599 int iwh = chambid.wheel();
00600 std::ostringstream os;
00601 os << "wh";
00602 if (iwh < 0) {
00603 os << 'm' << -iwh;
00604 } else {
00605 os << iwh;
00606 }
00607 os << "st" << chambid.station() << "se" << chambid.sector();
00608 return os.str();
00609 }
00610
00611
00612 void DTConfigDBProducer::configFromCfg(DTConfigManager & dttpgConfig){
00613
00614
00615 dttpgConfig.setCCBConfigValidity(true);
00616
00617
00618 edm::ParameterSet conf_ps = m_ps.getParameter<edm::ParameterSet>("DTTPGParameters");
00619 edm::ParameterSet conf_map = m_ps.getUntrackedParameter<edm::ParameterSet>("DTTPGMap");
00620 bool dttpgdebug = conf_ps.getUntrackedParameter<bool>("Debug");
00621 DTConfigSectColl sectcollconf(conf_ps.getParameter<edm::ParameterSet>("SectCollParameters"));
00622 edm::ParameterSet tups = conf_ps.getParameter<edm::ParameterSet>("TUParameters");
00623 DTConfigBti bticonf(tups.getParameter<edm::ParameterSet>("BtiParameters"));
00624 DTConfigTraco tracoconf(tups.getParameter<edm::ParameterSet>("TracoParameters"));
00625 DTConfigTSTheta tsthetaconf(tups.getParameter<edm::ParameterSet>("TSThetaParameters"));
00626 DTConfigTSPhi tsphiconf(tups.getParameter<edm::ParameterSet>("TSPhiParameters"));
00627 DTConfigTrigUnit trigunitconf(tups);
00628 DTConfigLUTs lutconf(tups.getParameter<edm::ParameterSet>("LutParameters"));
00629
00630
00631 for (int iwh=-2;iwh<=2;++iwh){
00632 for (int ist=1;ist<=4;++ist){
00633 for (int ise=1;ise<=12;++ise){
00634 DTChamberId chambid(iwh,ist,ise);
00635 vector<int> nmap = conf_map.getUntrackedParameter<vector<int> >(mapEntryName(chambid).c_str());
00636
00637 if(dttpgdebug)
00638 {
00639 cout << " Filling configuration for chamber : wh " << chambid.wheel() <<
00640 ", st " << chambid.station() <<
00641 ", se " << chambid.sector() << endl;
00642 }
00643
00644
00645 if(!flagDBBti){
00646 for (int isl=1;isl<=3;isl++){
00647 int ncell = nmap[isl-1];
00648
00649 for (int ibti=0;ibti<ncell;ibti++){
00650 dttpgConfig.setDTConfigBti(DTBtiId(chambid,isl,ibti+1),bticonf);
00651 if(dttpgdebug)
00652 cout << "Filling BTI config for chamber : wh " << chambid.wheel() <<
00653 ", st " << chambid.station() <<
00654 ", se " << chambid.sector() <<
00655 "... sl " << isl <<
00656 ", bti " << ibti+1 << endl;
00657 }
00658 }
00659 }
00660
00661
00662 if(!flagDBTraco){
00663 int ntraco = nmap[3];
00664
00665 for (int itraco=0;itraco<ntraco;itraco++){
00666 dttpgConfig.setDTConfigTraco(DTTracoId(chambid,itraco+1),tracoconf);
00667 if(dttpgdebug)
00668 cout << "Filling TRACO config for chamber : wh " << chambid.wheel() <<
00669 ", st " << chambid.station() <<
00670 ", se " << chambid.sector() <<
00671 ", traco " << itraco+1 << endl;
00672 }
00673 }
00674
00675
00676 if(!flagDBTSS || !flagDBTSM)
00677 {
00678 dttpgConfig.setDTConfigTSTheta(chambid,tsthetaconf);
00679 dttpgConfig.setDTConfigTSPhi(chambid,tsphiconf);
00680 dttpgConfig.setDTConfigTrigUnit(chambid,trigunitconf);
00681 }
00682
00683 }
00684 }
00685 }
00686
00687 for (int iwh=-2;iwh<=2;++iwh){
00688 for (int ise=13;ise<=14;++ise){
00689 int ist =4;
00690 DTChamberId chambid(iwh,ist,ise);
00691 vector<int> nmap = conf_map.getUntrackedParameter<vector<int> >(mapEntryName(chambid).c_str());
00692
00693 if(dttpgdebug)
00694 {
00695 cout << " Filling configuration for chamber : wh " << chambid.wheel() <<
00696 ", st " << chambid.station() <<
00697 ", se " << chambid.sector() << endl;
00698 }
00699
00700
00701 if(!flagDBBti){
00702 for (int isl=1;isl<=3;isl++){
00703 int ncell = nmap[isl-1];
00704
00705 for (int ibti=0;ibti<ncell;ibti++){
00706 dttpgConfig.setDTConfigBti(DTBtiId(chambid,isl,ibti+1),bticonf);
00707 if(dttpgdebug)
00708 cout << "Filling BTI config for chamber : wh " << chambid.wheel() <<
00709 ", st " << chambid.station() <<
00710 ", se " << chambid.sector() <<
00711 "... sl " << isl <<
00712 ", bti " << ibti+1 << endl;
00713 }
00714 }
00715 }
00716
00717
00718 if(!flagDBTraco){
00719 int ntraco = nmap[3];
00720
00721 for (int itraco=0;itraco<ntraco;itraco++){
00722 dttpgConfig.setDTConfigTraco(DTTracoId(chambid,itraco+1),tracoconf);
00723 if(dttpgdebug)
00724 cout << "Filling TRACO config for chamber : wh " << chambid.wheel() <<
00725 ", st " << chambid.station() <<
00726 ", se " << chambid.sector() <<
00727 ", traco " << itraco+1 << endl;
00728 }
00729 }
00730
00731
00732 if(!flagDBTSS || !flagDBTSM)
00733 {
00734 dttpgConfig.setDTConfigTSTheta(chambid,tsthetaconf);
00735 dttpgConfig.setDTConfigTSPhi(chambid,tsphiconf);
00736 dttpgConfig.setDTConfigTrigUnit(chambid,trigunitconf);
00737 }
00738 }
00739 }
00740
00741
00742 for (int wh=-2;wh<=2;wh++)
00743 for (int se=1;se<=12;se++)
00744 dttpgConfig.setDTConfigSectColl(DTSectCollId(wh,se),sectcollconf);
00745
00746
00747 dttpgConfig.setDTConfigPedestals(buildTrivialPedestals());
00748
00749 return;
00750
00751 }
00752
00753 DTConfigPedestals DTConfigDBProducer::buildTrivialPedestals()
00754 {
00755 DTTPGParameters* m_tpgParams = new DTTPGParameters();
00756
00757 int counts = m_ps.getParameter<int>("bxOffset");
00758 float fine = m_ps.getParameter<double>("finePhase");
00759
00760 if (m_debugPed)
00761 cout << "DTConfigTrivialProducer::buildPedestals()" << endl;
00762
00763
00764 for (int iwh=-2;iwh<=2;++iwh){
00765 for (int ist=1;ist<=4;++ist){
00766 for (int ise=1;ise<=14;++ise){
00767 if (ise>12 && ist!=4) continue;
00768
00769 DTChamberId chId(iwh,ist,ise);
00770 m_tpgParams->set(chId,counts,fine,DTTimeUnits::ns);
00771 }
00772 }
00773 }
00774
00775 DTConfigPedestals tpgPedestals;
00776 tpgPedestals.setUseT0(false);
00777 tpgPedestals.setES(m_tpgParams);
00778
00779 return tpgPedestals;
00780
00781 }
00782
00783