41 edm::LogError(
"L1T|EMTF") <<
"Payload size in 'SP Output Data Record' is different than expected";
45 for (
unsigned int i = 0;
i < 8;
i++) {
48 edm::LogError(
"L1T|EMTF") <<
"Payload[" <<
i <<
"] has more than 16 bits in 'SP Output Data Record'";
64 edm::LogError(
"L1T|EMTF") <<
"Format identifier bits in SP1a are incorrect";
68 edm::LogError(
"L1T|EMTF") <<
"Format identifier bits in SP1b are incorrect";
72 edm::LogError(
"L1T|EMTF") <<
"Format identifier bits in SP1c are incorrect";
76 edm::LogError(
"L1T|EMTF") <<
"Format identifier bits in SP1d are incorrect";
80 edm::LogError(
"L1T|EMTF") <<
"Format identifier bits in SP2a are incorrect";
84 edm::LogError(
"L1T|EMTF") <<
"Format identifier bits in SP2b are incorrect";
88 edm::LogError(
"L1T|EMTF") <<
"Format identifier bits in SP2c are incorrect";
92 edm::LogError(
"L1T|EMTF") <<
"Format identifier bits in SP2d are incorrect";
100 int new_sector = _sector;
103 int arr[] = {_csc_ID, -99, -99, -99};
104 std::vector<int> vec(arr, arr + 4);
106 }
else if (_csc_ID == 0) {
107 int arr[] = {-1, -1, -1, -1};
108 std::vector<int> vec(arr, arr + 4);
110 }
else if (_csc_ID <= 9) {
111 int arr[] = {_csc_ID, new_sector, _subsector + 1, 0};
112 std::vector<int> vec(arr, arr + 4);
115 new_sector = (_sector != 1) ? _sector - 1 : 6;
118 int arr[] = {3, new_sector, 2, 1};
119 std::vector<int> vec(arr, arr + 4);
121 }
else if (_csc_ID == 11) {
122 int arr[] = {6, new_sector, 2, 1};
123 std::vector<int> vec(arr, arr + 4);
125 }
else if (_csc_ID == 12) {
126 int arr[] = {9, new_sector, 2, 1};
127 std::vector<int> vec(arr, arr + 4);
130 int arr[] = {_csc_ID, -99, -99, -99};
131 std::vector<int> vec(arr, arr + 4);
134 }
else if (_station == 2 || _station == 3 || _station == 4) {
136 int arr[] = {_csc_ID, -99, -99, -99};
137 std::vector<int> vec(arr, arr + 4);
139 }
else if (_csc_ID == 0) {
140 int arr[] = {-1, -1, -1, -1};
141 std::vector<int> vec(arr, arr + 4);
143 }
else if (_csc_ID <= 9) {
144 int arr[] = {_csc_ID, new_sector, -1, 0};
145 std::vector<int> vec(arr, arr + 4);
148 new_sector = (_sector != 1) ? _sector - 1 : 6;
151 int arr[] = {3, new_sector, -1, 1};
152 std::vector<int> vec(arr, arr + 4);
154 }
else if (_csc_ID == 11) {
155 int arr[] = {9, new_sector, -1, 1};
156 std::vector<int> vec(arr, arr + 4);
159 int arr[] = {_csc_ID, -99, -99, -99};
160 std::vector<int> vec(arr, arr + 4);
164 int arr[] = {-99, -99, -99, -99};
165 std::vector<int> vec(arr, arr + 4);
197 res = static_cast<EMTFCollections*>(coll)->getEMTFDaqOuts();
198 int iOut =
res->size() - 1;
199 std::vector<int> conv_vals_SP;
200 std::vector<int> conv_vals_pT_LUT;
203 res_hit = static_cast<EMTFCollections*>(coll)->getEMTFHits();
206 res_track = static_cast<EMTFCollections*>(coll)->getEMTFTracks();
210 res_cand = static_cast<EMTFCollections*>(coll)->getRegionalMuonCands();
253 ImportSP(Track_, SP_, (
res->at(iOut)).PtrEventHeader()->Endcap(), (
res->at(iOut)).PtrEventHeader()->Sector());
256 if (!(
res->at(iOut)).PtrSPCollection()->empty())
257 if (SP_.
TBIN() == (
res->at(iOut)).PtrSPCollection()->at((
res->at(iOut)).PtrSPCollection()->size() - 1).TBIN())
277 int EMTF_kBX = ((
res->at(iOut)).PtrEventHeader()->L1A_BXN() % 2048) - 25 + Track_.
BX();
289 int nDelay[3] = {0, 0, 0};
290 if (Track_.
Mode() >= 8)
292 if ((Track_.
Mode() % 8) >= 4)
294 if ((Track_.
Mode() % 4) >= 2)
296 if ((Track_.
Mode() % 2) == 1)
303 else if (nDelay[2] + nDelay[1] >= 2)
305 else if (nDelay[2] + nDelay[1] + nDelay[0] >= 2)
314 auto get_subsector_rpc_cppf = [](
int subsector_rpc) {
return ((subsector_rpc + 3) % 6) + 1; };
316 std::array<int, 4> St_hits{{0, 0, 0, 0}};
318 for (
auto const&
Hit : *res_hit) {
319 if (Track_.
Mode() == 1)
325 if (
Hit.Station() == 1)
327 else if (
Hit.Station() == 2)
329 else if (
Hit.Station() == 3)
331 else if (
Hit.Station() == 4)
335 if (
Hit.BX() + 3 + hit_delay != SP_.
TBIN() + trk_delay)
342 if (
Hit.Station() == 1 &&
Hit.Sector() == conv_vals_SP.at(1) &&
Hit.Neighbor() == conv_vals_SP.at(3) &&
344 if (
Hit.Is_CSC() == 1 && (
Hit.CSC_ID() != conv_vals_SP.at(0) ||
Hit.Subsector() != conv_vals_SP.at(2)))
347 int tmp_subsector = get_subsector_rpc_cppf(
Hit.Subsector_RPC());
348 int RPC_subsector = ((tmp_subsector - 1) / 3) + 1;
349 int RPC_CSC_ID = ((tmp_subsector - 1) % 3) + 4;
351 if (
Hit.Is_RPC() == 1 && (RPC_CSC_ID != conv_vals_SP.at(0) || RPC_subsector != conv_vals_SP.at(2)))
354 if (St_hits.at(0) == 0) {
367 if (
Hit.Station() == 2 &&
Hit.Sector() == conv_vals_SP.at(1) &&
Hit.Neighbor() == conv_vals_SP.at(3) &&
369 if (
Hit.Is_CSC() == 1 &&
Hit.CSC_ID() != conv_vals_SP.at(0))
372 int tmp_subsector = get_subsector_rpc_cppf(
Hit.Subsector_RPC());
373 if (
Hit.Is_RPC() == 1 && tmp_subsector + 3 != conv_vals_SP.at(0))
376 if (St_hits.at(1) == 0) {
389 if (
Hit.Station() == 3 &&
Hit.Sector() == conv_vals_SP.at(1) &&
Hit.Neighbor() == conv_vals_SP.at(3) &&
391 if (
Hit.Is_CSC() == 1 &&
Hit.CSC_ID() != conv_vals_SP.at(0))
394 int tmp_subsector = get_subsector_rpc_cppf(
Hit.Subsector_RPC());
395 if (
Hit.Is_RPC() == 1 && tmp_subsector + 3 != conv_vals_SP.at(0))
398 if (St_hits.at(2) == 0) {
411 if (
Hit.Station() == 4 &&
Hit.Sector() == conv_vals_SP.at(1) &&
Hit.Neighbor() == conv_vals_SP.at(3) &&
413 if (
Hit.Is_CSC() == 1 &&
Hit.CSC_ID() != conv_vals_SP.at(0))
416 int tmp_subsector = get_subsector_rpc_cppf(
Hit.Subsector_RPC());
417 if (
Hit.Is_RPC() == 1 && tmp_subsector + 3 != conv_vals_SP.at(0))
420 if (St_hits.at(3) == 0) {
433 if (Track_.
Mode() == 1) {
435 int chamber_min = ((Track_.
GMT_phi() - 17) / 16) + Track_.
Sector() * 6 - 3;
436 int chamber_max = ((Track_.
GMT_phi() + 1) / 16) + Track_.
Sector() * 6 - 3;
437 for (
int iChamb = chamber_max; iChamb >= chamber_min; iChamb--) {
438 int chamber = (iChamb < 37 ? iChamb : (iChamb % 36));
440 for (
auto const&
Hit : *res_hit) {
443 if (
Hit.BX() != Track_.
BX())
447 if (
Hit.Is_CSC() != 1)
449 if (
Hit.Station() != 1)
451 if ((
Hit.Ring() % 3) != 1)
453 if (
Hit.Neighbor() == 1)
457 bool hit_already_used =
false;
458 for (
auto const& Trk : *res_track) {
461 if (Trk.NumHits() < 1)
464 if (Trk.Hits().at(0).Station() == 1 && Trk.Hits().at(0).Chamber() ==
chamber &&
465 Trk.Hits().at(0).BX() ==
Hit.BX() && Trk.Hits().at(0).Ring() ==
Hit.Ring() &&
466 Trk.Hits().at(0).Strip() ==
Hit.Strip() && Trk.Hits().at(0).Wire() ==
Hit.Wire()) {
467 hit_already_used =
true;
472 if (!hit_already_used) {
547 (
res->at(iOut)).push_SP(SP_);
549 res_track->push_back(Track_);