CMS 3D CMS Logo

Public Member Functions | Static Public Member Functions | Static Private Member Functions

MuonRPCDetLayerGeometryBuilder Class Reference

#include <MuonRPCDetLayerGeometryBuilder.h>

List of all members.

Public Member Functions

 MuonRPCDetLayerGeometryBuilder ()
 Constructor (disabled, only static access is allowed)
virtual ~MuonRPCDetLayerGeometryBuilder ()
 Destructor.

Static Public Member Functions

static std::vector< DetLayer * > buildBarrelLayers (const RPCGeometry &geo)
 Builds the barrel layers. Result vector is sorted inside-out.
static std::pair< std::vector
< DetLayer * >, std::vector
< DetLayer * > > 
buildEndcapLayers (const RPCGeometry &geo)

Static Private Member Functions

static MuRingForwardDoubleLayerbuildLayer (int endcap, std::vector< int > rings, int station, int layer, std::vector< int > &rolls, const RPCGeometry &geo)
static bool isFront (const RPCDetId &rpcId)
static void makeBarrelLayers (std::vector< const GeomDet * > &geomDets, std::vector< MuRodBarrelLayer * > &result)
static void makeBarrelRods (std::vector< const GeomDet * > &geomDets, std::vector< const DetRod * > &result)

Detailed Description

Build the RPC DetLayers.

Date:
2007/07/08 04:20:26
Revision:
1.9
Author:
N. Amapane - CERN

Definition at line 22 of file MuonRPCDetLayerGeometryBuilder.h.


Constructor & Destructor Documentation

MuonRPCDetLayerGeometryBuilder::MuonRPCDetLayerGeometryBuilder ( ) [inline]

Constructor (disabled, only static access is allowed)

Definition at line 25 of file MuonRPCDetLayerGeometryBuilder.h.

{}
MuonRPCDetLayerGeometryBuilder::~MuonRPCDetLayerGeometryBuilder ( ) [virtual]

Destructor.

Definition at line 30 of file MuonRPCDetLayerGeometryBuilder.cc.

                                                                {
}

Member Function Documentation

vector< DetLayer * > MuonRPCDetLayerGeometryBuilder::buildBarrelLayers ( const RPCGeometry geo) [static]

Builds the barrel layers. Result vector is sorted inside-out.

Definition at line 181 of file MuonRPCDetLayerGeometryBuilder.cc.

References RPCGeometry::idToDet(), LogTrace, RPCDetId::maxLayerId, RPCDetId::maxRingBarrelId, RPCDetId::maxRollId, RPCDetId::maxSectorId, RPCDetId::maxStationId, RPCDetId::maxSubSectorId, RPCDetId::minLayerId, RPCDetId::minRingBarrelId, RPCDetId::minRollId, RPCDetId::minSectorId, RPCDetId::minStationId, RPCDetId::minSubSectorId, PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), GeomDet::position(), query::result, and RPCDetId.

Referenced by MuonDetLayerGeometryESProducer::produce().

                                                                        {
  const std::string metname = "Muon|RPC|RecoMuon|RecoMuonDetLayers|MuonRPCDetLayerGeometryBuilder";

  vector<DetLayer*> detlayers;
  vector<MuRodBarrelLayer*> result;
  int region =0;

  for(int station = RPCDetId::minStationId; station <= RPCDetId::maxStationId; station++) {

    vector<const GeomDet*> geomDets;

    for(int layer=RPCDetId::minLayerId; layer<= RPCDetId::maxLayerId;++layer){
      for(int sector = RPCDetId::minSectorId; sector <= RPCDetId::maxSectorId; sector++) {
        for(int subsector = RPCDetId::minSubSectorId; subsector <= RPCDetId::maxSubSectorId; subsector++) {
          for(int wheel = RPCDetId::minRingBarrelId; wheel <= RPCDetId::maxRingBarrelId; wheel++) {
            for(int roll=RPCDetId::minRollId+1; roll <= RPCDetId::maxRollId; roll++){         
              const GeomDet* geomDet = geo.idToDet(RPCDetId(region,wheel,station,sector,layer,subsector,roll));
              if (geomDet) {
                geomDets.push_back(geomDet);
                LogTrace(metname) << "get RPC Barrel roll " <<  RPCDetId(region,wheel,station,sector,layer,subsector,roll)
                                  << " at R=" << geomDet->position().perp()
                                  << ", phi=" << geomDet->position().phi() ;
              }
            }
          }
        }
      }
    }
    makeBarrelLayers(geomDets, result);
  }
  

  for(vector<MuRodBarrelLayer*>::const_iterator it = result.begin(); it != result.end(); it++)
    detlayers.push_back((DetLayer*)(*it));

  return detlayers;
}
pair< vector< DetLayer * >, vector< DetLayer * > > MuonRPCDetLayerGeometryBuilder::buildEndcapLayers ( const RPCGeometry geo) [static]

Builds the forward (+Z, return.first) and backward (-Z, return.second) layers. Both vectors are sorted inside-out

Definition at line 36 of file MuonRPCDetLayerGeometryBuilder.cc.

References Reference_intrackfit_cff::endcap, RPCDetId::maxLayerId, RPCDetId::maxRingForwardId, RPCDetId::maxRollId, RPCDetId::maxStationId, RPCDetId::minLayerId, RPCDetId::minRingForwardId, RPCDetId::minRollId, query::result, relativeConstraints::ring, RingESSource_cfi::rings, and relativeConstraints::station.

Referenced by MuonDetLayerGeometryESProducer::produce().

                                                                        {
  
  vector<DetLayer*> result[2];

  for (int endcap = -1; endcap<=1; endcap+=2) {
    int iendcap = (endcap==1) ? 0 : 1; // +1: forward, -1: backward
    
    // ME 1
    int firstStation=1;
        
    // ME 1/1
    for (int layer = RPCDetId::minLayerId; layer <= RPCDetId::maxLayerId; ++layer) { 
      vector<int> rolls;      
      std::vector<int> rings;
      int FirstStationRing = 1; 
      rings.push_back(FirstStationRing);
      for(int roll = RPCDetId::minRollId+1; 
          roll <= RPCDetId::maxRollId; ++roll) {
        rolls.push_back(roll);
      }
      

      
      MuRingForwardDoubleLayer* ringLayer = buildLayer(endcap, rings,
                                                 firstStation , layer, 
                                                 rolls, geo);          
      if (ringLayer) result[iendcap].push_back(ringLayer);
      
    }
        
    // ME 1/2 and ME1/3       
    for(int layer = RPCDetId::minLayerId; layer <= RPCDetId::maxLayerId; ++layer) { 
      vector<int> rolls;      
      std::vector<int> rings;
      for(int ring = 2; ring <= 3; ++ring) {
        rings.push_back(ring);
      }
      for(int roll = RPCDetId::minRollId+1; roll <= RPCDetId::maxRollId; 
          ++roll) {
        rolls.push_back(roll);
      }
                
      MuRingForwardDoubleLayer* ringLayer = buildLayer(endcap, rings, firstStation , layer, rolls, geo);          
      if (ringLayer) result[iendcap].push_back(ringLayer);
    }
  

    // ME 2 and ME 3 
    for(int station = 2; station <= RPCDetId::maxStationId; ++station) {
      for(int layer = RPCDetId::minLayerId; layer <= RPCDetId::maxLayerId; ++layer) { 
        vector<int> rolls;      
        std::vector<int> rings;
        for(int ring = RPCDetId::minRingForwardId; ring <= RPCDetId::maxRingForwardId; ++ring) {
          rings.push_back(ring);
        }
        for(int roll = RPCDetId::minRollId+1; roll <= RPCDetId::maxRollId; ++roll) {
          rolls.push_back(roll);
        }
                
        MuRingForwardDoubleLayer* ringLayer = buildLayer(endcap, rings, station, layer, rolls, geo);          
        if (ringLayer) result[iendcap].push_back(ringLayer);
      }
    }
    
  }
  pair<vector<DetLayer*>, vector<DetLayer*> > res_pair(result[0], result[1]); 
  return res_pair;

}
MuRingForwardDoubleLayer * MuonRPCDetLayerGeometryBuilder::buildLayer ( int  endcap,
std::vector< int >  rings,
int  station,
int  layer,
std::vector< int > &  rolls,
const RPCGeometry geo 
) [static, private]

Definition at line 92 of file DTGeometryParserFromDDD.cc.

References DDFilteredView::copyno(), DDFilteredView::firstChild(), DDFilteredView::geoHistory(), MuonDDDNumbering::geoHistoryToBaseNumber(), DTNumberingScheme::getDetId(), and DDFilteredView::nextSibling().

                                                                                                                  {
  MuonDDDNumbering mdddnum(muonConstants);
  DTNumberingScheme dtnum(muonConstants);
  int rawid = dtnum.getDetId(mdddnum.geoHistoryToBaseNumber(fv.geoHistory()));
  DTLayerId layId(rawid);

  // Loop on wires
  bool doWire = fv.firstChild();
  int WCounter=0;
  int firstWire=fv.copyno();
  while (doWire) {
    WCounter++;
    doWire = fv.nextSibling(); // next wire
  }
  theLayerIdWiresMap[layId] = (make_pair(firstWire,WCounter));
}
bool MuonRPCDetLayerGeometryBuilder::isFront ( const RPCDetId rpcId) [static, private]

Definition at line 342 of file MuonRPCDetLayerGeometryBuilder.cc.

References query::result, RPCDetId::ring(), RPCDetId::sector(), RPCDetId::station(), and RPCDetId::subsector().

{
  // ME1/2 is always in back
  //  if(rpcId.station() == 1 && rpcId.ring() == 2)  return false;

  bool result = false;
  // 20 degree rings are a little weird! not anymore from 17x
  if(rpcId.ring() == 1 && rpcId.station() > 1)
  {
    // RE2/1 RE3/1  Upscope Geometry
    /* goes (sector) (subsector)            1/3
    1 1 back   // front 
    1 2 front  // back  
    1 3 front  // front 
    2 1 front  // back  
    2 2 back   // from  
    2 3 back   // back  
                        
    */
    result = (rpcId.subsector() != 2);
    if(rpcId.sector()%2 == 0) result = !result;
    return result;
  }
  else
  {
    // 10 degree rings have odd subsectors in front
    result = (rpcId.subsector()%2 == 0);
  }
  return result;
}
void MuonRPCDetLayerGeometryBuilder::makeBarrelLayers ( std::vector< const GeomDet * > &  geomDets,
std::vector< MuRodBarrelLayer * > &  result 
) [static, private]

Definition at line 220 of file MuonRPCDetLayerGeometryBuilder.cc.

References f, first, i, prof2calltree::last, LogTrace, and precomputed_value_sort().

{
  const std::string metname = "Muon|RPC|RecoMuon|RecoMuonDetLayers|MuonRPCDetLayerGeometryBuilder";

  //Sort in R
  precomputed_value_sort(geomDets.begin(), geomDets.end(),geomsort::DetR());

  // Clusterize in phi - phi0
  float resolution(25); // cm
  float r0 = float(geomDets.front()->position().perp());
  float rMin = - float(resolution);
  float rMax = float(geomDets.back()->position().perp()) - r0 + resolution;

  ClusterizingHistogram hisR( int((rMax-rMin)/resolution) + 1,
                                rMin, rMax);

  vector<const GeomDet*>::iterator first = geomDets.begin();
  vector<const GeomDet*>::iterator last = geomDets.end();

  for (vector<const GeomDet*>::iterator i=first; i!=last; i++){
    hisR.fill(float((*i)->position().perp())-r0);
    LogTrace(metname) << "R " << float((*i)->position().perp())-r0;
  }
  vector<float> rClust = hisR.clusterize(resolution);

  // LogTrace(metname) << "     Found " << phiClust.size() << " clusters in Phi, ";

  vector<const GeomDet*>::iterator layerStart = first;
  vector<const GeomDet*>::iterator separ = first;

  for (unsigned int i=0; i<rClust.size(); i++) {
    float rSepar;
    if (i<rClust.size()-1) {
      rSepar = (rClust[i] + rClust[i+1])/2.f;
    } else {
      rSepar = rMax;
    }

    // LogTrace(metname) << "       cluster " << i
    // << " phisepar " << phiSepar <<endl;
    while (separ < last && float((*separ)->position().perp())-r0 < rSepar ) {
      // LogTrace(metname) << "         roll at dphi:  " << float((*separ)->position().phi())-phi0;
      separ++;
    }

    if (int(separ-layerStart) > 0) {
      // we have a layer in R.  Now separate it into rods
      vector<const DetRod*> rods;
      vector<const GeomDet*> layerDets(layerStart, separ);
      makeBarrelRods(layerDets, rods);

      if (rods.size()!=0) {
        result.push_back(new MuRodBarrelLayer(rods));
        LogTrace(metname) << "    New MuRodBarrelLayer with " << rods.size()
                          << " rods, at R " << result.back()->specificSurface().radius();
      }
    }
    layerStart = separ;
  }
}
void MuonRPCDetLayerGeometryBuilder::makeBarrelRods ( std::vector< const GeomDet * > &  geomDets,
std::vector< const DetRod * > &  result 
) [static, private]

Definition at line 284 of file MuonRPCDetLayerGeometryBuilder.cc.

References f, first, i, prof2calltree::last, LogTrace, ExpressReco_HICollisions_FallBack::phiMax, ExpressReco_HICollisions_FallBack::phiMin, and precomputed_value_sort().

{
  const std::string metname = "Muon|RPC|RecoMuon|RecoMuonDetLayers|MuonRPCDetLayerGeometryBuilder";

  //Sort in phi
  precomputed_value_sort(geomDets.begin(), geomDets.end(),geomsort::DetPhi());

  // Clusterize in phi - phi0
  float resolution(0.01); // rad
  float phi0 = float(geomDets.front()->position().phi());
  float phiMin = - float(resolution);
  float phiMax = float(geomDets.back()->position().phi()) - phi0 + resolution;

  ClusterizingHistogram hisPhi( int((phiMax-phiMin)/resolution) + 1,
                                phiMin, phiMax);

  vector<const GeomDet*>::iterator first = geomDets.begin();
  vector<const GeomDet*>::iterator last = geomDets.end();

  for (vector<const GeomDet*>::iterator i=first; i!=last; i++){
    hisPhi.fill(float((*i)->position().phi())-phi0);
    LogTrace(metname) << "C " << float((*i)->position().phi())-phi0;
  }
  vector<float> phiClust = hisPhi.clusterize(resolution);

  // LogTrace(metname) << "     Found " << phiClust.size() << " clusters in Phi, ";

  vector<const GeomDet*>::iterator rodStart = first;
  vector<const GeomDet*>::iterator separ = first;

  for (unsigned int i=0; i<phiClust.size(); i++) {
    float phiSepar;
    if (i<phiClust.size()-1) {
      phiSepar = (phiClust[i] + phiClust[i+1])/2.f;
    } else {
      phiSepar = phiMax;
    }

    // LogTrace(metname) << "       cluster " << i
    // << " phisepar " << phiSepar <<endl;
    while (separ < last && float((*separ)->position().phi())-phi0 < phiSepar ) {
      // LogTrace(metname) << "         roll at dphi:  " << float((*separ)->position().phi())-phi0;
      separ++;
    }

    if (int(separ-rodStart) > 0) {
      result.push_back(new MuDetRod(rodStart, separ));
      LogTrace(metname) << "  New MuDetRod with " << int(separ-rodStart)
                        << " rolls at R=" << (*rodStart)->position().perp()
                        << ", phi=" << float((*rodStart)->position().phi());

    }
    rodStart = separ;
  }
}