CMS 3D CMS Logo

Functions
ecalsrcondtools Namespace Reference

Functions

void importParameterSet (EcalSRSettings &sr, const edm::ParameterSet &ps)
 
void importSrpConfigFile (EcalSRSettings &sr, std::istream &f, bool debug=false)
 
double normalizeWeights (int hwWeight)
 
string tokenize (const string &s, const string &delim, int &pos)
 
std::string trim (std::string s)
 

Function Documentation

◆ importParameterSet()

void ecalsrcondtools::importParameterSet ( EcalSRSettings sr,
const edm::ParameterSet ps 
)

Converts CMSSW python file selective readout setting ("parameter set") into a condition database object. Configuration from parameter set covers only part of the config, mainly the configuration needed for SR emulation in the MC. The parameters not supported by python configuration are left untouched in the sr object.

Parameters
sr[in] ECAL selective readout setting object to set
psCMSSW parameter set containing the SR parameters to set

Definition at line 80 of file EcalSRCondTools.cc.

References EcalSRSettings::actions_, filterCSVwithJSON::copy, EcalSRSettings::dccNormalizedWeights_, EcalSRSettings::deltaEta_, EcalSRSettings::deltaPhi_, EcalSRSettings::ebDccAdcToGeV_, EcalSRSettings::ecalDccZs1stSample_, EcalSRSettings::eeDccAdcToGeV_, edm::ParameterSet::getParameter(), EcalSRSettings::srpHighInterestChannelZS_, EcalSRSettings::srpLowInterestChannelZS_, EcalSRSettings::symetricZS_, and w().

Referenced by module::EcalSRCondTools::analyze(), and EcalSelectiveReadoutProducer::EcalSelectiveReadoutProducer().

80  {
81  sr.deltaPhi_.resize(1);
82  sr.deltaPhi_[0] = ps.getParameter<int>("deltaPhi");
83  sr.deltaEta_.resize(1);
84  sr.deltaEta_[0] = ps.getParameter<int>("deltaEta");
85  sr.ecalDccZs1stSample_.resize(1);
86  sr.ecalDccZs1stSample_[0] = ps.getParameter<int>("ecalDccZs1stSample");
87  sr.ebDccAdcToGeV_ = ps.getParameter<double>("ebDccAdcToGeV");
88  sr.eeDccAdcToGeV_ = ps.getParameter<double>("eeDccAdcToGeV");
89  sr.dccNormalizedWeights_.resize(1);
90  const std::vector<double>& w = ps.getParameter<std::vector<double> >("dccNormalizedWeights");
91  sr.dccNormalizedWeights_[0].resize(w.size());
92  std::copy(w.begin(), w.end(), sr.dccNormalizedWeights_[0].begin());
93  sr.symetricZS_.resize(1);
94  sr.symetricZS_[0] = ps.getParameter<bool>("symetricZS");
95  sr.srpLowInterestChannelZS_.resize(2);
96  const int eb = 0;
97  const int ee = 1;
98  sr.srpLowInterestChannelZS_[eb] = ps.getParameter<double>("srpBarrelLowInterestChannelZS");
99  sr.srpLowInterestChannelZS_[ee] = ps.getParameter<double>("srpEndcapLowInterestChannelZS");
100  sr.srpHighInterestChannelZS_.resize(2);
101  sr.srpHighInterestChannelZS_[eb] = ps.getParameter<double>("srpBarrelHighInterestChannelZS");
102  sr.srpHighInterestChannelZS_[ee] = ps.getParameter<double>("srpEndcapHighInterestChannelZS");
103  //sr.trigPrimBypass_.resize(1);
104  //sr.trigPrimBypass_[0] = ps.getParameter<bool >("trigPrimBypass");
105  //sr.trigPrimBypassMode_.resize(1);
106  //sr.trigPrimBypassMode_[0] = ps.getParameter<int >("trigPrimBypassMode");
107  //sr.trigPrimBypassLTH_.resize(1);
108  //sr.trigPrimBypassLTH_[0] = ps.getParameter<double >("trigPrimBypassLTH");
109  //sr.trigPrimBypassHTH_.resize(1);
110  //sr.trigPrimBypassHTH_[0] = ps.getParameter<double >("trigPrimBypassHTH");
111  //sr.trigPrimBypassWithPeakFinder_.resize(1);
112  //sr.trigPrimBypassWithPeakFinder_[0] = ps.getParameter<bool >("trigPrimBypassWithPeakFinder");
113  //sr.defaultTtf_.resize(1);
114  //sr.defaultTtf_[0] = ps.getParameter<int >("defaultTtf");
115  sr.actions_ = ps.getParameter<std::vector<int> >("actions");
116  }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
T w() const
std::vector< std::vector< float > > dccNormalizedWeights_
std::vector< float > srpHighInterestChannelZS_
std::vector< int > actions_
std::vector< int > ecalDccZs1stSample_
std::vector< int > deltaPhi_
std::vector< int > symetricZS_
float ebDccAdcToGeV_
ADC to GeV conversion factor used in ZS filter for EB.
std::vector< float > srpLowInterestChannelZS_
std::vector< int > deltaEta_
float eeDccAdcToGeV_
ADC to GeV conversion factor used in ZS filter for EE.

◆ importSrpConfigFile()

void ecalsrcondtools::importSrpConfigFile ( EcalSRSettings sr,
std::istream &  f,
bool  debug = false 
)

Imports an SRP configuration file (stored in database "CLOB") into a Selective readout setting object.

Parameters
sr[in] ECAL selective readout setting object to set
fconfiguration file stream. A stringstream can be used if the configuration is available as an stl string of a c-string: stringstream buf; buf << s;
debugverbosity flag. If true, imported parameter are displayed on stdout.

Definition at line 118 of file EcalSRCondTools.cc.

References EcalSRSettings::actions_, cms::cuda::assert(), EcalSRSettings::automaticMasks_, EcalSRSettings::automaticSrpSelect_, EcalSRSettings::bxOffsets_, gather_cfg::cout, ztail::d, ALPAKA_ACCELERATOR_NAMESPACE::ecal::reconstruction::internal::barrel::dcc(), EcalSRSettings::dccMasks_, dccNum, EcalSRSettings::deltaEta_, EcalSRSettings::deltaPhi_, Exception, f, mps_splice::line, nChs, EcalSRSettings::nDccs_, EcalSRSettings::nSrps_, EcalSRSettings::nTccs_, EcalSRSettings::srfMasks_, EcalSRSettings::srpMasksFromConfig_, EcalSRSettings::substitutionSrfs_, EcalSRSettings::tccMasksFromConfig_, tccNum, EcalSRSettings::testerDccTestSrpIds_, EcalSRSettings::testerSrpEmuSrpIds_, EcalSRSettings::testerSrpTestSrpIds_, EcalSRSettings::testerTccEmuSrpIds_, tokenize(), trim(), and relativeConstraints::value.

Referenced by module::EcalSRCondTools::analyze(), and popcon::EcalSRPHandler::getNewObjects().

118  {
119  //initialize vectors:
120  sr.deltaEta_ = vector<int>(1, 0);
121  sr.deltaPhi_ = vector<int>(1, 0);
122  sr.actions_ = vector<int>(4, 0);
123  sr.tccMasksFromConfig_ = vector<short>(EcalSRSettings::nTccs_, 0);
124  sr.srpMasksFromConfig_ = vector<vector<short> >(EcalSRSettings::nSrps_, vector<short>(8, 0));
125  sr.dccMasks_ = vector<short>(EcalSRSettings::nDccs_);
126  sr.srfMasks_ = vector<short>(EcalSRSettings::nDccs_);
127  sr.substitutionSrfs_ = vector<vector<short> >(EcalSRSettings::nSrps_, vector<short>(68, 0));
128  sr.testerTccEmuSrpIds_ = vector<int>(EcalSRSettings::nSrps_, 0);
129  sr.testerSrpEmuSrpIds_ = vector<int>(EcalSRSettings::nSrps_, 0);
130  sr.testerDccTestSrpIds_ = vector<int>(EcalSRSettings::nSrps_, 0);
131  sr.testerSrpTestSrpIds_ = vector<int>(EcalSRSettings::nSrps_, 0);
132  sr.bxOffsets_ = vector<short>(EcalSRSettings::nSrps_, 0);
133  sr.automaticMasks_ = 0;
134  sr.automaticSrpSelect_ = 0;
135 
136  //string line;
137  int iLine = 0;
138  int iValueSet = -1;
139  const int nValueSets = 6 * EcalSRSettings::nSrps_ + 9;
140  string line;
141  stringstream sErr("");
142  while (!f.eof() && sErr.str().empty()) {
143  getline(f, line);
144  ++iLine;
145  line = trim(line);
146  if (line[0] == '#' || line.empty()) { //comment line and empty line to ignore
147  continue;
148  } else {
149  ++iValueSet;
150  }
151  if (iValueSet >= nValueSets)
152  break;
153  uint32_t value;
154  string sValue;
155  int pos = 0;
156  int iCh = 0;
157  int nChs[nValueSets] = {
158  //TCC masks: 0-11
159  12,
160  12,
161  12,
162  12,
163  12,
164  12,
165  12,
166  12,
167  12,
168  12,
169  12,
170  12,
171  //SRP masks: 12-23
172  8,
173  8,
174  8,
175  8,
176  8,
177  8,
178  8,
179  8,
180  8,
181  8,
182  8,
183  8,
184  //DCC masks: 24-35
185  12,
186  12,
187  12,
188  12,
189  12,
190  12,
191  12,
192  12,
193  12,
194  12,
195  12,
196  12,
197  //SRF Masks: 36-47
198  6,
199  6,
200  6,
201  6,
202  6,
203  6,
204  6,
205  6,
206  6,
207  6,
208  6,
209  6,
210  //substitution SRFs: 48-59
211  68,
212  68,
213  68,
214  68,
215  68,
216  68,
217  68,
218  68,
219  68,
220  68,
221  68,
222  68,
223  //Tester card to emulate or test: 60-71
224  4,
225  4,
226  4,
227  4,
228  4,
229  4,
230  4,
231  4,
232  4,
233  4,
234  4,
235  4,
236  //Bx offsets: 72
237  12,
238  //algo type: 73
239  1,
240  //action flags: 74
241  4,
242  //pattern file directory: 75
243  1,
244  //VME slots: 76
245  12,
246  //card types: 77
247  12,
248  //config Mode
249  1,
250  //VME Interface card
251  1,
252  //Spy Mode
253  12,
254  };
255 
256  while (((sValue = tokenize(line, " \t", pos)) != string("")) && (iCh < nChs[iValueSet]) && sErr.str().empty()) {
257  value = strtoul(sValue.c_str(), nullptr, 0);
258  const int iSrp = iValueSet % EcalSRSettings::nSrps_;
259  if (iValueSet < 12) { //TCC
260  assert((unsigned)iSrp < sizeof(tccNum) / sizeof(tccNum[0]));
261  assert((unsigned)iCh < sizeof(tccNum[0]) / sizeof(tccNum[0][0]));
262  int tcc = tccNum[iSrp][iCh];
263  if (tcc >= 0) {
264  if (d)
265  cout << "tccMasksFromConfig_[" << tcc << "] <- " << value << "\n";
266  sr.tccMasksFromConfig_[tcc - 1] = value;
267  }
268  } else if (iValueSet < 24) { //SRP-SRP
269  if (d)
270  cout << "srpMasks_[" << iSrp << "][" << iCh << "] <- " << value << "\n";
271  sr.srpMasksFromConfig_[iSrp][iCh] = value;
272  } else if (iValueSet < 36) { //DCC output
273  assert((unsigned)iSrp < sizeof(dccNum) / sizeof(dccNum[0]));
274  assert((unsigned)iCh < sizeof(dccNum[0]) / sizeof(dccNum[0][0]));
275  int dcc = dccNum[iSrp][iCh];
276  if (dcc > 0) {
277  assert((unsigned)(dcc - 1) < sr.dccMasks_.size());
278  if (d)
279  cout << "dccMasks_[" << (dcc - 1) << "] <- " << value << "\n";
280  sr.dccMasks_[dcc - 1] = value;
281  }
282  } else if (iValueSet < 48) { //SRF masks
283  assert((unsigned)iSrp < sizeof(dccNum) / sizeof(dccNum[0]));
284  assert((unsigned)iCh < sizeof(dccNum[0]) / sizeof(dccNum[0][0]));
285  int dcc = dccNum[iSrp][iCh];
286  if (dcc > 0) {
287  if (d)
288  cout << "srfMasks_[" << (dcc - 1) << "] <- " << value << "\n";
289  assert((unsigned)(dcc - 1) < sr.srfMasks_.size());
290  sr.srfMasks_[dcc - 1] = value;
291  }
292  } else if (iValueSet < 60) { //substiution SRFs
293  assert((unsigned)iSrp < sr.substitutionSrfs_.size());
294  assert((unsigned)iCh < sr.substitutionSrfs_[0].size());
295  if (d)
296  cout << "substitutionMasks_[" << iSrp << "][" << iCh << "] <- " << value << "\n";
297  sr.substitutionSrfs_[iSrp][iCh] = value;
298  } else if (iValueSet < 72) { //Tester card config
299  switch (iCh) {
300  case 0:
301  assert((unsigned)iSrp < sr.testerTccEmuSrpIds_.size());
302  if (d)
303  cout << "testerTccEmuSrpIds_[" << iSrp << "] <- " << value << "\n";
304  sr.testerTccEmuSrpIds_[iSrp] = value;
305  break;
306  case 1:
307  assert((unsigned)iSrp < sr.testerSrpEmuSrpIds_.size());
308  if (d)
309  cout << "testerSrpEmuSrpIds_[" << iSrp << "] <- " << value << "\n";
310  sr.testerSrpEmuSrpIds_[iSrp] = value;
311  break;
312  case 2:
313  assert((unsigned)iSrp < sr.testerDccTestSrpIds_.size());
314  if (d)
315  cout << "testerDccTestSrpIds_[" << iSrp << "] <- " << value << "\n";
316  sr.testerDccTestSrpIds_[iSrp] = value;
317  break;
318  case 3:
319  assert((unsigned)iSrp < sr.testerSrpTestSrpIds_.size());
320  if (d)
321  cout << "testerSrpTestSrpIds_[" << iSrp << "] <- " << value << "\n";
322  sr.testerSrpTestSrpIds_[iSrp] = value;
323  break;
324  default:
325  sErr << "Syntax error in SRP system configuration "
326  << " line " << iLine << ".";
327  }
328  } else if (iValueSet < 73) { //bx offsets
329  assert((unsigned)iCh < sr.bxOffsets_.size());
330  if (d)
331  cout << "bxOffset_[" << iCh << "] <- " << value << "\n";
332  sr.bxOffsets_[iCh] = value;
333  } else if (iValueSet < 74) { //algo type
334  int algo = value;
335  switch (algo) {
336  case 0:
337  sr.deltaEta_[0] = sr.deltaPhi_[0] = 1;
338  break;
339  case 1:
340  sr.deltaEta_[0] = sr.deltaPhi_[0] = 2;
341  break;
342  default:
343  throw cms::Exception("OutOfRange")
344  << "Value of parameter algo ," << algo << ", is invalid. Valid values are 0 and 1.";
345  }
346  if (d)
347  cout << "deltaEta_[0] <- " << sr.deltaEta_[0] << "\t"
348  << "deltaPhi_[0] <- " << sr.deltaPhi_[0] << "\n";
349  } else if (iValueSet < 75) { //action flags
350  assert((unsigned)iCh < sr.actions_.size());
351  if (d)
352  cout << "actions_[" << iCh << "] <- " << value << "\n";
353  sr.actions_[iCh] = value;
354  } else if (iValueSet < 76) { //pattern file directory
355  // emuDir_ = sValue;
356  // if(d) cout << "emuDir_ <= "
357  // << value << "\n";
358  } else if (iValueSet < 77) { //VME slots
359  // slotIds_[iCh] = value;
360  // if(d) cout << "slotIds_[" << iCh << "] <= "
361  // << value << "\n";
362  } else if (iValueSet < 78) { //card types
363  // cardTypes_[iCh] = sValue[0];
364  // if(d) cout << "cardTypes_[" << iCh << "] <= "
365  // << value << "\n";
366  } else if (iValueSet < 79) { //config mode
367  //TODO validity check on value
368  // configMode_ = (ConfigMode)value;
369  // if(d) cout << "config mode <= " << value << "\n";
370  } else if (iValueSet < 80) { //VME I/F
371  //TODO validity check on value
372  // vmeInterface_ = (Vme::type_t)value;
373  //if(d) cout << "Vme Interface code <= " << value << "\n";
374  } else if (iValueSet < 81) { //Spy Mode
375  //TODO validity check on value
376  // spyMode_[iCh] = value & 0x3;
377  // if(d) cout << "Spy mode <= " << value << "\n";
378  } else { //should never be reached!
379  assert(false);
380  }
381  ++iCh;
382  }
383  if (iCh != nChs[iValueSet]) { //error
384  sErr << "Syntax error in imported SRP system configuration file "
385  /*<< filename <<*/ " line "
386  << iLine << ".";
387  }
388  }
389  if (sErr.str().empty() && iValueSet != (nValueSets - 1)) { //error
390  sErr << "Syntax Error in imported SRP system configuration file "
391  /*<< filename <<*/ " line "
392  << iLine << ".";
393  }
394  if (!sErr.str().empty())
395  throw cms::Exception("SyntaxError") << sErr.str();
396  }
static const int nTccs_
static const int nDccs_
constexpr int dccNum[12][12]
std::vector< short > srfMasks_
static void trim(std::string &s)
std::vector< int > testerSrpEmuSrpIds_
assert(be >=bs)
std::vector< int > actions_
const int nChs
std::vector< std::vector< short > > substitutionSrfs_
std::vector< int > testerDccTestSrpIds_
double f[11][100]
Definition: value.py:1
d
Definition: ztail.py:151
std::vector< short > tccMasksFromConfig_
std::vector< short > bxOffsets_
std::vector< short > dccMasks_
std::vector< int > deltaPhi_
std::vector< int > testerTccEmuSrpIds_
string tokenize(const string &s, const string &delim, int &pos)
std::vector< int > deltaEta_
std::vector< int > testerSrpTestSrpIds_
constexpr int tccNum[12][12]
static const int nSrps_
std::vector< std::vector< short > > srpMasksFromConfig_

◆ normalizeWeights()

double ecalsrcondtools::normalizeWeights ( int  hwWeight)

convert hardware weights (interger weights) into normalized weights. The former reprensentation is used in DCC firmware and in online databaser, while the later is used in offline software.

Definition at line 398 of file EcalSRCondTools.cc.

398  {
399  //Fix sign bit in case only the 12 least significant bits of hwWeight were set
400  //(hardware reprensentation uses only 12 bits)
401  if (hwWeight & (1 << 11))
402  hwWeight |= ~0xEFF;
403  return hwWeight / 1024.;
404  }

◆ tokenize()

string ecalsrcondtools::tokenize ( const string &  s,
const string &  delim,
int &  pos 
)

Definition at line 53 of file EcalSRCondTools.cc.

References spr::find(), and alignCSCRings::s.

Referenced by importSrpConfigFile().

53  {
54  if (pos < 0)
55  return "";
56  int pos0 = pos;
57  int len = s.size();
58  //eats delimeters at beginning of the string
59  while (pos0 < len && find(delim.begin(), delim.end(), s[pos0]) != delim.end()) {
60  ++pos0;
61  }
62  if (pos0 == len)
63  return "";
64  pos = s.find_first_of(delim, pos0);
65  return s.substr(pos0, (pos > 0 ? pos : len) - pos0);
66  }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19

◆ trim()

std::string ecalsrcondtools::trim ( std::string  s)

Definition at line 68 of file EcalSRCondTools.cc.

References alignCSCRings::s.

68  {
69  std::string::size_type pos0 = s.find_first_not_of(" \t");
70  if (pos0 == string::npos) {
71  pos0 = 0;
72  }
73  string::size_type pos1 = s.find_last_not_of(" \t") + 1;
74  if (pos1 == string::npos) {
75  pos1 = pos0;
76  }
77  return s.substr(pos0, pos1 - pos0);
78  }
uint16_t size_type