CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/L1TriggerConfig/DTTPGConfigProducers/src/DTConfigTrivialProducer.cc

Go to the documentation of this file.
00001 #include "L1TriggerConfig/DTTPGConfigProducers/src/DTConfigTrivialProducer.h"
00002 #include "DataFormats/MuonDetId/interface/DTChamberId.h"
00003 #include "DataFormats/MuonDetId/interface/DTSuperLayerId.h"
00004 #include "DataFormats/MuonDetId/interface/DTLayerId.h"
00005 #include <ostream>
00006 
00007 using std::cout;
00008 using std::endl;
00009 using std::vector;
00010 using std::auto_ptr;
00011 
00012 //
00013 // constructors and destructor
00014 //
00015 DTConfigTrivialProducer::DTConfigTrivialProducer(const edm::ParameterSet& ps)
00016 {
00017 
00018   setWhatProduced(this);
00019   
00020   //get and store parameter set 
00021   m_ps = ps;
00022   m_manager = new DTConfigManager();
00023   m_tpgParams = new DTTPGParameters();
00024 
00025   // set debug
00026   edm::ParameterSet conf_ps = m_ps.getParameter<edm::ParameterSet>("DTTPGParameters");  
00027   m_debug = conf_ps.getUntrackedParameter<bool>("Debug");
00028 
00029   if (m_debug) 
00030     cout << "DTConfigTrivialProducer::DTConfigTrivialProducer()" << endl;
00031 
00032   m_manager->setDTTPGDebug(m_debug);
00033 
00034   // DB specific requests
00035   bool tracoLutsFromDB = m_ps.getParameter<bool>("TracoLutsFromDB");
00036   bool useBtiAcceptParam = m_ps.getParameter<bool>("UseBtiAcceptParam");
00037 
00038   // set specific DB requests
00039   m_manager->setLutFromDB(tracoLutsFromDB);
00040   m_manager->setUseAcceptParam(useBtiAcceptParam);  // CB Are these needed here???
00041 }
00042 
00043 
00044 DTConfigTrivialProducer::~DTConfigTrivialProducer()
00045 {
00046 
00047   if (m_debug) 
00048     cout << "DTConfigTrivialProducer::~DTConfigTrivialProducer()" << endl;
00049  
00050 
00051 }
00052 
00053 
00054 //
00055 // member functions
00056 //
00057 
00058 std::auto_ptr<DTConfigManager> DTConfigTrivialProducer::produce (const DTConfigManagerRcd& iRecord)
00059 {
00060 
00061   if (m_debug) 
00062     cout << "DTConfigTrivialProducer::produce()" << endl;
00063 
00064    using namespace edm::es;
00065    buildManager();
00066 
00067    //m_manager->getDTConfigPedestals()->print();
00068 
00069    std::auto_ptr<DTConfigManager> dtConfig = std::auto_ptr<DTConfigManager>( m_manager );
00070 
00071    return dtConfig ;
00072 
00073 }
00074 
00075 void DTConfigTrivialProducer::buildManager()
00076 {
00077 
00078   if (m_debug) 
00079     cout << "DTConfigTrivialProducer::buildManager()" << endl;
00080 
00081   //create config classes&C.
00082   edm::ParameterSet conf_ps = m_ps.getParameter<edm::ParameterSet>("DTTPGParameters");
00083   edm::ParameterSet conf_map = m_ps.getUntrackedParameter<edm::ParameterSet>("DTTPGMap");
00084   DTConfigSectColl sectcollconf(conf_ps.getParameter<edm::ParameterSet>("SectCollParameters"));
00085   edm::ParameterSet tups = conf_ps.getParameter<edm::ParameterSet>("TUParameters");
00086   DTConfigBti bticonf(tups.getParameter<edm::ParameterSet>("BtiParameters"));
00087   DTConfigTraco tracoconf(tups.getParameter<edm::ParameterSet>("TracoParameters"));
00088   DTConfigLUTs lutconf(tups.getParameter<edm::ParameterSet>("LutParameters"));
00089   DTConfigTSTheta tsthetaconf(tups.getParameter<edm::ParameterSet>("TSThetaParameters"));
00090   DTConfigTSPhi tsphiconf(tups.getParameter<edm::ParameterSet>("TSPhiParameters"));
00091   DTConfigTrigUnit trigunitconf(tups);
00092    
00093   for (int iwh=-2;iwh<=2;++iwh){
00094     for (int ist=1;ist<=4;++ist){
00095       for (int ise=1;ise<=12;++ise){
00096         DTChamberId chambid(iwh,ist,ise);
00097         vector<int> nmap = conf_map.getUntrackedParameter<vector<int> >(mapEntryName(chambid).c_str());
00098 
00099         if(m_debug)
00100           {
00101             std::cout << " Filling configuration for chamber : wh " << chambid.wheel() << 
00102               ", st " << chambid.station() << 
00103               ", se " << chambid.sector() << endl;
00104           }
00105         
00106         //fill the bti map
00107         for (int isl=1;isl<=3;isl++){
00108           int ncell = nmap[isl-1];
00109           //      std::cout << ncell <<" , ";
00110           for (int ibti=0;ibti<ncell;ibti++)
00111             {
00112               m_manager->setDTConfigBti(DTBtiId(chambid,isl,ibti+1),bticonf);
00113               if(m_debug)
00114                 std::cout << "Filling BTI config for chamber : wh " << chambid.wheel() << 
00115                   ", st " << chambid.station() << 
00116                   ", se " << chambid.sector() << 
00117                   "... sl " << isl << 
00118                   ", bti " << ibti+1 << endl;
00119             }     
00120         }
00121         
00122         // fill the traco map
00123         int ntraco = nmap[3];
00124         //std::cout << ntraco << " }" << std::endl;
00125         for (int itraco=0;itraco<ntraco;itraco++)
00126           { 
00127             m_manager->setDTConfigTraco(DTTracoId(chambid,itraco+1),tracoconf);
00128             if(m_debug)
00129               std::cout << "Filling TRACO config for chamber : wh " << chambid.wheel() << 
00130                 ", st " << chambid.station() << 
00131                 ", se " << chambid.sector() << 
00132                 ", traco " << itraco+1 << endl;
00133           }     
00134         
00135         // fill TS & TrigUnit
00136         m_manager->setDTConfigTSTheta(chambid,tsthetaconf);
00137         m_manager->setDTConfigTSPhi(chambid,tsphiconf);
00138         m_manager->setDTConfigTrigUnit(chambid,trigunitconf);
00139         
00140         // fill LUTs
00141         m_manager->setDTConfigLUTs(chambid,lutconf);
00142         m_manager->setLutFromDB(false);    // 110204 SV to be sure to compute luts from geometry         
00143       }
00144     }
00145   }
00146 
00147   for (int iwh=-2;iwh<=2;++iwh){
00148     for (int ise=13;ise<=14;++ise){
00149       int ist =4;
00150       DTChamberId chambid(iwh,ist,ise);
00151       vector<int> nmap = conf_map.getUntrackedParameter<vector<int> >(mapEntryName(chambid).c_str());
00152 
00153       if(m_debug)
00154         {
00155           std::cout << " Filling configuration for chamber : wh " << chambid.wheel() << 
00156             ", st " << chambid.station() << 
00157             ", se " << chambid.sector() << endl;
00158         }
00159       
00160       //fill the bti map
00161       for (int isl=1;isl<=3;isl++){
00162         int ncell = nmap[isl-1];
00163 //      std::cout << ncell <<" , ";
00164         for (int ibti=0;ibti<ncell;ibti++)
00165           {
00166             m_manager->setDTConfigBti(DTBtiId(chambid,isl,ibti+1),bticonf);
00167             if(m_debug)
00168               std::cout << "Filling BTI config for chamber : wh " << chambid.wheel() << 
00169                 ", st " << chambid.station() << 
00170                 ", se " << chambid.sector() << 
00171                 "... sl " << isl << 
00172                 ", bti " << ibti+1 << endl;
00173           }     
00174       }
00175       
00176       // fill the traco map
00177       int ntraco = nmap[3];
00178 //       std::cout << ntraco << " }" << std::endl;
00179       for (int itraco=0;itraco<ntraco;itraco++)
00180         { 
00181           m_manager->setDTConfigTraco(DTTracoId(chambid,itraco+1),tracoconf);
00182           if(m_debug)
00183             std::cout << "Filling TRACO config for chamber : wh " << chambid.wheel() << 
00184               ", st " << chambid.station() << 
00185               ", se " << chambid.sector() << 
00186               ", traco " << itraco+1 << endl;
00187         }     
00188       
00189       // fill TS & TrigUnit
00190       m_manager->setDTConfigTSTheta(chambid,tsthetaconf);
00191       m_manager->setDTConfigTSPhi(chambid,tsphiconf);
00192       m_manager->setDTConfigTrigUnit(chambid,trigunitconf);
00193 
00194       // fill LUTs
00195       m_manager->setDTConfigLUTs(chambid,lutconf);
00196       m_manager->setLutFromDB(false);    // 110204 SV to be sure to compute luts from geometry         
00197     }
00198   }
00199   
00200   //loop on Sector Collectors
00201   for (int wh=-2;wh<=2;wh++)
00202     for (int se=1;se<=12;se++)
00203       m_manager->setDTConfigSectColl(DTSectCollId(wh,se),sectcollconf);
00204 
00205   //fake collection of pedestals
00206   m_manager->setDTConfigPedestals(buildTrivialPedestals());
00207 
00208 }
00209 
00210 DTConfigPedestals DTConfigTrivialProducer::buildTrivialPedestals()
00211 {
00212 
00213   int counts = m_ps.getParameter<int>("bxOffset");
00214   float fine = m_ps.getParameter<double>("finePhase");
00215    
00216   if (m_debug) 
00217     cout << "DTConfigTrivialProducer::buildPedestals()" << endl;
00218 
00219   //DTTPGParameters tpgParams;
00220   for (int iwh=-2;iwh<=2;++iwh){
00221     for (int ist=1;ist<=4;++ist){
00222       for (int ise=1;ise<=14;++ise){
00223         if (ise>12 && ist!=4) continue;
00224 
00225         DTChamberId chId(iwh,ist,ise);
00226         m_tpgParams->set(chId,counts,fine,DTTimeUnits::ns);
00227       }
00228     }
00229   }
00230 
00231   DTConfigPedestals tpgPedestals;
00232   tpgPedestals.setUseT0(false);
00233   tpgPedestals.setES(m_tpgParams);
00234  
00235   return tpgPedestals;
00236 
00237 }
00238 
00239 
00240 std::string DTConfigTrivialProducer::mapEntryName(const DTChamberId & chambid) const
00241 {
00242   int iwh = chambid.wheel();
00243   std::ostringstream os;
00244   os << "wh";
00245   if (iwh < 0) {
00246      os << 'm' << -iwh;
00247    } else {
00248      os << iwh;
00249   }
00250   os << "st" << chambid.station() << "se" << chambid.sector();
00251   return os.str();
00252 }