32 constexpr std::array<int,10> s_quadrants = { {2,3,4,5,6,7,8,9,10,11} };
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")},
62 <<
"\nConfiguration file used for UseEventSetup = 0 \n" <<
m_configFile <<
'\n' 70 constexpr std::array<int,3> boardIndex={{1,2,3}};
71 constexpr std::array<int,3> nWheels = { {2,1,2} };
85 produces<L1GtTechnicalTriggerRecord>();
86 consumes<edm::DetSetVector<RPCDigiSimLink> >(
edm::InputTag(
"simMuonRPCDigis",
"RPCDigiSimLink",
""));
110 std::unique_ptr<ProcessInputSignal> signal;
114 edm::LogError(
"RPCTechnicalTrigger") <<
"can't find RPCDigiCollection with label: " 120 signal = std::make_unique<RBCProcessRPCDigis>( rpcGeometry, pIn );
124 iEvent.
getByLabel(
"simMuonRPCDigis",
"RPCDigiSimLink", simIn);
127 edm::LogError(
"RPCTechnicalTrigger") <<
"can't find RPCDigiCollection with label: " 132 signal = std::make_unique<RBCProcessRPCSimDigis>( rpcGeometry, simIn );
135 LogDebug(
"RPCTechnicalTrigger") <<
"signal object created" <<
'\n';
138 edm::LogError(
"RPCTechnicalTrigger") <<
"cannot read hardware configuration \n";
143 status = signal->next();
150 auto*
input = signal->retrievedata();
152 std::vector<L1GtTechnicalTrigger> ttVec(
m_ttBits.size() );
155 std::bitset<5> triggerbits;
157 std::vector<std::unique_ptr<TTUResults>> serializedInfoLine1;
158 std::vector<std::unique_ptr<TTUResults>> serializedInfoLine2;
165 for(
auto firstSector : s_quadrants)
169 for(
auto const&
out :
m_ttu[
k].m_triggerBxVec)
170 serializedInfoLine1.emplace_back( std::make_unique<TTUResults>(
k,
out.m_bx,
out.m_trigger[0],
out.m_trigger[1] ) );
171 m_ttu[
k].clearTriggerResponse();
175 serializedInfoLine2.push_back( std::make_unique<TTUResults>(
k,
189 infoSize = serializedInfoLine1.size();
191 auto sortByBx = [](
auto& iLHS,
auto& iRHS) {
192 return iLHS->m_bx < iRHS->m_bx;
194 std::sort( serializedInfoLine1.begin(), serializedInfoLine1.end(), sortByBx );
197 for(
auto& ttu : serializedInfoLine1) {
198 if (
abs( ttu->m_bx ) <= 1 )
200 << ttu->m_ttuidx <<
'\t' 202 << ttu->m_trigWheel1 <<
'\t' 203 << ttu->m_trigWheel2 <<
'\n';
207 bool has_bx0 =
false;
211 bx = serializedInfoLine1[
k]->m_bx;
215 triggerbits.set(0, serializedInfoLine1[
k]->m_trigWheel2);
216 triggerbits.set(1, serializedInfoLine1[
k]->m_trigWheel1);
217 triggerbits.set(2, serializedInfoLine1[
k+1]->m_trigWheel1);
218 triggerbits.set(3, serializedInfoLine1[
k+2]->m_trigWheel1);
219 triggerbits.set(4, serializedInfoLine1[
k+2]->m_trigWheel2);
221 bool five_wheels_OR = triggerbits.any();
240 infoSize = serializedInfoLine2.size();
242 std::sort( serializedInfoLine2.begin(), serializedInfoLine2.end(), sortByBx );
245 for(
auto& ttu : serializedInfoLine2) {
246 if (
abs ( ttu->m_bx ) <= 1 )
248 << ttu->m_ttuidx <<
'\t' 250 << ttu->m_trigWheel1 <<
'\t' 251 << ttu->m_trigWheel2 <<
'\t' 252 << ttu->m_wedge <<
'\n';
256 auto ttuResultsByQuadrant =
convertToMap( serializedInfoLine2 );
258 std::bitset<8> triggerCoincidence;
259 triggerCoincidence.reset();
263 triggerCoincidence.set(0, result );
267 triggerCoincidence.set(1, result );
271 triggerCoincidence.set(2, result );
275 triggerCoincidence.set(3, result );
279 triggerCoincidence.set(4, result );
283 triggerCoincidence.set(5, result );
287 triggerCoincidence.set(6, result );
291 triggerCoincidence.set(7, result );
293 bool five_wheels_OR = triggerCoincidence.any();
295 if (
m_verbosity )
std::cout <<
"RPCTechnicalTrigger> pointing trigger: " << five_wheels_OR <<
'\n';
299 triggerCoincidence.reset();
305 LogDebug(
"RPCTechnicalTrigger") <<
"RPCTechnicalTrigger> end of event loop" << std::endl;
310 output->setGtTechnicalTrigger(ttVec);
315 LogDebug(
"RPCTechnicalTrigger") <<
"RPCTechnicalTrigger> end of event loop" << std::endl;
321 LogDebug(
"RPCTechnicalTrigger") <<
"RPCTechnicalTrigger::beginRun> starts" << std::endl;
334 edm::LogError(
"RPCTechnicalTrigger") <<
"can't find RBC/TTU BoardSpecsRcd" <<
'\n';
380 std::map<int,RPCTechnicalTrigger::TTUResults*>
383 std::map<int,TTUResults*> returnValue;
384 auto itr = ttuResults.begin();
386 while ( itr != ttuResults.end() ) {
388 if ( (*itr)->m_bx != 0 ) {
394 key = 1000 * ( (*itr)->m_ttuidx + 1 ) + 1*(*itr)->m_wedge;
395 returnValue[ key ] = itr->get();
407 std::map<int, TTUResults*>::const_iterator itr;
408 bool topRight(
false);
411 int indxW1 = wheelTtu[wheel1+kWheelOffset];
412 int indxW2 = wheelTtu[wheel2+kWheelOffset];
416 bool finalTrigger(
false);
417 int maxTopQuadrants = 4;
421 for(
auto firstSector : s_quadrants) {
423 key = 1000 * ( indxW1 ) + firstSector;
425 itr = ttuResultsByQuadrant.find( key );
426 if ( itr != ttuResultsByQuadrant.end() )
427 topRight = (*itr).second->getTriggerForWheel(wheel1);
431 key = 1000 * ( indxW2 ) + firstSector + 5;
433 itr = ttuResultsByQuadrant.find( key );
435 if ( itr != ttuResultsByQuadrant.end() )
436 botLeft = (*itr).second->getTriggerForWheel(wheel2);
440 finalTrigger |= ( topRight && botLeft );
444 if ( k > maxTopQuadrants)
453 for(
auto firstSector : s_quadrants) {
455 key = 1000 * ( indxW2 ) + firstSector;
457 itr = ttuResultsByQuadrant.find( key );
458 if ( itr != ttuResultsByQuadrant.end() )
459 topRight = (*itr).second->getTriggerForWheel(wheel1);
463 key = 1000 * ( indxW1 ) + firstSector + 5;
465 itr = ttuResultsByQuadrant.find( key );
467 if ( itr != ttuResultsByQuadrant.end() )
468 botLeft = (*itr).second->getTriggerForWheel(wheel2);
472 finalTrigger |= ( topRight && botLeft );
476 if ( k > maxTopQuadrants)
490 LogDebug(
"RPCTechnicalTrigger") <<
"RPCTechnicalTrigger::Printing TTU emulators info>" << std::endl;
void beginRun(edm::Run const &, const edm::EventSetup &) final
T getUntrackedParameter(std::string const &, T const &) const
bool searchCoincidence(int, int, std::map< int, TTUResults * > const &ttuResultsByQuandrant) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
std::unique_ptr< TTUConfigurator > m_readConfig
const edm::InputTag m_rpcDigiLabel
const int m_useRPCSimLink
bool getByToken(EDGetToken token, Handle< PROD > &result) const
~RPCTechnicalTrigger() override
std::array< TTUEmulator, kMaxTtuBoards > m_ttuRbcLine
const int m_useEventSetup
static std::string const input
#define DEFINE_FWK_MODULE(type)
RPCTechnicalTrigger(const edm::ParameterSet &)
Abs< T >::type abs(const T &t)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
const TTUBoardSpecs * m_ttuspecs
std::array< TTUEmulator, kMaxTtuBoards > m_ttu
const edm::EDGetTokenT< RPCDigiCollection > m_rpcDigiToken
const std::vector< unsigned > m_ttBits
const RBCBoardSpecs * m_rbcspecs
const std::vector< std::string > m_ttNames
T const * product() const
std::map< int, TTUResults * > convertToMap(const std::vector< std::unique_ptr< TTUResults >> &) const
void produce(edm::Event &, const edm::EventSetup &) override