CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
VolumeBasedMagneticFieldESProducer.cc
Go to the documentation of this file.
1 
9 
11 
15 
19 
20 #include <string>
21 #include <vector>
22 #include <iostream>
23 
24 #include <boost/algorithm/string/split.hpp>
25 #include <boost/algorithm/string/classification.hpp>
26 #include <boost/lexical_cast.hpp>
27 
28 using namespace std;
29 using namespace magneticfield;
30 
32 {
34 }
35 
36 // ------------ method called to produce the data ------------
37 std::auto_ptr<MagneticField> VolumeBasedMagneticFieldESProducer::produce(const IdealMagneticFieldRecord & iRecord)
38 {
39  bool debug = pset.getUntrackedParameter<bool>("debugBuilder", false);
40  if (debug) {
41  cout << "VolumeBasedMagneticFieldESProducer::produce() " << pset.getParameter<std::string>("version") << endl;
42  }
43 
45  iRecord.get("magfield",cpv );
47  pset.getParameter<int>("geometryVersion"),
48  debug);
49 
50  // Get scaling factors
51  vector<int> keys = pset.getParameter<vector<int> >("scalingVolumes");
52  vector<double> values = pset.getParameter<vector<double> >("scalingFactors");
53 
54  if (keys.size() != 0) {
55  builder.setScaling(keys, values);
56  }
57 
58  // Get specification for the grid tables to be used.
59  typedef vector<edm::ParameterSet> VPSet;
60  {
61  VPSet fileSpec = pset.getParameter<VPSet>("gridFiles");
62  if (fileSpec.size()!=0) {
63  auto_ptr<TableFileMap> gridFiles(new TableFileMap);
64  for(VPSet::const_iterator rule = fileSpec.begin(); rule != fileSpec.end(); ++rule){
65  string s_volumes = rule->getParameter<string>("volumes");
66  string s_sectors = rule->getParameter<string>("sectors"); // 0 means all volumes
67  int master = rule->getParameter<int>("master");
68  string path = rule->getParameter<string>("path");
69 
70  vector<unsigned> volumes = expandList(s_volumes);
71  vector<unsigned> sectors = expandList(s_sectors);
72 
73  if (debug) {
74  cout << s_volumes << endl;
75  copy(volumes.begin(), volumes.end(), ostream_iterator<unsigned>(cout, " "));
76  cout << endl;
77  cout << s_sectors << endl;
78  copy(sectors.begin(), sectors.end(), ostream_iterator<unsigned>(cout, " "));
79  cout << endl;
80  }
81 
82  for (vector<unsigned>::iterator i = volumes.begin(); i!=volumes.end(); ++i){
83  for (vector<unsigned>::iterator j = sectors.begin(); j!=sectors.end(); ++j){
84  unsigned vpacked = (*i)*100+(*j);
85  if (gridFiles->find(vpacked)==gridFiles->end()) {
86  (*gridFiles)[vpacked] = make_pair(path, master);
87  } else {
88  edm::LogError("BADconfiguration") << "ERROR: VolumeBasedMagneticFieldESProducer: malformed gridFiles config parameter";
89  abort();
90  }
91  }
92  }
93  }
94  builder.setGridFiles(gridFiles); // gridFiles passed by reference, which is required to exist until
95  }
96  }
97 
98  builder.build(*cpv);
99 
100 
101  // Get slave field
102  edm::ESHandle<MagneticField> paramField;
103  if (pset.getParameter<bool>("useParametrizedTrackerField")) {;
104  iRecord.get(pset.getParameter<string>("paramLabel"),paramField);
105  }
106  std::auto_ptr<MagneticField> s(new VolumeBasedMagneticField(pset,builder.barrelLayers(), builder.endcapSectors(), builder.barrelVolumes(), builder.endcapVolumes(), builder.maxR(), builder.maxZ(), paramField.product(), false));
107  return s;
108 }
109 
110 vector<unsigned> VolumeBasedMagneticFieldESProducer::expandList(const string& list) {
111  typedef vector<string> vstring;
112  vector<unsigned> values;
113  vstring v1;
114  boost::split(v1, list, boost::is_any_of(","));
115  for (vstring::const_iterator i= v1.begin(); i!=v1.end(); ++i){
116  vstring v2;
117  boost::split(v2, *i, boost::is_any_of("-"));
118  unsigned start = boost::lexical_cast<unsigned>(v2.front());
119  unsigned end = boost::lexical_cast<unsigned>(v2.back());
120  if ((v2.size()>2) || (start>end)) {
121  edm::LogError("BADconfiguration") << "VolumeBasedMagneticFieldESProducer: malformed configuration" << list << endl;
122  abort();
123  }
124  for (unsigned k = start; k<=end; ++k){
125  values.push_back(k);
126  }
127  }
128  return values;
129 }
130 
131 
132 
133 
134 
135 
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
tuple start
Check for commandline option errors.
Definition: dqm_diff.py:58
vector< string > vstring
Definition: ExoticaDQM.cc:75
std::vector< MagBLayer * > barrelLayers() const
Get barrel layers.
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
Definition: ESProducer.h:115
std::vector< MagVolume6Faces * > barrelVolumes() const
std::auto_ptr< MagneticField > produce(const IdealMagneticFieldRecord &iRecord)
virtual void build(const DDCompactView &cpv)
void get(HolderT &iHolder) const
int j
Definition: DBlmapReader.cc:9
std::vector< unsigned > expandList(const std::string &list)
std::vector< MagESector * > endcapSectors() const
Get endcap layers.
#define end
Definition: vmac.h:38
int k[5][pyjets_maxn]
T const * product() const
Definition: ESHandle.h:62
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
void setScaling(const std::vector< int > &keys, const std::vector< double > &values)
std::vector< MagVolume6Faces * > endcapVolumes() const
tuple cout
Definition: gather_cfg.py:121
#define debug
Definition: MEtoEDMFormat.h:34
void setGridFiles(const std::auto_ptr< magneticfield::TableFileMap > gridFiles)
double split
Definition: MVATrainer.cc:139
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run
std::map< unsigned, std::pair< std::string, int > > TableFileMap