20 namespace rpcdetlayergeomsort {
21 template <
class T,
class Scalar =
typename T::Scalar>
35 pair<vector<DetLayer*>, vector<DetLayer*> >
38 vector<DetLayer*>
result[2];
41 int iendcap = (
endcap==1) ? 0 : 1;
49 std::vector<int>
rings;
50 int FirstStationRing = 1;
51 rings.push_back(FirstStationRing);
54 rolls.push_back(roll);
62 if (ringLayer) result[iendcap].push_back(ringLayer);
69 std::vector<int>
rings;
71 rings.push_back(
ring);
75 rolls.push_back(roll);
79 if (ringLayer) result[iendcap].push_back(ringLayer);
87 std::vector<int>
rings;
89 rings.push_back(
ring);
92 rolls.push_back(roll);
96 if (ringLayer) result[iendcap].push_back(ringLayer);
101 pair<vector<DetLayer*>, vector<DetLayer*> > res_pair(result[0], result[1]);
114 const std::string
metname =
"Muon|RPC|RecoMuon|RecoMuonDetLayers|MuonRPCDetLayerGeometryBuilder";
116 vector<const ForwardDetRing*> frontRings, backRings;
119 for (std::vector<int>::iterator
ring=rings.begin();
ring<rings.end();++
ring){
120 for (vector<int>::iterator roll = rolls.begin(); roll!=rolls.end(); ++roll) {
121 vector<const GeomDet*> frontDets, backDets;
124 RPCDetId rpcId(endcap,*
ring, station,sector,layer,subsector, (*roll));
125 bool isInFront = isFront(rpcId);
131 frontDets.push_back(geomDet);
135 backDets.push_back(geomDet);
137 LogTrace(metname) <<
"get RPC Endcap roll "
139 << (isInFront ?
"front" :
"back ")
147 if (frontDets.size()!=0) {
149 frontRings.push_back(
new MuDetRing(frontDets));
150 LogTrace(metname) <<
"New front ring with " << frontDets.size()
151 <<
" chambers at z="<< frontRings.back()->position().z();
153 if (backDets.size()!=0) {
155 backRings.push_back(
new MuDetRing(backDets));
156 LogTrace(metname) <<
"New back ring with " << backDets.size()
157 <<
" chambers at z="<< backRings.back()->position().z();
164 if(!backRings.empty() || !frontRings.empty())
171 LogTrace(metname) <<
"New layer with " << frontRings.size()
172 <<
" front rings and " << backRings.size()
173 <<
" back rings, at Z " << result->position().z();
182 const std::string
metname =
"Muon|RPC|RecoMuon|RecoMuonDetLayers|MuonRPCDetLayerGeometryBuilder";
184 vector<DetLayer*> detlayers;
185 vector<MuRodBarrelLayer*>
result;
190 vector<const GeomDet*> geomDets;
199 geomDets.push_back(geomDet);
209 makeBarrelLayers(geomDets, result);
213 for(vector<MuRodBarrelLayer*>::const_iterator it = result.begin(); it != result.end(); it++)
214 detlayers.push_back((
DetLayer*)(*it));
221 vector<MuRodBarrelLayer*> &
result)
223 const std::string
metname =
"Muon|RPC|RecoMuon|RecoMuonDetLayers|MuonRPCDetLayerGeometryBuilder";
230 float r0 = float(geomDets.front()->position().perp());
231 float rMin = - float(resolution);
232 float rMax = float(geomDets.back()->position().perp()) - r0 + resolution;
237 vector<const GeomDet*>::iterator
first = geomDets.begin();
238 vector<const GeomDet*>::iterator
last = geomDets.end();
240 for (vector<const GeomDet*>::iterator
i=first;
i!=
last;
i++){
241 hisR.fill(
float((*i)->position().perp())-r0);
242 LogTrace(metname) <<
"R " << float((*i)->position().perp())-r0;
244 vector<float> rClust = hisR.clusterize(resolution);
248 vector<const GeomDet*>::iterator layerStart =
first;
249 vector<const GeomDet*>::iterator separ =
first;
251 for (
unsigned int i=0;
i<rClust.size();
i++) {
253 if (
i<rClust.size()-1) {
254 rSepar = (rClust[
i] + rClust[
i+1])/2.
f;
261 while (separ < last &&
float((*separ)->position().perp())-r0 < rSepar ) {
266 if (
int(separ-layerStart) > 0) {
268 vector<const DetRod*> rods;
269 vector<const GeomDet*> layerDets(layerStart, separ);
270 makeBarrelRods(layerDets, rods);
272 if (rods.size()!=0) {
274 LogTrace(metname) <<
" New MuRodBarrelLayer with " << rods.size()
275 <<
" rods, at R " << result.back()->specificSurface().radius();
285 vector<const DetRod*> &
result)
287 const std::string
metname =
"Muon|RPC|RecoMuon|RecoMuonDetLayers|MuonRPCDetLayerGeometryBuilder";
294 float phi0 = float(geomDets.front()->position().phi());
295 float phiMin = - float(resolution);
296 float phiMax = float(geomDets.back()->position().phi()) - phi0 + resolution;
301 vector<const GeomDet*>::iterator
first = geomDets.begin();
302 vector<const GeomDet*>::iterator
last = geomDets.end();
304 for (vector<const GeomDet*>::iterator
i=first;
i!=
last;
i++){
305 hisPhi.fill(
float((*i)->position().phi())-phi0);
306 LogTrace(metname) <<
"C " << float((*i)->position().phi())-phi0;
308 vector<float> phiClust = hisPhi.clusterize(resolution);
312 vector<const GeomDet*>::iterator rodStart =
first;
313 vector<const GeomDet*>::iterator separ =
first;
315 for (
unsigned int i=0;
i<phiClust.size();
i++) {
317 if (
i<phiClust.size()-1) {
318 phiSepar = (phiClust[
i] + phiClust[
i+1])/2.
f;
325 while (separ < last &&
float((*separ)->position().phi())-phi0 < phiSepar ) {
330 if (
int(separ-rodStart) > 0) {
331 result.push_back(
new MuDetRod(rodStart, separ));
332 LogTrace(metname) <<
" New MuDetRod with " << int(separ-rodStart)
333 <<
" rolls at R=" << (*rodStart)->position().perp()
334 <<
", phi=" << float((*rodStart)->position().phi());
362 if(rpcId.
sector()%2 == 0) result = !result;
static const int maxStationId
ExtractPhi< GeomDet, float > DetPhi
static const int maxLayerId
const std::string metname
static const int maxRingForwardId
static const int minRingBarrelId
virtual ~MuonRPCDetLayerGeometryBuilder()
Destructor.
Geom::Phi< T > phi() const
static const int minSubSectorId
static MuRingForwardDoubleLayer * buildLayer(int endcap, std::vector< int > rings, int station, int layer, std::vector< int > &rolls, const RPCGeometry &geo)
static const int minRollId
static const int minSectorId
const Surface::PositionType & position() const
The position (origin of the R.F.)
static const int minSubSectorForwardId
ExtractR< GeomDet, float > DetR
static const int maxSubSectorId
static const int minSectorForwardId
static bool isFront(const RPCDetId &rpcId)
static const int maxRollId
static const int minStationId
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 const int maxRingBarrelId
static const int maxSectorId
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...
static const int minRingForwardId
void precomputed_value_sort(RandomAccessIterator begin, RandomAccessIterator end, const Extractor &extr)
static const int maxSectorForwardId
static const int minLayerId
virtual const GeomDet * idToDet(DetId) const
static std::vector< DetLayer * > buildBarrelLayers(const RPCGeometry &geo)
Builds the barrel layers. Result vector is sorted inside-out.