CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC4_patch1/src/RecoMuon/DetLayers/src/MuonDTDetLayerGeometryBuilder.cc

Go to the documentation of this file.
00001 #include <RecoMuon/DetLayers/src/MuonDTDetLayerGeometryBuilder.h>
00002 
00003 #include <DataFormats/MuonDetId/interface/DTChamberId.h>
00004 #include <Geometry/CommonDetUnit/interface/GeomDet.h>
00005 #include <RecoMuon/DetLayers/interface/MuRodBarrelLayer.h>
00006 #include <RecoMuon/DetLayers/interface/MuDetRod.h>
00007 
00008 #include <Utilities/General/interface/precomputed_value_sort.h>
00009 #include <Geometry/CommonDetUnit/interface/DetSorting.h>
00010 
00011 #include <FWCore/MessageLogger/interface/MessageLogger.h>
00012 
00013 #include <iostream>
00014 
00015 using namespace std;
00016 
00017 MuonDTDetLayerGeometryBuilder::MuonDTDetLayerGeometryBuilder() {
00018 }
00019 
00020 MuonDTDetLayerGeometryBuilder::~MuonDTDetLayerGeometryBuilder() {
00021 }
00022 
00023 vector<DetLayer*> 
00024 MuonDTDetLayerGeometryBuilder::buildLayers(const DTGeometry& geo) {
00025         
00026   const std::string metname = "Muon|RecoMuon|RecoMuonDetLayers|MuonDTDetLayerGeometryBuilder";
00027 
00028   vector<DetLayer*> detlayers;
00029   vector<MuRodBarrelLayer*> result;
00030             
00031   for(int station = DTChamberId::minStationId; station <= DTChamberId::maxStationId; station++) {
00032     
00033     vector<const DetRod*> muDetRods;
00034     for(int sector = DTChamberId::minSectorId; sector <= DTChamberId::maxSectorId; sector++) {
00035       
00036       vector<const GeomDet*> geomDets;
00037       for(int wheel = DTChamberId::minWheelId; wheel <= DTChamberId::maxWheelId; wheel++) {               
00038         const GeomDet* geomDet = geo.idToDet(DTChamberId(wheel, station, sector));
00039         if (geomDet) {
00040           geomDets.push_back(geomDet);
00041           LogTrace(metname) << "get DT chamber " <<  DTChamberId(wheel, station, sector)
00042                             << " at R=" << geomDet->position().perp()
00043                             << ", phi=" << geomDet->position().phi() ;
00044         }
00045       }
00046       
00047       if (geomDets.size()!=0) {
00048         precomputed_value_sort(geomDets.begin(), geomDets.end(), geomsort::DetZ());
00049         muDetRods.push_back(new MuDetRod(geomDets));
00050         LogTrace(metname) << "  New MuDetRod with " << geomDets.size()
00051                           << " chambers at R=" << muDetRods.back()->position().perp()
00052                           << ", phi=" << muDetRods.back()->position().phi();
00053       }
00054     }
00055     precomputed_value_sort(muDetRods.begin(), muDetRods.end(), geomsort::ExtractPhi<GeometricSearchDet,float>());
00056     result.push_back(new MuRodBarrelLayer(muDetRods));  
00057     LogDebug(metname) << "    New MuRodBarrelLayer with " << muDetRods.size()
00058                       << " rods, at R " << result.back()->specificSurface().radius();
00059   }
00060   
00061   for(vector<MuRodBarrelLayer*>::const_iterator it = result.begin(); it != result.end(); it++)
00062     detlayers.push_back((DetLayer*)(*it));
00063   
00064   return detlayers;
00065 }