CMS 3D CMS Logo

ME0TPCollector.cc
Go to the documentation of this file.
3 
11 
13 
14 using namespace emtf::phase2;
15 
17  : context_(context),
18  input_token_(i_consumes_collector.consumes<ME0Tag::collection_type>(context.config_.me0_input_)) {}
19 
20 void ME0TPCollector::collect(const edm::Event& i_event, BXTPCMap& bx_tpc_map) const {
21  // Constants
22  // First quarter of ME0 chamber (5 deg) and last quarter
23  static const int me0_max_partition = 9;
24  static const int me0_nstrips = 384;
25  static const int me0_nphipositions = me0_nstrips * 2;
26  static const int phiposition_q1 = me0_nphipositions / 4;
27  static const int phiposition_q3 = (me0_nphipositions / 4) * 3;
28 
29  // Read ME0 digis
30  TPCollection tpc;
31 
33  i_event.getByToken(input_token_, me0_digis);
34 
35  auto chamber = me0_digis->begin();
36  auto chend = me0_digis->end();
37 
38  for (; chamber != chend; ++chamber) {
39  auto digi = (*chamber).second.first;
40  auto dend = (*chamber).second.second;
41 
42  for (; digi != dend; ++digi) {
43  tpc.emplace_back((*chamber).first, *digi);
44  }
45  }
46 
47  // Map to BX
48  for (auto& tp_entry : tpc) {
49  const auto& tp_det_id = tp_entry.tp_.detId<ME0DetId>();
50  const ME0Data& tp_data = tp_entry.tp_.getME0Data();
51 
52  const int tp_region = tp_det_id.region(); // 0: barrel, +/-1: endcap
53  const int tp_endcap = (tp_region == -1) ? 2 : tp_region; // 1: +endcap, 2: -endcap
54  const int tp_endcap_pm = (tp_endcap == 2) ? -1 : tp_endcap; // 1: +endcap, -1: -endcap
55  const int tp_station = tp_det_id.station();
56  const int tp_ring = 4;
57  const int tp_layer = tp_det_id.layer();
58  const int tp_roll = tp_det_id.roll();
59  const int tp_me0_chamber = tp_det_id.chamber();
60 
61  const int tp_pad = tp_data.phiposition;
62  const int tp_partition = tp_data.partition;
63  const int tp_bx = tp_data.bx + this->context_.config_.me0_bx_shift_;
64 
65  // Reject if outside eta of 2.4
66  if (tp_partition > me0_max_partition) {
67  continue;
68  }
69 
70  // Calculate EMTF Info
71  // Split 20-deg chamber into 10-deg chamber
72  // ME0 chamber is rotated by -5 deg relative to CSC chamber.
73  // ME0 chamber 1 starts at -10 deg, CSC chamber 1 starts at -5 deg.
74  const int tp_phiposition = tp_data.phiposition; // in half-strip unit
75 
76  int tp_chamber = (tp_me0_chamber - 1) * 2 + 1;
77 
78  if (tp_endcap == 1) {
79  // positive endcap
80  // phiposition increases counter-clockwise
81  if (tp_phiposition < phiposition_q1) {
82  tp_chamber = csc::getNext10DegChamber(tp_chamber);
83  } else if (tp_phiposition < phiposition_q3) {
84  // Do nothing
85  } else {
86  tp_chamber = csc::getPrev10DegChamber(tp_chamber);
87  }
88  } else {
89  // negative endcap
90  // phiposition increases clockwise
91  if (tp_phiposition < phiposition_q1) {
92  tp_chamber = csc::getPrev10DegChamber(tp_chamber);
93  } else if (tp_phiposition < phiposition_q3) {
94  // Do nothing
95  } else {
96  tp_chamber = csc::getNext10DegChamber(tp_chamber);
97  }
98  }
99 
100  const int tp_sector = csc::getTriggerSector(tp_station, tp_ring, tp_chamber);
101  const int tp_subsector = csc::getTriggerSubsector(tp_station, tp_chamber);
102  const int tp_csc_id = csc::getId(tp_station, tp_ring, tp_chamber);
103  const auto tp_csc_facing = csc::getFaceDirection(tp_station, tp_ring, tp_chamber);
104 
105  // Assertion checks
106  emtf_assert(kMinEndcap <= tp_endcap && tp_endcap <= kMaxEndcap);
107  emtf_assert(kMinTrigSector <= tp_sector && tp_sector <= kMaxTrigSector);
108  emtf_assert((1 <= tp_subsector) and (tp_subsector <= 2));
109  emtf_assert(tp_station == 1);
110  emtf_assert(tp_ring == 4);
111  emtf_assert((1 <= tp_chamber) and (tp_chamber <= 36));
112  emtf_assert(1 <= tp_csc_id && tp_csc_id <= 3);
113  emtf_assert(0 <= tp_pad && tp_pad <= 767);
114  emtf_assert(0 <= tp_partition && tp_partition <= 15);
115 
116  // Add info
117  tp_entry.info_.bx = tp_bx;
118 
119  tp_entry.info_.endcap = tp_endcap;
120  tp_entry.info_.endcap_pm = tp_endcap_pm;
121  tp_entry.info_.sector = tp_sector;
122  tp_entry.info_.subsector = tp_subsector;
123  tp_entry.info_.station = tp_station;
124  tp_entry.info_.ring = tp_ring;
125  tp_entry.info_.layer = tp_layer;
126  tp_entry.info_.roll = tp_roll;
127  tp_entry.info_.chamber = tp_chamber;
128 
129  tp_entry.info_.csc_id = tp_csc_id;
130  tp_entry.info_.csc_facing = tp_csc_facing;
131 
132  bx_tpc_map[tp_bx].push_back(tp_entry);
133  }
134 }
ME0TPCollector(const EMTFContext &, edm::ConsumesCollector &)
int getId(int ring, int station, int chamber)
Definition: CSCUtils.cc:39
const EMTFContext & context_
int getTriggerSubsector(int station, int chamber)
Definition: CSCUtils.cc:85
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:528
constexpr int kMaxEndcap
Definition: EMTFConstants.h:7
std::map< int, TPCollection > BXTPCMap
Definition: EMTFTypes.h:22
void collect(const edm::Event &, BXTPCMap &) const final
int getNext10DegChamber(int chamber)
Definition: CSCUtils.cc:8
#define emtf_assert(expr)
Definition: DebugTools.h:18
int getTriggerSector(int ring, int station, int chamber)
Definition: CSCUtils.cc:70
Facing getFaceDirection(int station, int ring, int chamber)
Definition: CSCUtils.cc:100
constexpr int kMinTrigSector
Definition: EMTFConstants.h:20
constexpr int kMinEndcap
Definition: EMTFConstants.h:6
int getPrev10DegChamber(int chamber)
Definition: CSCUtils.cc:10
constexpr int kMaxTrigSector
Definition: EMTFConstants.h:21
const edm::EDGetToken input_token_
std::vector< TPEntry > TPCollection
Definition: EMTFTypes.h:21
EMTFConfiguration config_
Definition: EMTFContext.h:39