CMS 3D CMS Logo

RPCLogCone.cc
Go to the documentation of this file.
1 /*******************************************************************************
2 * *
3 * Karol Bunkowski *
4 * Warsaw University 2002 *
5 * *
6 *******************************************************************************/
9 
10 #include <iostream>
11 #include <iomanip>
12 #include <sstream>
13 
19 RPCLogCone::RPCLogCone() : m_ConeCrdnts() {
21  m_MuonCode = 0;
22  m_MuonSign = 0;
23 }
30 RPCLogCone::RPCLogCone(int tower, int logSector, int logSegment) : m_ConeCrdnts(tower, logSector, logSegment) {
32  m_MuonCode = 0;
33  m_MuonSign = 0;
34 }
42 
43  m_ConeCrdnts = logHit.getConeCrdnts();
44 
45  m_MuonCode = 0;
46  m_MuonSign = 0;
47 
48  setLogStrip(logHit.getlogPlaneNumber() - 1, logHit.getStripNumberInCone(), logHit.getDigiIdx());
49 }
50 
51 RPCLogCone::RPCLogCone(const unsigned long long &pat, int tower, int logSector, int logSegment)
52  : m_ConeCrdnts(tower, logSector, logSegment) {
54  m_MuonCode = 0;
55  m_MuonSign = 0;
56 
57  unsigned long long int mask = 255; // (first 8 bits)
58  int shift = 0;
59 
60  //std::cout << "Decompressing pattern: " << pat << std::endl;
61  for (int logplane = RPCConst::m_FIRST_PLANE; logplane != RPCConst::m_USED_PLANES_COUNT[std::abs(getTower())];
62  ++logplane) {
63  unsigned int strip = (pat & (mask << shift)) >> shift;
64  //std::cout << logplane << " " << strip << std::endl;
65  shift += 8;
66  // We should prob. use m_NOT_CONNECTED value
67  if (strip != RPCConst::m_LOGPLANE_SIZE[std::abs(getTower())][logplane])
68  setLogStrip(logplane, strip);
69  }
70 }
71 
72 unsigned long long RPCLogCone::getCompressedCone() {
73  unsigned long long int pattern = 0;
74  int shift = 0;
75 
76  for (int logplane = RPCConst::m_FIRST_PLANE; logplane != RPCConst::m_USED_PLANES_COUNT[std::abs(getTower())];
77  logplane++) {
78  unsigned long long int strip;
79  if (getHitsCnt(logplane) == 0) {
80  // We need to mark somehow, that plane is empty (strip 0 is not fired)
82  } else if (getHitsCnt(logplane) == 1) {
83  RPCLogCone::TLogPlane lp = getLogPlane(logplane);
84  strip = lp.begin()->first;
85  } else {
86  throw RPCException("To many hits in logcone");
87  }
88  pattern = pattern | (strip << shift);
89  shift += 8;
90  }
91 
92  //std::cout << " Compressed cone: " << pattern << std::endl;
93  return pattern;
94 }
95 
97  std::ostringstream ostr;
98  ostr << "\n ======================> TOWER = ";
99  ostr << std::setw(2) << m_ConeCrdnts.m_Tower << ", m_LogSector = " << m_ConeCrdnts.m_LogSector
100  << ", m_LogSegment = " << m_ConeCrdnts.m_LogSegment << " <=======================" << std::endl;
101 
102  std::string spacer;
103 
104  for (int logPlane = RPCConst::m_LAST_PLANE; logPlane >= RPCConst::m_FIRST_PLANE; logPlane--) {
105  ostr << RPCConst::m_LOGPLANE_STR[logPlane] << " ";
106  spacer.assign((72 - RPCConst::m_LOGPLANE_SIZE[abs(m_ConeCrdnts.m_Tower)][logPlane]) / 2, ' ');
107  ostr << spacer;
108 
109  for (int i = RPCConst::m_LOGPLANE_SIZE[abs(m_ConeCrdnts.m_Tower)][logPlane] - 1; i >= 0; i--) {
110  if (getLogStripState(logPlane, i))
111  ostr << "X";
112  else {
113  if (i % 8 == 0)
114  ostr << i % 10;
115  else
116  ostr << ".";
117  }
118  }
119 
120  ostr << std::endl;
121  }
122 
123  ostr << std::endl;
124  return ostr.str();
125 }
127  int shiftPos;
128  for (int logPlane = RPCConst::m_FIRST_PLANE; logPlane <= RPCConst::m_LAST_PLANE; logPlane++) {
129  TLogPlane shifted;
130  for (TLogPlane::iterator it = m_LogPlanesVec[logPlane].begin(); it != m_LogPlanesVec[logPlane].end(); it++) {
131  shiftPos = it->first + pos;
132  /* std::cout << shiftPos << " "
133  << RPCConst::m_LOGPLANE_SIZE[abs(m_ConeCrdnts.m_Tower)]
134  << std::endl;*/
135  if (shiftPos >= 0 && shiftPos < (int)RPCConst::m_LOGPLANE_SIZE[abs(m_ConeCrdnts.m_Tower)][logPlane])
136  shifted.insert(TLogPlane::value_type(shiftPos, it->second));
137  }
138  m_LogPlanesVec[logPlane] = shifted;
139  }
140 }
141 //
142 //#############################################################################################
143 //
144 // Simple getters and setters
145 //
146 //#############################################################################################
147 RPCLogCone::TLogPlane RPCLogCone::getLogPlane(int logPlane) const { return m_LogPlanesVec[logPlane]; }
148 
150 int RPCLogCone::getHitsCnt(int logPlane) const { return m_LogPlanesVec[logPlane].size(); }
151 
153 void RPCLogCone::setMuonCode(int code) { m_MuonCode = code; }
154 
156 int RPCLogCone::getMuonCode() const { return m_MuonCode; }
157 
159 
160 int RPCLogCone::getMuonSign() const { return m_MuonSign; }
161 
163 
165 
167 
169 
171 
172 int RPCLogCone::getIdx() const { return m_Index; }
173 
174 void RPCLogCone::setLogStrip(int logPlane, int logStripNum, int m_digiIdx) {
175  //m_LogPlanesVec[logPlane].insert(logStripNum);
176  //m_LogPlanesVec[logPlane].insert(TLogPlane::value_type(logStripNum, vector<int>()));
177  m_LogPlanesVec[logPlane][logStripNum].push_back(m_digiIdx);
178 }
179 
180 void RPCLogCone::setLogStrip(int logPlane, int logStripNum) {
181  m_LogPlanesVec[logPlane].insert(TLogPlane::value_type(logStripNum, std::vector<int>()));
182 }
183 
184 bool RPCLogCone::getLogStripState(int logPlane, unsigned int logStripNum) const {
185  return m_LogPlanesVec[logPlane].count(logStripNum);
186 }
187 
193 bool RPCLogCone::addLogHit(const RPCLogHit &logHit) {
194  if (m_ConeCrdnts.m_Tower == logHit.getTower() && m_ConeCrdnts.m_LogSector == logHit.getLogSector() &&
196  setLogStrip(logHit.getlogPlaneNumber() - 1, logHit.getStripNumberInCone(), logHit.getDigiIdx());
197  return true;
198  } else
199  return false;
200 }
201 
202 std::vector<int> RPCLogCone::getLogStripDigisIdxs(int logPlane, unsigned int logStripNum) const {
203  TLogPlane::const_iterator it = m_LogPlanesVec[logPlane].find(logStripNum);
204  if (it != m_LogPlanesVec[logPlane].end())
205  return it->second;
206  else
207  return std::vector<int>();
208 }
209 
210 bool RPCLogCone::isPlaneFired(int logPlane) const {
211  if (m_LogPlanesVec[logPlane].empty())
212  return false;
213  else
214  return true;
215 }
216 
218  int firedPlanes = 0;
220  logPlane++) {
221  firedPlanes = firedPlanes + isPlaneFired(logPlane);
222  }
223  return firedPlanes;
224 }
225 
227  int triggerType = 0; //0 - trigger not possible
228  //1 - 3/4 (3 inner planes fired)
229  //2 - 4/6 (four palnes fired)
230  int firedPlanes = 0;
231 
232  int logPlane = RPCConst::m_FIRST_PLANE;
233  for (; logPlane <= RPCConst::m_LOGPLANE4; logPlane++) {
234  firedPlanes = firedPlanes + isPlaneFired(logPlane);
235  }
236  if (firedPlanes >= 3)
237  triggerType = 1;
238 
239  for (; logPlane < RPCConst::m_USED_PLANES_COUNT[abs(m_ConeCrdnts.m_Tower)]; logPlane++) {
240  firedPlanes = firedPlanes + isPlaneFired(logPlane);
241  }
242  if (firedPlanes >= 4)
243  triggerType = 2;
244 
245  return triggerType;
246 }
static const int m_USED_PLANES_COUNT[m_TOWER_COUNT]
m_Number of Logic Planes existing in each m_Tower.
Definition: RPCConst.h:87
int getLogSegment() const
Definition: RPCLogHit.cc:27
int getLogSegment() const
Definition: RPCLogCone.cc:166
std::map< int, std::vector< int > > TLogPlane
Definition: RPCLogCone.h:30
The coordinates of Logic Cone: m_Tower, m_LogSector, m_LogSegment.
Definition: RPCConst.h:118
std::string toString() const
Definition: RPCLogCone.cc:96
RPCLogCone()
Default constructor. No hits, no muon.
Definition: RPCLogCone.cc:19
void setMuonSign(int sign)
Definition: RPCLogCone.cc:158
void setMuonCode(int code)
sets pt code of muon that fired the strips */
Definition: RPCLogCone.cc:153
static const int m_LAST_PLANE
Use ase a last index in loops.
Definition: RPCConst.h:56
void shift(int pos)
Changes fired LogStrips: from "stripNum" to "stripNum + pos".
Definition: RPCLogCone.cc:126
TLogPlane getLogPlane(int logPlane) const
Definition: RPCLogCone.cc:147
RPCConst::l1RpcConeCrdnts getConeCrdnts() const
Definition: RPCLogHit.cc:21
int getHitsCnt(int logPlane) const
Gets fired strips count in given logPlane.
Definition: RPCLogCone.cc:150
int getIdx() const
Definition: RPCLogCone.cc:172
Definition: HeavyIon.h:7
static const int m_LOGPLANE4
Definition: RPCConst.h:51
int getMuonSign() const
Definition: RPCLogCone.cc:160
RPCConst::l1RpcConeCrdnts m_ConeCrdnts
Definition: RPCLogCone.h:109
static const std::string m_LOGPLANE_STR[]
Log Planes names.
Definition: RPCConst.h:78
bool getLogStripState(int logPlane, unsigned int logStripNum) const
Definition: RPCLogCone.cc:184
RPCConst::l1RpcConeCrdnts getConeCrdnts() const
Definition: RPCLogCone.cc:168
int getFiredPlanesCnt() const
Definition: RPCLogCone.cc:217
void setLogStrip(int logPlane, int logStripNum, int m_digiIdx)
Set logic strip as fired. m_digiIdx - index of digi in digis vector stored by L1RpcTrigg.
Definition: RPCLogCone.cc:174
int getTower() const
Definition: RPCLogHit.cc:23
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void setIdx(int index)
Definition: RPCLogCone.cc:170
bool addLogHit(const RPCLogHit &logHit)
Adds next logHit .
Definition: RPCLogCone.cc:193
static const unsigned int m_LOGPLANE_SIZE[m_TOWER_COUNT][m_LOGPLANES_COUNT]
Definition of Logic Cone Sizes - number of Logic m_Strips in each plane.
Definition: RPCConst.h:81
static const int m_FIRST_PLANE
Use ase a first index in loops.
Definition: RPCConst.h:55
int getLogSector() const
Definition: RPCLogHit.cc:25
int getStripNumberInCone() const
Definition: RPCLogHit.cc:31
std::vector< TLogPlane > m_LogPlanesVec
Logic Planes.
Definition: RPCLogCone.h:102
int m_MuonCode
Definition: RPCLogCone.h:111
int m_MuonSign
Definition: RPCLogCone.h:113
std::vector< int > getLogStripDigisIdxs(int logPlane, unsigned int logStripNum) const
Definition: RPCLogCone.cc:202
unsigned long long getCompressedCone()
Compresses cone. Throws exception, if there is more than one hit in any logplane. ...
Definition: RPCLogCone.cc:72
static const int m_LOGPLANES_COUNT
Max Logic Planes Count in trigger towers.
Definition: RPCConst.h:45
int getDigiIdx() const
Definition: RPCLogHit.cc:35
int getTower() const
Definition: RPCLogCone.cc:162
int getMuonCode() const
Definition: RPCLogCone.cc:156
int possibleTrigger() const
Definition: RPCLogCone.cc:226
int getLogSector() const
Definition: RPCLogCone.cc:164
int getlogPlaneNumber() const
Definition: RPCLogHit.cc:29
int m_Index
m_Index in LogConesVec stored by L1RpcTrigg
Definition: RPCLogCone.h:116
bool isPlaneFired(int logPlane) const
Definition: RPCLogCone.cc:210