File indexing completed on 2024-04-06 12:21:03
0001 #include <iostream>
0002 #include <sstream>
0003 #include <string>
0004
0005 #include "FWCore/Framework/interface/Event.h"
0006 #include "FWCore/Framework/interface/EventSetup.h"
0007 #include "FWCore/Framework/interface/ConsumesCollector.h"
0008 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0009 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0010
0011 #include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h"
0012 #include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConfiguration.h"
0013 #include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConstants.h"
0014 #include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFTypes.h"
0015 #include "L1Trigger/L1TMuonEndCapPhase2/interface/SectorProcessor.h"
0016 #include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPrimitives.h"
0017 #include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPCollectors.h"
0018 #include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPCollector.h"
0019 #include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPCollector.h"
0020 #include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPCollector.h"
0021 #include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPCollector.h"
0022 #include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPCollector.h"
0023
0024 #include "L1Trigger/L1TMuonEndCapPhase2/interface/TrackFinder.h"
0025
0026 using namespace emtf::phase2;
0027
0028 TrackFinder::TrackFinder(const edm::ParameterSet& i_config, edm::ConsumesCollector&& i_consumes_collector)
0029 : context_(i_config, i_consumes_collector), tp_collectors_(), sector_processors_() {
0030
0031
0032
0033
0034
0035 if (this->context_.config_.csc_en_) {
0036 tp_collectors_.push_back(std::make_unique<CSCTPCollector>(context_, i_consumes_collector));
0037 }
0038
0039 if (this->context_.config_.rpc_en_) {
0040 tp_collectors_.push_back(std::make_unique<RPCTPCollector>(context_, i_consumes_collector));
0041 }
0042
0043 if (this->context_.config_.gem_en_) {
0044 tp_collectors_.push_back(std::make_unique<GEMTPCollector>(context_, i_consumes_collector));
0045 }
0046
0047 if (this->context_.config_.me0_en_) {
0048 tp_collectors_.push_back(std::make_unique<ME0TPCollector>(context_, i_consumes_collector));
0049 }
0050
0051 if (this->context_.config_.ge0_en_) {
0052 tp_collectors_.push_back(std::make_unique<GE0TPCollector>(context_, i_consumes_collector));
0053 }
0054
0055
0056 for (unsigned int endcap = kMinEndcap; endcap <= kMaxEndcap; ++endcap) {
0057 for (unsigned int sector = kMinTrigSector; sector <= kMaxTrigSector; ++sector) {
0058 sector_processors_.push_back(std::make_unique<SectorProcessor>(context_, endcap, sector));
0059 }
0060 }
0061 }
0062
0063 TrackFinder::~TrackFinder() {
0064
0065 }
0066
0067 void TrackFinder::process(
0068
0069 const edm::Event& i_event,
0070 const edm::EventSetup& i_event_setup,
0071
0072 EMTFHitCollection& out_hits,
0073 EMTFTrackCollection& out_tracks,
0074 EMTFInputCollection& out_inputs) {
0075
0076
0077
0078
0079 out_hits.clear();
0080 out_tracks.clear();
0081 out_inputs.clear();
0082
0083
0084
0085
0086
0087 context_.update(i_event, i_event_setup);
0088
0089
0090
0091
0092
0093
0094 std::vector<int> bx_sequence;
0095
0096 {
0097 auto min_bx = this->context_.config_.min_bx_;
0098 auto delay_bx = this->context_.config_.bx_window_ - 1;
0099 auto max_bx = this->context_.config_.max_bx_ + delay_bx;
0100
0101 for (int bx = min_bx; bx <= max_bx; ++bx) {
0102 bx_sequence.push_back(bx);
0103 }
0104 }
0105
0106
0107 BXTPCMap bx_tpc_map;
0108
0109 for (auto& tp_collector : tp_collectors_) {
0110 tp_collector->collect(i_event, bx_tpc_map);
0111 }
0112
0113
0114 if (this->context_.config_.verbosity_ > 4) {
0115 int n_tp = 0;
0116
0117
0118 for (const auto& bx : bx_sequence) {
0119
0120 auto bx_tpc_map_it = bx_tpc_map.find(bx);
0121 auto bx_tpc_map_end = bx_tpc_map.end();
0122
0123
0124 if (bx_tpc_map_it == bx_tpc_map_end) {
0125 continue;
0126 }
0127
0128
0129 auto& bx_tpc = bx_tpc_map_it->second;
0130
0131
0132 if (bx_tpc.empty()) {
0133 continue;
0134 }
0135
0136
0137 edm::LogInfo("L1TEMTFpp") << "==========================================================================="
0138 << std::endl;
0139 edm::LogInfo("L1TEMTFpp") << "Begin TPC BX " << bx << " Dump" << std::endl;
0140 edm::LogInfo("L1TEMTFpp") << "---------------------------------------------------------------------------"
0141 << std::endl;
0142
0143 n_tp += bx_tpc.size();
0144
0145 for (const auto& tp_entry : bx_tpc) {
0146 tp_entry.tp_.print(std::cout);
0147
0148 edm::LogInfo("L1TEMTFpp") << "---------------------------------------------------------------------------"
0149 << std::endl;
0150 }
0151
0152 edm::LogInfo("L1TEMTFpp") << "End TPC BX " << bx << " Dump" << std::endl;
0153 edm::LogInfo("L1TEMTFpp") << "==========================================================================="
0154 << std::endl;
0155 }
0156
0157
0158 if (n_tp > 0) {
0159 edm::LogInfo("L1TEMTFpp") << "Num of TriggerPrimitive: " << n_tp << std::endl;
0160 edm::LogInfo("L1TEMTFpp") << "==========================================================================="
0161 << std::endl;
0162 }
0163 }
0164
0165
0166
0167
0168
0169
0170 for (auto& sector_processor : sector_processors_) {
0171 sector_processor->configureEvent(i_event);
0172 }
0173
0174
0175 for (const auto& bx : bx_sequence) {
0176
0177 auto bx_tpc_map_it = bx_tpc_map.find(bx);
0178 auto bx_tpc_map_end = bx_tpc_map.end();
0179
0180 TPCollection* bx_tpc_ptr = nullptr;
0181
0182 if (bx_tpc_map_it != bx_tpc_map_end) {
0183 bx_tpc_ptr = &(bx_tpc_map_it->second);
0184 }
0185
0186
0187 for (auto& sector_processor : sector_processors_) {
0188
0189 sector_processor->configureBx(bx);
0190
0191
0192 if (bx_tpc_ptr != nullptr) {
0193 for (const auto& tp_entry : *bx_tpc_ptr) {
0194 const auto& tp = tp_entry.tp_;
0195 const auto& tp_info = tp_entry.info_;
0196
0197 sector_processor->select(tp, tp_info);
0198 }
0199 }
0200
0201
0202 sector_processor->process(out_hits, out_tracks, out_inputs);
0203 }
0204
0205
0206 if (bx_tpc_ptr != nullptr) {
0207 bx_tpc_map.erase(bx_tpc_map_it);
0208 }
0209 }
0210
0211
0212 bx_tpc_map.clear();
0213 }
0214
0215 void TrackFinder::onJobBegin() {
0216
0217 }
0218
0219 void TrackFinder::onJobEnd() {
0220
0221 }