Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:49:00

0001 /** Implementation of the Model for RPC Geometry
0002  *
0003  *  \author M. Maggi - INFN Bari
0004  */
0005 
0006 #include <Geometry/RPCGeometry/interface/RPCGeometry.h>
0007 #include <Geometry/CommonDetUnit/interface/GeomDet.h>
0008 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0009 
0010 RPCGeometry::RPCGeometry() {}
0011 
0012 RPCGeometry::~RPCGeometry() {
0013   // delete all the chamber associated to the geometry
0014   //for (std::vector<RPCChamber*>::const_iterator ich = allChambers.begin();
0015   //      ich != allChambers.end(); ++ich){
0016   //  delete (*ich);
0017   //}
0018 }
0019 
0020 const RPCGeometry::DetTypeContainer& RPCGeometry::detTypes() const { return theRollTypes; }
0021 
0022 const RPCGeometry::DetContainer& RPCGeometry::detUnits() const { return theRolls; }
0023 
0024 const RPCGeometry::DetContainer& RPCGeometry::dets() const { return theDets; }
0025 
0026 const RPCGeometry::DetIdContainer& RPCGeometry::detUnitIds() const { return theRollIds; }
0027 
0028 const RPCGeometry::DetIdContainer& RPCGeometry::detIds() const { return theDetIds; }
0029 
0030 const GeomDet* RPCGeometry::idToDetUnit(DetId id) const { return dynamic_cast<const GeomDet*>(idToDet(id)); }
0031 
0032 const GeomDet* RPCGeometry::idToDet(DetId id) const {
0033   mapIdToDet::const_iterator i = theMap.find(id);
0034   if (i != theMap.end())
0035     return i->second;
0036 
0037   LogDebug("RPCGeometry") << "Invalid DetID: no GeomDet associated " << RPCDetId(id);
0038   GeomDet* geom = nullptr;
0039   return geom;
0040 }
0041 
0042 const std::vector<const RPCChamber*>& RPCGeometry::chambers() const { return allChambers; }
0043 
0044 const std::vector<const RPCRoll*>& RPCGeometry::rolls() const { return allRolls; }
0045 
0046 const RPCChamber* RPCGeometry::chamber(RPCDetId id) const {
0047   return dynamic_cast<const RPCChamber*>(idToDet(id.chamberId()));
0048 }
0049 
0050 const RPCRoll* RPCGeometry::roll(RPCDetId id) const { return dynamic_cast<const RPCRoll*>(idToDetUnit(id)); }
0051 
0052 void RPCGeometry::add(RPCRoll* roll) {
0053   theDets.emplace_back(roll);
0054   allRolls.emplace_back(roll);
0055   theRolls.emplace_back(roll);
0056   theRollIds.emplace_back(roll->geographicalId());
0057   theDetIds.emplace_back(roll->geographicalId());
0058   GeomDetType* _t = const_cast<GeomDetType*>(&roll->type());
0059   theRollTypes.emplace_back(_t);
0060   theMap.insert(std::pair<DetId, GeomDetUnit*>(roll->geographicalId(), roll));
0061 }
0062 
0063 void RPCGeometry::add(RPCChamber* chamber) {
0064   allChambers.emplace_back(chamber);
0065   theDets.emplace_back(chamber);
0066   theDetIds.emplace_back(chamber->geographicalId());
0067   theMap.insert(std::pair<DetId, GeomDet*>(chamber->geographicalId(), chamber));
0068 }