18 #include <boost/property_tree/ptree.hpp>
19 #include <boost/property_tree/xml_parser.hpp>
37 auto inoct_sector = ((sector + 2) % 4);
38 auto mioct_number = ((sector + 2) / 4) % 8;
39 return std::make_pair(inoct_sector,mioct_number);
43 return ((30 + 4 * mioct) +
number) % 32;
47 auto inoct_sector = ((sector + 1) % 6);
48 auto mioct_number = ((sector + 1) / 6) % 8;
49 return std::make_pair(inoct_sector,mioct_number);
54 return ((47 + 6 * mioct) +
number) % 48;
57 auto inoct_sector = (sector % 3);
58 auto mioct_number = (sector / 3) % 8;
59 return std::make_pair(inoct_sector,mioct_number);
64 return ((0 + 3 * mioct) +
number) % 24;
74 std::array<std::map<std::string,std::vector<std::string>>,2>
lhs_index;
75 std::array<std::map<std::string,std::vector<std::string>>,2>
rhs_index;
82 std::string
make_pair(
const std::string& lhs,
const std::string& rhs)
const {
83 return lhs +
":" + rhs;
89 for(
const auto& region : side_regions.second){
90 auto split = region.find(
':');
91 auto left = region.substr(0,
split);
92 auto right = region.substr(
split+1,std::string::npos);
93 lhs_index[side_regions.first][left].push_back(right);
94 rhs_index[side_regions.first][right].push_back(left);
99 std::vector<std::string>
get_lhs_keys(
const std::string& dettype,
int roi,
int sector)
const {
100 std::vector<std::string>
r;
105 std::vector<std::string>
get_rhs_keys(
const std::string& dettype,
int roi,
int sector)
const {
106 std::vector<std::string>
r;
112 std::vector<std::string>
r;
116 for(
const auto&
rr :
x->second){
124 for(
const auto&
rr :
x->second){
140 for(
const boost::property_tree::ptree::value_type &
x: topEle) {
142 std::string topElementName =
x.first;
145 if (topElementName !=
"LUT")
continue;
150 unsigned left_mod = 32;
151 unsigned right_mod = 32;
152 if (SectorId1[0] ==
'E') left_mod = 48;
153 if (SectorId1[0] ==
'F') left_mod = 24;
154 if (SectorId2[0] ==
'E') right_mod = 48;
155 if (SectorId2[0] ==
'F') right_mod = 24;
157 std::string snum_left = std::string(1,SectorId1[1])+std::string(1,SectorId1[2]);
158 int sec_left = std::stoi(snum_left) % left_mod;
160 std::string snum_right = std::string(1,SectorId2[1])+std::string(1,SectorId2[2]);
161 int sec_right = std::stoi(snum_right) % right_mod;
164 int active_side = (
side ==
"C") ? 0 : 1;
166 std::string System1 = SectorId1.substr(0,1);
167 std::string System2 = SectorId2.substr(0,1);
169 for(
const boost::property_tree::ptree::value_type &
z:
lut) {
170 std::string menuElementName =
z.first;
171 if(menuElementName!=
"Element" && menuElementName!=
"BBElement")
continue;
175 auto lhs_key =
make_key(System1,sec_left,roi1);
176 auto rhs_key =
make_key(System2,sec_right,roi2);
177 auto region =
make_pair(lhs_key,rhs_key);
190 m_l1topoLUT(nullptr),
200 : m_overlapHelper(std::move(o.m_overlapHelper)) {}
217 m_ptEncoding = std::vector<std::map<int, int> >(3, std::map<int, int>());
227 auto rpcPtValues = exMU->knownRpcPtValues();
228 auto tgcPtValues = exMU->knownTgcPtValues();
229 for (
unsigned i=0;
i<rpcPtValues.size();
i++){
232 for (
unsigned i=0;
i<tgcPtValues.size();
i++){
243 std::map<std::string,std::vector<std::pair<std::shared_ptr<LVL1MUONIF::Lvl1MuSectorLogicDataPhase1>,
unsigned> > > buckets;
252 for (
size_t isub=0;isub<2;isub++)
254 if (isub !=
size_t(
m_side))
continue;
257 std::shared_ptr<LVL1MUONIF::Lvl1MuSectorLogicDataPhase1> sectorData =
inputs->getSectorLogicDataPtr(isys, isub, isec,
bcid);
258 if (!sectorData)
continue;
260 for (
unsigned int icand=0;icand<LVL1MUONIF::NCAND[isys];icand++)
263 std::string sectorName=
"";
264 if (isys == 0) sectorName=
"B";
265 else if (isys == 1) sectorName=
"E";
266 else if (isys == 2) sectorName=
"F";
268 int roiID = sectorData->
roi(icand);
269 if (roiID < 0)
continue;
270 int ptword = sectorData->
pt(icand);
271 if (ptword < 0)
continue;
274 sectorData->
veto(icand,0);
279 if(
std::count(
rr.begin(),
rr.end(),
'B') == 2 && isys == 0 && sectorData->
ovl(icand) == 0 )
continue;
280 buckets[
rr].push_back(std::make_pair(sectorData, icand));
287 for(
auto candidate_vector : buckets){
290 unsigned i_notRemove = 0;
292 for (
unsigned i=0;
i<candidate_vector.second.size();
i++){
293 if( candidate_vector.second[
i].first->veto(candidate_vector.second[
i].second)==1 )
continue;
294 int pt = candidate_vector.second[
i].first->pt(candidate_vector.second[
i].second);
302 for (
unsigned i=0;
i<candidate_vector.second.size();
i++)
304 if( candidate_vector.second[
i].first->veto(candidate_vector.second[
i].second)==1 )
continue;
305 candidate_vector.second[
i].first->veto(candidate_vector.second[
i].second, (
i==i_notRemove)?0:1 );
321 for (
unsigned short isub=0;isub<2;isub++)
323 if (isub != (
unsigned short)(
m_side))
continue;
324 std::shared_ptr<LVL1MUONIF::Lvl1MuSectorLogicDataPhase1> sectorData =
inputs->getSectorLogicDataPtr(isys, isub, isec,
bcid);
325 if (!sectorData)
continue;
328 std::stringstream sectorName;
329 if (isys == 0) sectorName<<
"B";
330 else if (isys == 1) sectorName<<
"E";
331 else if (isys == 2) sectorName<<
"F";
336 int sectorNumber=isec;
338 if (sectorNumber < 10) sectorName <<
"0";
339 sectorName << sectorNumber;
344 else sectorName <<
"C";
345 if (isec < 10) sectorName <<
"0";
350 for (
unsigned int icand=0;icand<LVL1MUONIF::NCAND[isys];icand++)
353 int roiID = sectorData->
roi(icand);
354 if (roiID < 0)
continue;
355 int ptword = sectorData->
pt(icand);
356 if (ptword < 0)
continue;
365 std::stringstream
err;
366 err <<
"Couldn't decode L1Topo coordinates: Side = " << isub <<
", subsystem = " << isys <<
", sector = " << isec <<
", roi = " << roiID;
375 if (last_enc !=
m_ptEncoding[isys].rend() && ptword > last_enc->first)
381 std::stringstream
err;
382 err <<
"Pt threshold not found in L1Topo encoding. Thr: " << ptword <<
", subsys: " << isys;
386 else ptValue=enc->second;
390 std::stringstream
err;
391 err <<
"Default value returned for pt encoding. Thr: " << ptword <<
", isys: " << isys;
399 unsigned int mioctID = 0;
400 unsigned int ptCode=0;
406 (
unsigned int)ptword,
408 (
unsigned int)ptValue,
422 sectorData->
ovl(icand));
425 sectorData->
goodmf(icand),
426 sectorData->
charge(icand));