CMS 3D CMS Logo

DebugTools.cc
Go to the documentation of this file.
3 
4 namespace emtf {
5 
6  void dump_fw_raw_input(const l1t::EMTFHitCollection& out_hits, const l1t::EMTFTrackCollection& out_tracks) {
7  // from interface/Common.h
8  constexpr int MIN_ENDCAP = 1;
9  constexpr int MAX_ENDCAP = 2;
10  constexpr int MIN_TRIGSECTOR = 1;
11  constexpr int MAX_TRIGSECTOR = 6;
12 
13  for (int endcap = MIN_ENDCAP; endcap <= MAX_ENDCAP; ++endcap) {
14  for (int sector = MIN_TRIGSECTOR; sector <= MAX_TRIGSECTOR; ++sector) {
15  const int es = (endcap - MIN_ENDCAP) * (MAX_TRIGSECTOR - MIN_TRIGSECTOR + 1) + (sector - MIN_TRIGSECTOR);
16 
17  // _____________________________________________________________________
18  // This prints the hits as raw text input to the firmware simulator
19  // "12345" is the BX separator
20 
21  std::cout << "==== Endcap " << endcap << " Sector " << sector << " Hits ====" << std::endl;
22  std::cout << "bx e s ss st vf ql cp wg id bd hs" << std::endl;
23 
24  bool empty_sector = true;
25  for (const auto& h : out_hits) {
26  if (h.Sector_idx() != es)
27  continue;
28  empty_sector = false;
29  }
30 
31  for (int ibx = -3 - 5; (ibx < +3 + 5 + 5) && !empty_sector; ++ibx) {
32  for (const auto& h : out_hits) {
33  if (h.Subsystem() == L1TMuon::kCSC) {
34  if (h.Sector_idx() != es)
35  continue;
36  if (h.BX() != ibx)
37  continue;
38 
39  int bx = 1;
40  int endcap = (h.Endcap() == 1) ? 1 : 2;
41  int sector = h.PC_sector();
42  int station = (h.PC_station() == 0 && h.Subsector() == 1) ? 1 : h.PC_station();
43  int chamber = h.PC_chamber() + 1;
44  int strip = (h.Station() == 1 && h.Ring() == 4) ? h.Strip() + 128 : h.Strip(); // ME1/1a
45  int wire = h.Wire();
46  int valid = 1;
47  std::cout << bx << " " << endcap << " " << sector << " " << h.Subsector() << " " << station << " "
48  << valid << " " << h.Quality() << " " << h.Pattern() << " " << wire << " " << chamber << " "
49  << h.Bend() << " " << strip << std::endl;
50 
51  } else if (h.Subsystem() == L1TMuon::kRPC) {
52  if (h.Sector_idx() != es)
53  continue;
54  if (h.BX() + 6 != ibx)
55  continue; // RPC hits should be supplied 6 BX later relative to CSC hits
56 
57  // Assign RPC link index. Code taken from src/PrimitiveSelection.cc
58  int rpc_sub = -1;
59  int rpc_chm = -1;
60  if (!h.Neighbor()) {
61  rpc_sub = ((h.Subsector_RPC() + 3) % 6);
62  } else {
63  rpc_sub = 6;
64  }
65  if (h.Station() <= 2) {
66  rpc_chm = (h.Station() - 1);
67  } else {
68  rpc_chm = 2 + (h.Station() - 3) * 2 + (h.Ring() - 2);
69  }
70 
71  int bx = 1;
72  int endcap = (h.Endcap() == 1) ? 1 : 2;
73  int sector = h.PC_sector();
74  int station = rpc_sub;
75  int chamber = rpc_chm + 1;
76  int strip = (h.Phi_fp() >> 2);
77  int wire = (h.Theta_fp() >> 2);
78  int valid = 2; // this marks RPC stub
79  std::cout << bx << " " << endcap << " " << sector << " " << 0 << " " << station << " " << valid << " "
80  << 0 << " " << 0 << " " << wire << " " << chamber << " " << 0 << " " << strip << std::endl;
81  }
82  } // end loop over hits
83 
84  std::cout << "12345" << std::endl;
85  } // end loop over bx
86 
87  // _____________________________________________________________________
88  // This prints the tracks as raw text output from the firmware simulator
89 
90  std::cout << "==== Endcap " << endcap << " Sector " << sector << " Tracks ====" << std::endl;
91  std::cout << "bx e s a mo et ph cr q pt" << std::endl;
92 
93  for (const auto& t : out_tracks) {
94  if (t.Sector_idx() != es)
95  continue;
96 
97  std::cout << t.BX() << " " << (t.Endcap() == 1 ? 1 : 2) << " " << t.Sector() << " " << t.PtLUT().address
98  << " " << t.Mode() << " " << (t.GMT_eta() >= 0 ? t.GMT_eta() : t.GMT_eta() + 512) << " "
99  << t.GMT_phi() << " " << t.GMT_charge() << " " << t.GMT_quality() << " " << t.Pt() << std::endl;
100  } // end loop over tracks
101 
102  } // end loop over sector
103  } // end loop over endcap
104  }
105 
106 } // namespace emtf
emtf::MIN_TRIGSECTOR
constexpr int MIN_TRIGSECTOR
Definition: Common.h:49
relativeConstraints.station
station
Definition: relativeConstraints.py:67
DebugTools.h
digitizers_cfi.strip
strip
Definition: digitizers_cfi.py:19
gather_cfg.cout
cout
Definition: gather_cfg.py:144
l1GtPatternGenerator_cfi.bx
bx
Definition: l1GtPatternGenerator_cfi.py:18
emtf::MAX_ENDCAP
constexpr int MAX_ENDCAP
Definition: Common.h:46
makeMuonMisalignmentScenario.endcap
endcap
Definition: makeMuonMisalignmentScenario.py:320
emtf::MAX_TRIGSECTOR
constexpr int MAX_TRIGSECTOR
Definition: Common.h:50
L1TMuon::kRPC
Definition: L1TMuonSubsystems.h:5
l1t::EMTFTrackCollection
std::vector< EMTFTrack > EMTFTrackCollection
Definition: EMTFTrack.h:249
emtf
Definition: Event.h:15
emtf::MIN_ENDCAP
constexpr int MIN_ENDCAP
Definition: Common.h:45
h
L1TMuon::kCSC
Definition: L1TMuonSubsystems.h:5
emtf::dump_fw_raw_input
void dump_fw_raw_input(const l1t::EMTFHitCollection &out_hits, const l1t::EMTFTrackCollection &out_tracks)
Definition: DebugTools.cc:6
L1TMuonSubsystems.h
relativeConstraints.chamber
chamber
Definition: relativeConstraints.py:53
RunInfoPI::valid
Definition: RunInfoPayloadInspectoHelper.h:16
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
l1t::EMTFHitCollection
std::vector< EMTFHit > EMTFHitCollection
Definition: EMTFHit.h:342