CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

DTConfigDBProducer Class Reference

#include <L1TriggerConfig/DTTPGConfigProducers/interface/DTConfigDBProducer.h>

Inheritance diagram for DTConfigDBProducer:
edm::ESProducer edm::ESProxyFactoryProducer edm::eventsetup::DataProxyProvider

List of all members.

Public Member Functions

 DTConfigDBProducer (const edm::ParameterSet &)
 Constructor.
std::auto_ptr< DTConfigManagerproduce (const DTConfigManagerRcd &)
 ES produce method.
 ~DTConfigDBProducer ()
 Destructor.

Private Member Functions

DTConfigPedestals buildTrivialPedestals ()
 Build Config Pedestals : 110204 SV for debugging purpose ONLY.
int checkDTCCBConfig ()
 110629 SV function for CCB configuration check
void configFromCfg ()
 CB ??? 110204 SV for debugging purpose ONLY.
std::string mapEntryName (const DTChamberId &chambid) const
void readDBPedestalsConfig (const DTConfigManagerRcd &iRecord)
 Read DTTPG pedestal configuration.
int readDTCCBConfig (const DTConfigManagerRcd &iRecord)
 Read CCB string configuration.

Private Attributes

bool cfgConfig
bool flagDBBti
bool flagDBLUTS
bool flagDBTraco
bool flagDBTSM
bool flagDBTSS
int m_debugBti
bool m_debugDB
bool m_debugLUTs
bool m_debugPed
bool m_debugSC
int m_debugTraco
bool m_debugTSP
bool m_debugTST
bool m_debugTU
DTConfigManagerm_manager
edm::ParameterSet m_ps
bool m_UseT0

Detailed Description

Description: A Producer for the DT config, data retrieved from DB

Implementation: <Notes on="" implementation>="">

Definition at line 45 of file DTConfigDBProducer.h.


Constructor & Destructor Documentation

DTConfigDBProducer::DTConfigDBProducer ( const edm::ParameterSet p)

Constructor.

Definition at line 35 of file DTConfigDBProducer.cc.

References cfgConfig, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), m_debugBti, m_debugDB, m_debugLUTs, m_debugPed, m_debugSC, m_debugTraco, m_debugTSP, m_debugTST, m_debugTU, m_manager, m_ps, m_UseT0, AlCaHLTBitMon_ParallelJobs::p, produce(), DTConfigManager::setDTTPGDebug(), DTConfigManager::setLutFromDB(), DTConfigManager::setUseAcceptParam(), and edm::ESProducer::setWhatProduced().

{
  // tell the framework what record is being produced
  setWhatProduced(this,&DTConfigDBProducer::produce);

  cfgConfig = p.getParameter<bool>("cfgConfig");
    
  // get and store parameter set and config manager pointer
  m_ps = p;
  m_manager = new DTConfigManager();
  
  // debug flags
  m_debugDB    = p.getParameter<bool>("debugDB"); 
  m_debugBti   = p.getParameter<int>("debugBti");
  m_debugTraco = p.getParameter<int>("debugTraco");
  m_debugTSP   = p.getParameter<bool>("debugTSP");
  m_debugTST   = p.getParameter<bool>("debugTST");
  m_debugTU    = p.getParameter<bool>("debugTU");
  m_debugSC    = p.getParameter<bool>("debugSC");
  m_debugLUTs  = p.getParameter<bool>("debugLUTs");
  m_debugPed   = p.getParameter<bool>("debugPed");

  m_UseT0 = p.getParameter<bool>("UseT0");  // CB check for a better way to do it

  // DB specific requests
  bool tracoLutsFromDB   = p.getParameter<bool>("TracoLutsFromDB");
  bool useBtiAcceptParam = p.getParameter<bool>("UseBtiAcceptParam");

  // set specific DB requests
  m_manager->setLutFromDB(tracoLutsFromDB);
  m_manager->setUseAcceptParam(useBtiAcceptParam);

  // set debug
  edm::ParameterSet conf_ps = m_ps.getParameter<edm::ParameterSet>("DTTPGParameters");  
  bool dttpgdebug = conf_ps.getUntrackedParameter<bool>("Debug");
  m_manager->setDTTPGDebug(dttpgdebug);
}
DTConfigDBProducer::~DTConfigDBProducer ( )

Destructor.

Definition at line 74 of file DTConfigDBProducer.cc.

{

}

Member Function Documentation

DTConfigPedestals DTConfigDBProducer::buildTrivialPedestals ( ) [private]

Build Config Pedestals : 110204 SV for debugging purpose ONLY.

Definition at line 765 of file DTConfigDBProducer.cc.

References gather_cfg::cout, edm::ParameterSet::getParameter(), m_debugPed, m_ps, DTTimeUnits::ns, DTTPGParameters::set(), DTConfigPedestals::setES(), and DTConfigPedestals::setUseT0().

Referenced by configFromCfg(), and produce().

{
  DTTPGParameters* m_tpgParams = new DTTPGParameters();

  int counts = m_ps.getParameter<int>("bxOffset");
  float fine = m_ps.getParameter<double>("finePhase");
   
  if (m_debugPed) 
    cout << "DTConfigTrivialProducer::buildPedestals()" << endl;

  //DTTPGParameters tpgParams;
  for (int iwh=-2;iwh<=2;++iwh){
    for (int ist=1;ist<=4;++ist){
      for (int ise=1;ise<=14;++ise){
        if (ise>12 && ist!=4) continue;

        DTChamberId chId(iwh,ist,ise);
        m_tpgParams->set(chId,counts,fine,DTTimeUnits::ns);
      }
    }
  }

  DTConfigPedestals tpgPedestals;
  tpgPedestals.setUseT0(false);
  tpgPedestals.setES(m_tpgParams);
 
  return tpgPedestals;

}
int DTConfigDBProducer::checkDTCCBConfig ( ) [private]

110629 SV function for CCB configuration check

Definition at line 151 of file DTConfigDBProducer.cc.

References DTConfigManager::getDTConfigBtiMap(), DTConfigManager::getDTConfigTracoMap(), DTConfigManager::getDTConfigTSPhi(), m_manager, DTConfigTSPhi::nValidTSM(), and DTConfigTSPhi::nValidTSS().

Referenced by produce().

{
  // 110627 SV test if configuration from CCB has correct number of chips,
  // return error code: 
  // check_cfg_code = 1 : NO correct BTI number
  // check_cfg_code = 2 : NO correct TRACO number
  // check_cfg_code = 3 : NO correct valid TSS number
  // check_cfg_code = 4 : NO correct valid TSM number

  int check_cfg_code = 0; 

  // do not take chambers from MuonGeometryRecord to avoid geometry dependency
  for(int iwh=-2;iwh<=2;iwh++){
    for(int ise=1;ise<=12;ise++){
      for(int ist=1;ist<=4;ist++){

        check_cfg_code = 0; 
        DTChamberId chid(iwh,ist,ise);

        //retrive number of configurated chip
        int nbti      = m_manager->getDTConfigBtiMap(chid).size();
        int ntraco    = m_manager->getDTConfigTracoMap(chid).size();
        int ntss      = m_manager->getDTConfigTSPhi(chid)->nValidTSS();
        int ntsm      = m_manager->getDTConfigTSPhi(chid)->nValidTSM();

        //check BTIs 
        if((ist==1 && nbti!=168) || 
           (ist==2 && nbti!=192) || 
           (ist==3 && nbti!=224) || 
           (ist==4 && (ise==1||ise==2||ise==3||ise==5||ise==6||ise==7||ise==8||ise==12) && nbti!=192) ||
           (ist==4 && (ise==9||ise==11) && nbti!=96) ||
           (ist==4 && ise==10 && nbti!=128) || 
           (ist==4 && ise==4 && nbti!=160)){  
          check_cfg_code = 1;
          return check_cfg_code;
        }

        //check TRACOs
        if((ist==1 && ntraco!=13) || 
           (ist==2 && ntraco!=16) || 
           (ist==3 && ntraco!=20) || 
           (ist==4 && (ise==1||ise==2||ise==3||ise==5||ise==6||ise==7||ise==8||ise==12) && ntraco!=24) ||
           (ist==4 && (ise==9||ise==11) && ntraco!=12) ||
           (ist==4 && ise==10 && ntraco!=16) || 
           (ist==4 && ise==4 && ntraco!=20)){  
           check_cfg_code = 2;
           return check_cfg_code;
        }

        //check TSS
        if((ist==1 && ntss!=4) || 
           (ist==2 && ntss!=4) || 
           (ist==3 && ntss!=5) || 
           (ist==4 && (ise==1||ise==2||ise==3||ise==5||ise==6||ise==7||ise==8||ise==12) && ntss!=6) ||
           (ist==4 && (ise==9||ise==11) && ntss!=3) ||
           (ist==4 && ise==10 && ntss!=4) || 
           (ist==4 && ise==4 && ntss!=5) ){ 
           check_cfg_code = 3;
           return check_cfg_code;
        }   
        
        //check TSM
        if(ntsm!=1){ 
          check_cfg_code = 4;
          return check_cfg_code;
        }

        //if(check_cfg_code){
        //cout << "nbti " << nbti << " ntraco " << ntraco << " ntss " << ntss << " ntsm " << ntsm << endl; 
        //cout << "Check: ch " << ist << " sec " << ise << " wh " << iwh << " == >check_cfg_code " << check_cfg_code << endl;
        //}
        }// end st loop
    }// end sec loop

    // SV MB4 has two more chambers
    for(int ise=13;ise<=14;ise++){

      DTChamberId chid(iwh,4,ise);

      int nbti      = m_manager->getDTConfigBtiMap(chid).size();
      int ntraco    = m_manager->getDTConfigTracoMap(chid).size();
      int ntss      = m_manager->getDTConfigTSPhi(chid)->nValidTSS();
      int ntsm      = m_manager->getDTConfigTSPhi(chid)->nValidTSM();

      if((ise==13 && nbti != 160) ||
         (ise==14 && nbti != 128)){
         check_cfg_code = 1;
         return check_cfg_code;
      }  
      if((ise==13 && ntraco != 20) || 
         (ise==14 && ntraco != 16)){
         check_cfg_code = 2;
         return check_cfg_code;
      }  
      if((ise==13 && ntss != 5) ||
         (ise==14 && ntss != 4)) {
         check_cfg_code = 3;
         return check_cfg_code;
      }
      if(ntsm != 1){
        check_cfg_code = 4;
        return check_cfg_code;
      }  
      //if(check_cfg_code){
        //cout << "nbti " << nbti << " ntraco " << ntraco << " ntss " << ntss << " ntsm " << ntsm << endl; 
        //cout << "Check: ch " << 4 << " sec " << ise << " wh " << iwh << " == >check_cfg_code " << check_cfg_code << endl;
      //}
    }// end sec 13 14  

  }// end wh loop

  //cout << "CheckDTCCB: config OK! check_cfg_code = " << check_cfg_code << endl;
  return check_cfg_code;
}
void DTConfigDBProducer::configFromCfg ( ) [private]

CB ??? 110204 SV for debugging purpose ONLY.

Definition at line 624 of file DTConfigDBProducer.cc.

References buildTrivialPedestals(), gather_cfg::cout, flagDBBti, flagDBTraco, flagDBTSM, flagDBTSS, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), m_manager, m_ps, mapEntryName(), DTChamberId::sector(), DTConfigManager::setCCBConfigValidity(), DTConfigManager::setDTConfigBti(), DTConfigManager::setDTConfigPedestals(), DTConfigManager::setDTConfigSectColl(), DTConfigManager::setDTConfigTraco(), DTConfigManager::setDTConfigTrigUnit(), DTConfigManager::setDTConfigTSPhi(), DTConfigManager::setDTConfigTSTheta(), DTChamberId::station(), and DTChamberId::wheel().

Referenced by produce().

                                      {

  // ... but still set CCB validity flag to let the emulator run
  m_manager->setCCBConfigValidity(true);

  //create config classes&C.
  edm::ParameterSet conf_ps = m_ps.getParameter<edm::ParameterSet>("DTTPGParameters");
  edm::ParameterSet conf_map = m_ps.getUntrackedParameter<edm::ParameterSet>("DTTPGMap");
  bool dttpgdebug = conf_ps.getUntrackedParameter<bool>("Debug");
  DTConfigSectColl sectcollconf(conf_ps.getParameter<edm::ParameterSet>("SectCollParameters"));
  edm::ParameterSet tups = conf_ps.getParameter<edm::ParameterSet>("TUParameters");
  DTConfigBti bticonf(tups.getParameter<edm::ParameterSet>("BtiParameters"));
  DTConfigTraco tracoconf(tups.getParameter<edm::ParameterSet>("TracoParameters"));
  DTConfigTSTheta tsthetaconf(tups.getParameter<edm::ParameterSet>("TSThetaParameters"));
  DTConfigTSPhi tsphiconf(tups.getParameter<edm::ParameterSet>("TSPhiParameters"));
  DTConfigTrigUnit trigunitconf(tups);
  DTConfigLUTs lutconf(tups.getParameter<edm::ParameterSet>("LutParameters"));
 
 
  for (int iwh=-2;iwh<=2;++iwh){
    for (int ist=1;ist<=4;++ist){
      for (int ise=1;ise<=12;++ise){
        DTChamberId chambid(iwh,ist,ise);
        vector<int> nmap = conf_map.getUntrackedParameter<vector<int> >(mapEntryName(chambid).c_str());

        if(dttpgdebug)
          {
            cout << " Filling configuration for chamber : wh " << chambid.wheel() << 
              ", st " << chambid.station() << 
              ", se " << chambid.sector() << endl;
          }
        
        //fill the bti map
        if(!flagDBBti){
                for (int isl=1;isl<=3;isl++){
                        int ncell = nmap[isl-1];
                        //        cout << ncell <<" , ";
                        for (int ibti=0;ibti<ncell;ibti++){
                                m_manager->setDTConfigBti(DTBtiId(chambid,isl,ibti+1),bticonf);
                                if(dttpgdebug)
                                        cout << "Filling BTI config for chamber : wh " << chambid.wheel() << 
                                                ", st " << chambid.station() << 
                                                ", se " << chambid.sector() << 
                                                "... sl " << isl << 
                                                ", bti " << ibti+1 << endl;
                        }     
                }
        }               
        
        // fill the traco map
        if(!flagDBTraco){
                int ntraco = nmap[3];
                //cout << ntraco << " }" << endl;
                for (int itraco=0;itraco<ntraco;itraco++){ 
                        m_manager->setDTConfigTraco(DTTracoId(chambid,itraco+1),tracoconf);
                        if(dttpgdebug)
                                cout << "Filling TRACO config for chamber : wh " << chambid.wheel() << 
                                        ", st " << chambid.station() << 
                                        ", se " << chambid.sector() << 
                                        ", traco " << itraco+1 << endl;
                }     
        }
        
        // fill TS & TrigUnit
        if(!flagDBTSS || !flagDBTSM)
        {       
                m_manager->setDTConfigTSTheta(chambid,tsthetaconf);
                m_manager->setDTConfigTSPhi(chambid,tsphiconf);
                m_manager->setDTConfigTrigUnit(chambid,trigunitconf);
        }

      }
    }
  }

  for (int iwh=-2;iwh<=2;++iwh){
    for (int ise=13;ise<=14;++ise){
      int ist =4;
      DTChamberId chambid(iwh,ist,ise);
      vector<int> nmap = conf_map.getUntrackedParameter<vector<int> >(mapEntryName(chambid).c_str());

      if(dttpgdebug)
        {
          cout << " Filling configuration for chamber : wh " << chambid.wheel() << 
            ", st " << chambid.station() << 
            ", se " << chambid.sector() << endl;
        }
      
      //fill the bti map
      if(!flagDBBti){
                for (int isl=1;isl<=3;isl++){
                        int ncell = nmap[isl-1];
                        //      cout << ncell <<" , ";
                        for (int ibti=0;ibti<ncell;ibti++){
                                m_manager->setDTConfigBti(DTBtiId(chambid,isl,ibti+1),bticonf);
                                if(dttpgdebug)
                                        cout << "Filling BTI config for chamber : wh " << chambid.wheel() << 
                                                ", st " << chambid.station() << 
                                                ", se " << chambid.sector() << 
                                                "... sl " << isl << 
                                                ", bti " << ibti+1 << endl;
                        }     
                }
      } 
      
      // fill the traco map
      if(!flagDBTraco){
                int ntraco = nmap[3];   
                //       cout << ntraco << " }" << endl;
                for (int itraco=0;itraco<ntraco;itraco++){ 
                        m_manager->setDTConfigTraco(DTTracoId(chambid,itraco+1),tracoconf);
                        if(dttpgdebug)
                                cout << "Filling TRACO config for chamber : wh " << chambid.wheel() << 
                                ", st " << chambid.station() << 
                                ", se " << chambid.sector() << 
                                ", traco " << itraco+1 << endl;
                }     
      }
      
      // fill TS & TrigUnit
      if(!flagDBTSS || !flagDBTSM)
      {
                m_manager->setDTConfigTSTheta(chambid,tsthetaconf);
                m_manager->setDTConfigTSPhi(chambid,tsphiconf);
                m_manager->setDTConfigTrigUnit(chambid,trigunitconf);
      }
    }
  }
  
  //loop on Sector Collectors
  for (int wh=-2;wh<=2;wh++)
    for (int se=1;se<=12;se++)
      m_manager->setDTConfigSectColl(DTSectCollId(wh,se),sectcollconf);
      
  //fake collection of pedestals
  m_manager->setDTConfigPedestals(buildTrivialPedestals());

  return;          

}
std::string DTConfigDBProducer::mapEntryName ( const DTChamberId chambid) const [private]

Definition at line 609 of file DTConfigDBProducer.cc.

References DTChamberId::sector(), DTChamberId::station(), and DTChamberId::wheel().

Referenced by configFromCfg().

{
  int iwh = chambid.wheel();
  std::ostringstream os;
  os << "wh";
  if (iwh < 0) {
     os << 'm' << -iwh;
   } else {
     os << iwh;
  }
  os << "st" << chambid.station() << "se" << chambid.sector();
  return os.str();
}
std::auto_ptr< DTConfigManager > DTConfigDBProducer::produce ( const DTConfigManagerRcd iRecord)

ES produce method.

Definition at line 84 of file DTConfigDBProducer.cc.

References buildTrivialPedestals(), cfgConfig, checkDTCCBConfig(), configFromCfg(), m_manager, readDBPedestalsConfig(), readDTCCBConfig(), DTConfigManager::setCCBConfigValidity(), and DTConfigManager::setLutFromDB().

Referenced by DTConfigDBProducer().

{
   using namespace edm;

   int code; 
   if(cfgConfig){
     m_manager->setLutFromDB(false);
     configFromCfg();
     buildTrivialPedestals();
     code = 2;
   }  else{
     code = readDTCCBConfig(iRecord);
     readDBPedestalsConfig(iRecord); // no return code if fails exception is raised by ESHandle getter
     // 110628 SV add config check
     if(code != -1 && checkDTCCBConfig() > 0)
       code=-1;
   }
   //cout << "DTConfigDBProducer::produce CODE " << code << endl;
   if(code==-1) {
     //throw cms::Exception("DTTPG") << "DTConfigDBProducer::produce : " << endl
     //                            << "generic error pharsing DT CCB config strings." << endl
     //                              << "Run module with debug flags enable to get more info" << endl;
     m_manager->setCCBConfigValidity(false);
   } else if(code==2) {
     LogVerbatim ("DTTPG") << "DTConfigDBProducer::produce : Trivial : " << endl
                           << "configurations has been read from cfg" << endl; 
   } else if(code==0) {
     LogVerbatim ("DTTPG") << "DTConfigDBProducer::produce : " << endl 
                           << "Configurations successfully read from OMDS" << endl; 
   } else {
     LogProblem ("DTTPG") << "DTConfigDBProducer::produce : " << endl
                          << "Wrong configuration return CODE" << endl;
   }

   std::auto_ptr<DTConfigManager> dtConfig = std::auto_ptr<DTConfigManager>( m_manager );

   return dtConfig ;
}
void DTConfigDBProducer::readDBPedestalsConfig ( const DTConfigManagerRcd iRecord) [private]

Read DTTPG pedestal configuration.

Definition at line 123 of file DTConfigDBProducer.cc.

References edm::eventsetup::DependentRecordImplementation< RecordT, ListT >::getRecord(), m_debugPed, m_manager, m_UseT0, edm::ESHandle< T >::product(), DTConfigPedestals::setDebug(), DTConfigManager::setDTConfigPedestals(), DTConfigPedestals::setES(), and DTConfigPedestals::setUseT0().

Referenced by produce().

                                                                               {

  edm::ESHandle<DTTPGParameters> dttpgParams;
  iRecord.getRecord<DTTPGParametersRcd>().get(dttpgParams);

  DTConfigPedestals pedestals;
  pedestals.setDebug(m_debugPed);

  if (m_UseT0) {

    edm::ESHandle<DTT0> t0i;
    iRecord.getRecord<DTT0Rcd>().get(t0i);
 
    pedestals.setUseT0(true);
    pedestals.setES(dttpgParams.product(),t0i.product());
//cout << "checkDTCCBConfig CODE is " << checkDTCCBConfig() << endl;

  } else {

    pedestals.setUseT0(false);
    pedestals.setES(dttpgParams.product());

  }

  m_manager->setDTConfigPedestals(pedestals);

}
int DTConfigDBProducer::readDTCCBConfig ( const DTConfigManagerRcd iRecord) [private]

Read CCB string configuration.

Definition at line 266 of file DTConfigDBProducer.cc.

References trackerHits::c, alignmentValidation::c1, gather_cfg::cout, end, flagDBBti, flagDBLUTS, flagDBTraco, flagDBTSM, flagDBTSS, DTPosNegType::getCT(), DTConfigAbstractHandler::getInstance(), edm::ParameterSet::getParameter(), DTPosNegType::getPN(), edm::eventsetup::DependentRecordImplementation< RecordT, ListT >::getRecord(), edm::ParameterSet::getUntrackedParameter(), i, o2o::iov, list(), DTConfigManager::lutFromDB(), m_debugBti, m_debugDB, m_debugLUTs, m_debugSC, m_debugTraco, m_debugTSP, m_debugTST, m_debugTU, m_manager, m_ps, DTChamberId::sector(), DTCCBId::sectorId, DTConfigManager::setCCBConfigValidity(), DTConfigSectColl::setDebug(), DTConfigTrigUnit::setDebug(), DTConfigManager::setDTConfigBti(), DTConfigManager::setDTConfigLUTs(), DTConfigManager::setDTConfigSectColl(), DTConfigManager::setDTConfigTraco(), DTConfigManager::setDTConfigTrigUnit(), DTConfigManager::setDTConfigTSPhi(), DTConfigManager::setDTConfigTSTheta(), DTChamberId::station(), DTCCBId::stationId, AlCaHLTBitMon_QueryRunRegistry::string, edm::eventsetup::EventSetupRecord::validityInterval(), DTChamberId::wheel(), and DTCCBId::wheelId.

Referenced by produce().

{
  using namespace edm::eventsetup;

  // initialize CCB validity flag
  m_manager->setCCBConfigValidity(true);

  // get DTCCBConfigRcd from DTConfigManagerRcd (they are dependent records)
  edm::ESHandle<DTCCBConfig> ccb_conf;
  iRecord.getRecord<DTCCBConfigRcd>().get(ccb_conf);
  int ndata = std::distance( ccb_conf->begin(), ccb_conf->end() );

  DTConfigAbstractHandler* cfgCache = DTConfigAbstractHandler::getInstance();
  const DTKeyedConfigListRcd& keyRecord = iRecord.getRecord<DTKeyedConfigListRcd>();

  if(m_debugDB)
  {
        cout << ccb_conf->version() << endl;
        cout << ndata << " data in the container" << endl;
  }

  edm::ValidityInterval iov(iRecord.getRecord<DTCCBConfigRcd>().validityInterval() );
  unsigned int currValidityStart = iov.first().eventID().run();
  unsigned int currValidityEnd   = iov.last( ).eventID().run();

  if(m_debugDB)
        cout    << "valid since run " << currValidityStart
                << " to run "         << currValidityEnd << endl;  
            
  // if there are no data in the container, configuration from cfg files...         
  if( ndata==0 ){
    //throw cms::Exception("DTTPG") << "DTConfigDBProducer::readDTCCBConfig : " << endl 
    //                            << "DTCCBConfigRcd is empty!" << endl;
    //m_manager->setCCBConfigValidity(false);
    return -1;
  }

  // get DTTPGMap for retrieving bti number and traco number
  edm::ParameterSet conf_map = m_ps.getUntrackedParameter<edm::ParameterSet>("DTTPGMap");

  // loop over chambers
  DTCCBConfig::ccb_config_map configKeys( ccb_conf->configKeyMap() );
  DTCCBConfig::ccb_config_iterator iter = configKeys.begin();
  DTCCBConfig::ccb_config_iterator iend = configKeys.end();

  // 110628 SV check that number of CCB is equal to total number of chambers
  if(ccb_conf->configKeyMap().size() != 250) //check the number of chambers!!!
    return -1;

  // read data from CCBConfig
  while ( iter != iend ) {
    // 110628 SV moved here from constructor, to check config consistency for EVERY chamber 
    // initialize flags to check if data are present in OMDS 
    flagDBBti   = false;
    flagDBTraco         = false;
    flagDBTSS   = false;
    flagDBTSM   = false;
    flagDBLUTS    = false;

    // get chamber id
    const DTCCBId& ccbId = iter->first;
    if(m_debugDB)
                cout << " Filling configuration for chamber : wh " << ccbId.wheelId   << " st "
                        << ccbId.stationId << " se "
                        << ccbId.sectorId  << " -> " << endl;

        // get chamber type and id from ccbId
        int mbtype = DTPosNegType::getCT( ccbId.wheelId, ccbId.sectorId, ccbId.stationId );
        int posneg = DTPosNegType::getPN( ccbId.wheelId, ccbId.sectorId, ccbId.stationId );
        if(m_debugDB)
                cout << "Chamber type : " <<  mbtype
                        << " posneg : " << posneg << endl; 
        DTChamberId chambid(ccbId.wheelId, ccbId.stationId, ccbId.sectorId);
                        
        // get brick identifiers list
        const std::vector<int>& ccbConf = iter->second;
        std::vector<int>::const_iterator cfgIter = ccbConf.begin();
        std::vector<int>::const_iterator cfgIend = ccbConf.end();

        //TSS-TSM buffers
        unsigned short int tss_buffer[7][31];
        unsigned short int tsm_buffer[9];
        int ntss=0;

        // loop over configuration bricks
        while ( cfgIter != cfgIend ) {
                // get brick identifier
                int id = *cfgIter++;
                if(m_debugDB)
                        cout << " BRICK " << id << endl;  

                // create strings list
                std::vector<std::string> list;
                cfgCache->getData( keyRecord, id, list );

                // loop over strings
                std::vector<std::string>::const_iterator s_iter = list.begin();
                std::vector<std::string>::const_iterator s_iend = list.end();
                while ( s_iter != s_iend ) {
                        if(m_debugDB)
                                cout << "        ----> " << *s_iter << endl;
                                
                        // copy string in unsigned int buffer
                        std::string str = *s_iter++;
                        unsigned short int buffer[100];         //2 bytes
                        int c = 0;
                        const char* cstr = str.c_str();
                        const char* ptr = cstr + 2;
                        const char* end = cstr + str.length();
                        while ( ptr < end ) {
                                char c1 = *ptr++;
                                int i1 = 0;
                                if ( ( c1 >= '0' ) && ( c1 <= '9' ) ) i1 =      c1 - '0';
                                if ( ( c1 >= 'a' ) && ( c1 <= 'f' ) ) i1 = 10 + c1 - 'a';
                                if ( ( c1 >= 'A' ) && ( c1 <= 'F' ) ) i1 = 10 + c1 - 'A';
                                char c2 = *ptr++;
                                int i2 = 0;
                                if ( ( c2 >= '0' ) && ( c2 <= '9' ) ) i2 =      c2 - '0';
                                if ( ( c2 >= 'a' ) && ( c2 <= 'f' ) ) i2 = 10 + c2 - 'a';
                                if ( ( c2 >= 'A' ) && ( c2 <= 'F' ) ) i2 = 10 + c2 - 'A';
                                buffer[c] = ( i1 * 16 ) + i2;
                                c++;
                        }// end loop over string

                        // BTI configuration string     
                        if (buffer[2]==0x54){
                                if(m_debugDB)
                                        cout << "BTI STRING found in DB" << endl;

                                // BTI configuration read for BTI
                                flagDBBti = true;
                                
                                // compute sl and bti number from board and chip
                                int brd=buffer[3]; // Board Nr.
                                int chip=buffer[4]; // Chip Nr.

                                if (brd>7) {
                                        cout << "Not existing board ... " << brd << endl;
                                        return -1; // Non-existing board
                                }       
                                if (chip>31) {
                                        cout << "Not existing chip... " << chip << endl;
                                        return -1; // Non existing chip 
                                }
                                
                                // Is it Phi or Theta board?
                                bool ThetaSL, PhiSL;
                                PhiSL=false;
                                ThetaSL=false;
                                switch (mbtype) {
                                        case 1: // mb1
                                                if (brd==6 || brd==7) {
                                                        ThetaSL=true; 
                                                        brd-=6;
                                                }
                                                else if ((brd<3 && chip<32) || (brd==3 && chip<8)) 
                                                        PhiSL=true;
                                                break;
                                        case 2: // mb2
                                                if (brd==6 || brd==7) {
                                                        ThetaSL=true; 
                                                        brd-=6;
                                                }
                                                else if (brd<4 && chip<32) 
                                                        PhiSL=true;
                                                break;
                                        case 3: // mb3
                                                if (brd==6 || brd==7) {
                                                        ThetaSL=true; 
                                                        brd-=6;
                                                }
                                                else if (brd<5 && chip<32) 
                                                        PhiSL=true;
                                                break;
                                        case 4: // mb4-s, mb4_8
                                                if (brd<6 && chip<32) 
                                                        PhiSL=true;
                                                break;
                                        case 5: // mb4-9
                                                if (brd<3 && chip<32) 
                                                        PhiSL=true;
                                                break;
                                        case 6: // mb4-4
                                                if (brd<5 && chip<32) 
                                                        PhiSL=true;
                                                break;
                                        case 7: // mb4-10
                                                if (brd<4 && chip<32) 
                                                        PhiSL=true;
                                                break;
                                }
                                if (!PhiSL && !ThetaSL) {
                                        cout << "MB type " << mbtype << endl; 
                                        cout << "Board " << brd << " chip " <<chip << endl;
                                        cout << "Not phi SL nor Theta SL" << endl; 
                                        return -1; // Not PhiSL nor ThetaSL 
                                }        
                                        
                                // compute SL number and bti number
                                int isl;
                                int ibti;
                                if (PhiSL) {
                                        if ((chip%8)<4) 
                                                isl=1;  // Phi1 
                                        else 
                                                isl=3;  // Phi2 
                                        ibti=brd*16+(int)(chip/8)*4+(chip%4); 
                                }
                                else if (ThetaSL){
                                        isl=2;          // Theta 
                                        if ((chip%8)<4)
                                                ibti=brd*32+ chip-4*(int)(chip/8);
                                        else
                                                ibti=brd*32+ chip+12-4*(int)(chip/8);
                                }                
                        
                                // BTI config constructor from strings  
                                DTConfigBti bticonf(m_debugBti,buffer);
                                 
                                m_manager->setDTConfigBti(DTBtiId(chambid,isl,ibti+1),bticonf);
                                
                                if(m_debugDB)
                                        cout <<         "Filling BTI config for chamber : wh " << chambid.wheel() << 
                                                        ", st " << chambid.station() << 
                                                        ", se " << chambid.sector() << 
                                                        "... sl " << isl << 
                                                        ", bti " << ibti+1 << endl;                             
                        }
                                
                        // TRACO configuration string                   
                        if (buffer[2]==0x15){
                                if(m_debugDB)
                                        cout << "TRACO STRING found in DB" << endl;
                                // TRACO configuration read from OMDS
                                flagDBTraco = true;
                                
                                // TRACO config constructor from strings        
                                int traco_brd = buffer[3];      // Board Nr.;
                                int traco_chip = buffer[4];     // Chip Nr.;
                                int itraco = traco_brd * 4 + traco_chip + 1;
                                DTConfigTraco tracoconf(m_debugTraco,buffer);
                                m_manager->setDTConfigTraco(DTTracoId(chambid,itraco),tracoconf);
                                
                                if(m_debugDB)
                                        cout <<         "Filling TRACO config for chamber : wh " << chambid.wheel() <<
                                                        ", st " << chambid.station() <<
                                                        ", se " << chambid.sector() <<
                                                        ", board " << traco_brd <<
                                                        ", chip " << traco_chip <<
                                                        ", traco " << itraco << endl;   
                        }
                        
                        
                        // TSS configuration string     
                        if (buffer[2]==0x16){
                                if(m_debugDB)
                                        cout << "TSS STRING found in DB" << endl;
                                // TSS configuration read from OMDS
                                flagDBTSS = true;
                                
                                unsigned short int itss=buffer[3];
                                for (int i=0;i<31;i++) 
                                        tss_buffer[itss][i]=buffer[i];
                                ntss++;
                        }
                        
                        // TSM configuration string
                        if (buffer[2]==0x17){
                                if(m_debugDB)
                                        cout << "TSM STRING found in DB" << endl;
                         
                                // TSM configuration read from OMDS
                                flagDBTSM = true;                        
                         
                                for (int i=0; i<9; i++) 
                                        tsm_buffer[i]=buffer[i];
                        } 
                        
                        // LUT configuration string
                        if (buffer[2]==0xA8){
                                if(m_debugDB)
                                        cout << "LUT STRING found in DB" << endl;

                                // LUT parameters read from OMDS
                                flagDBLUTS = true;
                                DTConfigLUTs lutconf(m_debugLUTs,buffer);
                                //lutconf.setDebug(m_debugLUTs);
                                m_manager->setDTConfigLUTs(chambid,lutconf);
                        }
                        
                }//end string iteration                                 
        }//end brick iteration
        
        //TSS + TSM configurations are set in DTConfigTSPhi constructor
        if(flagDBTSM && flagDBTSS) {
          DTConfigTSPhi tsphiconf(m_debugTSP,tss_buffer,ntss,tsm_buffer);
          m_manager->setDTConfigTSPhi(chambid,tsphiconf);
        }

        // get configuration for TSTheta, SC and TU from .cfg
      edm::ParameterSet conf_ps = m_ps.getParameter<edm::ParameterSet>("DTTPGParameters");  
        edm::ParameterSet tups = conf_ps.getParameter<edm::ParameterSet>("TUParameters");

        // TSTheta configuration from .cfg
       DTConfigTSTheta tsthetaconf(tups.getParameter<edm::ParameterSet>("TSThetaParameters"));
        tsthetaconf.setDebug(m_debugTST);
        m_manager->setDTConfigTSTheta(chambid,tsthetaconf);

        // SC configuration from .cfg
       DTConfigSectColl sectcollconf(conf_ps.getParameter<edm::ParameterSet>("SectCollParameters"));
        sectcollconf.setDebug(m_debugSC);
       m_manager->setDTConfigSectColl(DTSectCollId(chambid.wheel(),chambid.sector()),sectcollconf);

        // TU configuration from .cfg
        DTConfigTrigUnit trigunitconf(tups);
        trigunitconf.setDebug(m_debugTU);
      m_manager->setDTConfigTrigUnit(chambid,trigunitconf);
       
     ++iter;
     
     // 110628 SV moved inside CCB loop to check for every chamber 
     // moved to exception handling no attempt to configure from cfg is DB is missing
     // SV comment exception handling and activate flag in DTConfigManager
     if(!flagDBBti || !flagDBTraco || !flagDBTSS || !flagDBTSM ){
       //throw cms::Exception("DTTPG") << "DTConfigDBProducer::readDTCCBConfig :"  << endl
       //                                 << "(at least) part of the CCB strings needed to configure"  << endl
       //                                 << "DTTPG emulator were not found in DTCCBConfigRcd" << endl;
       //m_manager->setCCBConfigValidity(false);
       return -1;
     }
     if(!flagDBLUTS && m_manager->lutFromDB()==true){
     //throw cms::Exception("DTTPG") << "DTConfigDBProducer::readDTCCBConfig : " << endl
     //                           << "Asked to configure the emulator using Lut seeds from DB "
     //                           << "but no configuration parameters found in DTCCBConfigRcd." << endl;
     //m_manager->setCCBConfigValidity(false);
       return -1;
     } 
  } // end loop over CCB

  
  return 0;
}

Member Data Documentation

Definition at line 95 of file DTConfigDBProducer.h.

Referenced by DTConfigDBProducer(), and produce().

Definition at line 97 of file DTConfigDBProducer.h.

Referenced by configFromCfg(), and readDTCCBConfig().

Definition at line 97 of file DTConfigDBProducer.h.

Referenced by readDTCCBConfig().

Definition at line 97 of file DTConfigDBProducer.h.

Referenced by configFromCfg(), and readDTCCBConfig().

Definition at line 97 of file DTConfigDBProducer.h.

Referenced by configFromCfg(), and readDTCCBConfig().

Definition at line 97 of file DTConfigDBProducer.h.

Referenced by configFromCfg(), and readDTCCBConfig().

Definition at line 83 of file DTConfigDBProducer.h.

Referenced by DTConfigDBProducer(), and readDTCCBConfig().

Definition at line 82 of file DTConfigDBProducer.h.

Referenced by DTConfigDBProducer(), and readDTCCBConfig().

Definition at line 89 of file DTConfigDBProducer.h.

Referenced by DTConfigDBProducer(), and readDTCCBConfig().

Definition at line 88 of file DTConfigDBProducer.h.

Referenced by DTConfigDBProducer(), and readDTCCBConfig().

Definition at line 84 of file DTConfigDBProducer.h.

Referenced by DTConfigDBProducer(), and readDTCCBConfig().

Definition at line 85 of file DTConfigDBProducer.h.

Referenced by DTConfigDBProducer(), and readDTCCBConfig().

Definition at line 86 of file DTConfigDBProducer.h.

Referenced by DTConfigDBProducer(), and readDTCCBConfig().

Definition at line 87 of file DTConfigDBProducer.h.

Referenced by DTConfigDBProducer(), and readDTCCBConfig().

Definition at line 93 of file DTConfigDBProducer.h.

Referenced by DTConfigDBProducer(), and readDBPedestalsConfig().