27 m_isReferenceRing(
false),
29 m_didFiltering(
false) {}
32 : m_didVirtuals(
false), m_didFiltering(
false), m_connectionsMap(cmap) {
62 throw cms::Exception(
"RPCInternal") <<
"RPCStripsRing::addRoll ringsIds dont match \n";
66 for (
int i = 1;
i <=
roll->nstrips();
i++) {
69 float phiRaw = gStripCentre.
phi();
72 (*this)[phiRaw] = newStrip;
82 return 1000 * (hwPlane) +
129 throw cms::Exception(
"RPCInternal") <<
"Calculated negative hwplane \n";
143 typedef std::map<uint32_t, int> TDetId2StripNo;
144 TDetId2StripNo det2stripNo;
147 int ch1EndStrips = 0;
150 RPCStripsRing::iterator
it = this->begin();
151 uint32_t ch1Det =
it->second.m_detRawId;
152 for (;
it != this->
end(); ++
it) {
153 if (det2stripNo.find(
it->second.m_detRawId) == det2stripNo.end()) {
154 det2stripNo[
it->second.m_detRawId] = 1;
156 ++det2stripNo[
it->second.m_detRawId];
159 if (det2stripNo.size() != 1 && ch1Det ==
it->second.m_detRawId) {
164 det2stripNo[ch1Det] -= ch1EndStrips;
174 uint32_t lastDet =
it->second.m_detRawId;
175 while (
it != this->
end()) {
176 if (det2stripNo[
it->second.m_detRawId] < 0) {
177 throw cms::Exception(
"RPCInternal") <<
" RPCStripsRing::filterOverlapingChambers() - no strips left \n";
179 if (
it->second.m_detRawId == lastDet) {
180 --det2stripNo[lastDet];
182 }
else if (det2stripNo[lastDet] == 0) {
184 if (lastDet == ch1Det) {
185 det2stripNo[ch1Det] += ch1EndStrips;
188 lastDet =
it->second.m_detRawId;
189 --det2stripNo[lastDet];
192 --det2stripNo[
it->second.m_detRawId];
193 RPCStripsRing::iterator itErase =
it;
196 this->erase(itErase);
206 const float pi = 3.141592654;
207 double dphi = 2.0 *
pi / 1152;
214 RPCStripsRing::iterator
it = this->begin();
215 RPCStripsRing::iterator itLast = this->begin();
216 for (;
it != this->
end(); ++
it) {
222 delta =
it->first - itLast->first;
224 itLast->second.m_detRawId ==
it->second.m_detRawId ||
230 stripsToAdd = (
int)std::floor(
delta / dphi) - 1;
236 for (
int i = 0;
i < stripsToAdd; ++
i) {
237 stripsToInsert[itLast->first + dphi * (
i + 1)] =
TStrip();
244 this->
insert(stripsToInsert.begin(), stripsToInsert.end());
260 throw cms::Exception(
"RPCInternal") <<
" RPCStripsRing::createRefConnections " 261 <<
" called for non-reference ring \n";
270 const float pi = 3.141592654;
271 const float offset = (5. / 360.) * 2 *
pi;
274 RPCStripsRing::iterator starEndIt = this->begin();
278 RPCStripsRing::iterator
it = starEndIt;
284 int curBegStripNo = 0;
286 bool firstIter =
true;
288 while (
it != starEndIt || firstIter) {
292 if (curStripNo % logplaneSize == 0) {
294 curBegStripNo = curStripNo;
295 RPCStripsRing::iterator plus8 =
it;
296 bool skipOccured =
false;
297 for (
int i = 0;
i < 7; ++
i) {
299 if (plus8 == this->
end()) {
300 plus8 = this->begin();
306 float phi =
it->first;
307 float phiP8 = plus8->first;
312 if (
phi * phiP8 > 0) {
313 throw cms::Exception(
"RPCInternal") <<
" RPCStripsRing::createRefConnections phi/phi8 error \n";
321 throw cms::Exception(
"RPCInternal") <<
" RPCStripsRing::createRefConnections " 322 <<
" problem with angle calc \n";
329 TOtherConnStructVec::iterator itOt = otherRings.begin();
330 for (; itOt != otherRings.end(); ++itOt) {
331 itOt->m_it->second.createOtherConnections(
336 if (!
it->second.isVirtual()) {
339 newCon.
m_PAC = curPACno;
341 newCon.
m_logstrip = curStripNo - curBegStripNo;
343 (*m_connectionsMap)[
it->second.m_detRawId][
it->second.m_strip].push_back(newCon);
348 if (
it == this->
end()) {
362 throw cms::Exception(
"RPCInternal") <<
" RPCStripsRing::createOtherConnections " 363 <<
" called for reference ring \n";
368 if (
it == this->
end())
371 for (
int i = 0;
i < logplaneSize / 2;
i++) {
372 if (
it == this->begin())
378 for (
int i = 0;
i < logplaneSize;
i++) {
379 if (!
it->second.isVirtual()) {
382 newCon.
m_PAC = PACno;
385 (*m_connectionsMap)[
it->second.m_detRawId][
it->second.m_strip].push_back(newCon);
390 if (
it == this->
end())
400 throw cms::Exception(
"RPCInternal") <<
" RPCStripsRing::getTowerForRefRing() " 401 <<
" called for non reference ring \n";
407 }
else if (etaAbs > 8) {
411 throw cms::Exception(
"RPCInternal") <<
" RPCStripsRing::getTowerForRefRing() " 412 <<
" called for etaPartition 8 \n";
443 auto uncompressedConsLeft = std::make_shared<L1RPCConeBuilder::TConMap>();
447 int compressedCons = 0, uncompressedConsBefore = 0, uncompressedConsAfter = 0;
452 uint32_t
detId = itChamber->first;
454 for (L1RPCConeBuilder::TStrip2ConVec::iterator itStrip = itChamber->second.begin();
455 itStrip != itChamber->second.end();
458 for (L1RPCConeBuilder::TStripConVec::iterator itConn = itStrip->second.begin(); itConn != itStrip->second.end();
461 ++uncompressedConsBefore;
462 bool alreadyDone =
false;
466 itCompConn != (*m_compressedConnectionMap)[
detId].end();
468 if (itCompConn->m_tower == itConn->m_tower && itCompConn->m_PAC == itConn->m_PAC &&
469 itCompConn->m_logplane == itConn->m_logplane)
473 int logStrip = itCompConn->m_mul * itStrip->first + itCompConn->m_offset;
474 if (logStrip != itConn->m_logstrip) {
476 (*uncompressedConsLeft)[
detId][itStrip->first].push_back(*itConn);
477 ++uncompressedConsAfter;
479 <<
" Compression failed for det " <<
detId <<
" strip " << (
int)itStrip->first <<
" . Got " 480 << (
int)logStrip <<
" expected " << (
int)itConn->m_logstrip << std::endl;
482 itCompConn->addStrip(itStrip->first);
491 L1RPCConeBuilder::TStrip2ConVec::iterator itStripOther = itStrip;
493 bool otherStripFound =
false;
495 for (; itStripOther != itChamber->second.end() && !otherStripFound; ++itStripOther) {
496 for (L1RPCConeBuilder::TStripConVec::iterator itConnOther = itStripOther->second.begin();
497 itConnOther != itStripOther->second.end();
499 if (itConnOther->m_tower == itConn->m_tower && itConnOther->m_PAC == itConn->m_PAC &&
500 itConnOther->m_logplane == itConn->m_logplane)
502 otherStripFound =
true;
503 if ((itStripOther->first - itStrip->first) * (itConnOther->m_logstrip - itConn->m_logstrip) < 0) {
524 nCompConn.
m_tower = itConn->m_tower;
525 nCompConn.
m_PAC = itConn->m_PAC;
527 nCompConn.
m_mul = mul;
528 nCompConn.
m_offset = itConn->m_logstrip - mul * (
signed short)(itStrip->first);
531 if (otherStripFound) {
536 (*m_compressedConnectionMap)[
detId].push_back(nCompConn);
547 edm::LogInfo(
"RPCTriggerConfig") <<
" Compressed: " << compressedCons <<
" " 549 <<
" Uncompressed before: " << uncompressedConsBefore <<
" " 551 <<
" Uncompressed after: " << uncompressedConsAfter <<
" "
std::shared_ptr< L1RPCConeBuilder::TConMap > m_connectionsMap
void compressConnections()
void fillWithVirtualStrips()
ret
prodAgent to be discontinued
Geom::Phi< T > phi() const
void addStrip(unsigned char strip)
virtual int eta_partition()
void createOtherConnections(int tower, int PACno, int logplane, int logplanesize, float angle)
void filterOverlapingChambers()
std::vector< TOtherConnStruct > TOtherConnStructVec
Abs< T >::type abs(const T &t)
bool insert(Storage &iStorage, ItemType *iItem, const IdTag &iIdTag)
Log< level::Info, false > LogInfo
void addRoll(const RPCRoll *roll)
std::shared_ptr< L1RPCConeBuilder::TCompressedConMap > m_compressedConnectionMap
static int calculateHwPlane(const RPCRoll *roll)
Calculate ringId for any given RPCRoll.
void createRefConnections(TOtherConnStructVec &otherRings, int logplane, int logplaneSize)
Log< level::Warning, false > LogWarning
T angle(T x1, T y1, T z1, T x2, T y2, T z2)