Go to the documentation of this file.00001
00002
00003
00004
00005
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "L1Trigger/RPCTrigger/interface/RPCConeBuilder.h"
00026 #include "L1Trigger/RPCTrigger/interface/RPCStripsRing.h"
00027
00028
00029
00030
00031 #include "Geometry/Records/interface/MuonGeometryRecord.h"
00032 #include "FWCore/Framework/interface/ModuleFactory.h"
00033
00034
00035 #include "CondFormats/DataRecord/interface/L1RPCConeDefinitionRcd.h"
00036
00037 #include <sstream>
00038 #include <vector>
00039
00040 #include "DataFormats/MuonDetId/interface/RPCDetId.h"
00041
00042
00043 RPCConeBuilder::RPCConeBuilder(const edm::ParameterSet& iConfig) :
00044 m_towerBeg(iConfig.getParameter<int>("towerBeg")),
00045 m_towerEnd(iConfig.getParameter<int>("towerEnd")),
00046 m_runOnceBuildCones(false)
00047
00048
00049
00050
00051 {
00052
00053 setWhatProduced(this, (dependsOn (&RPCConeBuilder::geometryCallback) &
00054 (&RPCConeBuilder::coneDefCallback) )
00055 );
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107 }
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117 RPCConeBuilder::ReturnType
00118 RPCConeBuilder::produce(const L1RPCConeBuilderRcd& iRecord)
00119
00120 {
00121
00122
00123
00124 using namespace edm::es;
00125 boost::shared_ptr<L1RPCConeBuilder> pL1RPCConeBuilder( ( new L1RPCConeBuilder ) );
00126
00127 pL1RPCConeBuilder->setFirstTower(m_towerBeg);
00128 pL1RPCConeBuilder->setLastTower(m_towerEnd);
00129
00130
00131
00132
00133
00134
00135
00136
00137 buildCones(m_rpcGeometry);
00138
00139
00140
00141 m_ringsMap.begin()->second.compressConnections();
00142
00143 pL1RPCConeBuilder->setConeConnectionMap(m_ringsMap.begin()->second.getConnectionsMap());
00144
00145 pL1RPCConeBuilder->setCompressedConeConnectionMap(
00146 m_ringsMap.begin()->second.getCompressedConnectionsMap());
00147
00148 m_ringsMap.clear();
00149
00150 return pL1RPCConeBuilder;
00151
00152 }
00153
00154
00155 void RPCConeBuilder::geometryCallback( const MuonGeometryRecord& record ){
00156
00157
00158 m_runOnceBuildCones = false;
00159 record.get(m_rpcGeometry);
00160
00161
00162 }
00163
00164 void RPCConeBuilder::coneDefCallback( const L1RPCConeDefinitionRcd& record ){
00165
00166
00167 m_runOnceBuildCones = false;
00168
00169
00170 record.get(m_L1RPCConeDefinition);
00171
00172
00173
00174
00175
00176 }
00177
00178
00179
00180 void RPCConeBuilder::buildCones(const edm::ESHandle<RPCGeometry> & rpcGeom ){
00181
00182
00183 if (!m_runOnceBuildCones){
00184 m_runOnceBuildCones = true;
00185 } else {
00186 throw cms::Exception("RPCInternal") << "buildCones called twice \n";
00187 }
00188
00189
00190
00191
00192 boost::shared_ptr<L1RPCConeBuilder::TConMap > uncompressedCons
00193 = boost::shared_ptr<L1RPCConeBuilder::TConMap >(new L1RPCConeBuilder::TConMap());
00194
00195
00196 int rolls = 0;
00197 for(TrackingGeometry::DetContainer::const_iterator it = rpcGeom->dets().begin();
00198 it != rpcGeom->dets().end();
00199 ++it)
00200 {
00201
00202 if( dynamic_cast< RPCRoll* >( *it ) == 0 ) continue;
00203
00204 ++rolls;
00205 RPCRoll* roll = dynamic_cast< RPCRoll*>( *it );
00206
00207 int ringId = RPCStripsRing::getRingId(roll);
00208 if ( m_ringsMap.find(ringId) == m_ringsMap.end() ) {
00209 m_ringsMap[ringId]=RPCStripsRing(roll, uncompressedCons);
00210 } else {
00211 m_ringsMap[ringId].addRoll(roll);
00212 }
00213
00214
00215 }
00216
00217
00218
00219 RPCStripsRing::TIdToRindMap::iterator it = m_ringsMap.begin();
00220
00221
00222 for (;it != m_ringsMap.end(); ++it){
00223
00224
00225
00226 it->second.filterOverlapingChambers();
00227 it->second.fillWithVirtualStrips();
00228
00229
00230
00231
00232
00233
00234
00235 if (it->second.isReferenceRing() && (it->second.size() != 1152)){
00236 throw cms::Exception("RPCInternal") << "Problem: refring " << it->first
00237 << " has " << it->second.size() << " strips \n";
00238 }
00239
00240
00241 }
00242
00243
00244 it = m_ringsMap.begin();
00245 for (;it != m_ringsMap.end(); ++it){
00246 int key = it->first;
00247 int sign = key/100 - (key/1000)*10;
00248
00249 if (sign == 0) {
00250 key += 100;
00251 } else {
00252 key -= 100;
00253 }
00254
00255 if (key != 2000){
00256 if (it->second.size() != m_ringsMap[key].size())
00257 {
00258 throw cms::Exception("RPCInternal") << " Size differs for ring " << key << " +- 100 \n";
00259 }
00260 }
00261
00262
00263 }
00264
00265 buildConnections();
00266 }
00267
00268
00269 void RPCConeBuilder::buildConnections(){
00270
00271
00272
00273 RPCStripsRing::TIdToRindMap::iterator itRef = m_ringsMap.begin();
00274 for (;itRef != m_ringsMap.end(); ++itRef){
00275
00276
00277 RPCStripsRing::TOtherConnStructVec ringsToConnect;
00278
00279 if (!itRef->second.isReferenceRing()) continue;
00280
00281 RPCStripsRing::TIdToRindMap::iterator itOther = m_ringsMap.begin();
00282 for (;itOther != m_ringsMap.end(); ++itOther){
00283
00284 if (itOther->second.isReferenceRing()) continue;
00285
00286 std::pair<int,int> pr = areConnected(itRef, itOther);
00287 if ( pr.first != -1 ) {
00288 RPCStripsRing::TOtherConnStruct newOtherConn;
00289 newOtherConn.m_it = itOther;
00290 newOtherConn.m_logplane = pr.first;
00291 newOtherConn.m_logplaneSize = pr.second;
00292 ringsToConnect.push_back(newOtherConn);
00293 }
00294
00295
00296 }
00297
00298
00299 std::pair<int,int> prRef = areConnected(itRef, itRef);
00300 if (prRef.first == -1){
00301 throw cms::Exception("RPCConfig") << " Cannot determine logplane for reference ring "
00302 << itRef->first << "\n ";
00303 }
00304 if (prRef.second != 8){
00305
00306 throw cms::Exception("RPCConfig") << " logplaneSize for reference ring "
00307 << itRef->first << " wrong "
00308 << " logplane: " << prRef.first
00309 << " etaPart: " << itRef->second.getEtaPartition()
00310 << " tower: " << itRef->second.getTowerForRefRing()
00311 << " hwPlane: " << itRef->second.getHwPlane()
00312 << " strips " << prRef.second << "\n";
00313 }
00314
00315 itRef->second.createRefConnections(ringsToConnect, prRef.first, prRef.second);
00316
00317 }
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339 }
00340
00341
00342
00343 std::pair<int, int> RPCConeBuilder::areConnected(RPCStripsRing::TIdToRindMap::iterator ref,
00344 RPCStripsRing::TIdToRindMap::iterator other){
00345
00346 int logplane = -1;
00347
00348
00349
00350
00351 if ( ref->second.getEtaPartition()*other->second.getEtaPartition()<0 )
00352 return std::make_pair(-1,0);
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371 L1RPCConeDefinition::TRingToTowerVec::const_iterator itRef
00372 = m_L1RPCConeDefinition->getRingToTowerVec().begin();
00373
00374 const L1RPCConeDefinition::TRingToTowerVec::const_iterator itEnd
00375 = m_L1RPCConeDefinition->getRingToTowerVec().end();
00376
00377 L1RPCConeDefinition::TRingToTowerVec::const_iterator itOther = itRef;
00378
00379 int refTowerCnt = 0;
00380 int index = -1;
00381 int refTower = -1;
00382
00383 for (;itRef != itEnd; ++itRef){
00384 if ( itRef->m_etaPart != std::abs(ref->second.getEtaPartition())
00385 || itRef->m_hwPlane != std::abs(ref->second.getHwPlane()-1)
00386 ) continue;
00387
00388 ++refTowerCnt;
00389 refTower = itRef->m_tower;
00390
00391 for (;itOther != itEnd; ++itOther){
00392 if ( itOther->m_etaPart != std::abs(other->second.getEtaPartition())
00393 || itOther->m_hwPlane != std::abs(other->second.getHwPlane()-1)
00394 ) continue;
00395
00396 if (itOther->m_tower == refTower) index = itOther->m_index;
00397
00398 }
00399
00400 }
00401
00402 if(refTowerCnt>1){
00403 throw cms::Exception("RPCConeBuilder") << " Reference(?) ring "
00404 << ref->first << " "
00405 << "wants to be connected to " << refTowerCnt << " towers \n";
00406
00407 }
00408
00409 if(refTowerCnt==0){
00410 throw cms::Exception("RPCConeBuilder") << " Reference(?) ring "
00411 << ref->first << " "
00412 << " is not connected anywhere \n";
00413
00414 }
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459 int lpSize = 0;
00460 if (index != -1){
00461
00462
00463
00464
00465 {
00466 L1RPCConeDefinition::TRingToLPVec::const_iterator it = m_L1RPCConeDefinition->getRingToLPVec().begin();
00467 L1RPCConeDefinition::TRingToLPVec::const_iterator itEnd = m_L1RPCConeDefinition->getRingToLPVec().end();
00468 for (;it!=itEnd;++it){
00469
00470 if (it->m_etaPart != std::abs(other->second.getEtaPartition())
00471 || it->m_hwPlane != std::abs(other->second.getHwPlane()-1)
00472 || it->m_index != index) continue;
00473
00474 logplane = it->m_LP;
00475
00476 }
00477 }
00478
00479
00480 {
00481 L1RPCConeDefinition::TLPSizeVec::const_iterator it = m_L1RPCConeDefinition->getLPSizeVec().begin();
00482 L1RPCConeDefinition::TLPSizeVec::const_iterator itEnd = m_L1RPCConeDefinition->getLPSizeVec().end();
00483 for (;it!=itEnd;++it){
00484
00485
00486 if (it->m_tower != std::abs(refTower) || it->m_LP != logplane-1) continue;
00487 lpSize = it->m_size;
00488
00489 }
00490
00491
00492 if (lpSize==-1) {
00493
00494 }
00495 }
00496 }
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508 return std::make_pair(logplane,lpSize);
00509
00510 }
00511
00512
00513