CMS 3D CMS Logo

Public Member Functions | Private Attributes

MagGeoBuilderFromDDD::bRod Class Reference

#include <bRod.h>

List of all members.

Public Member Functions

 bRod (handles::const_iterator begin, handles::const_iterator end)
 Constructor from list of volumes.
MagBRodbuildMagBRod () const
 Construct the MagBRod upon request.
const float RN () const
 Distance from center along sector normal.
 ~bRod ()
 Destructor.

Private Attributes

MagBRodmrod
std::vector< bSlabslabs
handles volumes

Detailed Description

A rod of volumes in a barrel sector. A rod is made of several "slabs".

Date:
2005/09/27 15:15:52
Revision:
1.2
Author:
N. Amapane - INFN Torino

Definition at line 19 of file bRod.h.


Constructor & Destructor Documentation

MagGeoBuilderFromDDD::bRod::bRod ( handles::const_iterator  begin,
handles::const_iterator  end 
)

Constructor from list of volumes.

Definition at line 22 of file bRod.cc.

References ClusterizingHistogram::clusterize(), gather_cfg::cout, MagGeoBuilderFromDDD::debug, f, ClusterizingHistogram::fill(), first, i, prof2calltree::last, precomputed_value_sort(), MagGeoBuilderFromDDD::volumeHandle::printUniqueNames(), slabs, and volumes.

                                                                   :
  volumes(begin,end),
  mrod(0)
{
  precomputed_value_sort(volumes.begin(), volumes.end(), ExtractZ());

  // Clusterize in Z
  const float resolution = 5.; // cm
  float zmin = volumes.front()->center().z()-resolution;
  float zmax = volumes.back()->center().z()+resolution;
  ClusterizingHistogram  hisZ( int((zmax-zmin)/resolution) + 1, zmin, zmax);

  if (MagGeoBuilderFromDDD::debug) std::cout << "     Z slabs: " << zmin << " " << zmax << std::endl;

  handles::const_iterator first = volumes.begin();
  handles::const_iterator last = volumes.end();  

  for (handles::const_iterator i=first; i!=last; ++i){
    hisZ.fill((*i)->center().z());
  }
  std::vector<float> zClust = hisZ.clusterize(resolution);

  if (MagGeoBuilderFromDDD::debug) std::cout << "     Found " << zClust.size() << " clusters in Z, "
                  << " slabs: " << std::endl;

  handles::const_iterator slabStart = first;
  handles::const_iterator separ = first;

  for (unsigned int i=0; i<zClust.size() - 1; ++i) {
    float zSepar = (zClust[i] + zClust[i+1])/2.f;
    while ((*separ)->center().z() < zSepar) ++separ;
    if (MagGeoBuilderFromDDD::debug) {
      std::cout << "     Slab at: " << zClust[i]
           << " elements: " << separ-slabStart << " unique volumes: ";
      volumeHandle::printUniqueNames(slabStart, separ);
    }
    
    slabs.push_back(bSlab(slabStart, separ));
    slabStart = separ;
  }
  {
    if (MagGeoBuilderFromDDD::debug) {
      std::cout << "     Slab at: " << zClust.back() <<" elements: " << last-separ
           << " unique volumes: ";
      volumeHandle::printUniqueNames(separ,last);
    }
    slabs.push_back(bSlab(separ, last));
  }

  // Check that all slabs have the same dphi.
  std::vector<bSlab>::const_iterator i = slabs.begin();
  Geom::Phi<float> phimax = (*i).maxPhi();
  Geom::Phi<float> phimin = (*i).minPhi();
  for (++i; i!= slabs.end(); ++i) { 
    if(fabs(phimax - (*i).maxPhi()) > 0.001 ||
       fabs(phimin - (*i).minPhi()) > 0.001){
      if (MagGeoBuilderFromDDD::debug) std::cout << "*** WARNING: slabs in this rod have different dphi!" <<std::endl;
    }
  }
}
MagGeoBuilderFromDDD::bRod::~bRod ( )

Destructor.

Definition at line 19 of file bRod.cc.

{}

Member Function Documentation

MagBRod * MagGeoBuilderFromDDD::bRod::buildMagBRod ( ) const

Construct the MagBRod upon request.

Definition at line 86 of file bRod.cc.

                                                     {
  if (mrod==0) {
    std::vector<MagBSlab*> mSlabs;
    for (std::vector<bSlab>::const_iterator slab = slabs.begin();
         slab!=slabs.end(); ++slab) {
      mSlabs.push_back((*slab).buildMagBSlab());
    }
    mrod = new MagBRod(mSlabs,slabs.front().minPhi()); //FIXME
  }
  return mrod;
}
const float MagGeoBuilderFromDDD::bRod::RN ( ) const [inline]

Distance from center along sector normal.

Definition at line 28 of file bRod.h.

References volumes.

                         {
    return volumes.front()->RN();
  }

Member Data Documentation

Definition at line 38 of file bRod.h.

std::vector<bSlab> MagGeoBuilderFromDDD::bRod::slabs [private]

Definition at line 36 of file bRod.h.

Referenced by bRod().

Definition at line 37 of file bRod.h.

Referenced by bRod(), and RN().