CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
AutoMagneticFieldESProducer.cc
Go to the documentation of this file.
1 
9 
15 
17 
19 
22 
27 
28 #include <string>
29 #include <sstream>
30 #include <iostream>
31 #include <vector>
32 
33 using namespace std;
34 using namespace edm;
35 using namespace magneticfield;
36 
37 
39  setWhatProduced(this, pset.getUntrackedParameter<std::string>("label",""));
40  nominalCurrents = pset.getUntrackedParameter<vector<int> >("nominalCurrents");
41  maps = pset.getUntrackedParameter<vector<string> >("mapLabels");
42 
43  if (maps.size()==0 || (maps.size() != nominalCurrents.size())) {
44  throw cms::Exception("InvalidParameter") << "Invalid values for parameters \"nominalCurrents\" and \"maps\"";
45  }
46 }
47 
48 
50 {
51 }
52 
53 
54 std::auto_ptr<MagneticField>
56 {
57  float current = pset.getParameter<int>("valueOverride");
58 
59  string message;
60 
61  if (current < 0) {
62  ESHandle<RunInfo> rInfo;
63  iRecord.getRecord<RunInfoRcd>().get(rInfo);
64  current = rInfo->m_avg_current;
65  message = " (from RunInfo DB)";
66  } else {
67  message = " (from valueOverride card)";
68  }
69 
70  string model = closerModel(current);
71 
72  edm::LogInfo("MagneticField|AutoMagneticField") << "Current: " << current << message << "; using map with label: " << model;
73 
74 
76 
77  iRecord.get(model,map);
78 
79  MagneticField* result = map.product()->clone();
80 
81  std::auto_ptr<MagneticField> s(result);
82 
83  return s;
84 }
85 
86 
88  int i=0;
89  for(;i<(int)maps.size()-1;i++) {
90  if(2*current < nominalCurrents[i]+nominalCurrents[i+1] )
91  return maps[i];
92  }
93  return maps[i];
94 }
95 
96 
97 
100 
101 
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
Definition: ESProducer.h:115
dictionary map
Definition: Association.py:160
std::auto_ptr< MagneticField > produce(const IdealMagneticFieldRecord &)
tuple result
Definition: query.py:137
void get(HolderT &iHolder) const
tuple pset
Definition: CrabTask.py:85
T const * product() const
Definition: ESHandle.h:62
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:48
string message
Definition: argparse.py:126
string s
Definition: asciidump.py:422