File indexing completed on 2024-04-06 12:22:15
0001 #include "DataFormats/MuonDetId/interface/DTChamberId.h"
0002 #include "DataFormats/MuonDetId/interface/DTLayerId.h"
0003 #include "DataFormats/MuonDetId/interface/DTSuperLayerId.h"
0004 #include "L1TriggerConfig/DTTPGConfigProducers/src/DTConfigTrivialProducer.h"
0005 #include <ostream>
0006
0007 using std::cout;
0008 using std::endl;
0009 using std::unique_ptr;
0010 using std::vector;
0011
0012
0013
0014
0015 DTConfigTrivialProducer::DTConfigTrivialProducer(const edm::ParameterSet &ps) {
0016 setWhatProduced(this);
0017
0018
0019 m_ps = ps;
0020 m_manager = new DTConfigManager();
0021 m_tpgParams = new DTTPGParameters();
0022
0023
0024 edm::ParameterSet conf_ps = m_ps.getParameter<edm::ParameterSet>("DTTPGParameters");
0025 m_debug = conf_ps.getUntrackedParameter<bool>("Debug");
0026
0027 if (m_debug)
0028 cout << "DTConfigTrivialProducer::DTConfigTrivialProducer()" << endl;
0029
0030 m_manager->setDTTPGDebug(m_debug);
0031
0032
0033 bool tracoLutsFromDB = m_ps.getParameter<bool>("TracoLutsFromDB");
0034 bool useBtiAcceptParam = m_ps.getParameter<bool>("UseBtiAcceptParam");
0035
0036
0037 m_manager->setLutFromDB(tracoLutsFromDB);
0038 m_manager->setUseAcceptParam(useBtiAcceptParam);
0039 }
0040
0041 DTConfigTrivialProducer::~DTConfigTrivialProducer() {
0042 if (m_debug)
0043 cout << "DTConfigTrivialProducer::~DTConfigTrivialProducer()" << endl;
0044 }
0045
0046
0047
0048
0049
0050 std::unique_ptr<DTConfigManager> DTConfigTrivialProducer::produce(const DTConfigManagerRcd &iRecord) {
0051 if (m_debug)
0052 cout << "DTConfigTrivialProducer::produce()" << endl;
0053
0054 using namespace edm::es;
0055 buildManager();
0056
0057
0058
0059 std::unique_ptr<DTConfigManager> dtConfig = std::unique_ptr<DTConfigManager>(m_manager);
0060
0061 return dtConfig;
0062 }
0063
0064 void DTConfigTrivialProducer::buildManager() {
0065 if (m_debug)
0066 cout << "DTConfigTrivialProducer::buildManager()" << endl;
0067
0068
0069 edm::ParameterSet conf_ps = m_ps.getParameter<edm::ParameterSet>("DTTPGParameters");
0070 edm::ParameterSet conf_map = m_ps.getUntrackedParameter<edm::ParameterSet>("DTTPGMap");
0071 DTConfigSectColl sectcollconf(conf_ps.getParameter<edm::ParameterSet>("SectCollParameters"));
0072 edm::ParameterSet tups = conf_ps.getParameter<edm::ParameterSet>("TUParameters");
0073 DTConfigBti bticonf(tups.getParameter<edm::ParameterSet>("BtiParameters"));
0074 DTConfigTraco tracoconf(tups.getParameter<edm::ParameterSet>("TracoParameters"));
0075 DTConfigLUTs lutconf(tups.getParameter<edm::ParameterSet>("LutParameters"));
0076 DTConfigTSTheta tsthetaconf(tups.getParameter<edm::ParameterSet>("TSThetaParameters"));
0077 DTConfigTSPhi tsphiconf(tups.getParameter<edm::ParameterSet>("TSPhiParameters"));
0078 DTConfigTrigUnit trigunitconf(tups);
0079
0080 for (int iwh = -2; iwh <= 2; ++iwh) {
0081 for (int ist = 1; ist <= 4; ++ist) {
0082 for (int ise = 1; ise <= 12; ++ise) {
0083 DTChamberId chambid(iwh, ist, ise);
0084 vector<int> nmap = conf_map.getUntrackedParameter<vector<int>>(mapEntryName(chambid).c_str());
0085
0086 if (m_debug) {
0087 std::cout << " Filling configuration for chamber : wh " << chambid.wheel() << ", st " << chambid.station()
0088 << ", se " << chambid.sector() << endl;
0089 }
0090
0091
0092 for (int isl = 1; isl <= 3; isl++) {
0093 int ncell = nmap[isl - 1];
0094
0095 for (int ibti = 0; ibti < ncell; ibti++) {
0096 m_manager->setDTConfigBti(DTBtiId(chambid, isl, ibti + 1), bticonf);
0097 if (m_debug)
0098 std::cout << "Filling BTI config for chamber : wh " << chambid.wheel() << ", st " << chambid.station()
0099 << ", se " << chambid.sector() << "... sl " << isl << ", bti " << ibti + 1 << endl;
0100 }
0101 }
0102
0103
0104 int ntraco = nmap[3];
0105
0106 for (int itraco = 0; itraco < ntraco; itraco++) {
0107 m_manager->setDTConfigTraco(DTTracoId(chambid, itraco + 1), tracoconf);
0108 if (m_debug)
0109 std::cout << "Filling TRACO config for chamber : wh " << chambid.wheel() << ", st " << chambid.station()
0110 << ", se " << chambid.sector() << ", traco " << itraco + 1 << endl;
0111 }
0112
0113
0114 m_manager->setDTConfigTSTheta(chambid, tsthetaconf);
0115 m_manager->setDTConfigTSPhi(chambid, tsphiconf);
0116 m_manager->setDTConfigTrigUnit(chambid, trigunitconf);
0117
0118
0119 m_manager->setDTConfigLUTs(chambid, lutconf);
0120 m_manager->setLutFromDB(false);
0121 }
0122 }
0123 }
0124
0125 for (int iwh = -2; iwh <= 2; ++iwh) {
0126 for (int ise = 13; ise <= 14; ++ise) {
0127 int ist = 4;
0128 DTChamberId chambid(iwh, ist, ise);
0129 vector<int> nmap = conf_map.getUntrackedParameter<vector<int>>(mapEntryName(chambid).c_str());
0130
0131 if (m_debug) {
0132 std::cout << " Filling configuration for chamber : wh " << chambid.wheel() << ", st " << chambid.station()
0133 << ", se " << chambid.sector() << endl;
0134 }
0135
0136
0137 for (int isl = 1; isl <= 3; isl++) {
0138 int ncell = nmap[isl - 1];
0139
0140 for (int ibti = 0; ibti < ncell; ibti++) {
0141 m_manager->setDTConfigBti(DTBtiId(chambid, isl, ibti + 1), bticonf);
0142 if (m_debug)
0143 std::cout << "Filling BTI config for chamber : wh " << chambid.wheel() << ", st " << chambid.station()
0144 << ", se " << chambid.sector() << "... sl " << isl << ", bti " << ibti + 1 << endl;
0145 }
0146 }
0147
0148
0149 int ntraco = nmap[3];
0150
0151 for (int itraco = 0; itraco < ntraco; itraco++) {
0152 m_manager->setDTConfigTraco(DTTracoId(chambid, itraco + 1), tracoconf);
0153 if (m_debug)
0154 std::cout << "Filling TRACO config for chamber : wh " << chambid.wheel() << ", st " << chambid.station()
0155 << ", se " << chambid.sector() << ", traco " << itraco + 1 << endl;
0156 }
0157
0158
0159 m_manager->setDTConfigTSTheta(chambid, tsthetaconf);
0160 m_manager->setDTConfigTSPhi(chambid, tsphiconf);
0161 m_manager->setDTConfigTrigUnit(chambid, trigunitconf);
0162
0163
0164 m_manager->setDTConfigLUTs(chambid, lutconf);
0165 m_manager->setLutFromDB(false);
0166 }
0167 }
0168
0169
0170 for (int wh = -2; wh <= 2; wh++)
0171 for (int se = 1; se <= 12; se++)
0172 m_manager->setDTConfigSectColl(DTSectCollId(wh, se), sectcollconf);
0173
0174
0175 m_manager->setDTConfigPedestals(buildTrivialPedestals());
0176 }
0177
0178 DTConfigPedestals DTConfigTrivialProducer::buildTrivialPedestals() {
0179 int counts = m_ps.getParameter<int>("bxOffset");
0180 float fine = m_ps.getParameter<double>("finePhase");
0181
0182 if (m_debug)
0183 cout << "DTConfigTrivialProducer::buildPedestals()" << endl;
0184
0185
0186 for (int iwh = -2; iwh <= 2; ++iwh) {
0187 for (int ist = 1; ist <= 4; ++ist) {
0188 for (int ise = 1; ise <= 14; ++ise) {
0189 if (ise > 12 && ist != 4)
0190 continue;
0191
0192 DTChamberId chId(iwh, ist, ise);
0193 m_tpgParams->set(chId, counts, fine, DTTimeUnits::ns);
0194 }
0195 }
0196 }
0197
0198 DTConfigPedestals tpgPedestals;
0199 tpgPedestals.setUseT0(false);
0200 tpgPedestals.setES(m_tpgParams);
0201
0202 return tpgPedestals;
0203 }
0204
0205 std::string DTConfigTrivialProducer::mapEntryName(const DTChamberId &chambid) const {
0206 int iwh = chambid.wheel();
0207 std::ostringstream os;
0208 os << "wh";
0209 if (iwh < 0) {
0210 os << 'm' << -iwh;
0211 } else {
0212 os << iwh;
0213 }
0214 os << "st" << chambid.station() << "se" << chambid.sector();
0215 return os.str();
0216 }