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() {
20  m_LogPlanesVec.assign(RPCConst::m_LOGPLANES_COUNT, TLogPlane());
21  m_MuonCode = 0;
22  m_MuonSign = 0;
23 }
30 RPCLogCone::RPCLogCone(int tower, int logSector, int logSegment) : m_ConeCrdnts(tower, logSector, logSegment) {
31  m_LogPlanesVec.assign(RPCConst::m_LOGPLANES_COUNT, TLogPlane());
32  m_MuonCode = 0;
33  m_MuonSign = 0;
34 }
40 RPCLogCone::RPCLogCone(const RPCLogHit &logHit) {
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 }
126 void RPCLogCone::shift(int pos) {
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 
162 int RPCLogCone::getTower() const { return m_ConeCrdnts.m_Tower; }
163 
164 int RPCLogCone::getLogSector() const { return m_ConeCrdnts.m_LogSector; }
165 
167 
169 
170 void RPCLogCone::setIdx(int index) { m_Index = index; }
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 
217 int RPCLogCone::getFiredPlanesCnt() const {
218  int firedPlanes = 0;
220  logPlane++) {
221  firedPlanes = firedPlanes + isPlaneFired(logPlane);
222  }
223  return firedPlanes;
224 }
225 
226 int RPCLogCone::possibleTrigger() const {
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 }
RPCLogCone::getLogStripState
bool getLogStripState(int logPlane, unsigned int logStripNum) const
Definition: RPCLogCone.cc:183
RPCLogCone::shift
void shift(int pos)
Changes fired LogStrips: from "stripNum" to "stripNum + pos".
Definition: RPCLogCone.cc:125
mps_fire.i
i
Definition: mps_fire.py:428
RPCLogCone::m_LogPlanesVec
std::vector< TLogPlane > m_LogPlanesVec
Logic Planes.
Definition: RPCLogCone.h:102
RPCException.h
RPCLogCone.h
RPCConst::l1RpcConeCrdnts::m_Tower
int m_Tower
Definition: RPCConst.h:119
RPCLogCone::m_MuonSign
int m_MuonSign
Definition: RPCLogCone.h:113
RPCLogCone::getTower
int getTower() const
Definition: RPCLogCone.cc:161
digitizers_cfi.strip
strip
Definition: digitizers_cfi.py:19
RPCLogCone::getIdx
int getIdx() const
Definition: RPCLogCone.cc:171
pos
Definition: PixelAliasList.h:18
hgcalTowerProducer_cfi.tower
tower
Definition: hgcalTowerProducer_cfi.py:4
Validation_hcalonly_cfi.sign
sign
Definition: Validation_hcalonly_cfi.py:32
RPCLogCone::getLogStripDigisIdxs
std::vector< int > getLogStripDigisIdxs(int logPlane, unsigned int logStripNum) const
Definition: RPCLogCone.cc:201
RPCLogCone::addLogHit
bool addLogHit(const RPCLogHit &logHit)
Adds next logHit .
Definition: RPCLogCone.cc:192
RPCLogCone::getCompressedCone
unsigned long long getCompressedCone()
Compresses cone. Throws exception, if there is more than one hit in any logplane.
Definition: RPCLogCone.cc:71
RPCLogHit::getTower
int getTower() const
Definition: RPCLogHit.cc:23
RPCLogCone::getFiredPlanesCnt
int getFiredPlanesCnt() const
Definition: RPCLogCone.cc:216
RPCLogHit
Definition: RPCLogHit.h:20
RPCConst::m_LOGPLANE4
static const int m_LOGPLANE4
Definition: RPCConst.h:51
RPCConst::l1RpcConeCrdnts
The coordinates of Logic Cone: m_Tower, m_LogSector, m_LogSegment.
Definition: RPCConst.h:118
RPCLogCone::setMuonCode
void setMuonCode(int code)
sets pt code of muon that fired the strips *‍/
Definition: RPCLogCone.cc:152
RPCLogHit::getLogSector
int getLogSector() const
Definition: RPCLogHit.cc:25
RPCLogCone::setIdx
void setIdx(int index)
Definition: RPCLogCone.cc:169
RPCLogHit::getStripNumberInCone
int getStripNumberInCone() const
Definition: RPCLogHit.cc:31
RPCConst::m_LOGPLANE_STR
static const std::string m_LOGPLANE_STR[]
Log Planes names.
Definition: RPCConst.h:78
RPCLogCone::getLogSector
int getLogSector() const
Definition: RPCLogCone.cc:163
RPCLogCone::TLogPlane
std::map< int, std::vector< int > > TLogPlane
Definition: RPCLogCone.h:30
RPCLogCone::getLogPlane
TLogPlane getLogPlane(int logPlane) const
Definition: RPCLogCone.cc:146
mps_fire.end
end
Definition: mps_fire.py:242
RPCLogCone::getLogSegment
int getLogSegment() const
Definition: RPCLogCone.cc:165
RPCLogCone::isPlaneFired
bool isPlaneFired(int logPlane) const
Definition: RPCLogCone.cc:209
RPCConst::m_FIRST_PLANE
static const int m_FIRST_PLANE
Use ase a first index in loops.
Definition: RPCConst.h:55
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
RPCLogCone::getMuonSign
int getMuonSign() const
Definition: RPCLogCone.cc:159
RPCLogCone::m_ConeCrdnts
RPCConst::l1RpcConeCrdnts m_ConeCrdnts
Definition: RPCLogCone.h:109
RPCConst::l1RpcConeCrdnts::m_LogSegment
int m_LogSegment
Definition: RPCConst.h:121
RPCLogCone::getHitsCnt
int getHitsCnt(int logPlane) const
Gets fired strips count in given logPlane.
Definition: RPCLogCone.cc:149
RPCLogHit::getlogPlaneNumber
int getlogPlaneNumber() const
Definition: RPCLogHit.cc:29
RPCException
Definition: RPCException.h:21
RPCLogHit::getDigiIdx
int getDigiIdx() const
Definition: RPCLogHit.cc:35
topSingleLeptonDQM_PU_cfi.pattern
pattern
Definition: topSingleLeptonDQM_PU_cfi.py:39
RPCLogCone::getMuonCode
int getMuonCode() const
Definition: RPCLogCone.cc:155
RPCLogCone::possibleTrigger
int possibleTrigger() const
Definition: RPCLogCone.cc:225
RPCLogCone::setLogStrip
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:173
pat
Definition: HeavyIon.h:7
HLT_FULL_cff.triggerType
triggerType
Definition: HLT_FULL_cff.py:8756
reco::JetExtendedAssociation::value_type
Container::value_type value_type
Definition: JetExtendedAssociation.h:30
RPCConst::m_USED_PLANES_COUNT
static const int m_USED_PLANES_COUNT[m_TOWER_COUNT]
m_Number of Logic Planes existing in each m_Tower.
Definition: RPCConst.h:87
RPCLogCone::toString
std::string toString() const
Definition: RPCLogCone.cc:95
RPCLogCone::setMuonSign
void setMuonSign(int sign)
Definition: RPCLogCone.cc:157
RPCLogCone::getConeCrdnts
RPCConst::l1RpcConeCrdnts getConeCrdnts() const
Definition: RPCLogCone.cc:167
RPCLogCone::m_Index
int m_Index
m_Index in LogConesVec stored by L1RpcTrigg
Definition: RPCLogCone.h:116
relativeConstraints.empty
bool empty
Definition: relativeConstraints.py:46
RPCLogHit::getLogSegment
int getLogSegment() const
Definition: RPCLogHit.cc:27
RPCLogCone::RPCLogCone
RPCLogCone()
Default constructor. No hits, no muon.
Definition: RPCLogCone.cc:18
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
RPCConst::m_LOGPLANE_SIZE
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
RPCConst::m_LOGPLANES_COUNT
static const int m_LOGPLANES_COUNT
Max Logic Planes Count in trigger towers.
Definition: RPCConst.h:45
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
RPCConst::l1RpcConeCrdnts::m_LogSector
int m_LogSector
Definition: RPCConst.h:120
RPCLogCone::m_MuonCode
int m_MuonCode
Definition: RPCLogCone.h:111
RPCLogHit::getConeCrdnts
RPCConst::l1RpcConeCrdnts getConeCrdnts() const
Definition: RPCLogHit.cc:21
RPCConst::m_LAST_PLANE
static const int m_LAST_PLANE
Use ase a last index in loops.
Definition: RPCConst.h:56