CMS 3D CMS Logo

MagFieldConfig.cc
Go to the documentation of this file.
1 
8 
9 #include <iostream>
10 #include <vector>
11 #include <memory>
12 
13 #include <boost/algorithm/string/split.hpp>
14 #include <boost/algorithm/string/classification.hpp>
15 #include <boost/lexical_cast.hpp>
16 
17 using namespace std;
18 using namespace magneticfield;
19 
21  version = pset.getParameter<std::string>("version");
22  geometryVersion = pset.getParameter<int>("geometryVersion");
23 
24  // Get specification for the grid tables to be used.
25  typedef vector<edm::ParameterSet> VPSet;
26 
27  VPSet fileSpec = pset.getParameter<VPSet>("gridFiles");
28  if (!fileSpec.empty()) {
29  for (VPSet::const_iterator rule = fileSpec.begin(); rule != fileSpec.end(); ++rule) {
30  string s_volumes = rule->getParameter<string>("volumes");
31  string s_sectors = rule->getParameter<string>("sectors"); // 0 means all volumes
32  int master = rule->getParameter<int>("master");
33  string path = rule->getParameter<string>("path");
34 
35  vector<unsigned> volumes = expandList(s_volumes);
36  vector<unsigned> sectors = expandList(s_sectors);
37 
38  if (debug) {
39  cout << "Volumes: " << s_volumes << " Sectors: " << s_sectors << " Master: " << master << " Path: " << path
40  << endl;
41  cout << " Expanded volumes: ";
42  copy(volumes.begin(), volumes.end(), ostream_iterator<unsigned>(cout, " "));
43  cout << endl;
44  cout << " Expanded sectors: ";
45  copy(sectors.begin(), sectors.end(), ostream_iterator<unsigned>(cout, " "));
46  cout << endl;
47  }
48 
49  for (vector<unsigned>::iterator i = volumes.begin(); i != volumes.end(); ++i) {
50  for (vector<unsigned>::iterator j = sectors.begin(); j != sectors.end(); ++j) {
51  unsigned vpacked = (*i) * 100 + (*j);
52  if (gridFiles.find(vpacked) == gridFiles.end()) {
53  gridFiles[vpacked] = make_pair(path, master);
54  } else {
55  throw cms::Exception("ConfigurationError")
56  << "VolumeBasedMagneticFieldESProducer: malformed gridFiles config parameter" << endl;
57  }
58  }
59  }
60  }
61  }
62 
63  // Get scaling factors
64  keys = pset.getParameter<vector<int> >("scalingVolumes");
65  values = pset.getParameter<vector<double> >("scalingFactors");
66 
67  // Slave field label. Either a label of an existing map (legacy support), or the
68  // type of parametrization to be constructed with the "paramData" parameters.
69  slaveFieldVersion = pset.getParameter<string>("paramLabel");
70  // Check for compatibility with older configurations
71  if (pset.existsAs<vector<double> >("paramData")) {
72  slaveFieldParameters = pset.getParameter<vector<double> >("paramData");
73  }
74 }
75 
76 vector<unsigned> MagFieldConfig::expandList(const string& list) {
77  typedef vector<string> vstring;
78  vector<unsigned> values;
79  vstring v1;
80  boost::split(v1, list, boost::is_any_of(","));
81  for (vstring::const_iterator i = v1.begin(); i != v1.end(); ++i) {
82  vstring v2;
83  boost::split(v2, *i, boost::is_any_of("-"));
84  unsigned start = boost::lexical_cast<unsigned>(v2.front());
85  unsigned end = boost::lexical_cast<unsigned>(v2.back());
86  if ((v2.size() > 2) || (start > end)) {
87  throw cms::Exception("ConfigurationError")
88  << "VolumeBasedMagneticFieldESProducerFromDB: malformed configuration" << list << endl;
89  }
90  for (unsigned k = start; k <= end; ++k) {
91  values.push_back(k);
92  }
93  }
94  return values;
95 }
Definition: start.py:1
T getParameter(std::string const &) const
Master< F > master(const F &f)
Definition: FunctClone.h:68
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:161
def copy(args, dbName)
vector< string > vstring
Definition: ExoticaDQM.cc:8
#define end
Definition: vmac.h:39
int k[5][pyjets_maxn]
#define debug
Definition: HDRShower.cc:19
double split
Definition: MVATrainer.cc:139
std::vector< unsigned > expandList(const std::string &list)
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