20 namespace rpcdetlayergeomsort {
21 template <
class T,
class Scalar =
typename T::Scalar>
33 vector<DetLayer*>
result[2];
36 int iendcap = (
endcap == 1) ? 0 : 1;
44 std::vector<int> rings;
45 int FirstStationRing = 1;
46 rings.push_back(FirstStationRing);
48 rolls.push_back(roll);
53 result[iendcap].push_back(ringLayer);
59 std::vector<int> rings;
61 rings.push_back(
ring);
64 rolls.push_back(roll);
69 result[iendcap].push_back(ringLayer);
76 std::vector<int> rings;
78 rings.push_back(
ring);
81 rolls.push_back(roll);
86 result[iendcap].push_back(ringLayer);
90 pair<vector<DetLayer*>, vector<DetLayer*> > res_pair(result[0], result[1]);
96 const std::string metname =
"Muon|RPC|RecoMuon|RecoMuonDetLayers|MuonRPCDetLayerGeometryBuilder";
98 vector<const ForwardDetRing*> frontRings, backRings;
100 for (std::vector<int>::const_iterator
ring = rings.begin();
ring < rings.end(); ++
ring) {
101 for (vector<int>::iterator roll = rolls.begin(); roll != rolls.end(); ++roll) {
102 vector<const GeomDet*> frontDets, backDets;
105 RPCDetId rpcId(endcap, *
ring, station, sector, layer, subsector, (*roll));
106 bool isInFront = isFront(rpcId);
110 frontDets.push_back(geomDet);
112 backDets.push_back(geomDet);
114 LogTrace(metname) <<
"get RPC Endcap roll " << rpcId << (isInFront ?
"front" :
"back ")
120 if (!frontDets.empty()) {
122 frontRings.push_back(
new MuDetRing(frontDets));
123 LogTrace(metname) <<
"New front ring with " << frontDets.size()
124 <<
" chambers at z=" << frontRings.back()->position().z();
126 if (!backDets.empty()) {
128 backRings.push_back(
new MuDetRing(backDets));
129 LogTrace(metname) <<
"New back ring with " << backDets.size()
130 <<
" chambers at z=" << backRings.back()->position().z();
137 if (!backRings.empty() || !frontRings.empty()) {
143 LogTrace(metname) <<
"New layer with " << frontRings.size() <<
" front rings and " << backRings.size()
144 <<
" back rings, at Z " << result->position().z();
151 const std::string metname =
"Muon|RPC|RecoMuon|RecoMuonDetLayers|MuonRPCDetLayerGeometryBuilder";
153 vector<DetLayer*> detlayers;
154 vector<MuRodBarrelLayer*>
result;
158 vector<const GeomDet*> geomDets;
167 geomDets.push_back(geomDet);
168 LogTrace(metname) <<
"get RPC Barrel roll "
177 makeBarrelLayers(geomDets, result);
180 for (vector<MuRodBarrelLayer*>::const_iterator it = result.begin(); it != result.end(); it++)
181 detlayers.push_back((
DetLayer*)(*it));
187 vector<MuRodBarrelLayer*>&
result) {
188 const std::string metname =
"Muon|RPC|RecoMuon|RecoMuonDetLayers|MuonRPCDetLayerGeometryBuilder";
195 float r0 = float(geomDets.front()->position().perp());
196 float rMin = -float(resolution);
197 float rMax = float(geomDets.back()->position().perp()) - r0 + resolution;
201 vector<const GeomDet*>::iterator
first = geomDets.begin();
202 vector<const GeomDet*>::iterator
last = geomDets.end();
204 for (vector<const GeomDet*>::iterator
i = first;
i !=
last;
i++) {
205 hisR.fill(
float((*i)->position().perp()) - r0);
206 LogTrace(metname) <<
"R " << float((*i)->position().perp()) - r0;
208 vector<float> rClust = hisR.clusterize(resolution);
213 vector<const GeomDet*>::iterator separ =
first;
215 for (
unsigned int i = 0;
i < rClust.size();
i++) {
217 if (
i < rClust.size() - 1) {
218 rSepar = (rClust[
i] + rClust[
i + 1]) / 2.
f;
225 while (separ < last &&
float((*separ)->position().perp()) - r0 < rSepar) {
230 if (
int(separ - layerStart) > 0) {
232 vector<const DetRod*> rods;
233 vector<const GeomDet*> layerDets(layerStart, separ);
234 makeBarrelRods(layerDets, rods);
238 LogTrace(metname) <<
" New MuRodBarrelLayer with " << rods.size() <<
" rods, at R "
239 << result.back()->specificSurface().radius();
247 const std::string metname =
"Muon|RPC|RecoMuon|RecoMuonDetLayers|MuonRPCDetLayerGeometryBuilder";
254 float phi0 = float(geomDets.front()->position().phi());
255 float phiMin = -float(resolution);
256 float phiMax = float(geomDets.back()->position().phi()) - phi0 + resolution;
260 vector<const GeomDet*>::iterator
first = geomDets.begin();
261 vector<const GeomDet*>::iterator
last = geomDets.end();
263 for (vector<const GeomDet*>::iterator
i = first;
i !=
last;
i++) {
264 hisPhi.fill(
float((*i)->position().phi()) - phi0);
265 LogTrace(metname) <<
"C " << float((*i)->position().phi()) - phi0;
267 vector<float> phiClust = hisPhi.clusterize(resolution);
271 vector<const GeomDet*>::iterator rodStart =
first;
272 vector<const GeomDet*>::iterator separ =
first;
274 for (
unsigned int i = 0;
i < phiClust.size();
i++) {
276 if (
i < phiClust.size() - 1) {
277 phiSepar = (phiClust[
i] + phiClust[
i + 1]) / 2.
f;
284 while (separ < last &&
float((*separ)->position().phi()) - phi0 < phiSepar) {
289 if (
int(separ - rodStart) > 0) {
290 result.push_back(
new MuDetRod(rodStart, separ));
291 LogTrace(metname) <<
" New MuDetRod with " << int(separ - rodStart)
292 <<
" rolls at R=" << (*rodStart)->position().perp()
293 <<
", phi=" << float((*rodStart)->position().phi());
307 if (ring == 1 && station > 1) {
319 if (rpcId.
sector() % 2 == 0)
static constexpr int minLayerId
ExtractPhi< GeomDet, float > DetPhi
const std::string metname
static constexpr int minRingForwardId
static constexpr int minRingBarrelId
virtual ~MuonRPCDetLayerGeometryBuilder()
Destructor.
Geom::Phi< T > phi() const
static constexpr int maxSectorForwardId
static constexpr int minSubSectorForwardId
static constexpr int minSectorForwardId
constexpr std::array< uint8_t, layerIndexSize > layer
static constexpr int maxSectorId
static constexpr int maxRingBarrelId
const Surface::PositionType & position() const
The position (origin of the R.F.)
ExtractR< GeomDet, float > DetR
static constexpr int maxRollId
static constexpr int minSubSectorId
static constexpr int maxRingForwardId
static bool isFront(const RPCDetId &rpcId)
static constexpr int minStationId
static constexpr int minSectorId
static void makeBarrelRods(std::vector< const GeomDet * > &geomDets, std::vector< const DetRod * > &result)
static void makeBarrelLayers(std::vector< const GeomDet * > &geomDets, std::vector< MuRodBarrelLayer * > &result)
static constexpr int maxLayerId
void precomputed_value_sort(RandomAccessIterator begin, RandomAccessIterator end, const Extractor &extr, const Compare &comp)
int sector() const
Sector id: the group of chambers at same phi (and increasing r)
static std::pair< std::vector< DetLayer * >, std::vector< DetLayer * > > buildEndcapLayers(const RPCGeometry &geo)
int subsector() const
SubSector id : some sectors are divided along the phi direction in subsectors (from 1 to 4 in Barrel...
constexpr uint32_t layerStart[numberOfLayers+1]
static constexpr int minRollId
static constexpr int maxSubSectorId
const GeomDet * idToDet(DetId) const override
static constexpr int maxStationId
static MuRingForwardDoubleLayer * buildLayer(int endcap, const std::vector< int > &rings, int station, int layer, std::vector< int > &rolls, const RPCGeometry &geo)
static std::vector< DetLayer * > buildBarrelLayers(const RPCGeometry &geo)
Builds the barrel layers. Result vector is sorted inside-out.