CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
RPCHalfSorter Class Reference

#include <RPCHalfSorter.h>

Public Member Functions

void maskHSBInput (L1RpcTBMuonsVec &newVec, int mask)
 
 RPCHalfSorter (RPCTriggerConfiguration *triggerConfig)
 
L1RpcTBMuonsVec2 run (L1RpcTBMuonsVec2 &tcsMuonsVec2, edm::ESHandle< L1RPCHsbConfig > hsbConf)
 
L1RpcTBMuonsVec2 runHalf (L1RpcTBMuonsVec2 &tcsMuonsVec2)
 

Private Attributes

L1RpcTBMuonsVec2 m_GBOutputMuons
 
RPCTriggerConfigurationm_TrigCnfg
 

Detailed Description

Emulates HalfSorter (currently both of them ;-) )

Author
Tomasz Fruboes (based on code by Karol Bunkowski)

Definition at line 16 of file RPCHalfSorter.h.

Constructor & Destructor Documentation

◆ RPCHalfSorter()

RPCHalfSorter::RPCHalfSorter ( RPCTriggerConfiguration triggerConfig)

Defualt constructor

Definition at line 17 of file RPCHalfSorter.cc.

17  {
18  m_TrigCnfg = triggerConfig;
19 
20  m_GBOutputMuons.assign(2, L1RpcTBMuonsVec());
21 }
std::vector< RPCTBMuon > L1RpcTBMuonsVec
Definition: RPCTBMuon.h:218
RPCTriggerConfiguration * m_TrigCnfg
Definition: RPCHalfSorter.h:29
L1RpcTBMuonsVec2 m_GBOutputMuons
Definition: RPCHalfSorter.h:27

Member Function Documentation

◆ maskHSBInput()

void RPCHalfSorter::maskHSBInput ( L1RpcTBMuonsVec newVec,
int  mask 
)

Definition at line 92 of file RPCHalfSorter.cc.

References Exception, and ALPAKA_ACCELERATOR_NAMESPACE::pixelClustering::pixelStatus::mask.

92  {
93  if (mask < 0 || mask > 3) {
94  throw cms::Exception("RPCHalfSorter::maskHSBInput") << " hsbMask has wrong value - " << mask << " \n";
95  }
96 
97  if (mask == 1) { // leave the best muons
98  newVec.at(2) = RPCTBMuon();
99  newVec.at(3) = RPCTBMuon();
100  } else if (mask == 2) {
101  newVec.at(0) = RPCTBMuon();
102  newVec.at(1) = RPCTBMuon();
103  } else {
104  newVec.at(0) = RPCTBMuon();
105  newVec.at(1) = RPCTBMuon();
106  newVec.at(2) = RPCTBMuon();
107  newVec.at(3) = RPCTBMuon();
108  }
109 }

◆ run()

L1RpcTBMuonsVec2 RPCHalfSorter::run ( L1RpcTBMuonsVec2 tcsMuonsVec2,
edm::ESHandle< L1RPCHsbConfig hsbConf 
)

Runs runHalf() for 2 detecors parts. Converts m_tower number (eta addr) from continous (0 - 32, m_tower 0 = 16) to 2'complement.

Returns
4 munons from barrel (m_GBOutputMuons[0]), and 4 from endcaps (m_GBOutputMuons[1]).

Definition at line 118 of file RPCHalfSorter.cc.

References MuonsGrabber::addMuon(), gather_cfg::cout, relativeConstraints::empty, L1RPCHsbConfig::getHsbMask(), mps_fire::i, MuonsGrabber::Instance(), DiDispStaMuonMonitor_cfi::pt, nano_mu_digi_cff::region, and nano_mu_digi_cff::sector.

Referenced by RPCPacTrigger::runEvent().

118  {
119  m_GBOutputMuons[0].clear();
120  m_GBOutputMuons[1].clear();
121 
122  L1RpcTBMuonsVec2 firstHalfTcsMuonsVec2;
123 
124  if (tcsMuonsVec2[m_TrigCnfg->getTCsCnt() - 1].empty() || hsbConf->getHsbMask(0, 0) == 3) {
125  firstHalfTcsMuonsVec2.push_back(tcsMuonsVec2[m_TrigCnfg->getTCsCnt() - 1]); //TC=11 (last one)
126  } else {
127  L1RpcTBMuonsVec newVec = tcsMuonsVec2[m_TrigCnfg->getTCsCnt() - 1];
128  maskHSBInput(newVec, hsbConf->getHsbMask(0, 0));
129  firstHalfTcsMuonsVec2.push_back(newVec);
130  }
131 
132  // update sectorAddr. Dont update sectorAddr of last tc (it will be done in other half)
133  int secAddr = 1;
134  // <6+1
135  for (int iTC = 0; iTC < m_TrigCnfg->getTCsCnt() / 2 + 1; iTC++) {
136  for (unsigned int iMu = 0; iMu < tcsMuonsVec2[iTC].size(); iMu++) {
137  if (secAddr != 0 && secAddr != 7) {
138  tcsMuonsVec2[iTC][iMu].setSectorAddr(secAddr); // |
139  // iTC=0 - firstTrigger crate (no=1)
140  // - in hw it has sectorAddr=1
141  //tcsMuonsVec2[iTC][iMu].setGBData(0); // gbData is used nowhere from now, we
142  // want to act same as hw
143  }
144  } // iter. over muons end
145  ++secAddr; // Next trigger crate. Update the address
146 
147  if (tcsMuonsVec2[iTC].empty() || hsbConf->getHsbMask(0, iTC + 1) == 3) {
148  firstHalfTcsMuonsVec2.push_back(tcsMuonsVec2[iTC]);
149  } else {
150  L1RpcTBMuonsVec newVec = tcsMuonsVec2[iTC];
151  maskHSBInput(newVec, hsbConf->getHsbMask(0, iTC + 1));
152  firstHalfTcsMuonsVec2.push_back(newVec);
153  }
154  }
155 
156  runHalf(firstHalfTcsMuonsVec2);
157 
158  unsigned int fhBMuons = m_GBOutputMuons[0].size(); // Number of first half barrel muons
159  unsigned int fhEMuons = m_GBOutputMuons[1].size(); // Number of first half endcap muons
160 
161  L1RpcTBMuonsVec2 secondHalfTcsMuonsVec2;
162  secAddr = 0;
163  // 5 <12
164  for (int iTC = m_TrigCnfg->getTCsCnt() / 2 - 1; iTC < m_TrigCnfg->getTCsCnt(); iTC++) {
165  for (unsigned int iMu = 0; iMu < tcsMuonsVec2[iTC].size(); iMu++) {
166  if (secAddr != 0 && secAddr != 7) {
167  tcsMuonsVec2[iTC][iMu].setSectorAddr(secAddr);
168  //tcsMuonsVec2[iTC][iMu].setGBData(0); // gbData is used nowhere from now, we
169  // want to act same as hw
170  }
171  }
172  ++secAddr;
173  if (tcsMuonsVec2[iTC].empty() || hsbConf->getHsbMask(1, iTC - 5) == 3) {
174  secondHalfTcsMuonsVec2.push_back(tcsMuonsVec2[iTC]);
175  } else {
176  L1RpcTBMuonsVec newVec = tcsMuonsVec2[iTC];
177  maskHSBInput(newVec, hsbConf->getHsbMask(1, iTC - 5));
178  secondHalfTcsMuonsVec2.push_back(newVec);
179  }
180  }
181 
182  //secondHalfTcsMuonsVec2.push_back(tcsMuonsVec2[0]);
183  if (tcsMuonsVec2[0].empty() || hsbConf->getHsbMask(1, 7) == 3) {
184  secondHalfTcsMuonsVec2.push_back(tcsMuonsVec2[0]);
185  } else {
186  L1RpcTBMuonsVec newVec = tcsMuonsVec2[0];
187  maskHSBInput(newVec, hsbConf->getHsbMask(1, 7));
188  secondHalfTcsMuonsVec2.push_back(newVec);
189  }
190 
191  runHalf(secondHalfTcsMuonsVec2);
192  // Debug
193  for (unsigned int region = 0; region < m_GBOutputMuons.size(); ++region) { // region: 0- barrel,1-endcaps
194  for (unsigned int i = 0; i < m_GBOutputMuons[region].size(); ++i) {
195  unsigned int halfNum = 0; // Number of halfsorter: 0 - first half, 1 - second half
196  int iMod = 0;
197 
198  // After second call of runHalf muons are written at the end of m_GBOutputMuons[0,1] vector
199  // not needed - fhBMuons ==4 (always)
200  if ((region == 0 && i >= fhBMuons) || (region == 1 && i >= fhEMuons)) {
201  halfNum = 1;
202  iMod = 4;
203  }
204  // Print out
205  if (m_TrigCnfg->getDebugLevel() == 1) {
206 #ifndef _STAND_ALONE
207  // LogDebug("RPCHwDebug")<<"GB 3"<< region <<halfNum
208  // << " " << i - iMod << " "
209  // << m_GBOutputMuons[region][i].printDebugInfo(m_TrigCnfg->getDebugLevel());
210  //MuonsGrabber::Instance().writeDataForRelativeBX(iBx);
211  MuonsGrabber::Instance().addMuon(m_GBOutputMuons[region][i], 3, region, halfNum, i - iMod);
212 
213 #else
214  std::cout << "GB 3" << region << halfNum << " " << i - iMod << " "
215  << m_GBOutputMuons[region][i].printDebugInfo(m_TrigCnfg->getDebugLevel()) << std::endl;
216 #endif
217  }
218  // Re-number the phi addr. This should be done by fs, temporary fix (doesnt change the logic)
219  int segment = m_GBOutputMuons[region][i].getSegmentAddr();
220  int sector = m_GBOutputMuons[region][i].getSectorAddr() - 1 + 6 * halfNum;
221  int pt = m_GBOutputMuons[region][i].getPtCode();
222  if (pt != 0) { // dont touch empty muons
223  m_GBOutputMuons[region][i].setPhiAddr((sector * 12 + segment + 2) % 144);
224  }
225  }
226  }
227 
228  return m_GBOutputMuons;
229 }
virtual int getTCsCnt()=0
returns count of Trigger Crates in system.
L1RpcTBMuonsVec2 runHalf(L1RpcTBMuonsVec2 &tcsMuonsVec2)
int getHsbMask(int hsb, int input) const
static MuonsGrabber & Instance()
Definition: MuonsGrabber.cc:48
void maskHSBInput(L1RpcTBMuonsVec &newVec, int mask)
std::vector< RPCTBMuon > L1RpcTBMuonsVec
Definition: RPCTBMuon.h:218
std::vector< L1RpcTBMuonsVec > L1RpcTBMuonsVec2
Definition: RPCTBMuon.h:219
void addMuon(RPCTBMuon &mu, int lvl, int region, int hs, int index)
RPCTriggerConfiguration * m_TrigCnfg
Definition: RPCHalfSorter.h:29
L1RpcTBMuonsVec2 m_GBOutputMuons
Definition: RPCHalfSorter.h:27

◆ runHalf()

L1RpcTBMuonsVec2 RPCHalfSorter::runHalf ( L1RpcTBMuonsVec2 tcsMuonsVec2)

Runs GB algorithm for half of the detector - 6 TC (sectors).

Returns
4 munons from barrel (m_GBOutputMuons[0]), and 4 from endcaps (m_GBOutputMuons[1]).

Definition at line 28 of file RPCHalfSorter.cc.

References funct::abs(), HLT_2024v12_cff::eta1, HLT_2024v12_cff::eta2, RPCConst::m_FINAL_OUT_MUONS_CNT, RPCConst::m_SEGMENTS_IN_SECTOR_CNT, and jetUpdater_cfi::sort.

28  {
29  //1+6+1 TC, wazne sa tylko te 6 w srodku
30  for (unsigned int iTC = 0; iTC < tcsMuonsVec2.size() - 1; iTC++) {
31  for (unsigned int iMu = 0; iMu < tcsMuonsVec2[iTC].size(); iMu++) {
32  if (tcsMuonsVec2[iTC][iMu].getCode() == 0)
33  continue;
34  if (tcsMuonsVec2[iTC][iMu].gBDataKilledLast()) {
35  for (unsigned int iMuN = 0; iMuN < tcsMuonsVec2[iTC + 1].size(); iMuN++) {
36  if (tcsMuonsVec2[iTC + 1][iMuN].getCode() == 0)
37  continue;
38  if (tcsMuonsVec2[iTC + 1][iMuN].gBDataKilledFirst()) {
39  int eta1 = tcsMuonsVec2[iTC][iMu].getEtaAddr();
40  int eta2 = tcsMuonsVec2[iTC + 1][iMuN].getEtaAddr();
41  if (eta1 > 16)
42  eta1 = -((~eta1 & 63) + 1);
43  if (eta2 > 16)
44  eta2 = -((~eta2 & 63) + 1);
45  if (abs(eta1 - eta2) <= 1) {
46  if (tcsMuonsVec2[iTC][iMu].getCode() <= tcsMuonsVec2[iTC + 1][iMuN].getCode()) {
47  if (tcsMuonsVec2[iTC][iMu].getSegmentAddr() == RPCConst::m_SEGMENTS_IN_SECTOR_CNT - 1) {
48  tcsMuonsVec2[iTC][iMu].kill();
49  }
50  } else {
51  tcsMuonsVec2[iTC + 1][iMuN].kill();
52  }
53  }
54  }
55  }
56  }
57  }
58  }
59 
60  L1RpcTBMuonsVec outputBarrelMuons;
61  L1RpcTBMuonsVec outputEndcapMuons;
62 
63  for (unsigned int iTC = 1; iTC < tcsMuonsVec2.size() - 1; iTC++)
64  for (unsigned int iMu = 0; iMu < tcsMuonsVec2[iTC].size(); iMu++)
65  if (tcsMuonsVec2[iTC][iMu].isLive()) {
66  // if(abs(16 - tcsMuonsVec2[iTC][iMu].getEtaAddr()) <=7){
67  // etaAddr should be encoded here in 6 bits with 2compl.
68  if (tcsMuonsVec2[iTC][iMu].getEtaAddr() >= 57 || tcsMuonsVec2[iTC][iMu].getEtaAddr() <= 7) {
69  outputBarrelMuons.push_back(tcsMuonsVec2[iTC][iMu]);
70  } else {
71  outputEndcapMuons.push_back(tcsMuonsVec2[iTC][iMu]);
72  }
73  }
74 
75  sort(outputBarrelMuons.begin(), outputBarrelMuons.end(), RPCTBMuon::TMuonMore());
76  sort(outputEndcapMuons.begin(), outputEndcapMuons.end(), RPCTBMuon::TMuonMore());
77 
78  while (outputBarrelMuons.size() < RPCConst::m_FINAL_OUT_MUONS_CNT)
79  outputBarrelMuons.push_back(RPCTBMuon());
80  while (outputBarrelMuons.size() > RPCConst::m_FINAL_OUT_MUONS_CNT)
81  outputBarrelMuons.pop_back();
82 
83  while (outputEndcapMuons.size() < RPCConst::m_FINAL_OUT_MUONS_CNT)
84  outputEndcapMuons.push_back(RPCTBMuon());
85  while (outputEndcapMuons.size() > RPCConst::m_FINAL_OUT_MUONS_CNT)
86  outputEndcapMuons.pop_back();
87 
88  m_GBOutputMuons[0].insert(m_GBOutputMuons[0].end(), outputBarrelMuons.begin(), outputBarrelMuons.end());
89  m_GBOutputMuons[1].insert(m_GBOutputMuons[1].end(), outputEndcapMuons.begin(), outputEndcapMuons.end());
90  return m_GBOutputMuons;
91 }
static const unsigned int m_FINAL_OUT_MUONS_CNT
m_Number of muon candidates return by Final GhostBuster&Sorter
Definition: RPCConst.h:162
static const unsigned int m_SEGMENTS_IN_SECTOR_CNT
m_Number of Logic Segments in one Logic Sector, defines also the number of Logic Cones for one Logic ...
Definition: RPCConst.h:154
std::vector< RPCTBMuon > L1RpcTBMuonsVec
Definition: RPCTBMuon.h:218
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
L1RpcTBMuonsVec2 m_GBOutputMuons
Definition: RPCHalfSorter.h:27
Used in sorting.
Definition: RPCTBMuon.h:89

Member Data Documentation

◆ m_GBOutputMuons

L1RpcTBMuonsVec2 RPCHalfSorter::m_GBOutputMuons
private

Definition at line 27 of file RPCHalfSorter.h.

◆ m_TrigCnfg

RPCTriggerConfiguration* RPCHalfSorter::m_TrigCnfg
private

Definition at line 29 of file RPCHalfSorter.h.