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