CMS 3D CMS Logo

RPCConeBuilder.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: RPCConeBuilder
4 // Class: RPCConeBuilder
5 //
13 //
14 // Original Author: Tomasz Maciej Frueboes
15 // Created: Fri Feb 22 13:57:06 CET 2008
16 //
17 //
18 
32 
33 #include <cmath>
34 #include <vector>
35 #include <map>
36 #include <memory>
37 #include <utility>
38 
40 public:
42 
43  using ReturnType = std::unique_ptr<L1RPCConeBuilder>;
44 
46 
47 private:
49 
51 
55  std::pair<int, int> areConnected(RPCStripsRing::TIdToRindMap::iterator ref,
56  RPCStripsRing::TIdToRindMap::iterator other,
57  L1RPCConeDefinition const*);
58 
59  // ----------member data ---------------------------
64 };
65 
67  : m_towerBeg(iConfig.getParameter<int>("towerBeg")), m_towerEnd(iConfig.getParameter<int>("towerEnd")) {
68  setWhatProduced(this).setConsumes(m_rpcGeometryToken).setConsumes(m_l1RPCConeDefinitionToken);
69 }
70 
71 // ------------ method called to produce the data ------------
73  auto pL1RPCConeBuilder = std::make_unique<L1RPCConeBuilder>();
74 
75  pL1RPCConeBuilder->setFirstTower(m_towerBeg);
76  pL1RPCConeBuilder->setLastTower(m_towerEnd);
77 
79 
80  buildCones(&iRecord.get(m_rpcGeometryToken), &iRecord.get(m_l1RPCConeDefinitionToken), ringsMap);
81 
82  // Compress all connections. Since members of this class are shared
83  // pointers this call will compress all data
84  ringsMap.begin()->second.compressConnections();
85 
86  pL1RPCConeBuilder->setConeConnectionMap(ringsMap.begin()->second.getConnectionsMap());
87 
88  pL1RPCConeBuilder->setCompressedConeConnectionMap(ringsMap.begin()->second.getCompressedConnectionsMap());
89 
90  return pL1RPCConeBuilder;
91 }
92 
94  L1RPCConeDefinition const* l1RPCConeDefinition,
95  RPCStripsRing::TIdToRindMap& ringsMap) {
96  // fetch geometrical data
97  auto uncompressedCons = std::make_shared<L1RPCConeBuilder::TConMap>();
98 
99  int rolls = 0;
100  for (auto const& it : rpcGeom->dets()) {
101  RPCRoll const* roll = dynamic_cast<RPCRoll const*>(it);
102  if (roll == nullptr) {
103  continue;
104  }
105 
106  ++rolls;
107 
108  int ringId = RPCStripsRing::getRingId(roll);
109  auto found = ringsMap.find(ringId);
110  if (found == ringsMap.end()) {
111  ringsMap[ringId] = RPCStripsRing(roll, uncompressedCons);
112  } else {
113  found->second.addRoll(roll);
114  }
115  }
116 
117  // filtermixed strips, fill gaps with virtual strips
118  for (auto& it : ringsMap) {
119  it.second.filterOverlapingChambers();
120  it.second.fillWithVirtualStrips();
121  }
122 
123  // Xcheck, if rings are symettrical
124  for (auto& it : ringsMap) {
125  int key = it.first;
126  int sign = key / 100 - (key / 1000) * 10;
127 
128  if (sign == 0) {
129  key += 100;
130  } else {
131  key -= 100;
132  }
133 
134  if (key != 2000) { // Hey 2100 has no counterring
135  if (it.second.size() != ringsMap[key].size()) {
136  throw cms::Exception("RPCInternal") << " Size differs for ring " << key << " +- 100 \n";
137  }
138  }
139  }
140  buildConnections(l1RPCConeDefinition, ringsMap);
141 }
142 
144  RPCStripsRing::TIdToRindMap& ringsMap) {
145  RPCStripsRing::TIdToRindMap::iterator itRef = ringsMap.begin();
146  for (; itRef != ringsMap.end(); ++itRef) { // iterate over reference rings
147 
148  RPCStripsRing::TOtherConnStructVec ringsToConnect;
149 
150  if (!itRef->second.isReferenceRing())
151  continue; // iterate over reference rings
152 
153  RPCStripsRing::TIdToRindMap::iterator itOther = ringsMap.begin();
154  for (; itOther != ringsMap.end(); ++itOther) { // iterate over nonreference rings
155 
156  if (itOther->second.isReferenceRing())
157  continue; // iterate over nonreference rings
158 
159  std::pair<int, int> pr = areConnected(itRef, itOther, l1RPCConeDefinition);
160  if (pr.first != -1) {
161  RPCStripsRing::TOtherConnStruct newOtherConn;
162  newOtherConn.m_it = itOther;
163  newOtherConn.m_logplane = pr.first;
164  newOtherConn.m_logplaneSize = pr.second;
165  ringsToConnect.push_back(newOtherConn);
166  }
167  } // OtherRings iteration ends
168 
169  std::pair<int, int> prRef = areConnected(itRef, itRef, l1RPCConeDefinition);
170  if (prRef.first == -1) {
171  throw cms::Exception("RPCConfig") << " Cannot determine logplane for reference ring " << itRef->first << "\n ";
172  }
173 
174  itRef->second.createRefConnections(ringsToConnect, prRef.first, prRef.second);
175 
176  } // RefRings iteration ends
177 }
178 
179 // first - logplane
180 // second - logplanesize
181 std::pair<int, int> RPCConeBuilder::areConnected(RPCStripsRing::TIdToRindMap::iterator ref,
182  RPCStripsRing::TIdToRindMap::iterator other,
183  L1RPCConeDefinition const* l1RPCConeDefinition) {
184  int logplane = -1;
185 
186  // Do not connect rolls lying on the oposite side of detector
187  if (ref->second.getEtaPartition() * other->second.getEtaPartition() < 0)
188  return std::make_pair(-1, 0);
189 
190  int refTowerCnt = 0;
191  int index = -1;
192  int refTower = -1;
193 
194  for (auto const& itRef : l1RPCConeDefinition->getRingToTowerVec()) {
195  if (itRef.m_etaPart != std::abs(ref->second.getEtaPartition()) ||
196  itRef.m_hwPlane != std::abs(ref->second.getHwPlane() - 1) // -1?
197  ) {
198  continue;
199  }
200 
201  ++refTowerCnt;
202  refTower = itRef.m_tower;
203 
204  for (auto const& itOther : l1RPCConeDefinition->getRingToTowerVec()) {
205  if (itOther.m_etaPart != std::abs(other->second.getEtaPartition()) ||
206  itOther.m_hwPlane != std::abs(other->second.getHwPlane() - 1) // -1?
207  ) {
208  continue;
209  }
210 
211  if (itOther.m_tower == refTower) {
212  index = itOther.m_index;
213  }
214  }
215  }
216 
217  if (refTowerCnt > 1) {
218  throw cms::Exception("RPCConeBuilder") << " Reference(?) ring " << ref->first << " "
219  << "wants to be connected to " << refTowerCnt << " towers \n";
220  }
221 
222  if (refTowerCnt == 0) {
223  throw cms::Exception("RPCConeBuilder") << " Reference(?) ring " << ref->first << " "
224  << " is not connected anywhere \n";
225  }
226 
227  int lpSize = 0;
228  if (index != -1) {
229  for (auto const& it : l1RPCConeDefinition->getRingToLPVec()) {
230  if (it.m_etaPart != std::abs(other->second.getEtaPartition()) ||
231  it.m_hwPlane != std::abs(other->second.getHwPlane() - 1) || it.m_index != index) {
232  continue;
233  }
234  logplane = it.m_LP;
235  }
236 
237  for (auto const& it : l1RPCConeDefinition->getLPSizeVec()) {
238  if (it.m_tower != std::abs(refTower) || it.m_LP != logplane - 1) {
239  continue;
240  }
241  lpSize = it.m_size;
242  }
243 
244  //FIXME
245  if (lpSize == -1) {
246  //throw cms::Exception("getLogStrip") << " lpSize==-1\n";
247  }
248  }
249  return std::make_pair(logplane, lpSize);
250 }
251 
RPCRoll
Definition: RPCRoll.h:12
RPCConeBuilder::areConnected
std::pair< int, int > areConnected(RPCStripsRing::TIdToRindMap::iterator ref, RPCStripsRing::TIdToRindMap::iterator other, L1RPCConeDefinition const *)
Definition: RPCConeBuilder.cc:181
L1RPCConeDefinition::getRingToLPVec
const TRingToLPVec & getRingToLPVec() const
Definition: L1RPCConeDefinition.h:86
L1RPCConeBuilderRcd.h
RPCConeBuilder::m_towerEnd
int m_towerEnd
Definition: RPCConeBuilder.cc:63
RPCConeBuilder::RPCConeBuilder
RPCConeBuilder(const edm::ParameterSet &)
Definition: RPCConeBuilder.cc:66
ESHandle.h
L1RPCConeDefinition::getLPSizeVec
const TLPSizeVec & getLPSizeVec() const
Definition: L1RPCConeDefinition.h:73
RPCStripsRing::TOtherConnStructVec
std::vector< TOtherConnStruct > TOtherConnStructVec
Definition: RPCStripsRing.h:48
edm::ESProducer::setWhatProduced
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:138
ESProducer.h
Validation_hcalonly_cfi.sign
sign
Definition: Validation_hcalonly_cfi.py:32
newFWLiteAna.found
found
Definition: newFWLiteAna.py:118
RPCStripsRing::TIdToRindMap
std::map< int, RPCStripsRing > TIdToRindMap
Definition: RPCStripsRing.h:39
RPCStripsRing::getRingId
int getRingId()
Definition: RPCStripsRing.cc:87
RPCStripsRing.h
L1RPCConeDefinitionRcd.h
trackingPlots.other
other
Definition: trackingPlots.py:1465
RPCGeometry::dets
const DetContainer & dets() const override
Returm a vector of all GeomDet (including all GeomDetUnits)
Definition: RPCGeometry.cc:24
edm::eventsetup::DependentRecordImplementation::get
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
Definition: DependentRecordImplementation.h:112
edm::ParameterSet
Definition: ParameterSet.h:36
sipixeldigitoraw
Definition: SiPixelDigiToRaw.cc:38
RPCStripsRing::TOtherConnStruct
Definition: RPCStripsRing.h:41
L1RPCConeBuilder.h
RPCConeBuilder::m_towerBeg
int m_towerBeg
Definition: RPCConeBuilder.cc:62
RPCStripsRing::TOtherConnStruct::m_logplane
short m_logplane
Definition: RPCStripsRing.h:42
createfilelist.int
int
Definition: createfilelist.py:10
L1RPCConeBuilderRcd
Definition: L1RPCConeBuilderRcd.h:31
RPCConeBuilder::buildCones
void buildCones(RPCGeometry const *, L1RPCConeDefinition const *, RPCStripsRing::TIdToRindMap &)
Definition: RPCConeBuilder.cc:93
RPCConeBuilder
Definition: RPCConeBuilder.cc:39
RPCConeBuilder::m_rpcGeometryToken
edm::ESGetToken< RPCGeometry, MuonGeometryRecord > m_rpcGeometryToken
Definition: RPCConeBuilder.cc:60
RPCStripsRing::TOtherConnStruct::m_logplaneSize
short m_logplaneSize
Definition: RPCStripsRing.h:44
RPCConeBuilder::ReturnType
std::unique_ptr< L1RPCConeBuilder > ReturnType
Definition: RPCConeBuilder.cc:43
RPCConeBuilder::produce
ReturnType produce(const L1RPCConeBuilderRcd &)
Definition: RPCConeBuilder.cc:72
L1RPCConeDefinition::getRingToTowerVec
const TRingToTowerVec & getRingToTowerVec() const
Definition: L1RPCConeDefinition.h:79
edm::ESGetToken< RPCGeometry, MuonGeometryRecord >
ModuleFactory.h
DEFINE_FWK_EVENTSETUP_MODULE
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
RPCConeBuilder::buildConnections
void buildConnections(L1RPCConeDefinition const *, RPCStripsRing::TIdToRindMap &)
Definition: RPCConeBuilder.cc:143
RPCStripsRing
Definition: RPCStripsRing.h:36
Exception
Definition: hltDiff.cc:246
Exception.h
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
edm::ESProducer
Definition: ESProducer.h:101
RPCConeBuilder::m_l1RPCConeDefinitionToken
edm::ESGetToken< L1RPCConeDefinition, L1RPCConeDefinitionRcd > m_l1RPCConeDefinitionToken
Definition: RPCConeBuilder.cc:61
RPCGeometry
Definition: RPCGeometry.h:20
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ParameterSet.h
MuonGeometryRecord.h
RPCStripsRing::TOtherConnStruct::m_it
TIdToRindMap::iterator m_it
Definition: RPCStripsRing.h:45
crabWrapper.key
key
Definition: crabWrapper.py:19
L1RPCConeDefinition
Definition: L1RPCConeDefinition.h:8
RPCGeometry.h
L1RPCConeDefinition.h