test
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 
7 
9 
11 
14 
19 
20 #include <string>
21 #include <sstream>
22 #include <iostream>
23 #include <vector>
24 
25 using namespace std;
26 using namespace edm;
27 using namespace magneticfield;
28 
29 
32  nominalCurrents = pset.getUntrackedParameter<vector<int> >("nominalCurrents");
33  maps = pset.getUntrackedParameter<vector<string> >("mapLabels");
34 
35  if (maps.size()==0 || (maps.size() != nominalCurrents.size())) {
36  throw cms::Exception("InvalidParameter") << "Invalid values for parameters \"nominalCurrents\" and \"maps\"";
37  }
38 }
39 
40 
42 {
43 }
44 
45 
46 std::auto_ptr<MagneticField>
48 {
49  float current = pset.getParameter<int>("valueOverride");
50 
51  string message;
52 
53  if (current < 0) {
54  ESHandle<RunInfo> rInfo;
55  iRecord.getRecord<RunInfoRcd>().get(rInfo);
56  current = rInfo->m_avg_current;
57  message = " (from RunInfo DB)";
58  } else {
59  message = " (from valueOverride card)";
60  }
61 
62  string model = closerModel(current);
63 
64  edm::LogInfo("MagneticField|AutoMagneticField") << "Current: " << current << message << "; using map with label: " << model;
65 
66 
68 
69  iRecord.get(model,map);
70 
71  MagneticField* result = map.product()->clone();
72 
73  std::auto_ptr<MagneticField> s(result);
74 
75  return s;
76 }
77 
78 
80  int i=0;
81  for(;i<(int)maps.size()-1;i++) {
82  if(2*current < nominalCurrents[i]+nominalCurrents[i+1] )
83  return maps[i];
84  }
85  return maps[i];
86 }
87 
88 
89 
92 
93 
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
std::auto_ptr< MagneticField > produce(const IdealMagneticFieldRecord &)
tuple result
Definition: query.py:137
void get(HolderT &iHolder) const
T const * product() const
Definition: ESHandle.h:86
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
tuple AutoMagneticFieldESProducer
Definition: HLT_ES_cff.py:2325