32 constexpr std::array<int, 10> s_quadrants = {{2, 3, 4, 5, 6, 7, 8, 9, 10, 11}};
35 constexpr
unsigned int kWheelOffset = 2;
36 constexpr std::array<int, 5> wheelTtu = {{3, 3, 2, 1, 1}};
41 m_useEventSetup{iConfig.getUntrackedParameter<
int>(
"UseEventSetup", 0)},
42 m_ttBits{iConfig.getParameter<std::vector<unsigned>>(
"BitNumbers")},
43 m_ttNames{iConfig.getParameter<std::vector<std::string>>(
"BitNames")},
44 m_rpcDigiLabel{iConfig.getParameter<
edm::InputTag>(
"RPCDigiLabel")},
45 m_rpcDigiToken{consumes<RPCDigiCollection>(m_rpcDigiLabel)},
46 m_useRPCSimLink{iConfig.getUntrackedParameter<
int>(
"UseRPCSimLink", 0)} {
52 m_configFile =
f1.fullPath();
55 LogTrace(
"RPCTechnicalTrigger") << m_rpcDigiLabel <<
'\n' << std::endl;
57 LogTrace(
"RPCTechnicalTrigger") <<
"\nConfiguration file used for UseEventSetup = 0 \n"
58 << m_configFile <<
'\n'
66 constexpr std::array<int, 3> boardIndex = {{1, 2, 3}};
67 constexpr std::array<int, 3> nWheels = {{2, 1, 2}};
74 m_ttuRbcLine[0] =
TTUEmulator(boardIndex[0], nWheels[0]);
75 m_ttuRbcLine[1] =
TTUEmulator(boardIndex[1], nWheels[1]);
76 m_ttuRbcLine[2] =
TTUEmulator(boardIndex[2], nWheels[2]);
81 produces<L1GtTechnicalTriggerRecord>();
82 consumes<edm::DetSetVector<RPCDigiSimLink>>(
edm::InputTag(
"simMuonRPCDigis",
"RPCDigiSimLink",
""));
101 std::unique_ptr<ProcessInputSignal> signal;
110 signal = std::make_unique<RBCProcessRPCDigis>(rpcGeometry, pIn);
113 iEvent.getByLabel(
"simMuonRPCDigis",
"RPCDigiSimLink", simIn);
120 signal = std::make_unique<RBCProcessRPCSimDigis>(rpcGeometry, simIn);
123 LogDebug(
"RPCTechnicalTrigger") <<
"signal object created" <<
'\n';
126 edm::LogError(
"RPCTechnicalTrigger") <<
"cannot read hardware configuration \n";
138 auto*
input = signal->retrievedata();
140 std::vector<L1GtTechnicalTrigger> ttVec(
m_ttBits.size());
143 std::bitset<5> triggerbits;
145 std::vector<std::unique_ptr<TTUResults>> serializedInfoLine1;
146 std::vector<std::unique_ptr<TTUResults>> serializedInfoLine2;
152 for (
auto firstSector : s_quadrants)
156 for (
auto const&
out :
m_ttu[
k].m_triggerBxVec)
157 serializedInfoLine1.emplace_back(std::make_unique<TTUResults>(
k,
out.m_bx,
out.m_trigger[0],
out.m_trigger[1]));
158 m_ttu[
k].clearTriggerResponse();
162 serializedInfoLine2.push_back(
163 std::make_unique<TTUResults>(
k,
out.m_bx,
out.m_trigger[0],
out.m_trigger[1],
out.m_wedge));
172 infoSize = serializedInfoLine1.size();
174 auto sortByBx = [](
auto& iLHS,
auto& iRHS) {
return iLHS->m_bx < iRHS->m_bx; };
175 std::sort(serializedInfoLine1.begin(), serializedInfoLine1.end(), sortByBx);
178 for (
auto& ttu : serializedInfoLine1) {
179 if (
abs(ttu->m_bx) <= 1)
180 std::cout <<
"RPCTechnicalTrigger> " << ttu->m_ttuidx <<
'\t' << ttu->m_bx <<
'\t' << ttu->m_trigWheel1 <<
'\t'
181 << ttu->m_trigWheel2 <<
'\n';
185 bool has_bx0 =
false;
188 bx = serializedInfoLine1[
k]->m_bx;
191 triggerbits.set(0, serializedInfoLine1[
k]->m_trigWheel2);
192 triggerbits.set(1, serializedInfoLine1[
k]->m_trigWheel1);
193 triggerbits.set(2, serializedInfoLine1[
k + 1]->m_trigWheel1);
194 triggerbits.set(3, serializedInfoLine1[
k + 2]->m_trigWheel1);
195 triggerbits.set(4, serializedInfoLine1[
k + 2]->m_trigWheel2);
197 bool five_wheels_OR = triggerbits.any();
217 infoSize = serializedInfoLine2.size();
219 std::sort(serializedInfoLine2.begin(), serializedInfoLine2.end(), sortByBx);
222 for (
auto& ttu : serializedInfoLine2) {
223 if (
abs(ttu->m_bx) <= 1)
224 std::cout <<
"RPCTechnicalTrigger> " << ttu->m_ttuidx <<
'\t' << ttu->m_bx <<
'\t' << ttu->m_trigWheel1 <<
'\t'
225 << ttu->m_trigWheel2 <<
'\t' << ttu->m_wedge <<
'\n';
229 auto ttuResultsByQuadrant =
convertToMap(serializedInfoLine2);
231 std::bitset<8> triggerCoincidence;
232 triggerCoincidence.reset();
236 triggerCoincidence.set(0,
result);
240 triggerCoincidence.set(1,
result);
244 triggerCoincidence.set(2,
result);
248 triggerCoincidence.set(3,
result);
252 triggerCoincidence.set(4,
result);
256 triggerCoincidence.set(5,
result);
260 triggerCoincidence.set(6,
result);
264 triggerCoincidence.set(7,
result);
266 bool five_wheels_OR = triggerCoincidence.any();
269 std::cout <<
"RPCTechnicalTrigger> pointing trigger: " << five_wheels_OR <<
'\n';
274 triggerCoincidence.reset();
280 LogDebug(
"RPCTechnicalTrigger") <<
"RPCTechnicalTrigger> end of event loop" << std::endl;
284 output->setGtTechnicalTrigger(ttVec);
289 LogDebug(
"RPCTechnicalTrigger") <<
"RPCTechnicalTrigger> end of event loop" << std::endl;
293 LogDebug(
"RPCTechnicalTrigger") <<
"RPCTechnicalTrigger::beginRun> starts" << std::endl;
305 edm::LogError(
"RPCTechnicalTrigger") <<
"can't find RBC/TTU BoardSpecsRcd" <<
'\n';
346 const std::vector<std::unique_ptr<TTUResults>>& ttuResults)
const {
347 std::map<int, TTUResults*> returnValue;
348 auto itr = ttuResults.begin();
350 while (
itr != ttuResults.end()) {
351 if ((*itr)->m_bx != 0) {
357 key = 1000 * ((*itr)->m_ttuidx + 1) + 1 * (*itr)->m_wedge;
358 returnValue[
key] =
itr->get();
368 std::map<int, TTUResults*>
const& ttuResultsByQuadrant)
const {
369 std::map<int, TTUResults*>::const_iterator
itr;
370 bool topRight(
false);
373 int indxW1 = wheelTtu[wheel1 + kWheelOffset];
374 int indxW2 = wheelTtu[wheel2 + kWheelOffset];
378 bool finalTrigger(
false);
379 int maxTopQuadrants = 4;
383 for (
auto firstSector : s_quadrants) {
384 key = 1000 * (indxW1) + firstSector;
386 itr = ttuResultsByQuadrant.find(
key);
387 if (
itr != ttuResultsByQuadrant.end())
388 topRight = (*itr).second->getTriggerForWheel(wheel1);
392 key = 1000 * (indxW2) + firstSector + 5;
394 itr = ttuResultsByQuadrant.find(
key);
396 if (
itr != ttuResultsByQuadrant.end())
397 botLeft = (*itr).second->getTriggerForWheel(wheel2);
401 finalTrigger |= (topRight && botLeft);
405 if (
k > maxTopQuadrants)
413 for (
auto firstSector : s_quadrants) {
414 key = 1000 * (indxW2) + firstSector;
416 itr = ttuResultsByQuadrant.find(
key);
417 if (
itr != ttuResultsByQuadrant.end())
418 topRight = (*itr).second->getTriggerForWheel(wheel1);
422 key = 1000 * (indxW1) + firstSector + 5;
424 itr = ttuResultsByQuadrant.find(
key);
426 if (
itr != ttuResultsByQuadrant.end())
427 botLeft = (*itr).second->getTriggerForWheel(wheel2);
431 finalTrigger |= (topRight && botLeft);
435 if (
k > maxTopQuadrants)
445 LogDebug(
"RPCTechnicalTrigger") <<
"RPCTechnicalTrigger::Printing TTU emulators info>" << std::endl;