CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/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 //
00014 // constants, enums and typedefs
00015 //
00016 
00017 //
00018 // static data member definitions
00019 //
00020 
00021 //
00022 // constructors and destructor
00023 //
00024 DTConfigTrivialProducer::DTConfigTrivialProducer(const edm::ParameterSet& ps)
00025 {
00026  
00027   //the following line is needed to tell the framework what
00028   // data is being produced
00029   setWhatProduced(this);
00030 
00031   //now do what ever other initialization is needed
00032   
00033   //get and store parameter set 
00034   m_ps = ps;
00035   m_manager = new DTConfigManager();
00036 
00037   // set debug
00038   edm::ParameterSet conf_ps = m_ps.getParameter<edm::ParameterSet>("DTTPGParameters");  
00039   bool dttpgdebug = conf_ps.getUntrackedParameter<bool>("Debug");
00040   m_manager->setDTTPGDebug(dttpgdebug);
00041 
00042   // DB specific requests
00043   bool tracoLutsFromDB = m_ps.getParameter< bool        >("TracoLutsFromDB");
00044   bool useBtiAcceptParam = m_ps.getParameter< bool        >("UseBtiAcceptParam");
00045 
00046   // set specific DB requests
00047   m_manager->setLutFromDB(tracoLutsFromDB);
00048   m_manager->setUseAcceptParam(useBtiAcceptParam);
00049 }
00050 
00051 
00052 DTConfigTrivialProducer::~DTConfigTrivialProducer()
00053 {
00054  
00055    // do anything here that needs to be done at destruction time
00056    // (e.g. close files, deallocate resources etc.)
00057 
00058 }
00059 
00060 
00061 //
00062 // member functions
00063 //
00064 // ------------ method called to produce the data  ------------
00065 std::auto_ptr<DTConfigManager> DTConfigTrivialProducer::produce (const DTConfigManagerRcd& iRecord)
00066 {
00067    using namespace edm::es;
00068 
00069    buildManager();
00070 
00071    std::auto_ptr<DTConfigManager> dtConfig = std::auto_ptr<DTConfigManager>( m_manager );
00072 
00073    return dtConfig ;
00074 }
00075 
00076 void DTConfigTrivialProducer::buildManager()
00077 {
00078 
00079   //create config classes&C.
00080   edm::ParameterSet conf_ps = m_ps.getParameter<edm::ParameterSet>("DTTPGParameters");
00081   edm::ParameterSet conf_map = m_ps.getUntrackedParameter<edm::ParameterSet>("DTTPGMap");
00082   bool dttpgdebug = conf_ps.getUntrackedParameter<bool>("Debug");
00083   DTConfigSectColl sectcollconf(conf_ps.getParameter<edm::ParameterSet>("SectCollParameters"));
00084   edm::ParameterSet tups = conf_ps.getParameter<edm::ParameterSet>("TUParameters");
00085   DTConfigBti bticonf(tups.getParameter<edm::ParameterSet>("BtiParameters"));
00086   DTConfigTraco tracoconf(tups.getParameter<edm::ParameterSet>("TracoParameters"));
00087   DTConfigLUTs lutconf(tups.getParameter<edm::ParameterSet>("LutParameters"));
00088   DTConfigTSTheta tsthetaconf(tups.getParameter<edm::ParameterSet>("TSThetaParameters"));
00089   DTConfigTSPhi tsphiconf(tups.getParameter<edm::ParameterSet>("TSPhiParameters"));
00090   DTConfigTrigUnit trigunitconf(tups);
00091    
00092   for (int iwh=-2;iwh<=2;++iwh){
00093     for (int ist=1;ist<=4;++ist){
00094       for (int ise=1;ise<=12;++ise){
00095         DTChamberId chambid(iwh,ist,ise);
00096         vector<int> nmap = conf_map.getUntrackedParameter<vector<int> >(mapEntryName(chambid).c_str());
00097 //      std::cout << "  untracked vint32 wh" << chambid.wheel()
00098 //                << "st" << chambid.station()
00099 //                << "se" << chambid.sector() << " = { ";
00100         if(dttpgdebug)
00101           {
00102             std::cout << " Filling configuration for chamber : wh " << chambid.wheel() << 
00103               ", st " << chambid.station() << 
00104               ", se " << chambid.sector() << endl;
00105           }
00106         
00107         //fill the bti map
00108         for (int isl=1;isl<=3;isl++){
00109           int ncell = nmap[isl-1];
00110           //      std::cout << ncell <<" , ";
00111           for (int ibti=0;ibti<ncell;ibti++)
00112             {
00113               m_manager->setDTConfigBti(DTBtiId(chambid,isl,ibti+1),bticonf);
00114               if(dttpgdebug)
00115                 std::cout << "Filling BTI config for chamber : wh " << chambid.wheel() << 
00116                   ", st " << chambid.station() << 
00117                   ", se " << chambid.sector() << 
00118                   "... sl " << isl << 
00119                   ", bti " << ibti+1 << endl;
00120             }     
00121         }
00122         
00123         // fill the traco map
00124         int ntraco = nmap[3];
00125         //std::cout << ntraco << " }" << std::endl;
00126         for (int itraco=0;itraco<ntraco;itraco++)
00127           { 
00128             m_manager->setDTConfigTraco(DTTracoId(chambid,itraco+1),tracoconf);
00129             if(dttpgdebug)
00130               std::cout << "Filling TRACO config for chamber : wh " << chambid.wheel() << 
00131                 ", st " << chambid.station() << 
00132                 ", se " << chambid.sector() << 
00133                 ", traco " << itraco+1 << endl;
00134           }     
00135         
00136         // fill TS & TrigUnit
00137         m_manager->setDTConfigTSTheta(chambid,tsthetaconf);
00138         m_manager->setDTConfigTSPhi(chambid,tsphiconf);
00139         m_manager->setDTConfigTrigUnit(chambid,trigunitconf);
00140         
00141         // fill LUTs
00142         m_manager->setDTConfigLUTs(chambid,lutconf);
00143         
00144       }
00145     }
00146   }
00147 
00148   for (int iwh=-2;iwh<=2;++iwh){
00149     for (int ise=13;ise<=14;++ise){
00150       int ist =4;
00151       DTChamberId chambid(iwh,ist,ise);
00152       vector<int> nmap = conf_map.getUntrackedParameter<vector<int> >(mapEntryName(chambid).c_str());
00153 //       std::cout << "  untracked vint32 wh" << chambid.wheel()
00154 //              << "st" << chambid.station()
00155 //              << "se" << chambid.sector() << " = { ";
00156       if(dttpgdebug)
00157         {
00158           std::cout << " Filling configuration for chamber : wh " << chambid.wheel() << 
00159             ", st " << chambid.station() << 
00160             ", se " << chambid.sector() << endl;
00161         }
00162       
00163       //fill the bti map
00164       for (int isl=1;isl<=3;isl++){
00165         int ncell = nmap[isl-1];
00166 //      std::cout << ncell <<" , ";
00167         for (int ibti=0;ibti<ncell;ibti++)
00168           {
00169             m_manager->setDTConfigBti(DTBtiId(chambid,isl,ibti+1),bticonf);
00170             if(dttpgdebug)
00171               std::cout << "Filling BTI config for chamber : wh " << chambid.wheel() << 
00172                 ", st " << chambid.station() << 
00173                 ", se " << chambid.sector() << 
00174                 "... sl " << isl << 
00175                 ", bti " << ibti+1 << endl;
00176           }     
00177       }
00178       
00179       // fill the traco map
00180       int ntraco = nmap[3];
00181 //       std::cout << ntraco << " }" << std::endl;
00182       for (int itraco=0;itraco<ntraco;itraco++)
00183         { 
00184           m_manager->setDTConfigTraco(DTTracoId(chambid,itraco+1),tracoconf);
00185           if(dttpgdebug)
00186             std::cout << "Filling TRACO config for chamber : wh " << chambid.wheel() << 
00187               ", st " << chambid.station() << 
00188               ", se " << chambid.sector() << 
00189               ", traco " << itraco+1 << endl;
00190         }     
00191       
00192       // fill TS & TrigUnit
00193       m_manager->setDTConfigTSTheta(chambid,tsthetaconf);
00194       m_manager->setDTConfigTSPhi(chambid,tsphiconf);
00195       m_manager->setDTConfigTrigUnit(chambid,trigunitconf);
00196 
00197       // fill LUTs
00198       m_manager->setDTConfigLUTs(chambid,lutconf);
00199       
00200     }
00201   }
00202   
00203   //loop on Sector Collectors
00204   for (int wh=-2;wh<=2;wh++)
00205     for (int se=1;se<=12;se++)
00206       m_manager->setDTConfigSectColl(DTSectCollId(wh,se),sectcollconf);
00207 
00208 }
00209 
00210 
00211 std::string DTConfigTrivialProducer::mapEntryName(const DTChamberId & chambid) const
00212 {
00213   int iwh = chambid.wheel();
00214   std::ostringstream os;
00215   os << "wh";
00216   if (iwh < 0) {
00217      os << 'm' << -iwh;
00218    } else {
00219      os << iwh;
00220   }
00221   os << "st" << chambid.station() << "se" << chambid.sector();
00222   return os.str();
00223 }