CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

magneticfield::VolumeBasedMagneticFieldESProducer Class Reference

#include <VolumeBasedMagneticFieldESProducer.h>

Inheritance diagram for magneticfield::VolumeBasedMagneticFieldESProducer:
edm::ESProducer edm::ESProxyFactoryProducer edm::eventsetup::DataProxyProvider

List of all members.

Public Member Functions

std::auto_ptr< MagneticFieldproduce (const IdealMagneticFieldRecord &iRecord)
 VolumeBasedMagneticFieldESProducer (const edm::ParameterSet &iConfig)

Private Member Functions

std::vector< unsigned > expandList (const std::string &list)
const
VolumeBasedMagneticFieldESProducer
operator= (const VolumeBasedMagneticFieldESProducer &)
 VolumeBasedMagneticFieldESProducer (const VolumeBasedMagneticFieldESProducer &)

Private Attributes

edm::ParameterSet pset

Detailed Description

Definition at line 23 of file VolumeBasedMagneticFieldESProducer.h.


Constructor & Destructor Documentation

VolumeBasedMagneticFieldESProducer::VolumeBasedMagneticFieldESProducer ( const edm::ParameterSet iConfig)
magneticfield::VolumeBasedMagneticFieldESProducer::VolumeBasedMagneticFieldESProducer ( const VolumeBasedMagneticFieldESProducer ) [private]

Member Function Documentation

vector< unsigned > VolumeBasedMagneticFieldESProducer::expandList ( const std::string &  list) [private]

Definition at line 110 of file VolumeBasedMagneticFieldESProducer.cc.

References end, i, gen::k, split, dqm_diff::start, and makeHLTPrescaleTable::values.

Referenced by produce().

                                                                                  {
  typedef vector<string> vstring;
  vector<unsigned> values;
  vstring v1;
  boost::split(v1, list, boost::is_any_of(","));
  for (vstring::const_iterator i= v1.begin(); i!=v1.end(); ++i){
    vstring v2;
    boost::split(v2, *i, boost::is_any_of("-"));        
    unsigned start = boost::lexical_cast<unsigned>(v2.front());
    unsigned end   = boost::lexical_cast<unsigned>(v2.back());
    if ((v2.size()>2) || (start>end)) {
      edm::LogError("BADconfiguration") << "VolumeBasedMagneticFieldESProducer: malformed configuration" << list << endl;
      abort();
    }
    for (unsigned k = start; k<=end; ++k){
      values.push_back(k);
    }
  }
  return values;
}
const VolumeBasedMagneticFieldESProducer& magneticfield::VolumeBasedMagneticFieldESProducer::operator= ( const VolumeBasedMagneticFieldESProducer ) [private]
std::auto_ptr< MagneticField > VolumeBasedMagneticFieldESProducer::produce ( const IdealMagneticFieldRecord iRecord)

Definition at line 37 of file VolumeBasedMagneticFieldESProducer.cc.

References MagGeoBuilderFromDDD::barrelLayers(), MagGeoBuilderFromDDD::barrelVolumes(), MagGeoBuilderFromDDD::build(), filterCSVwithJSON::copy, gather_cfg::cout, debug, MagGeoBuilderFromDDD::endcapSectors(), MagGeoBuilderFromDDD::endcapVolumes(), expandList(), edm::eventsetup::EventSetupRecord::get(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), i, j, relativeConstraints::keys, autoMagneticFieldProducer_cfi::master, MagGeoBuilderFromDDD::maxR(), MagGeoBuilderFromDDD::maxZ(), getHLTPrescaleColumns::path, edm::ESHandle< T >::product(), pset, alignCSCRings::s, mergeVDriftHistosByStation::sectors, MagGeoBuilderFromDDD::setGridFiles(), MagGeoBuilderFromDDD::setScaling(), AlCaHLTBitMon_QueryRunRegistry::string, makeHLTPrescaleTable::values, and autoMagneticFieldProducer_cfi::volumes.

{
  bool debug = pset.getUntrackedParameter<bool>("debugBuilder", false);
  if (debug) {
    cout << "VolumeBasedMagneticFieldESProducer::produce() " << pset.getParameter<std::string>("version") << endl;
  }
  
  edm::ESTransientHandle<DDCompactView> cpv;
  iRecord.get("magfield",cpv );
  MagGeoBuilderFromDDD builder(pset.getParameter<std::string>("version"),
                               pset.getParameter<int>("geometryVersion"),
                               debug);

  // Get scaling factors
  vector<int> keys = pset.getParameter<vector<int> >("scalingVolumes");
  vector<double> values = pset.getParameter<vector<double> >("scalingFactors");

  if (keys.size() != 0) {
    builder.setScaling(keys, values);
  }
  
  // Get specification for the grid tables to be used.
  typedef vector<edm::ParameterSet> VPSet;
  {
    VPSet fileSpec = pset.getParameter<VPSet>("gridFiles");
    if (fileSpec.size()!=0) {
      auto_ptr<TableFileMap> gridFiles(new TableFileMap);
      for(VPSet::const_iterator rule = fileSpec.begin(); rule != fileSpec.end(); ++rule){
        string s_volumes = rule->getParameter<string>("volumes");
        string s_sectors = rule->getParameter<string>("sectors"); // 0 means all volumes
        int master       = rule->getParameter<int>("master");
        string path      = rule->getParameter<string>("path");

        vector<unsigned> volumes = expandList(s_volumes);
        vector<unsigned> sectors = expandList(s_sectors);

        if (debug) {
          cout << s_volumes << endl;
          copy(volumes.begin(), volumes.end(), ostream_iterator<unsigned>(cout, " "));
          cout << endl;
          cout << s_sectors << endl;
          copy(sectors.begin(), sectors.end(), ostream_iterator<unsigned>(cout, " "));
          cout << endl;
        }
        
        for (vector<unsigned>::iterator i = volumes.begin(); i!=volumes.end(); ++i){
          for (vector<unsigned>::iterator j = sectors.begin(); j!=sectors.end(); ++j){
            unsigned vpacked = (*i)*100+(*j);
            if (gridFiles->find(vpacked)==gridFiles->end()) {
              (*gridFiles)[vpacked] = make_pair(path, master);
            } else {
              edm::LogError("BADconfiguration") << "ERROR: VolumeBasedMagneticFieldESProducer: malformed gridFiles config parameter";
              abort();
            }
          }
        }
      }
      builder.setGridFiles(gridFiles); // gridFiles passed by reference, which is required to exist until  
    }
  }
  
  builder.build(*cpv);


  // Get slave field
  edm::ESHandle<MagneticField> paramField;
  if (pset.getParameter<bool>("useParametrizedTrackerField")) {;
    iRecord.get(pset.getParameter<string>("paramLabel"),paramField);
  }
  std::auto_ptr<MagneticField> s(new VolumeBasedMagneticField(pset,builder.barrelLayers(), builder.endcapSectors(), builder.barrelVolumes(), builder.endcapVolumes(), builder.maxR(), builder.maxZ(), paramField.product(), false));
  return s;
}

Member Data Documentation