CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
emtf::phase2::TrackFinder Class Reference

#include <TrackFinder.h>

Public Member Functions

void onJobBegin ()
 
void onJobEnd ()
 
void process (const edm::Event &, const edm::EventSetup &, EMTFHitCollection &, EMTFTrackCollection &, EMTFInputCollection &)
 
 TrackFinder (const edm::ParameterSet &, edm::ConsumesCollector &&)
 
 ~TrackFinder ()
 

Private Attributes

EMTFContext context_
 
std::vector< std::unique_ptr< SectorProcessor > > sector_processors_
 
std::vector< std::unique_ptr< TPCollector > > tp_collectors_
 

Detailed Description

Definition at line 10 of file TrackFinder.h.

Constructor & Destructor Documentation

◆ TrackFinder()

TrackFinder::TrackFinder ( const edm::ParameterSet i_config,
edm::ConsumesCollector &&  i_consumes_collector 
)
explicit

Definition at line 28 of file TrackFinder.cc.

References emtf::phase2::EMTFContext::config_, context_, emtf::phase2::EMTFConfiguration::csc_en_, makeMuonMisalignmentScenario::endcap, emtf::phase2::EMTFConfiguration::ge0_en_, emtf::phase2::EMTFConfiguration::gem_en_, emtf::phase2::kMaxEndcap, emtf::phase2::kMaxTrigSector, emtf::phase2::kMinEndcap, emtf::phase2::kMinTrigSector, emtf::phase2::EMTFConfiguration::me0_en_, emtf::phase2::EMTFConfiguration::rpc_en_, nano_mu_digi_cff::sector, sector_processors_, and tp_collectors_.

29  : context_(i_config, i_consumes_collector), tp_collectors_(), sector_processors_() {
30  // ===========================================================================
31  // Emulation Setup
32  // ===========================================================================
33 
34  // Register Trigger Primitives
35  if (this->context_.config_.csc_en_) {
36  tp_collectors_.push_back(std::make_unique<CSCTPCollector>(context_, i_consumes_collector));
37  }
38 
39  if (this->context_.config_.rpc_en_) {
40  tp_collectors_.push_back(std::make_unique<RPCTPCollector>(context_, i_consumes_collector));
41  }
42 
43  if (this->context_.config_.gem_en_) {
44  tp_collectors_.push_back(std::make_unique<GEMTPCollector>(context_, i_consumes_collector));
45  }
46 
47  if (this->context_.config_.me0_en_) {
48  tp_collectors_.push_back(std::make_unique<ME0TPCollector>(context_, i_consumes_collector));
49  }
50 
51  if (this->context_.config_.ge0_en_) {
52  tp_collectors_.push_back(std::make_unique<GE0TPCollector>(context_, i_consumes_collector));
53  }
54 
55  // Register Sector Processor
56  for (unsigned int endcap = kMinEndcap; endcap <= kMaxEndcap; ++endcap) {
57  for (unsigned int sector = kMinTrigSector; sector <= kMaxTrigSector; ++sector) {
58  sector_processors_.push_back(std::make_unique<SectorProcessor>(context_, endcap, sector));
59  }
60  }
61 }
std::vector< std::unique_ptr< TPCollector > > tp_collectors_
Definition: TrackFinder.h:32
constexpr int kMaxEndcap
Definition: EMTFConstants.h:7
std::vector< std::unique_ptr< SectorProcessor > > sector_processors_
Definition: TrackFinder.h:33
constexpr int kMinTrigSector
Definition: EMTFConstants.h:20
constexpr int kMinEndcap
Definition: EMTFConstants.h:6
constexpr int kMaxTrigSector
Definition: EMTFConstants.h:21
EMTFConfiguration config_
Definition: EMTFContext.h:39

◆ ~TrackFinder()

TrackFinder::~TrackFinder ( )

Definition at line 63 of file TrackFinder.cc.

63  {
64  // Do Nothing
65 }

Member Function Documentation

◆ onJobBegin()

void TrackFinder::onJobBegin ( )

Definition at line 215 of file TrackFinder.cc.

215  {
216  // Do Nothing
217 }

◆ onJobEnd()

void TrackFinder::onJobEnd ( )

Definition at line 219 of file TrackFinder.cc.

219  {
220  // Do Nothing
221 }

◆ process()

void TrackFinder::process ( const edm::Event i_event,
const edm::EventSetup i_event_setup,
EMTFHitCollection out_hits,
EMTFTrackCollection out_tracks,
EMTFInputCollection out_inputs 
)

Definition at line 67 of file TrackFinder.cc.

References nano_mu_digi_cff::bx, emtf::phase2::EMTFConfiguration::bx_window_, emtf::phase2::EMTFContext::config_, context_, gather_cfg::cout, emtf::phase2::EMTFConfiguration::max_bx_, emtf::phase2::EMTFConfiguration::min_bx_, sector_processors_, cmsswSequenceInfo::tp, tp_collectors_, emtf::phase2::EMTFContext::update(), and emtf::phase2::EMTFConfiguration::verbosity_.

74  {
75  // ===========================================================================
76  // Clear output collections
77  // ===========================================================================
78 
79  out_hits.clear();
80  out_tracks.clear();
81  out_inputs.clear();
82 
83  // ===========================================================================
84  // Load the event configuration
85  // ===========================================================================
86 
87  context_.update(i_event, i_event_setup);
88 
89  // ===========================================================================
90  // Collect trigger primitives
91  // ===========================================================================
92 
93  // Build BX Sequence
94  std::vector<int> bx_sequence;
95 
96  {
97  auto min_bx = this->context_.config_.min_bx_;
98  auto delay_bx = this->context_.config_.bx_window_ - 1;
99  auto max_bx = this->context_.config_.max_bx_ + delay_bx;
100 
101  for (int bx = min_bx; bx <= max_bx; ++bx) {
102  bx_sequence.push_back(bx);
103  }
104  }
105 
106  // Collect TP per BX
107  BXTPCMap bx_tpc_map;
108 
109  for (auto& tp_collector : tp_collectors_) {
110  tp_collector->collect(i_event, bx_tpc_map);
111  }
112 
113  // Debug Info
114  if (this->context_.config_.verbosity_ > 4) {
115  int n_tp = 0;
116 
117  // Loop BX
118  for (const auto& bx : bx_sequence) {
119  // Get trigger primitives for this BX
120  auto bx_tpc_map_it = bx_tpc_map.find(bx);
121  auto bx_tpc_map_end = bx_tpc_map.end();
122 
123  // Short-Circuit: Empty trigger primitive collection
124  if (bx_tpc_map_it == bx_tpc_map_end) {
125  continue;
126  }
127 
128  // Reference TPC
129  auto& bx_tpc = bx_tpc_map_it->second;
130 
131  // Short-Circuit: Empty trigger primitive collection
132  if (bx_tpc.empty()) {
133  continue;
134  }
135 
136  // Print trigger primitives
137  edm::LogInfo("L1TEMTFpp") << "==========================================================================="
138  << std::endl;
139  edm::LogInfo("L1TEMTFpp") << "Begin TPC BX " << bx << " Dump" << std::endl;
140  edm::LogInfo("L1TEMTFpp") << "---------------------------------------------------------------------------"
141  << std::endl;
142 
143  n_tp += bx_tpc.size();
144 
145  for (const auto& tp_entry : bx_tpc) {
146  tp_entry.tp_.print(std::cout);
147 
148  edm::LogInfo("L1TEMTFpp") << "---------------------------------------------------------------------------"
149  << std::endl;
150  }
151 
152  edm::LogInfo("L1TEMTFpp") << "End TPC BX " << bx << " Dump" << std::endl;
153  edm::LogInfo("L1TEMTFpp") << "==========================================================================="
154  << std::endl;
155  }
156 
157  // Print TPrimitives Summary
158  if (n_tp > 0) {
159  edm::LogInfo("L1TEMTFpp") << "Num of TriggerPrimitive: " << n_tp << std::endl;
160  edm::LogInfo("L1TEMTFpp") << "==========================================================================="
161  << std::endl;
162  }
163  }
164 
165  // ===========================================================================
166  // Run sector processors
167  // ===========================================================================
168 
169  // Before event
170  for (auto& sector_processor : sector_processors_) {
171  sector_processor->configureEvent(i_event);
172  }
173 
174  // Orderly loop BX
175  for (const auto& bx : bx_sequence) {
176  // Get trigger primitives for this BX
177  auto bx_tpc_map_it = bx_tpc_map.find(bx);
178  auto bx_tpc_map_end = bx_tpc_map.end();
179 
180  TPCollection* bx_tpc_ptr = nullptr;
181 
182  if (bx_tpc_map_it != bx_tpc_map_end) {
183  bx_tpc_ptr = &(bx_tpc_map_it->second);
184  }
185 
186  // Loop over all sector processors
187  for (auto& sector_processor : sector_processors_) {
188  // Before BX
189  sector_processor->configureBx(bx);
190 
191  // Select trigger primitives in BX
192  if (bx_tpc_ptr != nullptr) {
193  for (const auto& tp_entry : *bx_tpc_ptr) {
194  const auto& tp = tp_entry.tp_;
195  const auto& tp_info = tp_entry.info_;
196 
197  sector_processor->select(tp, tp_info);
198  }
199  }
200 
201  // Process trigger primitives
202  sector_processor->process(out_hits, out_tracks, out_inputs);
203  }
204 
205  // Free memory: Removes BX TPCollections after all Sector Processors have selected their TPrimitives
206  if (bx_tpc_ptr != nullptr) {
207  bx_tpc_map.erase(bx_tpc_map_it);
208  }
209  }
210 
211  // Free memory: Drops any BX TPCollections outside of the [min bx, max bx] range
212  bx_tpc_map.clear();
213 }
void update(const edm::Event &, const edm::EventSetup &)
Definition: EMTFContext.cc:69
std::vector< std::unique_ptr< TPCollector > > tp_collectors_
Definition: TrackFinder.h:32
std::vector< std::unique_ptr< SectorProcessor > > sector_processors_
Definition: TrackFinder.h:33
std::map< int, TPCollection > BXTPCMap
Definition: EMTFTypes.h:22
Log< level::Info, false > LogInfo
std::vector< TPEntry > TPCollection
Definition: EMTFTypes.h:21
EMTFConfiguration config_
Definition: EMTFContext.h:39

Member Data Documentation

◆ context_

EMTFContext emtf::phase2::TrackFinder::context_
private

Definition at line 30 of file TrackFinder.h.

Referenced by process(), and TrackFinder().

◆ sector_processors_

std::vector<std::unique_ptr<SectorProcessor> > emtf::phase2::TrackFinder::sector_processors_
private

Definition at line 33 of file TrackFinder.h.

Referenced by process(), and TrackFinder().

◆ tp_collectors_

std::vector<std::unique_ptr<TPCollector> > emtf::phase2::TrackFinder::tp_collectors_
private

Definition at line 32 of file TrackFinder.h.

Referenced by process(), and TrackFinder().