test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
20  m_ConeCrdnts()
21 {
23  m_MuonCode = 0;
24  m_MuonSign = 0;
25 }
32 RPCLogCone::RPCLogCone(int tower, int logSector, int logSegment):
33  m_ConeCrdnts(tower, logSector, logSegment)
34 {
36  m_MuonCode = 0;
37  m_MuonSign = 0;
38 }
45 {
47 
48  m_ConeCrdnts = logHit.getConeCrdnts();
49 
50  m_MuonCode = 0;
51  m_MuonSign = 0;
52 
53  setLogStrip(logHit.getlogPlaneNumber() -1, logHit.getStripNumberInCone(), logHit.getDigiIdx());
54 }
55 
56 RPCLogCone::RPCLogCone(const unsigned long long &pat, int tower, int logSector, int logSegment):
57  m_ConeCrdnts(tower, logSector, logSegment)
58 {
60  m_MuonCode = 0;
61  m_MuonSign = 0;
62 
63  unsigned long long int mask = 255; // (first 8 bits)
64  int shift = 0;
65 
66  //std::cout << "Decompressing pattern: " << pat << std::endl;
67  for (int logplane = RPCConst::m_FIRST_PLANE;
69  ++logplane )
70  {
71  unsigned int strip = (pat & (mask<<shift) ) >> shift;
72  //std::cout << logplane << " " << strip << std::endl;
73  shift += 8;
74  // We should prob. use m_NOT_CONNECTED value
75  if (strip != RPCConst::m_LOGPLANE_SIZE[std::abs(getTower())][logplane])
76  setLogStrip(logplane,strip);
77  }
78 }
79 
80 unsigned long long RPCLogCone::getCompressedCone(){
81 
82  unsigned long long int pattern = 0;
83  int shift = 0;
84 
85  for (int logplane = RPCConst::m_FIRST_PLANE;
87  logplane++ )
88  {
89  unsigned long long int strip;
90  if (getHitsCnt(logplane)==0) {
91  // We need to mark somehow, that plane is empty (strip 0 is not fired)
92  strip = RPCConst::m_LOGPLANE_SIZE[std::abs(getTower())][logplane];
93  }
94  else if (getHitsCnt(logplane)==1) {
95  RPCLogCone::TLogPlane lp = getLogPlane(logplane);
96  strip = lp.begin()->first;
97  }
98  else {
99  throw RPCException("To many hits in logcone");
100  }
101  pattern = pattern | (strip << shift);
102  shift += 8;
103  }
104 
105  //std::cout << " Compressed cone: " << pattern << std::endl;
106  return pattern;
107 }
108 
109 
111  std::ostringstream ostr;
112  ostr << "\n ======================> TOWER = ";
113  ostr<<std::setw(2)
115  <<", m_LogSector = "
117  <<", m_LogSegment = "
119  <<" <======================="<< std::endl;
120 
121  std::string spacer;
122 
123  for (int logPlane = RPCConst::m_LAST_PLANE; logPlane >= RPCConst::m_FIRST_PLANE; logPlane--) {
124  ostr<<RPCConst::m_LOGPLANE_STR[logPlane]<<" ";
125  spacer.assign((72 - RPCConst::m_LOGPLANE_SIZE[abs(m_ConeCrdnts.m_Tower)][logPlane])/2, ' ');
126  ostr<<spacer;
127 
128  for(int i = RPCConst::m_LOGPLANE_SIZE[abs(m_ConeCrdnts.m_Tower)][logPlane]-1; i >=0; i--) {
129  if(getLogStripState(logPlane, i))
130  ostr<<"X";
131  else {
132  if(i%8 == 0)
133  ostr<<i%10;
134  else
135  ostr<<".";
136  }
137  }
138 
139  ostr<<std::endl;
140  }
141 
142  ostr<< std::endl;
143  return ostr.str();
144 }
145 void RPCLogCone::shift(int pos) {
146  int shiftPos;
147  for(int logPlane = RPCConst::m_FIRST_PLANE; logPlane <= RPCConst::m_LAST_PLANE; logPlane++) {
148  TLogPlane shifted;
149  for(TLogPlane::iterator it = m_LogPlanesVec[logPlane].begin();
150  it != m_LogPlanesVec[logPlane].end();
151  it++)
152  {
153  shiftPos = it->first + pos;
154  /* std::cout << shiftPos << " "
155  << RPCConst::m_LOGPLANE_SIZE[abs(m_ConeCrdnts.m_Tower)]
156  << std::endl;*/
157  if ( shiftPos >= 0 && shiftPos < (int)RPCConst::m_LOGPLANE_SIZE[abs(m_ConeCrdnts.m_Tower)][logPlane])
158  shifted.insert(TLogPlane::value_type(shiftPos, it->second));
159  }
160  m_LogPlanesVec[logPlane] = shifted;
161  }
162 }
163 //
164 //#############################################################################################
165 //
166 // Simple getters and setters
167 //
168 //#############################################################################################
170  return m_LogPlanesVec[logPlane];
171 }
172 
174 int RPCLogCone::getHitsCnt(int logPlane) const {
175  return m_LogPlanesVec[logPlane].size();
176 }
177 
179 void RPCLogCone::setMuonCode(int code) { m_MuonCode = code; }
180 
182 int RPCLogCone::getMuonCode() const { return m_MuonCode; }
183 
185 
186 int RPCLogCone::getMuonSign() const { return m_MuonSign; }
187 
189 
191 
193 
195 
197 
198 int RPCLogCone::getIdx() const { return m_Index; }
199 
200 void RPCLogCone::setLogStrip(int logPlane, int logStripNum, int m_digiIdx) {
201 //m_LogPlanesVec[logPlane].insert(logStripNum);
202 //m_LogPlanesVec[logPlane].insert(TLogPlane::value_type(logStripNum, vector<int>()));
203  m_LogPlanesVec[logPlane][logStripNum].push_back(m_digiIdx);
204 }
205 
206 void RPCLogCone::setLogStrip(int logPlane, int logStripNum) {
207  m_LogPlanesVec[logPlane].insert(TLogPlane::value_type(logStripNum, std::vector<int>()));
208 }
209 
210 
211 bool RPCLogCone::getLogStripState(int logPlane, unsigned int logStripNum) const {
212  return m_LogPlanesVec[logPlane].count(logStripNum);
213 }
214 
215 
221 bool RPCLogCone::addLogHit(const RPCLogHit &logHit) {
222 
223  if (m_ConeCrdnts.m_Tower == logHit.getTower() &&
224  m_ConeCrdnts.m_LogSector == logHit.getLogSector() &&
226  {
227  setLogStrip(logHit.getlogPlaneNumber()-1, logHit.getStripNumberInCone(), logHit.getDigiIdx());
228  return true;
229  }
230  else
231  return false;
232 }
233 
234 
235 std::vector<int> RPCLogCone::getLogStripDigisIdxs(int logPlane, unsigned int logStripNum) const {
236  TLogPlane::const_iterator it = m_LogPlanesVec[logPlane].find(logStripNum);
237  if(it != m_LogPlanesVec[logPlane].end())
238  return it->second;
239  else
240  return std::vector<int>();
241 }
242 
243 
244 bool RPCLogCone::isPlaneFired(int logPlane) const {
245  if(m_LogPlanesVec[logPlane].size() == 0)
246  return false;
247  else
248  return true;
249 }
250 
252  int firedPlanes = 0;
253  for(int logPlane = RPCConst::m_FIRST_PLANE;
255  logPlane++)
256  {
257  firedPlanes = firedPlanes + isPlaneFired(logPlane);
258  }
259  return firedPlanes;
260 }
261 
262 
264  int triggerType = 0; //0 - trigger not possible
265  //1 - 3/4 (3 inner planes fired)
266  //2 - 4/6 (four palnes fired)
267  int firedPlanes = 0;
268 
269  int logPlane = RPCConst::m_FIRST_PLANE;
270  for( ; logPlane <= RPCConst::m_LOGPLANE4; logPlane++) {
271  firedPlanes = firedPlanes + isPlaneFired(logPlane);
272  }
273  if(firedPlanes >= 3)
274  triggerType = 1;
275 
276  for( ;
278  logPlane++)
279  {
280  firedPlanes = firedPlanes + isPlaneFired(logPlane);
281  }
282  if(firedPlanes >= 4)
283  triggerType = 2;
284 
285  return triggerType;
286 }
static const int m_USED_PLANES_COUNT[m_TOWER_COUNT]
m_Number of Logic Planes existing in each m_Tower.
Definition: RPCConst.h:88
int i
Definition: DBlmapReader.cc:9
int getLogSegment() const
Definition: RPCLogHit.cc:36
std::map< int, std::vector< int > > TLogPlane
Definition: RPCLogCone.h:34
The coordinates of Logic Cone: m_Tower, m_LogSector, m_LogSegment.
Definition: RPCConst.h:119
int getMuonCode() const
Definition: RPCLogCone.cc:182
bool getLogStripState(int logPlane, unsigned int logStripNum) const
Definition: RPCLogCone.cc:211
double sign(double x)
RPCLogCone()
Default constructor. No hits, no muon.
Definition: RPCLogCone.cc:19
void setMuonSign(int sign)
Definition: RPCLogCone.cc:184
void setMuonCode(int code)
sets pt code of muon that fired the strips */
Definition: RPCLogCone.cc:179
static const int m_LAST_PLANE
Use ase a last index in loops.
Definition: RPCConst.h:57
void shift(int pos)
Changes fired LogStrips: from &quot;stripNum&quot; to &quot;stripNum + pos&quot;.
Definition: RPCLogCone.cc:145
std::string toString() const
Definition: RPCLogCone.cc:110
int getLogSegment() const
Definition: RPCLogCone.cc:192
bool isPlaneFired(int logPlane) const
Definition: RPCLogCone.cc:244
RPCConst::l1RpcConeCrdnts getConeCrdnts() const
Definition: RPCLogHit.cc:24
static const int m_LOGPLANE4
Definition: RPCConst.h:52
int getFiredPlanesCnt() const
Definition: RPCLogCone.cc:251
RPCConst::l1RpcConeCrdnts m_ConeCrdnts
Definition: RPCLogCone.h:116
TLogPlane getLogPlane(int logPlane) const
Definition: RPCLogCone.cc:169
int getTower() const
Definition: RPCLogCone.cc:188
static const std::string m_LOGPLANE_STR[]
Log Planes names.
Definition: RPCConst.h:79
int getMuonSign() const
Definition: RPCLogCone.cc:186
int getIdx() const
Definition: RPCLogCone.cc:198
int getHitsCnt(int logPlane) const
Gets fired strips count in given logPlane.
Definition: RPCLogCone.cc:174
int getLogSector() const
Definition: RPCLogCone.cc:190
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:200
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void setIdx(int index)
Definition: RPCLogCone.cc:196
bool addLogHit(const RPCLogHit &logHit)
Adds next logHit .
Definition: RPCLogCone.cc:221
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:82
#define end
Definition: vmac.h:37
static const int m_FIRST_PLANE
Use ase a first index in loops.
Definition: RPCConst.h:56
std::vector< TLogPlane > m_LogPlanesVec
Logic Planes.
Definition: RPCLogCone.h:109
int m_MuonCode
Definition: RPCLogCone.h:118
int getStripNumberInCone() const
Definition: RPCLogHit.cc:44
int m_MuonSign
Definition: RPCLogCone.h:120
RPCConst::l1RpcConeCrdnts getConeCrdnts() const
Definition: RPCLogCone.cc:194
unsigned long long getCompressedCone()
Compresses cone. Throws exception, if there is more than one hit in any logplane. ...
Definition: RPCLogCone.cc:80
static const int m_LOGPLANES_COUNT
Max Logic Planes Count in trigger towers.
Definition: RPCConst.h:47
int getTower() const
Definition: RPCLogHit.cc:28
#define begin
Definition: vmac.h:30
int getlogPlaneNumber() const
Definition: RPCLogHit.cc:40
int getLogSector() const
Definition: RPCLogHit.cc:32
int getDigiIdx() const
Definition: RPCLogHit.cc:52
std::vector< int > getLogStripDigisIdxs(int logPlane, unsigned int logStripNum) const
Definition: RPCLogCone.cc:235
int possibleTrigger() const
Definition: RPCLogCone.cc:263
tuple size
Write out results.
int m_Index
m_Index in LogConesVec stored by L1RpcTrigg
Definition: RPCLogCone.h:123