CMS 3D CMS Logo

Public Member Functions | Public Attributes | Private Member Functions | Private Attributes

magneticfield::AutoMagneticFieldESProducer Class Reference

#include <AutoMagneticFieldESProducer.h>

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

List of all members.

Public Member Functions

 AutoMagneticFieldESProducer (const edm::ParameterSet &)
std::auto_ptr< MagneticFieldproduce (const IdealMagneticFieldRecord &)
 ~AutoMagneticFieldESProducer ()

Public Attributes

edm::ParameterSet pset

Private Member Functions

std::string closerModel (float current)

Private Attributes

std::vector< std::string > maps
std::vector< int > nominalCurrents

Detailed Description

Definition at line 24 of file AutoMagneticFieldESProducer.h.


Constructor & Destructor Documentation

AutoMagneticFieldESProducer::AutoMagneticFieldESProducer ( const edm::ParameterSet iConfig)

Definition at line 32 of file AutoMagneticFieldESProducer.cc.

References Exception, edm::ParameterSet::getUntrackedParameter(), maps, nominalCurrents, pset, and edm::ESProducer::setWhatProduced().

                                                                                       : pset(iConfig) {
  setWhatProduced(this, pset.getUntrackedParameter<std::string>("label",""));
  nominalCurrents = pset.getUntrackedParameter<vector<int> >("nominalCurrents"); 
  maps = pset.getUntrackedParameter<vector<string> >("mapLabels");

  if (maps.size()==0 || (maps.size() != nominalCurrents.size())) {
    throw cms::Exception("InvalidParameter") << "Invalid values for parameters \"nominalCurrents\" and \"maps\"";
  }
}
AutoMagneticFieldESProducer::~AutoMagneticFieldESProducer ( )

Definition at line 43 of file AutoMagneticFieldESProducer.cc.

{
}

Member Function Documentation

std::string AutoMagneticFieldESProducer::closerModel ( float  current) [private]

Definition at line 81 of file AutoMagneticFieldESProducer.cc.

References i, maps, and nominalCurrents.

Referenced by produce().

                                                                {
  int i=0;
  for(;i<(int)maps.size()-1;i++) {
    if(2*current < nominalCurrents[i]+nominalCurrents[i+1] )
      return maps[i];
  }
  return  maps[i];
}
std::auto_ptr< MagneticField > AutoMagneticFieldESProducer::produce ( const IdealMagneticFieldRecord iRecord)

Definition at line 49 of file AutoMagneticFieldESProducer.cc.

References closerModel(), cond::rpcobimon::current, edm::eventsetup::EventSetupRecord::get(), edm::ParameterSet::getParameter(), edm::eventsetup::DependentRecordImplementation< RecordT, ListT >::getRecord(), Association::map, python::rootplot::argparse::message, edm::ESHandle< T >::product(), pset, query::result, and alignCSCRings::s.

{
  float current = pset.getParameter<int>("valueOverride");

  string message;

  if (current < 0) {
    ESHandle<RunInfo> rInfo;
    iRecord.getRecord<RunInfoRcd>().get(rInfo);
    current = rInfo->m_avg_current;
    message = " (from RunInfo DB)";
  } else {
    message = " (from valueOverride card)";
  }

  string model  = closerModel(current);

  edm::LogInfo("MagneticField|AutoMagneticField") << "Current: " << current << message << "; using map with label: " << model;


  edm::ESHandle<MagneticField> map;
  
  iRecord.get(model,map);

  MagneticField* result = map.product()->clone();

  std::auto_ptr<MagneticField> s(result);
  
  return s;
}

Member Data Documentation

std::vector<std::string> magneticfield::AutoMagneticFieldESProducer::maps [private]

Definition at line 35 of file AutoMagneticFieldESProducer.h.

Referenced by AutoMagneticFieldESProducer(), and closerModel().

Definition at line 34 of file AutoMagneticFieldESProducer.h.

Referenced by AutoMagneticFieldESProducer(), and closerModel().

Definition at line 31 of file AutoMagneticFieldESProducer.h.

Referenced by AutoMagneticFieldESProducer(), and produce().