CMS 3D CMS Logo

List of all members | Public Member Functions
EMTFSubsystemCollector Class Reference

#include <EMTFSubsystemCollector.h>

Public Member Functions

void cluster_gem (const TriggerPrimitiveCollection &muon_primitives, TriggerPrimitiveCollection &clus_muon_primitives) const
 
void cluster_rpc (const TriggerPrimitiveCollection &muon_primitives, TriggerPrimitiveCollection &clus_muon_primitives) const
 
template<>
void extractPrimitives (CSCTag tag, const edm::Event &iEvent, const edm::EDGetToken &token, TriggerPrimitiveCollection &out) const
 
template<typename T >
void extractPrimitives (T tag, const edm::Event &iEvent, const edm::EDGetToken &token, TriggerPrimitiveCollection &out) const
 
template<>
void extractPrimitives (RPCTag tag, const edm::Event &iEvent, const edm::EDGetToken &token, TriggerPrimitiveCollection &out) const
 
template<>
void extractPrimitives (GEMTag tag, const edm::Event &iEvent, const edm::EDGetToken &token, TriggerPrimitiveCollection &out) const
 
void make_copad_gem (const TriggerPrimitiveCollection &muon_primitives, TriggerPrimitiveCollection &copad_muon_primitives) const
 

Detailed Description

Definition at line 15 of file EMTFSubsystemCollector.h.

Member Function Documentation

void EMTFSubsystemCollector::cluster_gem ( const TriggerPrimitiveCollection muon_primitives,
TriggerPrimitiveCollection clus_muon_primitives 
) const

Definition at line 274 of file EMTFSubsystemCollector.cc.

References L1TMuon::TriggerPrimitive::kGEM, tier0::unique(), and x.

Referenced by extractPrimitives().

274  {
275  // Define operator to select GEM digis
276  struct {
278  bool operator()(const value_type& x) const {
279  return (x.subsystem() == TriggerPrimitive::kGEM);
280  }
281  } gem_digi_select;
282 
283  // Define operator to sort the GEM digis prior to clustering.
284  // Use rawId, bx and pad as the sorting id. GEM rawId fully specifies
285  // endcap, station, ring, layer, roll, chamber. Pad is used as
286  // the least significant sorting id.
287  struct {
289  bool operator()(const value_type& lhs, const value_type& rhs) const {
290  bool cmp = (
291  std::make_pair(std::make_pair(lhs.rawId(), lhs.getGEMData().bx), lhs.getGEMData().pad) <
292  std::make_pair(std::make_pair(rhs.rawId(), rhs.getGEMData().bx), rhs.getGEMData().pad)
293  );
294  return cmp;
295  }
296  } gem_digi_less;
297 
298  struct {
300  bool operator()(const value_type& lhs, const value_type& rhs) const {
301  bool cmp = (
302  std::make_pair(std::make_pair(lhs.rawId(), lhs.getGEMData().bx), lhs.getGEMData().pad) ==
303  std::make_pair(std::make_pair(rhs.rawId(), rhs.getGEMData().bx), rhs.getGEMData().pad)
304  );
305  return cmp;
306  }
307  } gem_digi_equal;
308 
309  // Define operators for the nearest-neighbor clustering algorithm.
310  // If two digis are next to each other (check pad_hi on the 'left', and
311  // pad_low on the 'right'), cluster them (increment pad_hi on the 'left')
312  struct {
314  bool operator()(const value_type& lhs, const value_type& rhs) const {
315  bool cmp = (
316  (lhs.rawId() == rhs.rawId()) &&
317  (lhs.getGEMData().bx == rhs.getGEMData().bx) &&
318  (lhs.getGEMData().pad_hi+1 == rhs.getGEMData().pad_low)
319  );
320  return cmp;
321  }
322  } gem_digi_adjacent;
323 
324  struct {
326  void operator()(value_type& lhs, value_type& rhs) { // pass by reference
327  lhs.accessGEMData().pad_hi += 1;
328  }
329  } gem_digi_cluster;
330 
331  // ___________________________________________________________________________
332  // Do clustering using C++ <algorithm> functions
333 
334  // 1. Select GEM digis
335  std::copy_if(muon_primitives.begin(), muon_primitives.end(), std::back_inserter(clus_muon_primitives), gem_digi_select);
336 
337  // 2. Sort
338  std::stable_sort(clus_muon_primitives.begin(), clus_muon_primitives.end(), gem_digi_less);
339 
340  // 3. Remove duplicates
341  clus_muon_primitives.erase(
342  std::unique(clus_muon_primitives.begin(), clus_muon_primitives.end(), gem_digi_equal),
343  clus_muon_primitives.end()
344  );
345 
346  // 4. Cluster adjacent digis
347  clus_muon_primitives.erase(
348  adjacent_cluster(clus_muon_primitives.begin(), clus_muon_primitives.end(), gem_digi_adjacent, gem_digi_cluster),
349  clus_muon_primitives.end()
350  );
351 }
def unique(seq, keepstr=True)
Definition: tier0.py:24
void EMTFSubsystemCollector::cluster_rpc ( const TriggerPrimitiveCollection muon_primitives,
TriggerPrimitiveCollection clus_muon_primitives 
) const

Definition at line 108 of file EMTFSubsystemCollector.cc.

References L1TMuon::TriggerPrimitive::kRPC, tier0::unique(), and x.

Referenced by extractPrimitives().

108  {
109  // Define operator to select RPC digis
110  struct {
112  bool operator()(const value_type& x) const {
113  return (x.subsystem() == TriggerPrimitive::kRPC);
114  }
115  } rpc_digi_select;
116 
117  // Define operator to sort the RPC digis prior to clustering.
118  // Use rawId, bx and strip as the sorting id. RPC rawId fully specifies
119  // sector, subsector, endcap, station, ring, layer, roll. Strip is used as
120  // the least significant sorting id.
121  struct {
123  bool operator()(const value_type& lhs, const value_type& rhs) const {
124  bool cmp = (
125  std::make_pair(std::make_pair(lhs.rawId(), lhs.getRPCData().bx), lhs.getRPCData().strip) <
126  std::make_pair(std::make_pair(rhs.rawId(), rhs.getRPCData().bx), rhs.getRPCData().strip)
127  );
128  return cmp;
129  }
130  } rpc_digi_less;
131 
132  struct {
134  bool operator()(const value_type& lhs, const value_type& rhs) const {
135  bool cmp = (
136  std::make_pair(std::make_pair(lhs.rawId(), lhs.getRPCData().bx), lhs.getRPCData().strip) ==
137  std::make_pair(std::make_pair(rhs.rawId(), rhs.getRPCData().bx), rhs.getRPCData().strip)
138  );
139  return cmp;
140  }
141  } rpc_digi_equal;
142 
143  // Define operators for the nearest-neighbor clustering algorithm.
144  // If two digis are next to each other (check strip_hi on the 'left', and
145  // strip_low on the 'right'), cluster them (increment strip_hi on the 'left')
146  struct {
148  bool operator()(const value_type& lhs, const value_type& rhs) const {
149  bool cmp = (
150  (lhs.rawId() == rhs.rawId()) &&
151  (lhs.getRPCData().bx == rhs.getRPCData().bx) &&
152  (lhs.getRPCData().strip_hi+1 == rhs.getRPCData().strip_low)
153  );
154  return cmp;
155  }
156  } rpc_digi_adjacent;
157 
158  struct {
160  void operator()(value_type& lhs, value_type& rhs) { // pass by reference
161  lhs.accessRPCData().strip_hi += 1;
162  }
163  } rpc_digi_cluster;
164 
165  // ___________________________________________________________________________
166  // Do clustering using C++ <algorithm> functions
167 
168  // 1. Select RPC digis
169  std::copy_if(muon_primitives.begin(), muon_primitives.end(), std::back_inserter(clus_muon_primitives), rpc_digi_select);
170 
171  // 2. Sort
172  std::stable_sort(clus_muon_primitives.begin(), clus_muon_primitives.end(), rpc_digi_less);
173 
174  // 3. Remove duplicates
175  clus_muon_primitives.erase(
176  std::unique(clus_muon_primitives.begin(), clus_muon_primitives.end(), rpc_digi_equal),
177  clus_muon_primitives.end()
178  );
179 
180  // 4. Cluster adjacent digis
181  clus_muon_primitives.erase(
182  adjacent_cluster(clus_muon_primitives.begin(), clus_muon_primitives.end(), rpc_digi_adjacent, rpc_digi_cluster),
183  clus_muon_primitives.end()
184  );
185 }
def unique(seq, keepstr=True)
Definition: tier0.py:24
template<>
void EMTFSubsystemCollector::extractPrimitives ( CSCTag  tag,
const edm::Event iEvent,
const edm::EDGetToken token,
TriggerPrimitiveCollection out 
) const

Definition at line 11 of file EMTFSubsystemCollector.cc.

References relativeConstraints::chamber, and edm::Event::getByToken().

16  {
18  iEvent.getByToken(token, cscDigis);
19 
20  auto chamber = cscDigis->begin();
21  auto chend = cscDigis->end();
22  for( ; chamber != chend; ++chamber ) {
23  auto digi = (*chamber).second.first;
24  auto dend = (*chamber).second.second;
25  for( ; digi != dend; ++digi ) {
26  // emplace_back does the same thing as push_back: appends to the end of the vector
27  out.emplace_back((*chamber).first,*digi);
28  }
29  }
30  return;
31 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
template<typename T >
void EMTFSubsystemCollector::extractPrimitives ( T  tag,
const edm::Event iEvent,
const edm::EDGetToken token,
TriggerPrimitiveCollection out 
) const

Referenced by TrackFinder::process().

template<>
void EMTFSubsystemCollector::extractPrimitives ( RPCTag  tag,
const edm::Event iEvent,
const edm::EDGetToken token,
TriggerPrimitiveCollection out 
) const

Definition at line 35 of file EMTFSubsystemCollector.cc.

References relativeConstraints::chamber, cluster_rpc(), popcon2dropbox::copy(), and edm::Event::getByToken().

40  {
42  iEvent.getByToken(token, rpcDigis);
43 
44  TriggerPrimitiveCollection muon_primitives;
45 
46  auto chamber = rpcDigis->begin();
47  auto chend = rpcDigis->end();
48  for( ; chamber != chend; ++chamber ) {
49  auto digi = (*chamber).second.first;
50  auto dend = (*chamber).second.second;
51  for( ; digi != dend; ++digi ) {
52  if ((*chamber).first.region() != 0) { // 0 is barrel
53  if ((*chamber).first.station() <= 2 && (*chamber).first.ring() == 3) continue; // do not include RE1/3, RE2/3
54  if ((*chamber).first.station() >= 3 && (*chamber).first.ring() == 1) continue; // do not include RE3/1, RE4/1
55 
56  muon_primitives.emplace_back((*chamber).first,*digi);
57  }
58  }
59  }
60 
61  // Cluster the RPC digis
62  TriggerPrimitiveCollection clus_muon_primitives;
63  cluster_rpc(muon_primitives, clus_muon_primitives);
64 
65  // Output
66  std::copy(clus_muon_primitives.begin(), clus_muon_primitives.end(), std::back_inserter(out));
67  return;
68 }
void cluster_rpc(const TriggerPrimitiveCollection &muon_primitives, TriggerPrimitiveCollection &clus_muon_primitives) const
def copy(args, dbName)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
L1TMuon::TriggerPrimitiveCollection TriggerPrimitiveCollection
Definition: Common.h:33
template<>
void EMTFSubsystemCollector::extractPrimitives ( GEMTag  tag,
const edm::Event iEvent,
const edm::EDGetToken token,
TriggerPrimitiveCollection out 
) const

Definition at line 72 of file EMTFSubsystemCollector.cc.

References relativeConstraints::chamber, cluster_gem(), popcon2dropbox::copy(), edm::Event::getByToken(), and make_copad_gem().

77  {
79  iEvent.getByToken(token, gemDigis);
80 
81  TriggerPrimitiveCollection muon_primitives;
82 
83  auto chamber = gemDigis->begin();
84  auto chend = gemDigis->end();
85  for( ; chamber != chend; ++chamber ) {
86  auto digi = (*chamber).second.first;
87  auto dend = (*chamber).second.second;
88  for( ; digi != dend; ++digi ) {
89  muon_primitives.emplace_back((*chamber).first,*digi);
90  }
91  }
92 
93  // Cluster the GEM digis.
94  TriggerPrimitiveCollection copad_muon_primitives;
95  make_copad_gem(muon_primitives, copad_muon_primitives);
96 
97  TriggerPrimitiveCollection clus_muon_primitives;
98  cluster_gem(copad_muon_primitives, clus_muon_primitives);
99 
100  // Output
101  std::copy(clus_muon_primitives.begin(), clus_muon_primitives.end(), std::back_inserter(out));
102  return;
103 }
def copy(args, dbName)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
void make_copad_gem(const TriggerPrimitiveCollection &muon_primitives, TriggerPrimitiveCollection &copad_muon_primitives) const
L1TMuon::TriggerPrimitiveCollection TriggerPrimitiveCollection
Definition: Common.h:33
void cluster_gem(const TriggerPrimitiveCollection &muon_primitives, TriggerPrimitiveCollection &clus_muon_primitives) const
void EMTFSubsystemCollector::make_copad_gem ( const TriggerPrimitiveCollection muon_primitives,
TriggerPrimitiveCollection copad_muon_primitives 
) const

Definition at line 190 of file EMTFSubsystemCollector.cc.

References funct::abs(), L1TMuon::TriggerPrimitive::GEMData::bx, relativeConstraints::chamber, L1TMuon::TriggerPrimitive::detId(), runEdmFileComparison::found, L1TMuon::TriggerPrimitive::getGEMData(), L1TMuon::TriggerPrimitive::kGEM, GEMDetId::layer(), AlCaHLTBitMon_ParallelJobs::p, L1TMuon::TriggerPrimitive::GEMData::pad, DetId::rawId(), relativeConstraints::ring, relativeConstraints::station, and L1TMuon::TriggerPrimitive::subsystem().

Referenced by extractPrimitives().

190  {
191  // Use the inner layer (layer 1) hit coordinates as output, and the outer
192  // layer (layer 2) as coincidence
193  // Copied from: L1Trigger/CSCTriggerPrimitives/src/GEMCoPadProcessor.cc
194 
195  const unsigned int maxDeltaBX = 1;
196  const unsigned int maxDeltaPadGE11 = 2;
197  const unsigned int maxDeltaPadGE21 = 2;
198 
199  std::map<int, TriggerPrimitiveCollection> in_pads_layer1, in_pads_layer2;
200 
201  TriggerPrimitiveCollection::const_iterator tp_it = muon_primitives.begin();
202  TriggerPrimitiveCollection::const_iterator tp_end = muon_primitives.end();
203 
204  for (; tp_it != tp_end; ++tp_it) {
205  const TriggerPrimitive& muon_primitive = *tp_it;
206 
207  // Split by layer
208  if (muon_primitive.subsystem() == TriggerPrimitive::kGEM) {
209  const GEMDetId& tp_detId = muon_primitive.detId<GEMDetId>();
210  assert(tp_detId.layer() == 1 || tp_detId.layer() == 2);
211  if (tp_detId.layer() == 1) {
212  in_pads_layer1[tp_detId.rawId()].push_back(muon_primitive);
213  } else {
214  in_pads_layer2[tp_detId.rawId()].push_back(muon_primitive);
215  }
216 
217  // Modified copad logic
218  bool modified_copad_logic = false;
219  if (modified_copad_logic) {
220  if (tp_detId.layer() == 1) {
221  auto id = tp_detId;
222  const GEMDetId co_detId(id.region(), id.ring(), id.station(), 2, id.chamber(), id.roll());
223  const GEMPadDigi co_digi(muon_primitive.getGEMData().pad, muon_primitive.getGEMData().bx);
224  const TriggerPrimitive co_muon_primitive(co_detId, co_digi);
225  in_pads_layer2[co_detId.rawId()].push_back(co_muon_primitive);
226  } else {
227  auto id = tp_detId;
228  const GEMDetId co_detId(id.region(), id.ring(), id.station(), 1, id.chamber(), id.roll());
229  const GEMPadDigi co_digi(muon_primitive.getGEMData().pad, muon_primitive.getGEMData().bx);
230  const TriggerPrimitive co_muon_primitive(co_detId, co_digi);
231  in_pads_layer1[co_detId.rawId()].push_back(co_muon_primitive);
232  }
233  }
234  }
235  }
236 
237  std::map<int, TriggerPrimitiveCollection>::iterator map_tp_it = in_pads_layer1.begin();
238  std::map<int, TriggerPrimitiveCollection>::iterator map_tp_end = in_pads_layer1.end();
239 
240  for (; map_tp_it != map_tp_end; ++map_tp_it) {
241  const GEMDetId& id = map_tp_it->first;
242  const TriggerPrimitiveCollection& pads = map_tp_it->second;
243  assert(id.layer() == 1);
244 
245  // find the corresponding id with layer=2 and same roll number
246  const GEMDetId co_id(id.region(), id.ring(), id.station(), 2, id.chamber(), id.roll());
247 
248  // empty range = no possible coincidence pads
249  auto found = in_pads_layer2.find(co_id);
250  if (found == in_pads_layer2.end()) continue;
251 
252  // now let's correlate the pads in two layers of this partition
253  const TriggerPrimitiveCollection& co_pads = found->second;
254  for (TriggerPrimitiveCollection::const_iterator p = pads.begin(); p != pads.end(); ++p) {
255  for (TriggerPrimitiveCollection::const_iterator co_p = co_pads.begin(); co_p != co_pads.end(); ++co_p) {
256  unsigned int deltaPad = std::abs(p->getGEMData().pad - co_p->getGEMData().pad);
257  unsigned int deltaBX = std::abs(p->getGEMData().bx - co_p->getGEMData().bx);
258 
259  // check the match in pad
260  if ((id.station() == 1 && deltaPad > maxDeltaPadGE11) || (id.station() == 2 && deltaPad > maxDeltaPadGE21))
261  continue;
262 
263  // check the match in BX
264  if (deltaBX > maxDeltaBX)
265  continue;
266 
267  // make a new coincidence pad digi
268  copad_muon_primitives.push_back(*p);
269  }
270  }
271  }
272 }
const subsystem_type subsystem() const
const GEMData getGEMData() const
uint32_t rawId() const
get the raw id
Definition: DetId.h:44
int layer() const
Layer id: each station have two layers of chambers: layer 1 is the inner chamber and layer 2 is the o...
Definition: GEMDetId.h:69
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
L1TMuon::TriggerPrimitiveCollection TriggerPrimitiveCollection
Definition: Common.h:33