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 ( RPCTriggerConfiguration triggerConfig)

Defualt constructor

Definition at line 17 of file RPCHalfSorter.cc.

17  {
18 
19  m_TrigCnfg = triggerConfig;
20 
21  m_GBOutputMuons.assign(2, L1RpcTBMuonsVec());
22 
23 }
std::vector< RPCTBMuon > L1RpcTBMuonsVec
Definition: RPCTBMuon.h:206
RPCTriggerConfiguration * m_TrigCnfg
Definition: RPCHalfSorter.h:30
L1RpcTBMuonsVec2 m_GBOutputMuons
Definition: RPCHalfSorter.h:28

Member Function Documentation

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

Definition at line 104 of file RPCHalfSorter.cc.

References Exception.

104  {
105 
106  if ( mask < 0 || mask > 3) {
107  throw cms::Exception("RPCHalfSorter::maskHSBInput") << " hsbMask has wrong value - " << mask <<" \n";
108  }
109 
110  if ( mask == 1) { // leave the best muons
111  newVec.at(2) = RPCTBMuon();
112  newVec.at(3) = RPCTBMuon();
113  } else if (mask == 2){
114  newVec.at(0) = RPCTBMuon();
115  newVec.at(1) = RPCTBMuon();
116  } else {
117  newVec.at(0) = RPCTBMuon();
118  newVec.at(1) = RPCTBMuon();
119  newVec.at(2) = RPCTBMuon();
120  newVec.at(3) = RPCTBMuon();
121  }
122 
123 }
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 134 of file RPCHalfSorter.cc.

References MuonsGrabber::addMuon(), gather_cfg::cout, relativeConstraints::empty, L1RPCHsbConfig::getHsbMask(), mps_fire::i, MuonsGrabber::Instance(), and EnergyCorrector::pt.

Referenced by RPCPacTrigger::runEvent().

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

References funct::abs(), end, RPCConst::m_FINAL_OUT_MUONS_CNT, and RPCConst::m_SEGMENTS_IN_SECTOR_CNT.

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

Member Data Documentation

L1RpcTBMuonsVec2 RPCHalfSorter::m_GBOutputMuons
private

Definition at line 28 of file RPCHalfSorter.h.

RPCTriggerConfiguration* RPCHalfSorter::m_TrigCnfg
private

Definition at line 30 of file RPCHalfSorter.h.