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