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