CMS 3D CMS Logo

Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | Friends

MagGeoBuilderFromDDD Class Reference

#include <MagGeoBuilderFromDDD.h>

List of all members.

Classes

class  bLayer
class  bRod
class  bSector
class  bSlab
class  eLayer
class  eSector
struct  ExtractAbsZ
struct  ExtractPhi
struct  ExtractPhiMax
struct  ExtractR
struct  ExtractRN
struct  ExtractZ
struct  LessDPhi
struct  LessZ
class  volumeHandle

Public Member Functions

std::vector< MagBLayer * > barrelLayers () const
 Get barrel layers.
std::vector< MagESector * > endcapSectors () const
 Get endcap layers.
 MagGeoBuilderFromDDD (std::string tableSet_, int geometryVersion, bool debug=false)
 Constructor.
float maxR () const
float maxZ () const
void setGridFiles (const std::auto_ptr< magneticfield::TableFileMap > gridFiles)
void setScaling (const std::vector< int > &keys, const std::vector< double > &values)
virtual ~MagGeoBuilderFromDDD ()
 Destructor.

Private Types

typedef std::vector
< volumeHandle * > 
handles
typedef
ConstReferenceCountingPointer
< Surface
RCPS
typedef std::unary_function
< const volumeHandle *, double > 
uFcn

Private Member Functions

std::vector< MagVolume6Faces * > barrelVolumes () const
virtual void build (const DDCompactView &cpv)
void buildInterpolator (const volumeHandle *vol, std::map< std::string, MagProviderInterpol * > &interpolators)
void buildMagVolumes (const handles &volumes, std::map< std::string, MagProviderInterpol * > &interpolators)
std::vector< MagVolume6Faces * > endcapVolumes () const
void summary (handles &volumes)
void testInside (handles &volumes)

Private Attributes

handles bVolumes
handles eVolumes
int geometryVersion
std::vector< MagBLayer * > mBLayers
std::vector< MagESector * > mESectors
std::string tableSet
std::auto_ptr
< magneticfield::TableFileMap
theGridFiles
std::map< int, double > theScalingFactors

Static Private Attributes

static bool debug

Friends

class MagGeometry
class magneticfield::AutoMagneticFieldESProducer
class magneticfield::VolumeBasedMagneticFieldESProducer
class TestMagVolume

Detailed Description

Parse the XML magnetic geometry, build individual volumes and match their shared surfaces. Build MagVolume6Faces and organise them in a hierarchical structure. Build MagGeometry out of it.

Date:
2013/05/30 22:00:08
Revision:
1.15
Author:
N. Amapane - INFN Torino

Definition at line 35 of file MagGeoBuilderFromDDD.h.


Member Typedef Documentation

typedef std::vector<volumeHandle*> MagGeoBuilderFromDDD::handles [private]

Definition at line 79 of file MagGeoBuilderFromDDD.h.

Definition at line 61 of file MagGeoBuilderFromDDD.h.

typedef std::unary_function<const volumeHandle*, double> MagGeoBuilderFromDDD::uFcn [private]

Definition at line 107 of file MagGeoBuilderFromDDD.h.


Constructor & Destructor Documentation

MagGeoBuilderFromDDD::MagGeoBuilderFromDDD ( std::string  tableSet_,
int  geometryVersion,
bool  debug = false 
)

Constructor.

Definition at line 63 of file MagGeoBuilderFromDDD.cc.

References gather_cfg::cout, and debug.

                                                                                             :
  tableSet (tableSet_),
  geometryVersion(geometryVersion_),
  theGridFiles(0)
{  
  debug = debug_;
  if (debug) cout << "Constructing a MagGeoBuilderFromDDD" <<endl;
}
MagGeoBuilderFromDDD::~MagGeoBuilderFromDDD ( ) [virtual]

Destructor.

Definition at line 72 of file MagGeoBuilderFromDDD.cc.

References bVolumes, eVolumes, and i.

                                           {
  for (handles::const_iterator i=bVolumes.begin();
       i!=bVolumes.end(); ++i){
    delete (*i);
  }
  
  for (handles::const_iterator i=eVolumes.begin();
       i!=eVolumes.end(); ++i){
    delete (*i);
  }
}

Member Function Documentation

vector< MagBLayer * > MagGeoBuilderFromDDD::barrelLayers ( ) const

Get barrel layers.

Definition at line 629 of file MagGeoBuilderFromDDD.cc.

References mBLayers.

Referenced by magneticfield::VolumeBasedMagneticFieldESProducer::produce().

                                                           {
  return mBLayers;
}
vector< MagVolume6Faces * > MagGeoBuilderFromDDD::barrelVolumes ( ) const [private]

Definition at line 637 of file MagGeoBuilderFromDDD.cc.

References bVolumes, i, and findQualityFiles::v.

Referenced by magneticfield::VolumeBasedMagneticFieldESProducer::produce().

                                                                  {
  vector<MagVolume6Faces*> v;
  v.reserve(bVolumes.size());
  for (handles::const_iterator i=bVolumes.begin();
       i!=bVolumes.end(); ++i){
    v.push_back((*i)->magVolume);
  }
  return v;
}
void MagGeoBuilderFromDDD::build ( const DDCompactView cpv) [private, virtual]

Definition at line 130 of file MagGeoBuilderFromDDD.cc.

References buildInterpolator(), buildMagVolumes(), bVolumes, MagGeoBuilderFromDDD::volumeHandle::center(), ClusterizingHistogram::clusterize(), conv, MagGeoBuilderFromDDD::volumeHandle::copyno, gather_cfg::cout, debug, eVolumes, Exception, f, ClusterizingHistogram::fill(), first, DDExpandedView::firstChild(), Geom::fpi(), Geom::ftwoPi(), DDExpandedView::geoHistory(), i, combine::key, prof2calltree::last, DDExpandedView::logicalPart(), MagGeoBuilderFromDDD::volumeHandle::magFile, MagGeoBuilderFromDDD::volumeHandle::masterSector, mBLayers, mESectors, DDName::name(), DDBase< N, C >::name(), mergeVDriftHistosByStation::name, DDExpandedView::nextSibling(), evf::evtn::offset(), PV3DBase< T, PVType, FrameType >::perp(), precomputed_value_sort(), dttmaxenums::R, dtDQMClient_cfg::resolution, DDExpandedView::rotation(), mergeVDriftHistosByStation::sectors, AlCaHLTBitMon_QueryRunRegistry::string, summary(), testInside(), theGridFiles, DDExpandedView::translation(), findQualityFiles::v, MagGeoBuilderFromDDD::volumeHandle::volumeno, Gflash::Z, and PV3DBase< T, PVType, FrameType >::z().

Referenced by buildInterpolator(), and magneticfield::VolumeBasedMagneticFieldESProducer::produce().

{
//    DDCompactView cpv;
  DDExpandedView fv(cpva);

  if (debug) cout << "**********************************************************" <<endl;

  // The actual field interpolators
  map<string, MagProviderInterpol*> bInterpolators;
  map<string, MagProviderInterpol*> eInterpolators;
  
  // Counter of different volumes
  int bVolCount = 0;
  int eVolCount = 0;

  if (fv.logicalPart().name().name()!="MAGF") {
     std::string topNodeName(fv.logicalPart().name().name());

     //see if one of the children is MAGF
     bool doSubDets = fv.firstChild();
     
     bool go=true;
     while(go&& doSubDets) {
        if (fv.logicalPart().name().name()=="MAGF")
           break;
        else
           go = fv.nextSibling();
     }
     if (!go) {
        throw cms::Exception("NoMAGFinDDD")<<" Neither the top node, nor any child node of the DDCompactView is \"MAGF\" but the top node is instead \""<<topNodeName<<"\"";
     }
  }
  // Loop over MAGF volumes and create volumeHandles. 
  if (debug) { cout << endl << "*** MAGF: " << fv.geoHistory() << endl
                    << "translation: " << fv.translation() << endl
                    << " rotation: " << fv.rotation() << endl;
  }
  
  bool doSubDets = fv.firstChild();
  while (doSubDets){
    
    string name = fv.logicalPart().name().name();
    if (debug) cout << endl << "Name: " << name << endl
                               << "      " << fv.geoHistory() <<endl;
    
    // FIXME: single-volyme cylinders - this is feature has been removed 
    //        and should be revisited.
    //    bool mergeCylinders=false;

    // If true, In the barrel, cylinders sectors will be skipped to build full 
    // cylinders out of sector copyno #1.
    bool expand = false;

//     if (mergeCylinders) {
//       if (name == "V_ZN_1"
//        || name == "V_ZN_2") {
//      if (debug && fv.logicalPart().solid().shape()!=ddtubs) {
//        cout << "ERROR: MagGeoBuilderFromDDD::build: volume " << name
//             << " should be a cylinder" << endl;
//      }
//      if(fv.copyno()==1) {
//        expand = true;
//      } else {
//        //cout << "... to be skipped: "
//        //     << name << " " << fv.copyno() << endl;
//      }
//       }
//     }

    volumeHandle* v = new volumeHandle(fv, expand);

    if (theGridFiles.get()) {
      int key = (v->volumeno)*100+v->copyno;
      TableFileMap::const_iterator itable = theGridFiles->find(key);
      if (itable == theGridFiles->end()) {
        key = (v->volumeno)*100;
        itable = theGridFiles->find(key);
      }

      if (itable != theGridFiles->end()) {
        string magFile = (*itable).second.first;        
        stringstream conv;
        string svol, ssec;
        conv << setfill('0') << setw(3) << v->volumeno << " " << setw(2) << v->copyno; // volume assumed to have 0s padding to 3 digits; sector assumed to have 0s padding to 2 digits
        conv >> svol >> ssec;   
        boost::replace_all(magFile, "[v]",svol);
        boost::replace_all(magFile, "[s]",ssec); 
        int masterSector = (*itable).second.second;
        if (masterSector==0) masterSector=v->copyno;
        v->magFile = magFile;
        v->masterSector = masterSector;
      } else {
        edm::LogError("MagGeoBuilderFromDDDbuild") << "ERROR: no table spec found for V " <<  v->volumeno << ":" << v->copyno;
      }
    }


    // Select volumes, build volume handles.
    float Z = v->center().z();
    float R = v->center().perp();

    // v 85l: Barrel is everything up to |Z| = 661.0, excluding 
    // volume #7, centered at 6477.5
    // v 1103l: same numbers work fine. #16 instead of #7, same coords;
    // see comment below for V6,7
    //ASSUMPTION: no misalignment is applied to mag volumes.
    //FIXME: implement barrel/endcap flags as DDD SpecPars.
    if ((fabs(Z)<647. || (R>350. && fabs(Z)<662.)) &&
        !(fabs(Z)>480 && R<172) // in 1103l we place V_6 and V_7 in the 
                                // endcaps to preserve nice layer structure
                                // in the barrel. This does not hurt in v85l
                                // where there is a single V1 
        ) { // Barrel
      if (debug) cout << " (Barrel)" <<endl;
      bVolumes.push_back(v);


      // Build the interpolator of the "master" volume (the one which is
      // not replicated in phi)
      // ASSUMPTION: copyno == sector.
      if (v->copyno==v->masterSector) {
        buildInterpolator(v, bInterpolators);
        ++bVolCount;
      }
    } else {               // Endcaps
      if (debug) cout << " (Endcaps)" <<endl;
      eVolumes.push_back(v);
      if (v->copyno==v->masterSector) { 
        buildInterpolator(v, eInterpolators);
        ++eVolCount;
      }
    }

    doSubDets = fv.nextSibling(); // end of loop over MAGF
  }
    
  if (debug) {
    cout << "Number of volumes (barrel): " << bVolumes.size() <<endl
                  << "Number of volumes (endcap): " << eVolumes.size() <<endl;
    cout << "**********************************************************" <<endl;
  }

  // Now all volumeHandles are there, and parameters for each of the planes
  // are calculated.

  //----------------------------------------------------------------------
  // Print summary information

  if (debug) {
    cout << "-----------------------" << endl;
    cout << "SUMMARY: Barrel " << endl;
    summary(bVolumes);
    
    cout << endl << "SUMMARY: Endcaps " << endl;
    summary(eVolumes);
    cout << "-----------------------" << endl;
  }


  //----------------------------------------------------------------------
  // Find barrel layers.

  vector<bLayer> layers; // the barrel layers
  precomputed_value_sort(bVolumes.begin(), bVolumes.end(), ExtractRN());

  // Find the layers (in R)
  const float resolution = 1.; // cm
  float rmin = bVolumes.front()->RN()-resolution;
  float rmax = bVolumes.back()->RN()+resolution;
  ClusterizingHistogram  hisR( int((rmax-rmin)/resolution) + 1, rmin, rmax);

  if (debug) cout << " R layers: " << rmin << " " << rmax << endl;

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

  for (handles::const_iterator i=first; i!=last; ++i){
    hisR.fill((*i)->RN());
  }
  vector<float> rClust = hisR.clusterize(resolution);

  handles::const_iterator ringStart = first;
  handles::const_iterator separ = first;

  for (unsigned int i=0; i<rClust.size() - 1; ++i) {
    if (debug) cout << " Layer at RN = " << rClust[i];
    float rSepar = (rClust[i] + rClust[i+1])/2.f;
    while ((*separ)->RN() < rSepar) ++separ;

    bLayer thislayer(ringStart, separ);
    layers.push_back(thislayer);
    ringStart = separ;
  }
  {
    if (debug) cout << " Layer at RN = " << rClust.back();
    bLayer thislayer(separ, last);
    layers.push_back(thislayer);
  }

  if (debug) cout << "Barrel: Found " << rClust.size() << " clusters in R, "
                  << layers.size() << " layers " << endl << endl;


  //----------------------------------------------------------------------
  // Find endcap sectors
  vector<eSector> sectors; // the endcap sectors

  // Find the number of sectors (should be 12 or 24 depending on the geometry model)
  float phireso = 0.05; // rad
  ClusterizingHistogram hisPhi( int((Geom::ftwoPi())/phireso) + 1,
                                -Geom::fpi(), Geom::fpi());
  
  for (handles::const_iterator i=eVolumes.begin(); i!=eVolumes.end(); ++i){
    hisPhi.fill((*i)->minPhi());
  }
  vector<float> phiClust = hisPhi.clusterize(phireso);
  int nESectors = phiClust.size();
  if (debug && (nESectors%12)!=0) cout << "ERROR: unexpected # of sectors: " << nESectors << endl;

  //Sort in phi
  precomputed_value_sort(eVolumes.begin(), eVolumes.end(), ExtractPhi());

  //Group volumes in sectors
  for (int i = 0; i<nESectors; ++i) {
    int offset = eVolumes.size()/nESectors;
    if (debug) cout << " Sector at phi = "
                    << (*(eVolumes.begin()+((i)*offset)))->center().phi()
                    << endl;
    sectors.push_back(eSector(eVolumes.begin()+((i)*offset),
                              eVolumes.begin()+((i+1)*offset)));
  }
   
  if (debug) cout << "Endcap: Found " 
                  << sectors.size() << " sectors " << endl;


  //----------------------------------------------------------------------  
  // Match surfaces.

//  cout << "------------------" << endl << "Now associating planes..." << endl;

//   // Loop on layers
//   for (vector<bLayer>::const_iterator ilay = layers.begin();
//        ilay!= layers.end(); ++ilay) {
//     cout << "On Layer: " << ilay-layers.begin() << " RN: " << (*ilay).RN()
//       <<endl;     

//     // Loop on wheels
//     for (vector<bWheel>::const_iterator iwheel = (*ilay).wheels.begin();
//       iwheel != (*ilay).wheels.end(); ++iwheel) {
//       cout << "  On Wheel: " << iwheel- (*ilay).wheels.begin()<< " Z: "
//         << (*iwheel).minZ() << " " << (*iwheel).maxZ() << " " 
//         << ((*iwheel).minZ()+(*iwheel).maxZ())/2. <<endl;

//       // Loop on sectors.
//       for (int isector = 0; isector<12; ++isector) {
//      // FIXME: create new constructor...
//      bSectorNavigator navy(layers,
//                            ilay-layers.begin(),
//                            iwheel-(*ilay).wheels.begin(),isector);
        
//      const bSector & isect = (*iwheel).sector(isector);
        
//      isect.matchPlanes(navy); //FIXME refcount
//       }
//     }
//   }


  //----------------------------------------------------------------------
  // Build MagVolumes and the MagGeometry hierarchy.

  //--- Barrel

  // Build MagVolumes and associate interpolators to them
  buildMagVolumes(bVolumes, bInterpolators);

  // Build MagBLayers
  for (vector<bLayer>::const_iterator ilay = layers.begin();
       ilay!= layers.end(); ++ilay) {
    mBLayers.push_back((*ilay).buildMagBLayer());
  }

  if (debug) {  
    cout << "*** BARREL ********************************************" << endl
         << "Number of different volumes   = " << bVolCount << endl
         << "Number of interpolators built = " << bInterpolators.size() << endl
         << "Number of MagBLayers built    = " << mBLayers.size() << endl;

    testInside(bVolumes); // FIXME: all volumes should be checked in one go.
  }
  
  //--- Endcap
  // Build MagVolumes  and associate interpolators to them
  buildMagVolumes(eVolumes, eInterpolators);

  // Build the MagESectors
  for (vector<eSector>::const_iterator isec = sectors.begin();
       isec!= sectors.end(); ++isec) {
    mESectors.push_back((*isec).buildMagESector());
  }

  if (debug) {
    cout << "*** ENDCAP ********************************************" << endl
         << "Number of different volumes   = " << eVolCount << endl
         << "Number of interpolators built = " << eInterpolators.size() << endl
         << "Number of MagESector built    = " << mESectors.size() << endl;

    testInside(eVolumes); // FIXME: all volumes should be checked in one go.
  }
}
void MagGeoBuilderFromDDD::buildInterpolator ( const volumeHandle vol,
std::map< std::string, MagProviderInterpol * > &  interpolators 
) [private]

Definition at line 491 of file MagGeoBuilderFromDDD.cc.

References build(), MagGeoBuilderFromDDD::volumeHandle::center(), dtNoiseDBValidation_cfg::cerr, MagGeoBuilderFromDDD::volumeHandle::copyno, gather_cfg::cout, Dimensions::d, debug, edm::FileInPath::fullPath(), Dimensions::h, i, j, gen::k, MagGeoBuilderFromDDD::volumeHandle::magFile, MagGeoBuilderFromDDD::volumeHandle::masterSector, PV3DBase< T, PVType, FrameType >::phi(), Geom::pi(), MagGeoBuilderFromDDD::volumeHandle::placement(), GloballyPositioned< T >::position(), makeMuonMisalignmentScenario::rot, GloballyPositioned< T >::rotation(), MagGeoBuilderFromDDD::volumeHandle::shape(), MagGeoBuilderFromDDD::volumeHandle::sides(), tableSet, MagGeoBuilderFromDDD::volumeHandle::toExpand(), MagGeoBuilderFromDDD::volumeHandle::volumeno, Dimensions::w, MagException::what(), and cms::Exception::what().

Referenced by build().

                                                                                                                       {

  // Phi of the master sector
  double masterSectorPhi = (vol->masterSector-1)*Geom::pi()/6.;

  if (debug) {
    cout << "Building interpolator from "
         << vol->volumeno << " copyno " << vol->copyno
         << " at " << vol->center()
         << " phi: " << vol->center().phi()
         << " file: " << vol->magFile
         << endl;

    if ( fabs(vol->center().phi() - masterSectorPhi) > Geom::pi()/9.) {
      cout << "***WARNING wrong sector? " << endl;
    }
  }

  if (tableSet == "fake" || vol->magFile== "fake") {
    interpolators[vol->magFile] = new magneticfield::FakeInterpolator();
    return;
  }

  string fullPath;

  try {
    edm::FileInPath mydata("MagneticField/Interpolation/data/"+tableSet+"/"+vol->magFile);
    fullPath = mydata.fullPath();
  } catch (edm::Exception& exc) {
    cerr << "MagGeoBuilderFromDDD: exception in reading table; " << exc.what() << endl;
    if (!debug) throw;
    return;
  }
  
  
  try{
    if (vol->toExpand()){
      //FIXME: see discussion on mergeCylinders above.
//       interpolators[vol->magFile] =
//      MFGridFactory::build( fullPath, *(vol->placement()), vol->minPhi(), vol->maxPhi());
    } else {
      // If the table is in "local" coordinates, must create a reference 
      // frame that is appropriately rotated along the CMS Z axis.

      GloballyPositioned<float> rf = *(vol->placement());

      if (vol->masterSector != 1) {
        typedef Basic3DVector<float> Vector;

        GloballyPositioned<float>::RotationType rot(Vector(0,0,1), -masterSectorPhi);
        Vector vpos(vol->placement()->position());
        

        rf = GloballyPositioned<float>(GloballyPositioned<float>::PositionType(rot.multiplyInverse(vpos)), vol->placement()->rotation()*rot);
      }

      interpolators[vol->magFile] =
        MFGridFactory::build( fullPath, rf);
    }
  } catch (MagException& exc) {
    cout << exc.what() << endl;
    interpolators.erase(vol->magFile);
    if (!debug) throw; 
    return;
  }


    if (debug) {
    // Check that all grid points of the interpolator are inside the volume.
      const MagVolume6Faces tempVolume(vol->placement()->position(),
                                 vol->placement()->rotation(),
                                 vol->shape(),
                                 vol->sides(), 
                                 interpolators[vol->magFile]);

      const MFGrid* grid = dynamic_cast<const MFGrid*>(interpolators[vol->magFile]);
      if (grid!=0) {
        
        Dimensions sizes = grid->dimensions();
        cout << "Grid has 3 dimensions " 
             << " number of nodes is " << sizes.w << " " << sizes.h
             << " " << sizes.d << endl;
      
        const double tolerance = 0.03;


        size_t dumpCount = 0;
        for (int j=0; j < sizes.h; j++) {
          for (int k=0; k < sizes.d; k++) {
            for (int i=0; i < sizes.w; i++) {
              MFGrid::LocalPoint lp = grid->nodePosition( i, j, k);
              if (! tempVolume.inside(lp, tolerance)) {
                if (++dumpCount < 2) {
                  MFGrid::GlobalPoint gp = tempVolume.toGlobal(lp);
                  cout << "GRID ERROR: " << i << " " << j << " " << k
                       << " local: " << lp
                       << " global: " << gp
                       << " R= " << gp.perp() << " phi=" << gp.phi() << endl;
                }
              }
            }
          }
        }
    
        cout << "Volume:" << vol->volumeno << " : Number of grid points outside the MagVolume: " << dumpCount << "/" << sizes.w*sizes.h*sizes.d << endl;
      }
    }
}
void MagGeoBuilderFromDDD::buildMagVolumes ( const handles volumes,
std::map< std::string, MagProviderInterpol * > &  interpolators 
) [private]

Definition at line 443 of file MagGeoBuilderFromDDD.cc.

References combine::key, MagVolume::ownsFieldProvider(), GloballyPositioned< T >::position(), GloballyPositioned< T >::rotation(), and theScalingFactors.

Referenced by build().

                                                                                                                     {
  // Build all MagVolumes setting the MagProviderInterpol
  for (handles::const_iterator vol=volumes.begin(); vol!=volumes.end();
       ++vol){
    const MagProviderInterpol* mp = 0;
    if (interpolators.find((*vol)->magFile)!=interpolators.end()) {
      mp = interpolators[(*vol)->magFile];
    } else {
      edm::LogError("MagGeoBuilderFromDDDbuildMagVolumes") << "No interpolator found for file " << (*vol)->magFile
                                                           << " vol: " << (*vol)->volumeno << "\n" << interpolators.size() <<endl;
    }  

    // Search for [volume,sector] in the list of scaling factors; sector = 0 handled as wildcard
    // ASSUMPTION: copyno == sector.
    int key = ((*vol)->volumeno)*100+(*vol)->copyno; 
    map<int, double>::const_iterator isf = theScalingFactors.find(key);
    if (isf == theScalingFactors.end()) {
      key = ((*vol)->volumeno)*100;
      isf = theScalingFactors.find(key);
    }
    
    double sf = 1.;
    if (isf != theScalingFactors.end()) {
      sf = (*isf).second;

      edm::LogInfo("MagneticField|VolumeBasedMagneticFieldESProducer") << "Applying scaling factor " << sf << " to "<< (*vol)->volumeno << "["<< (*vol)->copyno << "] (key:" << key << ")" << endl;
    }

    const GloballyPositioned<float> * gpos = (*vol)->placement();
    (*vol)->magVolume = new MagVolume6Faces(gpos->position(),
                                            gpos->rotation(),
                                            (*vol)->shape(),
                                            (*vol)->sides(),
                                            mp, sf);

    if ((*vol)->copyno==(*vol)->masterSector) {
      (*vol)->magVolume->ownsFieldProvider(true);
    }

    (*vol)->magVolume->setIsIron((*vol)->isIron());

    // The name and sector of the volume are saved for debug purposes only. They may be removed at some point...
    (*vol)->magVolume->volumeNo = (*vol)->volumeno;
    (*vol)->magVolume->copyno = (*vol)->copyno;
  }
}
vector< MagESector * > MagGeoBuilderFromDDD::endcapSectors ( ) const

Get endcap layers.

Definition at line 633 of file MagGeoBuilderFromDDD.cc.

References mESectors.

Referenced by magneticfield::VolumeBasedMagneticFieldESProducer::produce().

                                                             {
  return mESectors;
}
vector< MagVolume6Faces * > MagGeoBuilderFromDDD::endcapVolumes ( ) const [private]

Definition at line 647 of file MagGeoBuilderFromDDD.cc.

References eVolumes, i, and findQualityFiles::v.

Referenced by magneticfield::VolumeBasedMagneticFieldESProducer::produce().

                                                                  {
  vector<MagVolume6Faces*> v;
  v.reserve(eVolumes.size());
  for (handles::const_iterator i=eVolumes.begin();
       i!=eVolumes.end(); ++i){
    v.push_back((*i)->magVolume);
  }
  return v;
}
float MagGeoBuilderFromDDD::maxR ( ) const

Definition at line 658 of file MagGeoBuilderFromDDD.cc.

Referenced by magneticfield::VolumeBasedMagneticFieldESProducer::produce().

                                      {
  //FIXME: should get it from the actual geometry
  return 900.;
}
float MagGeoBuilderFromDDD::maxZ ( ) const

Definition at line 663 of file MagGeoBuilderFromDDD.cc.

References geometryVersion.

Referenced by MagGeoBuilderFromDDD::bSector::bSector(), and magneticfield::VolumeBasedMagneticFieldESProducer::produce().

                                      {
  //FIXME: should get it from the actual geometry
  if (geometryVersion>=120812) return 2000.;
  else return 1600.;
}
void MagGeoBuilderFromDDD::setGridFiles ( const std::auto_ptr< magneticfield::TableFileMap gridFiles)

Definition at line 682 of file MagGeoBuilderFromDDD.cc.

References theGridFiles.

Referenced by magneticfield::VolumeBasedMagneticFieldESProducer::produce().

                                                                       {
  theGridFiles=gridFiles;
}
void MagGeoBuilderFromDDD::setScaling ( const std::vector< int > &  keys,
const std::vector< double > &  values 
)

Set scaling factors for individual volumes. "keys" is a vector of 100*volume number + sector (sector 0 = all sectors) "values" are the corresponding scaling factors

Definition at line 670 of file MagGeoBuilderFromDDD.cc.

References Exception, i, and theScalingFactors.

Referenced by magneticfield::VolumeBasedMagneticFieldESProducer::produce().

{
  if (keys.size() != values.size()) {
    throw cms::Exception("InvalidParameter") << "Invalid field scaling parameters 'scalingVolumes' and 'scalingFactors' ";
  }
  for (unsigned int i=0; i<keys.size(); ++i) {
    theScalingFactors[keys[i]] = values[i];
  }
}
void MagGeoBuilderFromDDD::summary ( handles volumes) [private]

Definition at line 85 of file MagGeoBuilderFromDDD.cc.

References gather_cfg::cout, first, i, prof2calltree::last, and edm::second().

Referenced by build().

                                                   {  
  // The final countdown.
  int ivolumes  = volumes.size();  // number of volumes
  int isurfaces = ivolumes*6;       // number of individual surfaces
  int iassigned = 0;                // How many have been assigned
  int iunique   = 0;                // number of unique surfaces
  int iref_ass  = 0;
  int iref_nass = 0;

  set<const void *> ptrs;

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

  for (handles::const_iterator i=first; i!=last; ++i){
    if (int((*i)->shape())>4) continue; // FIXME: implement test for missing shapes...
    for (int side = 0; side < 6; ++side) {
      int references =  (*i)->references(side);
      if ((*i)->isPlaneMatched(side)) {
        ++iassigned;
        bool firstOcc = (ptrs.insert(&((*i)->surface(side)))).second;
        if (firstOcc) iref_ass+=references;
        if (references<2){  
          cout << "*** Only 1 ref, vol: " << (*i)->volumeno << " # "
               << (*i)->copyno << " side: " << side << endl;
        }       
      } else {
        iref_nass+=references;
        if (references>1){
          cout << "*** Ref_nass >1 " <<endl;
        }
      }
    }
  }
  iunique = ptrs.size();

  cout << "    volumes   " << ivolumes  << endl
       << "    surfaces  " << isurfaces << endl
       << "    assigned  " << iassigned << endl
       << "    unique    " << iunique << endl
       << "    iref_ass  " << iref_ass << endl
       << "    iref_nass " << iref_nass << endl;
}
void MagGeoBuilderFromDDD::testInside ( handles volumes) [private]

Definition at line 602 of file MagGeoBuilderFromDDD.cc.

References gather_cfg::cout, and i.

Referenced by build().

                                                       {
  // test inside() for all volumes.
  cout << "--------------------------------------------------" << endl;
  cout << " inside(center) test" << endl;
  for (handles::const_iterator vol=volumes.begin(); vol!=volumes.end();
       ++vol){
    for (handles::const_iterator i=volumes.begin(); i!=volumes.end();
         ++i){
      if ((*i)==(*vol)) continue;
      //if ((*i)->magVolume == 0) continue;
      if ((*i)->magVolume->inside((*vol)->center())) {
        cout << "*** ERROR: center of V " << (*vol)->volumeno << " is inside V " 
             << (*i)->volumeno <<endl;
      }
    }
    
    if ((*vol)->magVolume->inside((*vol)->center())) {
      cout << "V " << (*vol)->volumeno << " OK " << endl;
    } else {
      cout << "*** ERROR: center of volume is not inside it, "
           << (*vol)->volumeno << endl;
    }
  }
  cout << "--------------------------------------------------" << endl;
}

Friends And Related Function Documentation

friend class MagGeometry [friend]

Definition at line 70 of file MagGeoBuilderFromDDD.h.

Definition at line 72 of file MagGeoBuilderFromDDD.h.

Definition at line 71 of file MagGeoBuilderFromDDD.h.

friend class TestMagVolume [friend]

Definition at line 69 of file MagGeoBuilderFromDDD.h.


Member Data Documentation

Definition at line 120 of file MagGeoBuilderFromDDD.h.

Referenced by barrelVolumes(), build(), and ~MagGeoBuilderFromDDD().

bool MagGeoBuilderFromDDD::debug [static, private]

Definition at line 123 of file MagGeoBuilderFromDDD.h.

Referenced by build(), endcapVolumes(), and ~MagGeoBuilderFromDDD().

Definition at line 129 of file MagGeoBuilderFromDDD.h.

Referenced by maxZ().

std::vector<MagBLayer*> MagGeoBuilderFromDDD::mBLayers [private]

Definition at line 125 of file MagGeoBuilderFromDDD.h.

Referenced by barrelLayers(), and build().

Definition at line 126 of file MagGeoBuilderFromDDD.h.

Referenced by build(), and endcapSectors().

std::string MagGeoBuilderFromDDD::tableSet [private]

Definition at line 128 of file MagGeoBuilderFromDDD.h.

Referenced by buildInterpolator().

Definition at line 132 of file MagGeoBuilderFromDDD.h.

Referenced by build(), and setGridFiles().

std::map<int, double> MagGeoBuilderFromDDD::theScalingFactors [private]

Definition at line 131 of file MagGeoBuilderFromDDD.h.

Referenced by buildMagVolumes(), and setScaling().