File indexing completed on 2024-04-06 12:22:16
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #include <iostream>
0021
0022
0023 #include "CondTools/L1Trigger/interface/L1ConfigOnlineProdBase.h"
0024
0025 #include "CondFormats/L1TObjects/interface/L1MuDTTFMasks.h"
0026 #include "CondFormats/DataRecord/interface/L1MuDTTFMasksRcd.h"
0027
0028
0029
0030
0031
0032 class DTTFMasksOnlineProd : public L1ConfigOnlineProdBase<L1MuDTTFMasksRcd, L1MuDTTFMasks> {
0033 public:
0034 DTTFMasksOnlineProd(const edm::ParameterSet&);
0035 ~DTTFMasksOnlineProd() override;
0036
0037 std::unique_ptr<L1MuDTTFMasks> newObject(const std::string& objectKey) override;
0038
0039 private:
0040
0041 };
0042
0043
0044
0045
0046 DTTFMasksOnlineProd::DTTFMasksOnlineProd(const edm::ParameterSet& iConfig)
0047 : L1ConfigOnlineProdBase<L1MuDTTFMasksRcd, L1MuDTTFMasks>(iConfig) {
0048
0049
0050
0051
0052 }
0053
0054 DTTFMasksOnlineProd::~DTTFMasksOnlineProd() {
0055
0056
0057 }
0058
0059 std::unique_ptr<L1MuDTTFMasks> DTTFMasksOnlineProd::newObject(const std::string& objectKey) {
0060 auto pDTTFMasks = std::make_unique<L1MuDTTFMasks>();
0061
0062 pDTTFMasks->reset();
0063
0064 std::string dttfSchema = "CMS_DT_TF";
0065
0066
0067 std::vector<std::string> crateMaskColumns;
0068 crateMaskColumns.push_back("WEDGE_CRATE_1");
0069 crateMaskColumns.push_back("WEDGE_CRATE_2");
0070 crateMaskColumns.push_back("WEDGE_CRATE_3");
0071 crateMaskColumns.push_back("WEDGE_CRATE_4");
0072 crateMaskColumns.push_back("WEDGE_CRATE_5");
0073 crateMaskColumns.push_back("WEDGE_CRATE_6");
0074 crateMaskColumns.push_back("WEDGE_CRATE_1_E");
0075 crateMaskColumns.push_back("WEDGE_CRATE_2_E");
0076 crateMaskColumns.push_back("WEDGE_CRATE_3_E");
0077 crateMaskColumns.push_back("WEDGE_CRATE_4_E");
0078 crateMaskColumns.push_back("WEDGE_CRATE_5_E");
0079 crateMaskColumns.push_back("WEDGE_CRATE_6_E");
0080
0081 l1t::OMDSReader::QueryResults crateMaskResults = m_omdsReader.basicQuery(crateMaskColumns,
0082 dttfSchema,
0083 "DTTF_RUN_SETTINGS",
0084 "DTTF_RUN_SETTINGS.ID",
0085 m_omdsReader.singleAttribute(objectKey));
0086
0087 if (crateMaskResults.queryFailed() || crateMaskResults.numberRows() != 1)
0088 {
0089 edm::LogError("L1-O2O") << "Problem with L1MuDTTFMasks key " << objectKey;
0090 return std::unique_ptr<L1MuDTTFMasks>();
0091 }
0092
0093
0094 unsigned long crateMaskL[6];
0095 unsigned long crateMaskR[6];
0096 unsigned long krateMaskL[6];
0097 unsigned long krateMaskR[6];
0098 for (int icrate = 0; icrate < 6; ++icrate) {
0099 std::string crateMask;
0100 crateMaskResults.fillVariable(crateMaskColumns[icrate], crateMask);
0101 char* pEnd;
0102 crateMaskL[icrate] = std::strtol(crateMask.c_str(), &pEnd, 16);
0103 crateMaskR[icrate] = std::strtol(pEnd, (char**)nullptr, 16);
0104
0105 crateMaskResults.fillVariable(crateMaskColumns[icrate + 6], crateMask);
0106 krateMaskL[icrate] = std::strtol(crateMask.c_str(), &pEnd, 16);
0107 krateMaskR[icrate] = std::strtol(pEnd, (char**)nullptr, 16);
0108
0109 std::cout << "Crate " << icrate << " masks"
0110 << " L: " << std::hex << crateMaskL[icrate] << " " << std::hex << krateMaskL[icrate] << " R: " << std::hex
0111 << crateMaskR[icrate] << " " << std::hex << krateMaskR[icrate] << std::endl;
0112 }
0113
0114
0115 std::string sectorNames[12] = {"R", "L", "R", "L", "L", "R", "L", "R", "R", "L", "R", "L"};
0116
0117
0118 int crateNumbers[12] = {3, 3, 4, 4, 5, 5, 2, 2, 1, 1, 0, 0};
0119
0120
0121 int wheelNumbers[6] = {-3, -2, -1, 1, 2, 3};
0122
0123
0124 std::string wheelNames[6] = {"N2", "N1", "N0", "P0", "P1", "P2"};
0125
0126
0127 std::map<std::string, unsigned int> crateMaskBitmap;
0128 crateMaskBitmap.insert(std::make_pair("N2", 24));
0129 crateMaskBitmap.insert(std::make_pair("N1", 20));
0130 crateMaskBitmap.insert(std::make_pair("N0", 16));
0131 crateMaskBitmap.insert(std::make_pair("P0", 8));
0132 crateMaskBitmap.insert(std::make_pair("P1", 4));
0133 crateMaskBitmap.insert(std::make_pair("P2", 0));
0134
0135 std::map<std::string, unsigned int> krateMaskBitmap;
0136 krateMaskBitmap.insert(std::make_pair("N2", 16));
0137 krateMaskBitmap.insert(std::make_pair("N1", 12));
0138 krateMaskBitmap.insert(std::make_pair("P0", 8));
0139 krateMaskBitmap.insert(std::make_pair("P1", 4));
0140 krateMaskBitmap.insert(std::make_pair("P2", 0));
0141
0142
0143 for (int isc = 0; isc < 12; ++isc) {
0144 int crateNumber = crateNumbers[isc];
0145 unsigned long crateMask = crateMaskL[crateNumber];
0146 if (sectorNames[isc] == "R")
0147 crateMask = crateMaskR[crateNumber];
0148 unsigned long krateMask = krateMaskL[crateNumber];
0149 if (sectorNames[isc] == "R")
0150 krateMask = krateMaskR[crateNumber];
0151 std::cout << "isc " << isc << " icr " << crateNumber << std::endl;
0152
0153
0154 for (int iwh = 0; iwh < 6; ++iwh) {
0155 std::string sectorWheelName = sectorNames[isc] + wheelNames[iwh];
0156
0157 unsigned int maskBit = 30;
0158 std::map<std::string, unsigned int>::const_iterator itr = crateMaskBitmap.find(wheelNames[iwh]);
0159 if (itr != crateMaskBitmap.end())
0160 maskBit = itr->second;
0161
0162 unsigned long phtfEnabled = (crateMask >> maskBit) & 0xF;
0163
0164 if (wheelNames[iwh] == "P2")
0165 phtfEnabled += (crateMask >> 24) & 0x10;
0166 if (wheelNames[iwh] == "N2")
0167 phtfEnabled += (crateMask >> 25) & 0x10;
0168
0169 std::cout << "Bits " << std::dec << maskBit << " (" << sectorWheelName << ") of mask " << std::hex << crateMask
0170 << " is " << std::hex << phtfEnabled << std::endl;
0171
0172 int nwh = wheelNumbers[iwh];
0173
0174 unsigned long chmask = phtfEnabled & 0x1;
0175 std::cout << " INREC_CHDIS_ST1 " << 1 - chmask;
0176 pDTTFMasks->set_inrec_chdis_st1(nwh, isc, 1 - chmask);
0177 chmask = (phtfEnabled >> 1) & 0x1;
0178 std::cout << " INREC_CHDIS_ST2 " << 1 - chmask;
0179 pDTTFMasks->set_inrec_chdis_st2(nwh, isc, 1 - chmask);
0180 chmask = (phtfEnabled >> 2) & 0x1;
0181 std::cout << " INREC_CHDIS_ST3 " << 1 - chmask;
0182 pDTTFMasks->set_inrec_chdis_st3(nwh, isc, 1 - chmask);
0183 chmask = (phtfEnabled >> 3) & 0x1;
0184 std::cout << " INREC_CHDIS_ST4 " << 1 - chmask;
0185 pDTTFMasks->set_inrec_chdis_st4(nwh, isc, 1 - chmask);
0186 chmask = (phtfEnabled >> 4) & 0x1;
0187 std::cout << " INREC_CHDIS_CSC " << 1 - chmask << std::endl;
0188 pDTTFMasks->set_inrec_chdis_csc(nwh, isc, 1 - chmask);
0189
0190 if (wheelNames[iwh] == "N0")
0191 continue;
0192
0193 maskBit = 20;
0194 itr = krateMaskBitmap.find(wheelNames[iwh]);
0195 if (itr != krateMaskBitmap.end())
0196 maskBit = itr->second;
0197
0198 unsigned long ettfEnabled = (krateMask >> maskBit) & 0x7;
0199
0200 std::cout << "Bits " << std::dec << maskBit << " (" << sectorWheelName << ") of mask " << std::hex << krateMask
0201 << " is " << std::hex << ettfEnabled << std::endl;
0202
0203 chmask = ettfEnabled & 0x1;
0204 std::cout << " ETSOC_CHDIS_ST1 " << 1 - chmask;
0205 pDTTFMasks->set_etsoc_chdis_st1(nwh, isc, 1 - chmask);
0206 chmask = (ettfEnabled >> 1) & 0x1;
0207 std::cout << " ETSOC_CHDIS_ST2 " << 1 - chmask;
0208 pDTTFMasks->set_etsoc_chdis_st2(nwh, isc, 1 - chmask);
0209 chmask = (ettfEnabled >> 2) & 0x1;
0210 std::cout << " ETSOC_CHDIS_ST3 " << 1 - chmask << std::endl;
0211 pDTTFMasks->set_etsoc_chdis_st3(nwh, isc, 1 - chmask);
0212 }
0213 }
0214
0215 return pDTTFMasks;
0216 }
0217
0218
0219
0220
0221 DEFINE_FWK_EVENTSETUP_MODULE(DTTFMasksOnlineProd);