CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/L1TriggerConfig/DTTPGConfigProducers/src/DTConfigDBProducer.cc

Go to the documentation of this file.
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 // constructors and destructor
00033 //
00034 
00035 DTConfigDBProducer::DTConfigDBProducer(const edm::ParameterSet& p)
00036 {
00037   // tell the framework what record is being produced
00038   setWhatProduced(this,&DTConfigDBProducer::produce);
00039 
00040   cfgConfig = p.getParameter<bool>("cfgConfig");
00041     
00042   // get and store parameter set and config manager pointer
00043   m_ps = p;
00044   m_manager = new DTConfigManager();
00045   
00046   // debug flags
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");  // CB check for a better way to do it
00058 
00059   // DB specific requests
00060   bool tracoLutsFromDB   = p.getParameter<bool>("TracoLutsFromDB");
00061   bool useBtiAcceptParam = p.getParameter<bool>("UseBtiAcceptParam");
00062 
00063   // set specific DB requests
00064   m_manager->setLutFromDB(tracoLutsFromDB);
00065   m_manager->setUseAcceptParam(useBtiAcceptParam);
00066 
00067   // initialize flags to check if data are present in OMDS 
00068   flagDBBti     = false;
00069   flagDBTraco   = false;
00070   flagDBTSS     = false;
00071   flagDBTSM     = false;
00072   flagDBLUTS    = false;
00073 
00074   // set debug
00075   edm::ParameterSet conf_ps = m_ps.getParameter<edm::ParameterSet>("DTTPGParameters");  
00076   bool dttpgdebug = conf_ps.getUntrackedParameter<bool>("Debug");
00077   m_manager->setDTTPGDebug(dttpgdebug);
00078 }
00079 
00080 
00081 DTConfigDBProducer::~DTConfigDBProducer()
00082 {
00083 
00084 }
00085 
00086 
00087 //
00088 // member functions
00089 //
00090 
00091 std::auto_ptr<DTConfigManager> DTConfigDBProducer::produce(const DTConfigManagerRcd& iRecord)
00092 {
00093    using namespace edm;
00094 
00095    int code; 
00096    if(cfgConfig){
00097      m_manager->setLutFromDB(false);
00098      configFromCfg();
00099      buildTrivialPedestals();
00100      code = 2;
00101    }  else{
00102      code = readDTCCBConfig(iRecord);
00103      readDBPedestalsConfig(iRecord); // no return code if fails exception is raised by ESHandle getter
00104    }
00105    if(code==-1) {
00106      //throw cms::Exception("DTTPG") << "DTConfigDBProducer::produce : " << endl
00107      //                            << "generic error pharsing DT CCB config strings." << endl
00108      //                              << "Run module with debug flags enable to get more info" << endl;
00109      m_manager->setCCBConfigValidity(false);
00110    } else if(code==2) {
00111      LogVerbatim ("DTTPG") << "DTConfigDBProducer::produce : Trivial : " << endl
00112                            << "configurations has been read from cfg" << endl; 
00113    } else if(code==0) {
00114      LogVerbatim ("DTTPG") << "DTConfigDBProducer::produce : " << endl 
00115                            << "Configurations successfully read from OMDS" << endl; 
00116    } else {
00117      LogProblem ("DTTPG") << "DTConfigDBProducer::produce : " << endl
00118                           << "Wrong congiguration rertun CODE" << endl;
00119    }
00120 
00121    std::auto_ptr<DTConfigManager> dtConfig = std::auto_ptr<DTConfigManager>( m_manager );
00122 
00123    return dtConfig ;
00124 }
00125 
00126 void DTConfigDBProducer::readDBPedestalsConfig(const DTConfigManagerRcd& iRecord){
00127 
00128   edm::ESHandle<DTTPGParameters> dttpgParams;
00129   iRecord.getRecord<DTTPGParametersRcd>().get(dttpgParams);
00130 
00131   DTConfigPedestals pedestals;
00132   pedestals.setDebug(m_debugPed);
00133 
00134   if (m_UseT0) {
00135 
00136     edm::ESHandle<DTT0> t0i;
00137     iRecord.getRecord<DTT0Rcd>().get(t0i);
00138  
00139     pedestals.setUseT0(true);
00140     pedestals.setES(dttpgParams.product(),t0i.product());
00141 
00142   } else {
00143 
00144     pedestals.setUseT0(false);
00145     pedestals.setES(dttpgParams.product());
00146 
00147   }
00148 
00149   m_manager->setDTConfigPedestals(pedestals);
00150 
00151 }
00152 
00153 int DTConfigDBProducer::readDTCCBConfig(const DTConfigManagerRcd& iRecord)
00154 {
00155   using namespace edm::eventsetup;
00156 
00157   // initialize CCB validity flag
00158   m_manager->setCCBConfigValidity(true);
00159 
00160   // get DTCCBConfigRcd from DTConfigManagerRcd (they are dependent records)
00161   edm::ESHandle<DTCCBConfig> ccb_conf;
00162   iRecord.getRecord<DTCCBConfigRcd>().get(ccb_conf);
00163   int ndata = std::distance( ccb_conf->begin(), ccb_conf->end() );
00164 
00165   DTConfigAbstractHandler* cfgCache = DTConfigAbstractHandler::getInstance();
00166   const DTKeyedConfigListRcd& keyRecord = iRecord.getRecord<DTKeyedConfigListRcd>();
00167 
00168   if(m_debugDB)
00169   {
00170         cout << ccb_conf->version() << endl;
00171         cout << ndata << " data in the container" << endl;
00172   }
00173 
00174   edm::ValidityInterval iov(iRecord.getRecord<DTCCBConfigRcd>().validityInterval() );
00175   unsigned int currValidityStart = iov.first().eventID().run();
00176   unsigned int currValidityEnd   = iov.last( ).eventID().run();
00177 
00178   if(m_debugDB)
00179         cout    << "valid since run " << currValidityStart
00180                 << " to run "         << currValidityEnd << endl;  
00181             
00182   // if there are no data in the container, configuration from cfg files...         
00183   if( ndata==0 ){
00184     //throw cms::Exception("DTTPG") << "DTConfigDBProducer::readDTCCBConfig : " << endl 
00185     //                            << "DTCCBConfigRcd is empty!" << endl;
00186     m_manager->setCCBConfigValidity(false);
00187   }
00188 
00189   // get DTTPGMap for retrieving bti number and traco number
00190   edm::ParameterSet conf_map = m_ps.getUntrackedParameter<edm::ParameterSet>("DTTPGMap");
00191 
00192   // loop over chambers
00193   DTCCBConfig::ccb_config_map configKeys( ccb_conf->configKeyMap() );
00194   DTCCBConfig::ccb_config_iterator iter = configKeys.begin();
00195   DTCCBConfig::ccb_config_iterator iend = configKeys.end();
00196 
00197   // read data from CCBConfig
00198   while ( iter != iend ) {
00199     // get chamber id
00200         const DTCCBId& ccbId = iter->first;
00201         if(m_debugDB)
00202                 cout << " Filling configuration for chamber : wh " << ccbId.wheelId   << " st "
00203                         << ccbId.stationId << " se "
00204                         << ccbId.sectorId  << " -> " << endl;
00205 
00206         // get chamber type and id from ccbId
00207         int mbtype = DTPosNegType::getCT( ccbId.wheelId, ccbId.sectorId, ccbId.stationId );
00208         int posneg = DTPosNegType::getPN( ccbId.wheelId, ccbId.sectorId, ccbId.stationId );
00209         if(m_debugDB)
00210                 cout << "Chamber type : " <<  mbtype
00211                         << " posneg : " << posneg << endl; 
00212         DTChamberId chambid(ccbId.wheelId, ccbId.stationId, ccbId.sectorId);
00213                         
00214         // get brick identifiers list
00215         const std::vector<int>& ccbConf = iter->second;
00216         std::vector<int>::const_iterator cfgIter = ccbConf.begin();
00217         std::vector<int>::const_iterator cfgIend = ccbConf.end();
00218 
00219         //TSS-TSM buffers
00220         unsigned short int tss_buffer[7][31];
00221         unsigned short int tsm_buffer[9];
00222         int ntss=0;
00223 
00224         // loop over configuration bricks
00225         while ( cfgIter != cfgIend ) {
00226                 // get brick identifier
00227                 int id = *cfgIter++;
00228                 if(m_debugDB)
00229                         cout << " BRICK " << id << endl;  
00230 
00231                 // create strings list
00232                 std::vector<std::string> list;
00233                 cfgCache->getData( keyRecord, id, list );
00234 
00235                 // loop over strings
00236                 std::vector<std::string>::const_iterator s_iter = list.begin();
00237                 std::vector<std::string>::const_iterator s_iend = list.end();
00238                 while ( s_iter != s_iend ) {
00239                         if(m_debugDB)
00240                                 cout << "        ----> " << *s_iter << endl;
00241                                 
00242                         // copy string in unsigned int buffer
00243                         std::string str = *s_iter++;
00244                         unsigned short int buffer[100];         //2 bytes
00245                         int c = 0;
00246                         const char* cstr = str.c_str();
00247                         const char* ptr = cstr + 2;
00248                         const char* end = cstr + str.length();
00249                         while ( ptr < end ) {
00250                                 char c1 = *ptr++;
00251                                 int i1 = 0;
00252                                 if ( ( c1 >= '0' ) && ( c1 <= '9' ) ) i1 =      c1 - '0';
00253                                 if ( ( c1 >= 'a' ) && ( c1 <= 'f' ) ) i1 = 10 + c1 - 'a';
00254                                 if ( ( c1 >= 'A' ) && ( c1 <= 'F' ) ) i1 = 10 + c1 - 'A';
00255                                 char c2 = *ptr++;
00256                                 int i2 = 0;
00257                                 if ( ( c2 >= '0' ) && ( c2 <= '9' ) ) i2 =      c2 - '0';
00258                                 if ( ( c2 >= 'a' ) && ( c2 <= 'f' ) ) i2 = 10 + c2 - 'a';
00259                                 if ( ( c2 >= 'A' ) && ( c2 <= 'F' ) ) i2 = 10 + c2 - 'A';
00260                                 buffer[c] = ( i1 * 16 ) + i2;
00261                                 c++;
00262                         }// end loop over string
00263 
00264                         // BTI configuration string     
00265                         if (buffer[2]==0x54){
00266                                 if(m_debugDB)
00267                                         cout << "BTI STRING found in DB" << endl;
00268 
00269                                 // BTI configuration read for BTI
00270                                 flagDBBti = true;
00271                                 
00272                                 // compute sl and bti number from board and chip
00273                                 int brd=buffer[3]; // Board Nr.
00274                                 int chip=buffer[4]; // Chip Nr.
00275 
00276                                 if (brd>7) {
00277                                         cout << "Not existing board ... " << brd << endl;
00278                                         return -1; // Non-existing board
00279                                 }       
00280                                 if (chip>31) {
00281                                         cout << "Not existing chip... " << chip << endl;
00282                                         return -1; // Non existing chip 
00283                                 }
00284                                 
00285                                 // Is it Phi or Theta board?
00286                                 bool ThetaSL, PhiSL;
00287                                 PhiSL=false;
00288                                 ThetaSL=false;
00289                                 switch (mbtype) {
00290                                         case 1: // mb1
00291                                                 if (brd==6 || brd==7) {
00292                                                         ThetaSL=true; 
00293                                                         brd-=6;
00294                                                 }
00295                                                 else if ((brd<3 && chip<32) || (brd==3 && chip<8)) 
00296                                                         PhiSL=true;
00297                                                 break;
00298                                         case 2: // mb2
00299                                                 if (brd==6 || brd==7) {
00300                                                         ThetaSL=true; 
00301                                                         brd-=6;
00302                                                 }
00303                                                 else if (brd<4 && chip<32) 
00304                                                         PhiSL=true;
00305                                                 break;
00306                                         case 3: // mb3
00307                                                 if (brd==6 || brd==7) {
00308                                                         ThetaSL=true; 
00309                                                         brd-=6;
00310                                                 }
00311                                                 else if (brd<5 && chip<32) 
00312                                                         PhiSL=true;
00313                                                 break;
00314                                         case 4: // mb4-s, mb4_8
00315                                                 if (brd<6 && chip<32) 
00316                                                         PhiSL=true;
00317                                                 break;
00318                                         case 5: // mb4-9
00319                                                 if (brd<3 && chip<32) 
00320                                                         PhiSL=true;
00321                                                 break;
00322                                         case 6: // mb4-4
00323                                                 if (brd<5 && chip<32) 
00324                                                         PhiSL=true;
00325                                                 break;
00326                                         case 7: // mb4-10
00327                                                 if (brd<4 && chip<32) 
00328                                                         PhiSL=true;
00329                                                 break;
00330                                 }
00331                                 if (!PhiSL && !ThetaSL) {
00332                                         cout << "MB type " << mbtype << endl; 
00333                                         cout << "Board " << brd << " chip " <<chip << endl;
00334                                         cout << "Not phi SL nor Theta SL" << endl; 
00335                                         return -1; // Not PhiSL nor ThetaSL 
00336                                 }        
00337                                         
00338                                 // compute SL number and bti number
00339                                 int isl;
00340                                 int ibti;
00341                                 if (PhiSL) {
00342                                         if ((chip%8)<4) 
00343                                                 isl=1;  // Phi1 
00344                                         else 
00345                                                 isl=3;  // Phi2 
00346                                         ibti=brd*16+(int)(chip/8)*4+(chip%4); 
00347                                 }
00348                                 else if (ThetaSL){
00349                                         isl=2;          // Theta 
00350                                         if ((chip%8)<4)
00351                                                 ibti=brd*32+ chip-4*(int)(chip/8);
00352                                         else
00353                                                 ibti=brd*32+ chip+12-4*(int)(chip/8);
00354                                 }                
00355                         
00356                                 // BTI config constructor from strings  
00357                                 DTConfigBti bticonf(m_debugBti,buffer);
00358                                  
00359                                 m_manager->setDTConfigBti(DTBtiId(chambid,isl,ibti+1),bticonf);
00360                                 
00361                                 if(m_debugDB)
00362                                         cout <<         "Filling BTI config for chamber : wh " << chambid.wheel() << 
00363                                                         ", st " << chambid.station() << 
00364                                                         ", se " << chambid.sector() << 
00365                                                         "... sl " << isl << 
00366                                                         ", bti " << ibti+1 << endl;                             
00367                         }
00368                                 
00369                         // TRACO configuration string                   
00370                         if (buffer[2]==0x15){
00371                                 if(m_debugDB)
00372                                         cout << "TRACO STRING found in DB" << endl;
00373                                 // TRACO configuration read from OMDS
00374                                 flagDBTraco = true;
00375                                 
00376                                 // TRACO config constructor from strings        
00377                                 int traco_brd = buffer[3];      // Board Nr.;
00378                                 int traco_chip = buffer[4];     // Chip Nr.;
00379                                 int itraco = traco_brd * 4 + traco_chip + 1;
00380                                 DTConfigTraco tracoconf(m_debugTraco,buffer);
00381                                 m_manager->setDTConfigTraco(DTTracoId(chambid,itraco),tracoconf);
00382                                 
00383                                 if(m_debugDB)
00384                                         cout <<         "Filling TRACO config for chamber : wh " << chambid.wheel() <<
00385                                                         ", st " << chambid.station() <<
00386                                                         ", se " << chambid.sector() <<
00387                                                         ", board " << traco_brd <<
00388                                                         ", chip " << traco_chip <<
00389                                                         ", traco " << itraco << endl;   
00390                         }
00391                         
00392                         
00393                         // TSS configuration string     
00394                         if (buffer[2]==0x16){
00395                                 if(m_debugDB)
00396                                         cout << "TSS STRING found in DB" << endl;
00397                                 // TSS configuration read from OMDS
00398                                 flagDBTSS = true;
00399                                 
00400                                 unsigned short int itss=buffer[3];
00401                                 for (int i=0;i<31;i++) 
00402                                         tss_buffer[itss][i]=buffer[i];
00403                                 ntss++;
00404                         }
00405                         
00406                         // TSM configuration string
00407                         if (buffer[2]==0x17){
00408                                 if(m_debugDB)
00409                                         cout << "TSM STRING found in DB" << endl;
00410                          
00411                                 // TSM configuration read from OMDS
00412                                 flagDBTSM = true;                        
00413                          
00414                                 for (int i=0; i<9; i++) 
00415                                         tsm_buffer[i]=buffer[i];
00416                         } 
00417                         
00418                         // LUT configuration string
00419                         if (buffer[2]==0xA8){
00420                                 if(m_debugDB)
00421                                         cout << "LUT STRING found in DB" << endl;
00422 
00423                                 // LUT parameters read from OMDS
00424                                 flagDBLUTS = true;
00425                                 DTConfigLUTs lutconf(m_debugLUTs,buffer);
00426                                 //lutconf.setDebug(m_debugLUTs);
00427                                 m_manager->setDTConfigLUTs(chambid,lutconf);
00428                         }
00429                         
00430                 }//end string iteration                                 
00431         }//end brick iteration
00432         
00433         //TSS + TSM configurations are set in DTConfigTSPhi constructor
00434         if(flagDBTSM && flagDBTSS) {
00435           DTConfigTSPhi tsphiconf(m_debugTSP,tss_buffer,ntss,tsm_buffer);
00436           m_manager->setDTConfigTSPhi(chambid,tsphiconf);
00437         }
00438 
00439         // get configuration for TSTheta, SC and TU from .cfg
00440         edm::ParameterSet conf_ps = m_ps.getParameter<edm::ParameterSet>("DTTPGParameters");  
00441         edm::ParameterSet tups = conf_ps.getParameter<edm::ParameterSet>("TUParameters");
00442 
00443         // TSTheta configuration from .cfg
00444         DTConfigTSTheta tsthetaconf(tups.getParameter<edm::ParameterSet>("TSThetaParameters"));
00445         tsthetaconf.setDebug(m_debugTST);
00446         m_manager->setDTConfigTSTheta(chambid,tsthetaconf);
00447 
00448         // SC configuration from .cfg
00449         DTConfigSectColl sectcollconf(conf_ps.getParameter<edm::ParameterSet>("SectCollParameters"));
00450         sectcollconf.setDebug(m_debugSC);
00451         m_manager->setDTConfigSectColl(DTSectCollId(chambid.wheel(),chambid.sector()),sectcollconf);
00452 
00453         // TU configuration from .cfg
00454         DTConfigTrigUnit trigunitconf(tups);
00455         trigunitconf.setDebug(m_debugTU);
00456         m_manager->setDTConfigTrigUnit(chambid,trigunitconf);
00457        
00458         ++iter;
00459   }
00460 
00461   // moved to exception handling no attempt to configure from cfg is DB is missing
00462   // SV comment exception handling and activate flag in DTConfigManager
00463   if(!flagDBBti || !flagDBTraco || !flagDBTSS || !flagDBTSM ){
00464     //throw cms::Exception("DTTPG") << "DTConfigDBProducer::readDTCCBConfig :"  << endl
00465     //                            << "(at least) part of the CCB strings needed to configure"  << endl
00466     //                            << "DTTPG emulator were not found in DTCCBConfigRcd" << endl;
00467     m_manager->setCCBConfigValidity(false);
00468     
00469   }
00470   if(!flagDBLUTS && m_manager->lutFromDB()==true){
00471     //throw cms::Exception("DTTPG") << "DTConfigDBProducer::readDTCCBConfig : " << endl
00472     //                            << "Asked to configure the emulator using Lut seeds from DB "
00473     //                            << "but no configuration parameters found in DTCCBConfigRcd." << endl;
00474     m_manager->setCCBConfigValidity(false);
00475   } 
00476   
00477   return 0;
00478 }
00479 
00480 std::string DTConfigDBProducer::mapEntryName(const DTChamberId & chambid) const
00481 {
00482   int iwh = chambid.wheel();
00483   std::ostringstream os;
00484   os << "wh";
00485   if (iwh < 0) {
00486      os << 'm' << -iwh;
00487    } else {
00488      os << iwh;
00489   }
00490   os << "st" << chambid.station() << "se" << chambid.sector();
00491   return os.str();
00492 }
00493 
00494 
00495 void DTConfigDBProducer::configFromCfg(){
00496 
00497   // ... but still set CCB validity flag to let the emulator run
00498   m_manager->setCCBConfigValidity(true);
00499 
00500   //create config classes&C.
00501   edm::ParameterSet conf_ps = m_ps.getParameter<edm::ParameterSet>("DTTPGParameters");
00502   edm::ParameterSet conf_map = m_ps.getUntrackedParameter<edm::ParameterSet>("DTTPGMap");
00503   bool dttpgdebug = conf_ps.getUntrackedParameter<bool>("Debug");
00504   DTConfigSectColl sectcollconf(conf_ps.getParameter<edm::ParameterSet>("SectCollParameters"));
00505   edm::ParameterSet tups = conf_ps.getParameter<edm::ParameterSet>("TUParameters");
00506   DTConfigBti bticonf(tups.getParameter<edm::ParameterSet>("BtiParameters"));
00507   DTConfigTraco tracoconf(tups.getParameter<edm::ParameterSet>("TracoParameters"));
00508   DTConfigTSTheta tsthetaconf(tups.getParameter<edm::ParameterSet>("TSThetaParameters"));
00509   DTConfigTSPhi tsphiconf(tups.getParameter<edm::ParameterSet>("TSPhiParameters"));
00510   DTConfigTrigUnit trigunitconf(tups);
00511   DTConfigLUTs lutconf(tups.getParameter<edm::ParameterSet>("LutParameters"));
00512  
00513  
00514   for (int iwh=-2;iwh<=2;++iwh){
00515     for (int ist=1;ist<=4;++ist){
00516       for (int ise=1;ise<=12;++ise){
00517         DTChamberId chambid(iwh,ist,ise);
00518         vector<int> nmap = conf_map.getUntrackedParameter<vector<int> >(mapEntryName(chambid).c_str());
00519 
00520         if(dttpgdebug)
00521           {
00522             cout << " Filling configuration for chamber : wh " << chambid.wheel() << 
00523               ", st " << chambid.station() << 
00524               ", se " << chambid.sector() << endl;
00525           }
00526         
00527         //fill the bti map
00528         if(!flagDBBti){
00529                 for (int isl=1;isl<=3;isl++){
00530                         int ncell = nmap[isl-1];
00531                         //        cout << ncell <<" , ";
00532                         for (int ibti=0;ibti<ncell;ibti++){
00533                                 m_manager->setDTConfigBti(DTBtiId(chambid,isl,ibti+1),bticonf);
00534                                 if(dttpgdebug)
00535                                         cout << "Filling BTI config for chamber : wh " << chambid.wheel() << 
00536                                                 ", st " << chambid.station() << 
00537                                                 ", se " << chambid.sector() << 
00538                                                 "... sl " << isl << 
00539                                                 ", bti " << ibti+1 << endl;
00540                         }     
00541                 }
00542         }               
00543         
00544         // fill the traco map
00545         if(!flagDBTraco){
00546                 int ntraco = nmap[3];
00547                 //cout << ntraco << " }" << endl;
00548                 for (int itraco=0;itraco<ntraco;itraco++){ 
00549                         m_manager->setDTConfigTraco(DTTracoId(chambid,itraco+1),tracoconf);
00550                         if(dttpgdebug)
00551                                 cout << "Filling TRACO config for chamber : wh " << chambid.wheel() << 
00552                                         ", st " << chambid.station() << 
00553                                         ", se " << chambid.sector() << 
00554                                         ", traco " << itraco+1 << endl;
00555                 }     
00556         }
00557         
00558         // fill TS & TrigUnit
00559         if(!flagDBTSS || !flagDBTSM)
00560         {       
00561                 m_manager->setDTConfigTSTheta(chambid,tsthetaconf);
00562                 m_manager->setDTConfigTSPhi(chambid,tsphiconf);
00563                 m_manager->setDTConfigTrigUnit(chambid,trigunitconf);
00564         }
00565 
00566       }
00567     }
00568   }
00569 
00570   for (int iwh=-2;iwh<=2;++iwh){
00571     for (int ise=13;ise<=14;++ise){
00572       int ist =4;
00573       DTChamberId chambid(iwh,ist,ise);
00574       vector<int> nmap = conf_map.getUntrackedParameter<vector<int> >(mapEntryName(chambid).c_str());
00575 
00576       if(dttpgdebug)
00577         {
00578           cout << " Filling configuration for chamber : wh " << chambid.wheel() << 
00579             ", st " << chambid.station() << 
00580             ", se " << chambid.sector() << endl;
00581         }
00582       
00583       //fill the bti map
00584       if(!flagDBBti){
00585                 for (int isl=1;isl<=3;isl++){
00586                         int ncell = nmap[isl-1];
00587                         //      cout << ncell <<" , ";
00588                         for (int ibti=0;ibti<ncell;ibti++){
00589                                 m_manager->setDTConfigBti(DTBtiId(chambid,isl,ibti+1),bticonf);
00590                                 if(dttpgdebug)
00591                                         cout << "Filling BTI config for chamber : wh " << chambid.wheel() << 
00592                                                 ", st " << chambid.station() << 
00593                                                 ", se " << chambid.sector() << 
00594                                                 "... sl " << isl << 
00595                                                 ", bti " << ibti+1 << endl;
00596                         }     
00597                 }
00598       } 
00599       
00600       // fill the traco map
00601       if(!flagDBTraco){
00602                 int ntraco = nmap[3];   
00603                 //       cout << ntraco << " }" << endl;
00604                 for (int itraco=0;itraco<ntraco;itraco++){ 
00605                         m_manager->setDTConfigTraco(DTTracoId(chambid,itraco+1),tracoconf);
00606                         if(dttpgdebug)
00607                                 cout << "Filling TRACO config for chamber : wh " << chambid.wheel() << 
00608                                 ", st " << chambid.station() << 
00609                                 ", se " << chambid.sector() << 
00610                                 ", traco " << itraco+1 << endl;
00611                 }     
00612       }
00613       
00614       // fill TS & TrigUnit
00615       if(!flagDBTSS || !flagDBTSM)
00616       {
00617                 m_manager->setDTConfigTSTheta(chambid,tsthetaconf);
00618                 m_manager->setDTConfigTSPhi(chambid,tsphiconf);
00619                 m_manager->setDTConfigTrigUnit(chambid,trigunitconf);
00620       }
00621     }
00622   }
00623   
00624   //loop on Sector Collectors
00625   for (int wh=-2;wh<=2;wh++)
00626     for (int se=1;se<=12;se++)
00627       m_manager->setDTConfigSectColl(DTSectCollId(wh,se),sectcollconf);
00628       
00629   //fake collection of pedestals
00630   m_manager->setDTConfigPedestals(buildTrivialPedestals());
00631 
00632   return;          
00633 
00634 }
00635 
00636 DTConfigPedestals DTConfigDBProducer::buildTrivialPedestals()
00637 {
00638   DTTPGParameters* m_tpgParams = new DTTPGParameters();
00639 
00640   int counts = m_ps.getParameter<int>("bxOffset");
00641   float fine = m_ps.getParameter<double>("finePhase");
00642    
00643   if (m_debugPed) 
00644     cout << "DTConfigTrivialProducer::buildPedestals()" << endl;
00645 
00646   //DTTPGParameters tpgParams;
00647   for (int iwh=-2;iwh<=2;++iwh){
00648     for (int ist=1;ist<=4;++ist){
00649       for (int ise=1;ise<=14;++ise){
00650         if (ise>12 && ist!=4) continue;
00651 
00652         DTChamberId chId(iwh,ist,ise);
00653         m_tpgParams->set(chId,counts,fine,DTTimeUnits::ns);
00654       }
00655     }
00656   }
00657 
00658   DTConfigPedestals tpgPedestals;
00659   tpgPedestals.setUseT0(false);
00660   tpgPedestals.setES(m_tpgParams);
00661  
00662   return tpgPedestals;
00663 
00664 }
00665 
00666