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
00236 int etaPart = it->first%100;
00237 if (it->second.isReferenceRing() && (it->second.size() != 1152)){
00238
00239 if (std::abs(etaPart)>=14 || std::abs(etaPart)<=17 ) {
00240
00241 }
00242 else {
00243 throw cms::Exception("RPCInternal") << "Problem: refring " << it->first
00244 << " has " << it->second.size() << " strips \n";
00245 }
00246 }
00247
00248
00249 }
00250
00251
00252 it = m_ringsMap.begin();
00253 for (;it != m_ringsMap.end(); ++it){
00254 int key = it->first;
00255 int sign = key/100 - (key/1000)*10;
00256
00257 if (sign == 0) {
00258 key += 100;
00259 } else {
00260 key -= 100;
00261 }
00262
00263 if (key != 2000){
00264 if (it->second.size() != m_ringsMap[key].size())
00265 {
00266 throw cms::Exception("RPCInternal") << " Size differs for ring " << key << " +- 100 \n";
00267 }
00268 }
00269
00270
00271 }
00272
00273 buildConnections();
00274 }
00275
00276
00277 void RPCConeBuilder::buildConnections(){
00278
00279
00280
00281 RPCStripsRing::TIdToRindMap::iterator itRef = m_ringsMap.begin();
00282 for (;itRef != m_ringsMap.end(); ++itRef){
00283
00284
00285 RPCStripsRing::TOtherConnStructVec ringsToConnect;
00286
00287 if (!itRef->second.isReferenceRing()) continue;
00288
00289 RPCStripsRing::TIdToRindMap::iterator itOther = m_ringsMap.begin();
00290 for (;itOther != m_ringsMap.end(); ++itOther){
00291
00292 if (itOther->second.isReferenceRing()) continue;
00293
00294 std::pair<int,int> pr = areConnected(itRef, itOther);
00295 if ( pr.first != -1 ) {
00296 RPCStripsRing::TOtherConnStruct newOtherConn;
00297 newOtherConn.m_it = itOther;
00298 newOtherConn.m_logplane = pr.first;
00299 newOtherConn.m_logplaneSize = pr.second;
00300 ringsToConnect.push_back(newOtherConn);
00301 }
00302
00303
00304 }
00305
00306
00307 std::pair<int,int> prRef = areConnected(itRef, itRef);
00308 if (prRef.first == -1){
00309 throw cms::Exception("RPCConfig") << " Cannot determine logplane for reference ring "
00310 << itRef->first << "\n ";
00311 }
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325 itRef->second.createRefConnections(ringsToConnect, prRef.first, prRef.second);
00326
00327 }
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349 }
00350
00351
00352
00353 std::pair<int, int> RPCConeBuilder::areConnected(RPCStripsRing::TIdToRindMap::iterator ref,
00354 RPCStripsRing::TIdToRindMap::iterator other){
00355
00356 int logplane = -1;
00357
00358
00359
00360
00361 if ( ref->second.getEtaPartition()*other->second.getEtaPartition()<0 )
00362 return std::make_pair(-1,0);
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381 L1RPCConeDefinition::TRingToTowerVec::const_iterator itRef
00382 = m_L1RPCConeDefinition->getRingToTowerVec().begin();
00383
00384 const L1RPCConeDefinition::TRingToTowerVec::const_iterator itEnd
00385 = m_L1RPCConeDefinition->getRingToTowerVec().end();
00386
00387 L1RPCConeDefinition::TRingToTowerVec::const_iterator itOther = itRef;
00388
00389 int refTowerCnt = 0;
00390 int index = -1;
00391 int refTower = -1;
00392
00393 for (;itRef != itEnd; ++itRef){
00394 if ( itRef->m_etaPart != std::abs(ref->second.getEtaPartition())
00395 || itRef->m_hwPlane != std::abs(ref->second.getHwPlane()-1)
00396 ) continue;
00397
00398 ++refTowerCnt;
00399 refTower = itRef->m_tower;
00400
00401 for (;itOther != itEnd; ++itOther){
00402 if ( itOther->m_etaPart != std::abs(other->second.getEtaPartition())
00403 || itOther->m_hwPlane != std::abs(other->second.getHwPlane()-1)
00404 ) continue;
00405
00406 if (itOther->m_tower == refTower) index = itOther->m_index;
00407
00408 }
00409
00410 }
00411
00412 if(refTowerCnt>1){
00413 throw cms::Exception("RPCConeBuilder") << " Reference(?) ring "
00414 << ref->first << " "
00415 << "wants to be connected to " << refTowerCnt << " towers \n";
00416
00417 }
00418
00419 if(refTowerCnt==0){
00420 throw cms::Exception("RPCConeBuilder") << " Reference(?) ring "
00421 << ref->first << " "
00422 << " is not connected anywhere \n";
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
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469 int lpSize = 0;
00470 if (index != -1){
00471
00472
00473
00474
00475 {
00476 L1RPCConeDefinition::TRingToLPVec::const_iterator it = m_L1RPCConeDefinition->getRingToLPVec().begin();
00477 L1RPCConeDefinition::TRingToLPVec::const_iterator itEnd = m_L1RPCConeDefinition->getRingToLPVec().end();
00478 for (;it!=itEnd;++it){
00479
00480 if (it->m_etaPart != std::abs(other->second.getEtaPartition())
00481 || it->m_hwPlane != std::abs(other->second.getHwPlane()-1)
00482 || it->m_index != index) continue;
00483
00484 logplane = it->m_LP;
00485
00486 }
00487 }
00488
00489
00490 {
00491 L1RPCConeDefinition::TLPSizeVec::const_iterator it = m_L1RPCConeDefinition->getLPSizeVec().begin();
00492 L1RPCConeDefinition::TLPSizeVec::const_iterator itEnd = m_L1RPCConeDefinition->getLPSizeVec().end();
00493 for (;it!=itEnd;++it){
00494
00495
00496 if (it->m_tower != std::abs(refTower) || it->m_LP != logplane-1) continue;
00497 lpSize = it->m_size;
00498
00499 }
00500
00501
00502 if (lpSize==-1) {
00503
00504 }
00505 }
00506 }
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518 return std::make_pair(logplane,lpSize);
00519
00520 }
00521
00522
00523