CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SiStripPartition.cc
Go to the documentation of this file.
1 
6 #include <iostream>
7 #include <cmath>
8 
9 using namespace sistrip;
10 
11 // -----------------------------------------------------------------------------
12 //
13 const std::string SiStripPartition::defaultPartitionName_ = "DefaultPartition";
14 
15 // -----------------------------------------------------------------------------
16 //
18  : partitionName_(defaultPartitionName_),
19  runNumber_(0),
20  runType_(sistrip::UNDEFINED_RUN_TYPE),
21  forceVersions_(false),
22  forceCurrentState_(false),
23  cabVersion_(0, 0),
24  fedVersion_(0, 0),
25  fecVersion_(0, 0),
26  dcuVersion_(0, 0),
27  psuVersion_(0, 0),
28  //#ifdef USING_DATABASE_MASKING
29  maskVersion_(0, 0),
30  //#endif
31  globalAnalysisV_(0),
32  runTableVersion_(0, 0),
33  fastCablingV_(0, 0),
34  apvTimingV_(0, 0),
35  optoScanV_(0, 0),
36  vpspScanV_(0, 0),
37  apvCalibV_(0, 0),
38  pedestalsV_(0, 0),
39  pedsFullNoiseV_(0, 0),
40  apvLatencyV_(0, 0),
41  fineDelayV_(0, 0),
42  inputModuleXml_(""),
43  inputDcuInfoXml_(""),
44  inputFecXml_(),
45  inputFedXml_() {
46  ;
47 }
48 
49 // -----------------------------------------------------------------------------
50 //
52  : partitionName_(partition),
53  runNumber_(0),
54  runType_(sistrip::UNDEFINED_RUN_TYPE),
55  forceVersions_(false),
56  forceCurrentState_(false),
57  cabVersion_(0, 0),
58  fedVersion_(0, 0),
59  fecVersion_(0, 0),
60  dcuVersion_(0, 0),
61  psuVersion_(0, 0),
62  //#ifdef USING_DATABASE_MASKING
63  maskVersion_(0, 0),
64  //#endif
65  globalAnalysisV_(0),
66  runTableVersion_(0, 0),
67  fastCablingV_(0, 0),
68  apvTimingV_(0, 0),
69  optoScanV_(0, 0),
70  vpspScanV_(0, 0),
71  apvCalibV_(0, 0),
72  pedestalsV_(0, 0),
73  pedsFullNoiseV_(0, 0),
74  apvLatencyV_(0, 0),
75  fineDelayV_(0, 0),
76  inputModuleXml_(""),
77  inputDcuInfoXml_(""),
78  inputFecXml_(),
79  inputFedXml_() {
80  if (partitionName_.empty()) {
82  }
83 }
84 
85 // -----------------------------------------------------------------------------
86 //
88  : partitionName_(input.partitionName()),
89  runNumber_(input.runNumber()),
90  runType_(input.runType()),
91  forceVersions_(input.forceVersions()),
92  forceCurrentState_(input.forceCurrentState()),
93  cabVersion_(input.cabVersion()),
94  fedVersion_(input.fedVersion()),
95  fecVersion_(input.fecVersion()),
96  dcuVersion_(input.dcuVersion()),
97  psuVersion_(input.psuVersion()),
98  //#ifdef USING_DATABASE_MASKING
99  maskVersion_(input.maskVersion()),
100  //#endif
101  globalAnalysisV_(input.globalAnalysisVersion()),
102  runTableVersion_(input.runTableVersion()),
103  fastCablingV_(input.fastCablingVersion()),
104  apvTimingV_(input.apvTimingVersion()),
105  optoScanV_(input.optoScanVersion()),
106  vpspScanV_(input.vpspScanVersion()),
107  apvCalibV_(input.apvCalibVersion()),
108  pedestalsV_(input.pedestalsVersion()),
109  pedsFullNoiseV_(input.pedsFullNoiseVersion()),
110  apvLatencyV_(input.apvLatencyVersion()),
111  fineDelayV_(input.fineDelayVersion()),
112  inputModuleXml_(input.inputModuleXml()),
113  inputDcuInfoXml_(input.inputDcuInfoXml()),
114  inputFecXml_(input.inputFecXml()),
115  inputFedXml_(input.inputFedXml()) {
116  ;
117 }
118 
119 // -----------------------------------------------------------------------------
120 //
122  if (this == &input) {
123  return *this;
124  } // self-assignment
125  partitionName_ = input.partitionName();
126  runNumber_ = input.runNumber();
127  runType_ = input.runType();
128  forceVersions_ = input.forceVersions();
130  cabVersion_ = input.cabVersion();
131  fedVersion_ = input.fedVersion();
132  fecVersion_ = input.fecVersion();
133  dcuVersion_ = input.dcuVersion();
134  psuVersion_ = input.psuVersion();
135  //#ifdef USING_DATABASE_MASKING
136  maskVersion_ = input.maskVersion();
137  //#endif
141  apvTimingV_ = input.apvTimingVersion();
142  optoScanV_ = input.optoScanVersion();
143  vpspScanV_ = input.vpspScanVersion();
144  apvCalibV_ = input.apvCalibVersion();
145  pedestalsV_ = input.pedestalsVersion();
148  fineDelayV_ = input.fineDelayVersion();
151  inputFecXml_ = input.inputFecXml();
152  inputFedXml_ = input.inputFedXml();
153  return *this;
154 }
155 
156 // -----------------------------------------------------------------------------
157 //
159  return (partitionName_ == input.partitionName() && runNumber_ == input.runNumber() && runType_ == input.runType() &&
161  cabVersion_ == input.cabVersion() && fedVersion_ == input.fedVersion() && fecVersion_ == input.fecVersion() &&
162  dcuVersion_ == input.dcuVersion() && psuVersion_ == input.psuVersion() &&
163  //#ifdef USING_DATABASE_MASKING
164  maskVersion_ == input.maskVersion() &&
165  //#endif
168  optoScanV_ == input.optoScanVersion() && vpspScanV_ == input.vpspScanVersion() &&
169  apvCalibV_ == input.apvCalibVersion() && pedestalsV_ == input.pedestalsVersion() &&
171  fineDelayV_ == input.fineDelayVersion() && inputModuleXml_ == input.inputModuleXml() &&
172  inputDcuInfoXml_ == input.inputDcuInfoXml() && inputFecXml_ == input.inputFecXml() &&
173  inputFedXml_ == input.inputFedXml());
174 }
175 
176 // -----------------------------------------------------------------------------
177 //
178 bool SiStripPartition::operator!=(const SiStripPartition& input) const { return !(*this == input); }
179 
180 // -----------------------------------------------------------------------------
181 //
183  inputFecXml_.clear();
184  inputFedXml_.clear();
185 }
186 
187 // -----------------------------------------------------------------------------
188 //
190  partitionName_ = "";
191  runNumber_ = 0;
193  forceVersions_ = false;
194  forceCurrentState_ = false;
195 
196  cabVersion_ = std::make_pair(0, 0);
197  fedVersion_ = std::make_pair(0, 0);
198  fecVersion_ = std::make_pair(0, 0);
199  dcuVersion_ = std::make_pair(0, 0);
200  psuVersion_ = std::make_pair(0, 0);
201  //#ifdef USING_DATABASE_MASKING
202  maskVersion_ = std::make_pair(0, 0);
203  //#endif
204 
205  globalAnalysisV_ = 0;
206  runTableVersion_ = std::make_pair(0, 0);
207  fastCablingV_ = std::make_pair(0, 0);
208  apvTimingV_ = std::make_pair(0, 0);
209  optoScanV_ = std::make_pair(0, 0);
210  vpspScanV_ = std::make_pair(0, 0);
211  apvCalibV_ = std::make_pair(0, 0);
212  pedestalsV_ = std::make_pair(0, 0);
213  pedsFullNoiseV_ = std::make_pair(0, 0);
214  apvLatencyV_ = std::make_pair(0, 0);
215  fineDelayV_ = std::make_pair(0, 0);
216 
217  inputModuleXml_ = "";
218  inputDcuInfoXml_ = "";
219  inputFecXml_.clear();
220  inputFecXml_.push_back("");
221  inputFedXml_.clear();
222  inputFedXml_.push_back("");
223 }
224 
225 // -----------------------------------------------------------------------------
226 //
228  partitionName_ = pset.getUntrackedParameter<std::string>("PartitionName", "");
229  runNumber_ = pset.getUntrackedParameter<unsigned int>("RunNumber", 0);
230  forceVersions_ = pset.getUntrackedParameter<bool>("ForceVersions", false);
231  forceCurrentState_ = pset.getUntrackedParameter<bool>("ForceCurrentState", false);
232 
233  std::vector<uint32_t> tmp1(2, 0);
234  cabVersion_ = versions(pset.getUntrackedParameter<std::vector<uint32_t> >("CablingVersion", tmp1));
235  fedVersion_ = versions(pset.getUntrackedParameter<std::vector<uint32_t> >("FedVersion", tmp1));
236  fecVersion_ = versions(pset.getUntrackedParameter<std::vector<uint32_t> >("FecVersion", tmp1));
237  dcuVersion_ = versions(pset.getUntrackedParameter<std::vector<uint32_t> >("DcuDetIdsVersion", tmp1));
238  psuVersion_ = versions(pset.getUntrackedParameter<std::vector<uint32_t> >("DcuPsuMapVersion", tmp1));
239  //#ifdef USING_DATABASE_MASKING
240  maskVersion_ = versions(pset.getUntrackedParameter<std::vector<uint32_t> >("MaskVersion", tmp1));
241  //#endif
242 
243  std::vector<uint32_t> tmp2(2, 0);
244  globalAnalysisV_ = pset.getUntrackedParameter<uint32_t>("GlobalAnalysisVersion", 0);
245  fastCablingV_ = versions(pset.getUntrackedParameter<std::vector<uint32_t> >("FastCablingVersion", tmp2));
246  apvTimingV_ = versions(pset.getUntrackedParameter<std::vector<uint32_t> >("ApvTimingVersion", tmp2));
247  optoScanV_ = versions(pset.getUntrackedParameter<std::vector<uint32_t> >("OptoScanVersion", tmp2));
248  vpspScanV_ = versions(pset.getUntrackedParameter<std::vector<uint32_t> >("VpspScanVersion", tmp2));
249  apvCalibV_ = versions(pset.getUntrackedParameter<std::vector<uint32_t> >("ApvCalibVersion", tmp2));
250  pedestalsV_ = versions(pset.getUntrackedParameter<std::vector<uint32_t> >("PedestalsVersion", tmp2));
251  pedsFullNoiseV_ = versions(pset.getUntrackedParameter<std::vector<uint32_t> >("PedsFullNoiseVersion", tmp2));
252  apvLatencyV_ = versions(pset.getUntrackedParameter<std::vector<uint32_t> >("ApvLatencyVersion", tmp2));
253  fineDelayV_ = versions(pset.getUntrackedParameter<std::vector<uint32_t> >("FineDelayVersion", tmp2));
254 
255  std::vector<std::string> tmp3(1, "");
256  inputModuleXml_ = pset.getUntrackedParameter<std::string>("InputModuleXml", "");
257  inputDcuInfoXml_ = pset.getUntrackedParameter<std::string>("InputDcuInfoXml", "");
258  inputFecXml_ = pset.getUntrackedParameter<std::vector<std::string> >("InputFecXml", tmp3);
259  inputFedXml_ = pset.getUntrackedParameter<std::vector<std::string> >("InputFedXml", tmp3);
260 }
261 
262 // -----------------------------------------------------------------------------
263 //
265  // Check
266  if (!db) {
267  edm::LogError(mlConfigDb_) << "[SiStripPartition::" << __func__ << "]"
268  << " NULL pointer to SiStripConfigDb object!"
269  << " Aborting update...";
270  return;
271  }
272 
273  // Check
274  DeviceFactory* const df = db->deviceFactory(__func__);
275  if (!df) {
276  edm::LogError(mlConfigDb_) << "[SiStripPartition::" << __func__ << "]"
277  << " NULL pointer to DeviceFactory object!"
278  << " Aborting update...";
279  return;
280  }
281 
282  // Check partition name
284  return;
285  }
286 
287  // Debug
288  std::stringstream ss;
289  ss << "[SiStripPartition::" << __func__ << "]"
290  << " Updating description versions for partition \"" << partitionName_ << "\"...";
291  LogTrace(mlConfigDb_) << ss.str();
292 
293  try {
294  // Reset container indicating state versions for commissioning runs
295  runTableVersion_ = Versions(0, 0);
296 
297  // Update versions if using versions from "current state"
299  // Find state for given partition
300  tkStateVector states;
301  states = df->getCurrentStates();
302  tkStateVector::const_iterator istate = states.begin();
303  tkStateVector::const_iterator jstate = states.end();
304  while (istate != jstate) {
305  if (*istate && partitionName_ == (*istate)->getPartitionName()) {
306  break;
307  }
308  istate++;
309  }
310 
311  // Set versions if state was found
312  if (istate != states.end()) {
313  if (!cabVersion_.first && !cabVersion_.second) {
314  cabVersion_.first = (*istate)->getConnectionVersionMajorId();
315  cabVersion_.second = (*istate)->getConnectionVersionMinorId();
316  }
317  if (!fecVersion_.first && !fecVersion_.second) {
318  fecVersion_.first = (*istate)->getFecVersionMajorId();
319  fecVersion_.second = (*istate)->getFecVersionMinorId();
320  }
321  if (!fedVersion_.first && !fedVersion_.second) {
322  fedVersion_.first = (*istate)->getFedVersionMajorId();
323  fedVersion_.second = (*istate)->getFedVersionMinorId();
324  }
325  if (!dcuVersion_.first && !dcuVersion_.second) {
326  dcuVersion_.first = (*istate)->getDcuInfoVersionMajorId();
327  dcuVersion_.second = (*istate)->getDcuInfoVersionMinorId();
328  }
329  if (!psuVersion_.first && !psuVersion_.second) {
330  psuVersion_.first = (*istate)->getDcuPsuMapVersionMajorId();
331  psuVersion_.second = (*istate)->getDcuPsuMapVersionMinorId();
332  }
333  //#ifdef USING_DATABASE_MASKING
334  if (!forceVersions_ && !maskVersion_.first && !maskVersion_.second) {
335  maskVersion_.first = (*istate)->getMaskVersionMajorId();
336  maskVersion_.second = (*istate)->getMaskVersionMinorId();
337  }
338  //#endif
339 
340  // Retrieve global and local versions
341  if (forceCurrentState_ || globalAnalysisV_) { // use global version (or current state)
342 
343  // Set global version
344  if (forceCurrentState_) {
345  globalAnalysisV_ = (*istate)->getAnalysisVersionMapPointerId();
346  }
347 
348  // Retrieve local versions
349  HashMapAnalysisVersions local_versions = df->getLocalAnalysisVersions(globalAnalysisV_);
350 
351  // Iterate through map< AnalysisType, pair<Major,Minor> >
352  HashMapAnalysisVersions::const_iterator ivers = local_versions.begin();
353  HashMapAnalysisVersions::const_iterator jvers = local_versions.end();
354  for (; ivers != jvers; ++ivers) {
355  if (ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_FASTFEDCABLING) {
356  fastCablingV_.first = ivers->second.first;
357  fastCablingV_.second = ivers->second.second;
358  } else if (ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_TIMING) {
359  apvTimingV_.first = ivers->second.first;
360  apvTimingV_.second = ivers->second.second;
361  } else if (ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_OPTOSCAN) {
362  optoScanV_.first = ivers->second.first;
363  optoScanV_.second = ivers->second.second;
364  } else if (ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_VPSPSCAN) {
365  vpspScanV_.first = ivers->second.first;
366  vpspScanV_.second = ivers->second.second;
367  } else if (ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_CALIBRATION) {
368  apvCalibV_.first = ivers->second.first;
369  apvCalibV_.second = ivers->second.second;
370  } else if (ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_PEDESTALS) {
371  pedestalsV_.first = ivers->second.first;
372  pedestalsV_.second = ivers->second.second;
373  } else if (ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_PEDSFULLNOISE) {
374  pedsFullNoiseV_.first = ivers->second.first;
375  pedsFullNoiseV_.second = ivers->second.second;
376  } else if (ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_APVLATENCY) {
377  apvLatencyV_.first = ivers->second.first;
378  apvLatencyV_.second = ivers->second.second;
379  } else if (ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_FINEDELAY) {
380  fineDelayV_.first = ivers->second.first;
381  fineDelayV_.second = ivers->second.second;
382  } else if (ivers->first == CommissioningAnalysisDescription::T_UNKNOWN) {
383  std::stringstream ss;
384  edm::LogError(mlConfigDb_) << "[SiStripPartition::" << __func__ << "]"
385  << " Found UNKNOWN AnalysisType!";
386  edm::LogWarning(mlConfigDb_) << ss.str();
387  } else {
388  std::stringstream ss;
389  edm::LogError(mlConfigDb_) << "[SiStripPartition::" << __func__ << "]"
390  << " Unable to match content to any AnalysisType!";
391  edm::LogWarning(mlConfigDb_) << ss.str();
392  }
393  }
394 
395  } else if (!globalAnalysisV_) { // use local versions
396 
397  // Retrieve local versions and set if necessary
398  globalAnalysisV_ = (*istate)->getAnalysisVersionMapPointerId();
399  HashMapAnalysisVersions local_versions = df->getLocalAnalysisVersions(globalAnalysisV_);
400 
401  // Iterate through map< AnalysisType, pair<Major,Minor> >
402  HashMapAnalysisVersions::const_iterator ivers = local_versions.begin();
403  HashMapAnalysisVersions::const_iterator jvers = local_versions.end();
404  for (; ivers != jvers; ++ivers) {
405  if (ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_FASTFEDCABLING) {
406  if (!fastCablingV_.first && !fastCablingV_.second) {
407  fastCablingV_.first = ivers->second.first;
408  fastCablingV_.second = ivers->second.second;
409  }
410  } else if (ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_TIMING) {
411  if (!apvTimingV_.first && !apvTimingV_.second) {
412  apvTimingV_.first = ivers->second.first;
413  apvTimingV_.second = ivers->second.second;
414  }
415  } else if (ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_OPTOSCAN) {
416  if (!optoScanV_.first && !optoScanV_.second) {
417  optoScanV_.first = ivers->second.first;
418  optoScanV_.second = ivers->second.second;
419  }
420  } else if (ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_VPSPSCAN) {
421  if (!vpspScanV_.first && !vpspScanV_.second) {
422  vpspScanV_.first = ivers->second.first;
423  vpspScanV_.second = ivers->second.second;
424  }
425  } else if (ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_CALIBRATION) {
426  if (!apvCalibV_.first && !apvCalibV_.second) {
427  apvCalibV_.first = ivers->second.first;
428  apvCalibV_.second = ivers->second.second;
429  }
430  } else if (ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_PEDESTALS) {
431  if (!pedestalsV_.first && !pedestalsV_.second) {
432  pedestalsV_.first = ivers->second.first;
433  pedestalsV_.second = ivers->second.second;
434  }
435  } else if (ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_PEDSFULLNOISE) {
436  if (!pedsFullNoiseV_.first && !pedsFullNoiseV_.second) {
437  pedsFullNoiseV_.first = ivers->second.first;
438  pedsFullNoiseV_.second = ivers->second.second;
439  }
440  } else if (ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_APVLATENCY) {
441  if (!apvLatencyV_.first && !apvLatencyV_.second) {
442  apvLatencyV_.first = ivers->second.first;
443  apvLatencyV_.second = ivers->second.second;
444  }
445  } else if (ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_FINEDELAY) {
446  if (!fineDelayV_.first && !fineDelayV_.second) {
447  fineDelayV_.first = ivers->second.first;
448  fineDelayV_.second = ivers->second.second;
449  }
450  } else if (ivers->first == CommissioningAnalysisDescription::T_UNKNOWN) {
451  std::stringstream ss;
452  edm::LogError(mlConfigDb_) << "[SiStripPartition::" << __func__ << "]"
453  << " Found UNKNOWN AnalysisType!";
454  edm::LogWarning(mlConfigDb_) << ss.str();
455  } else {
456  std::stringstream ss;
457  edm::LogError(mlConfigDb_) << "[SiStripPartition::" << __func__ << "]"
458  << " Unable to match content to any AnalysisType!";
459  edm::LogWarning(mlConfigDb_) << ss.str();
460  }
461  }
462  }
463 
464  } else {
465  std::stringstream ss;
466  edm::LogError(mlConfigDb_) << "[SiStripPartition::" << __func__ << "]"
467  << " Unable to find \"current state\" for partition \"" << partitionName_ << "\"";
468  }
469 
470  } else { // ---------- USE RUN NUMBER ----------
471 
472  // Retrieve TkRun object for given run (0 means "latest run")
473  TkRun* run = nullptr;
474  if (!runNumber_) {
475  run = df->getLastRun(partitionName_);
476  } else {
477  run = df->getRun(partitionName_, runNumber_);
478  }
479 
480  // Retrieve versioning for given TkRun object
481  if (run) {
482  if (run->getRunNumber()) {
483  if (!runNumber_) {
484  runNumber_ = run->getRunNumber();
485  }
486 
487  if (runNumber_ == run->getRunNumber()) {
488  cabVersion_.first = run->getConnectionVersionMajorId();
489  cabVersion_.second = run->getConnectionVersionMinorId();
490 
491  fecVersion_.first = run->getFecVersionMajorId();
492  fecVersion_.second = run->getFecVersionMinorId();
493 
494  fedVersion_.first = run->getFedVersionMajorId();
495  fedVersion_.second = run->getFedVersionMinorId();
496 
497  dcuVersion_.first = run->getDcuInfoVersionMajorId();
498  dcuVersion_.second = run->getDcuInfoVersionMinorId();
499 
500  psuVersion_.first = run->getDcuPsuMapVersionMajorId();
501  psuVersion_.second = run->getDcuPsuMapVersionMinorId();
502 
503  //#ifdef USING_DATABASE_MASKING
504  maskVersion_.first = run->getMaskVersionMajorId();
505  maskVersion_.second = run->getMaskVersionMinorId();
506  //#endif
507 
508  // Check run type
509  uint16_t type = run->getModeId(run->getMode());
510  if (type == 1) {
512  } else if (type == 2) {
514  } else if (type == 3) {
516  } else if (type == 4) {
518  } else if (type == 5) {
520  } else if (type == 6) {
522  } else if (type == 7) {
524  } else if (type == 8) {
526  } else if (type == 10) {
528  } else if (type == 12) {
530  } else if (type == 13) {
532  } else if (type == 14) {
534  } else if (type == 15) {
536  } else if (type == 16) {
538  } else if (type == 17) {
540  } else if (type == 18) {
542  } else if (type == 19) {
544  } else if (type == 20) {
546  } else if (type == 21) {
548  } else if (type == 22) {
550  } else if (type == 23) {
552  } else if (type == 24) {
554  } else if (type == 33) {
556  } else if (type == 0) {
558  edm::LogWarning(mlConfigDb_) << "[SiStripPartition::" << __func__ << "]"
559  << " NULL run type returned!"
560  << " for partition \"" << partitionName_ << "\"";
561  } else {
563  edm::LogWarning(mlConfigDb_) << "[SiStripPartition::" << __func__ << "]"
564  << " UNKNOWN run type (" << type << ") returned!"
565  << " for partition \"" << partitionName_ << "\"";
566  }
567 
568  // Retrieve global and local versions from state associated with given run
569  globalAnalysisV_ = run->getAnalysisVersionMapPointerId();
570  HashMapAnalysisVersions local_versions = df->getLocalAnalysisVersions(globalAnalysisV_);
571  HashMapAnalysisVersions::const_iterator ivers = local_versions.begin();
572  HashMapAnalysisVersions::const_iterator jvers = local_versions.end();
573  for (; ivers != jvers; ++ivers) {
574  if (ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_FASTFEDCABLING) {
575  fastCablingV_.first = ivers->second.first;
576  fastCablingV_.second = ivers->second.second;
577  } else if (ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_TIMING) {
578  apvTimingV_.first = ivers->second.first;
579  apvTimingV_.second = ivers->second.second;
580  } else if (ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_OPTOSCAN) {
581  optoScanV_.first = ivers->second.first;
582  optoScanV_.second = ivers->second.second;
583  } else if (ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_VPSPSCAN) {
584  vpspScanV_.first = ivers->second.first;
585  vpspScanV_.second = ivers->second.second;
586  } else if (ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_CALIBRATION) {
587  apvCalibV_.first = ivers->second.first;
588  apvCalibV_.second = ivers->second.second;
589  } else if (ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_PEDESTALS) {
590  pedestalsV_.first = ivers->second.first;
591  pedestalsV_.second = ivers->second.second;
592  } else if (ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_PEDSFULLNOISE) {
593  pedsFullNoiseV_.first = ivers->second.first;
594  pedsFullNoiseV_.second = ivers->second.second;
595  } else if (ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_APVLATENCY) {
596  apvLatencyV_.first = ivers->second.first;
597  apvLatencyV_.second = ivers->second.second;
598  } else if (ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_FINEDELAY) {
599  fineDelayV_.first = ivers->second.first;
600  fineDelayV_.second = ivers->second.second;
601  } else if (ivers->first == CommissioningAnalysisDescription::T_UNKNOWN) {
602  std::stringstream ss;
603  edm::LogError(mlConfigDb_) << "[SiStripPartition::" << __func__ << "]"
604  << " Found UNKNOWN AnalysisType!";
605  edm::LogWarning(mlConfigDb_) << ss.str();
606  } else {
607  std::stringstream ss;
608  edm::LogError(mlConfigDb_) << "[SiStripPartition::" << __func__ << "]"
609  << " Unable to match content to any AnalysisType!";
610  edm::LogWarning(mlConfigDb_) << ss.str();
611  }
612  }
613 
614  // If commissioning run, override version of analysis type with version PRODUCED by run (from history)
617  // Determine analysis type from run type
618  CommissioningAnalysisDescription::commissioningType type = CommissioningAnalysisDescription::T_UNKNOWN;
620  type = CommissioningAnalysisDescription::T_ANALYSIS_FASTFEDCABLING;
621  } else if (runType_ == sistrip::APV_TIMING) {
622  type = CommissioningAnalysisDescription::T_ANALYSIS_TIMING;
623  } else if (runType_ == sistrip::OPTO_SCAN) {
624  type = CommissioningAnalysisDescription::T_ANALYSIS_OPTOSCAN;
625  } else if (runType_ == sistrip::VPSP_SCAN) {
626  type = CommissioningAnalysisDescription::T_ANALYSIS_VPSPSCAN;
627  } else if (runType_ == sistrip::CALIBRATION) {
628  type = CommissioningAnalysisDescription::T_ANALYSIS_CALIBRATION;
629  } else if (runType_ == sistrip::CALIBRATION_SCAN) {
630  type = CommissioningAnalysisDescription::T_ANALYSIS_CALIBRATION;
631  } else if (runType_ == sistrip::CALIBRATION_DECO) {
632  type = CommissioningAnalysisDescription::T_ANALYSIS_CALIBRATION;
634  type = CommissioningAnalysisDescription::T_ANALYSIS_CALIBRATION;
635  } else if (runType_ == sistrip::PEDESTALS) {
636  type = CommissioningAnalysisDescription::T_ANALYSIS_PEDESTALS;
637  } else if (runType_ == sistrip::PEDS_FULL_NOISE) {
638  type = CommissioningAnalysisDescription::T_ANALYSIS_PEDSFULLNOISE;
639  } else if (runType_ == sistrip::APV_LATENCY) {
640  type = CommissioningAnalysisDescription::T_ANALYSIS_APVLATENCY;
641  } else if (runType_ == sistrip::FINE_DELAY_TTC) {
642  type = CommissioningAnalysisDescription::T_ANALYSIS_FINEDELAY;
643  }
644 
645  // Retrieve local versions for COMMISSIONING runs from history
646  HashMapRunVersion local_versions = df->getAnalysisHistory(partitionName_, type);
647 
648  // Iterate through map< RunNumber, vector< pair<Major,Minor> > > to find appropriate run
649  HashMapRunVersion::const_iterator ivers = local_versions.end();
650  if (runNumber_ == 0) {
651  ivers = --(local_versions.end());
652  } else {
653  ivers = local_versions.find(runNumber_);
654  }
655 
656  // Set appropriate versions
657  if (ivers != local_versions.end()) {
658  if (type == CommissioningAnalysisDescription::T_ANALYSIS_FASTFEDCABLING) {
660  fastCablingV_.first = ivers->second.back().first;
661  fastCablingV_.second = ivers->second.back().second;
662 
663  //@@
664 
665  } else if (type == CommissioningAnalysisDescription::T_ANALYSIS_TIMING) {
667  apvTimingV_.first = ivers->second.back().first;
668  apvTimingV_.second = ivers->second.back().second;
669  } else if (type == CommissioningAnalysisDescription::T_ANALYSIS_OPTOSCAN) {
671  optoScanV_.first = ivers->second.back().first;
672  optoScanV_.second = ivers->second.back().second;
673  } else if (type == CommissioningAnalysisDescription::T_ANALYSIS_VPSPSCAN) {
675  vpspScanV_.first = ivers->second.back().first;
676  vpspScanV_.second = ivers->second.back().second;
677  } else if (type == CommissioningAnalysisDescription::T_ANALYSIS_CALIBRATION) {
679  apvCalibV_.first = ivers->second.back().first;
680  apvCalibV_.second = ivers->second.back().second;
681  } else if (type == CommissioningAnalysisDescription::T_ANALYSIS_PEDESTALS) {
683  pedestalsV_.first = ivers->second.back().first;
684  pedestalsV_.second = ivers->second.back().second;
685  } else if (type == CommissioningAnalysisDescription::T_ANALYSIS_PEDSFULLNOISE) {
687  pedsFullNoiseV_.first = ivers->second.back().first;
688  pedsFullNoiseV_.second = ivers->second.back().second;
689  } else if (type == CommissioningAnalysisDescription::T_ANALYSIS_APVLATENCY) {
691  apvLatencyV_.first = ivers->second.back().first;
692  apvLatencyV_.second = ivers->second.back().second;
693  } else if (type == CommissioningAnalysisDescription::T_ANALYSIS_FINEDELAY) {
695  fineDelayV_.first = ivers->second.back().first;
696  fineDelayV_.second = ivers->second.back().second;
697  } else if (type == CommissioningAnalysisDescription::T_UNKNOWN) {
698  std::stringstream ss;
699  edm::LogError(mlConfigDb_) << "[SiStripPartition::" << __func__ << "]"
700  << " Found UNKNOWN AnalysisType!";
701  edm::LogWarning(mlConfigDb_) << ss.str();
702  } else {
703  std::stringstream ss;
704  edm::LogError(mlConfigDb_) << "[SiStripPartition::" << __func__ << "]"
705  << " Unable to match content to any AnalysisType!";
706  edm::LogWarning(mlConfigDb_) << ss.str();
707  }
708  } else {
709  std::stringstream ss;
711  << "[SiStripPartition::" << __func__ << "]"
712  << " Unable to find run number " << runNumber_ << " in \"history\" hash map ";
713  edm::LogWarning(mlConfigDb_) << ss.str();
714  }
715  }
716 
717  } else {
718  edm::LogError(mlConfigDb_) << "[SiStripPartition::" << __func__ << "]"
719  << " Mismatch of run number requested (" << runNumber_ << ") and received ("
720  << run->getRunNumber() << ")"
721  << " to/from database for partition \"" << partitionName_ << "\"";
722  }
723 
724  } else {
725  edm::LogError(mlConfigDb_) << "[SiStripPartition::" << __func__ << "]"
726  << " NULL run number returned!"
727  << " for partition \"" << partitionName_ << "\"";
728  }
729 
730  } else {
731  edm::LogError(mlConfigDb_) << "[SiStripPartition::" << __func__ << "]"
732  << " NULL pointer to TkRun object!"
733  << " Unable to retrieve versions for run number " << runNumber_
734  << ". Run number may not be consistent with partition \"" << partitionName_
735  << "\"!"; //@@ only using first here!!!
736  }
737  }
738 
739  } catch (...) {
740  db->handleException(__func__, "");
741  }
742 }
743 
744 // -----------------------------------------------------------------------------
745 //
746 void SiStripPartition::print(std::stringstream& ss, bool using_db) const {
747  ss << " Partition : \"" << partitionName_ << "\"" << std::endl;
748 
749  if (using_db) {
750  ss << " Run number : ";
751  if (forceCurrentState_) {
752  ss << "Forced \"current state\"! (equivalent to versions below)";
753  } else if (forceVersions_) {
754  ss << "Forced versions specified below!";
755  } else /* use run number */ {
756  ss << runNumber_;
757  }
758 
759  ss << std::endl;
760  if (!forceVersions_) {
761  ss << " Run type : " << SiStripEnumsAndStrings::runType(runType_) << std::endl;
762  }
763 
764  ss << " Cabling major/minor vers : " << cabVersion_.first << "." << cabVersion_.second << std::endl
765  << " FEC major/minor vers : " << fecVersion_.first << "." << fecVersion_.second << std::endl
766  << " FED major/minor vers : " << fedVersion_.first << "." << fedVersion_.second << std::endl
767  << " DCU-DetId map maj/min vers : " << dcuVersion_.first << "." << dcuVersion_.second
768  << std::endl
769  //#ifdef USING_DATABASE_MASKING
770  << " DCU-PSU map maj/min vers : " << psuVersion_.first << "." << psuVersion_.second << std::endl
771  << " Mask maj/min vers : " << maskVersion_.first << "." << maskVersion_.second << std::endl;
772  //#else
773  // << " DCU-PSU map maj/min vers : " << psuVersion_.first << "." << psuVersion_.second << std::endl;
774  //#endif
775 
776  ss << " Global analysis version : " << globalAnalysisV_ << std::endl;
777 
780  ss << " FED cabling maj/min vers : " << fastCablingV_.first << "." << fastCablingV_.second << std::endl;
781  ss << " APV timing maj/min vers : " << apvTimingV_.first << "." << apvTimingV_.second << std::endl;
782  ss << " Opto scan maj/min vers : " << optoScanV_.first << "." << optoScanV_.second << std::endl;
783  ss << " VPSP scan maj/min vers : " << vpspScanV_.first << "." << vpspScanV_.second << std::endl;
784  ss << " APV calib maj/min vers : " << apvCalibV_.first << "." << apvCalibV_.second << std::endl;
785  ss << " Pedestals maj/min vers : " << pedestalsV_.first << "." << pedestalsV_.second << std::endl;
786  ss << " PedsFullNoise maj/min vers : " << pedsFullNoiseV_.first << "." << pedsFullNoiseV_.second
787  << std::endl;
788  ss << " APV latency maj/min vers : " << apvLatencyV_.first << "." << apvLatencyV_.second << std::endl;
789  ss << " Fine delay maj/min vers : " << fineDelayV_.first << "." << fineDelayV_.second << std::endl;
790 
791  } else {
793  ss << " FED cabling maj/min vers : " << fastCablingV_.first << "." << fastCablingV_.second << std::endl;
794  } else {
795  ss << " FED cabling maj/min vers : " << runTableVersion_.first << "." << runTableVersion_.second
796  << " <= This \"state\" version overriden by \"history\" version " << fastCablingV_.first << "."
797  << fastCablingV_.second << " for this FED cabling run!" << std::endl;
798  }
799 
800  if (runType_ != sistrip::APV_TIMING) {
801  ss << " APV timing maj/min vers : " << apvTimingV_.first << "." << apvTimingV_.second << std::endl;
802  } else {
803  ss << " APV timing maj/min vers : " << runTableVersion_.first << "." << runTableVersion_.second
804  << " <= This \"state\" version overriden by \"history\" version " << apvTimingV_.first << "."
805  << apvTimingV_.second << " for this APV timing run!" << std::endl;
806  }
807 
808  if (runType_ != sistrip::OPTO_SCAN) {
809  ss << " Opto scan maj/min vers : " << optoScanV_.first << "." << optoScanV_.second << std::endl;
810  } else {
811  ss << " Opto scan maj/min vers : " << runTableVersion_.first << "." << runTableVersion_.second
812  << " <= This \"state\" version overriden by \"history\" version " << optoScanV_.first << "."
813  << optoScanV_.second << " for this opto scan run!" << std::endl;
814  }
815 
816  if (runType_ != sistrip::VPSP_SCAN) {
817  ss << " VPSP scan maj/min vers : " << vpspScanV_.first << "." << vpspScanV_.second << std::endl;
818  } else {
819  ss << " VPSP scan maj/min vers : " << runTableVersion_.first << "." << runTableVersion_.second
820  << " <= This \"state\" version overriden by \"history\" version " << vpspScanV_.first << "."
821  << vpspScanV_.second << " for this VPSP scan run!" << std::endl;
822  }
823 
826  ss << " APV calib maj/min vers : " << apvCalibV_.first << "." << apvCalibV_.second << std::endl;
827  } else {
828  ss << " APV calib maj/min vers : " << runTableVersion_.first << "." << runTableVersion_.second
829  << " <= This \"state\" version overriden by \"history\" version " << apvCalibV_.first << "."
830  << apvCalibV_.second << " for this APV calib run!" << std::endl;
831  }
832 
833  if (runType_ != sistrip::PEDESTALS) {
834  ss << " Pedestals maj/min vers : " << pedestalsV_.first << "." << pedestalsV_.second << std::endl;
835  } else {
836  ss << " Pedestals maj/min vers : " << runTableVersion_.first << "." << runTableVersion_.second
837  << " <= This \"state\" version overriden by \"history\" version " << pedestalsV_.first << "."
838  << pedestalsV_.second << " for this pedestals run!" << std::endl;
839  }
840 
842  ss << " PedsFullNoise maj/min vers : " << pedsFullNoiseV_.first << "." << pedsFullNoiseV_.second
843  << std::endl;
844  } else {
845  ss << " Pedestals maj/min vers : " << runTableVersion_.first << "." << runTableVersion_.second
846  << " <= This \"state\" version overriden by \"history\" version " << pedsFullNoiseV_.first << "."
847  << pedsFullNoiseV_.second << " for this pedestals run!" << std::endl;
848  }
849 
851  ss << " APV latency maj/min vers : " << apvLatencyV_.first << "." << apvLatencyV_.second << std::endl;
852  } else {
853  ss << " APV latency maj/min vers : " << runTableVersion_.first << "." << runTableVersion_.second
854  << " <= This \"state\" version overriden by \"history\" version " << apvLatencyV_.first << "."
855  << apvLatencyV_.second << " for this APV latency run!" << std::endl;
856  }
857 
859  ss << " Fine delay maj/min vers : " << fineDelayV_.first << "." << fineDelayV_.second << std::endl;
860  } else {
861  ss << " Fine delay maj/min vers : " << runTableVersion_.first << "." << runTableVersion_.second
862  << " <= This \"state\" version overriden by \"history\" version " << fineDelayV_.first << "."
863  << fineDelayV_.second << " for this fine delay run!" << std::endl;
864  }
865  }
866 
867  } else {
868  ss << " Input \"module.xml\" file : " << inputModuleXml_ << std::endl
869  << " Input \"dcuinfo.xml\" file : " << inputDcuInfoXml_ << std::endl
870  << " Input \"fec.xml\" file(s) : ";
871  std::vector<std::string>::const_iterator ifec = inputFecXml_.begin();
872  for (; ifec != inputFecXml_.end(); ifec++) {
873  ss << *ifec << ", ";
874  }
875  ss << std::endl;
876  ss << " Input \"fed.xml\" file(s) : ";
877  std::vector<std::string>::const_iterator ifed = inputFedXml_.begin();
878  for (; ifed != inputFedXml_.end(); ifed++) {
879  ss << *ifed << ", ";
880  }
881  ss << std::endl;
882  }
883 }
884 
885 // -----------------------------------------------------------------------------
886 //
887 std::ostream& operator<<(std::ostream& os, const SiStripPartition& params) {
888  std::stringstream ss;
889  params.print(ss);
890  os << ss.str();
891  return os;
892 }
893 
894 // -----------------------------------------------------------------------------
895 //
896 SiStripPartition::Versions SiStripPartition::versions(const std::vector<uint32_t>& _input) {
897  std::vector<uint32_t> input = _input;
898  if (input.size() != 2) {
899  edm::LogWarning(mlConfigDb_) << "[SiStripPartition::" << __func__ << "]"
900  << " Unexpected size (" << input.size()
901  << ") for vector containing version numbers (major,minor)!"
902  << " Resizing to 2 elements (default values will be 0,0)...";
903  input.resize(2, 0);
904  }
905  return std::make_pair(input[0], input[1]);
906 }
static const char runNumber_[]
sistrip::RunType runType_
T getUntrackedParameter(std::string const &, T const &) const
static const std::string defaultPartitionName_
Versions maskVersion() const
Versions pedestalsVersion() const
Versions vpspScanVersion() const
DeviceFactory *const deviceFactory(std::string method_name="") const
Versions fineDelayVersion() const
Versions optoScanVersion() const
std::string partitionName() const
void handleException(const std::string &method_name, const std::string &extra_info="") const
bool operator!=(const SiStripPartition &) const
tuple db
Definition: EcalCondDB.py:153
std::string partitionName_
tuple runType
Definition: runPedHist.py:37
uint32_t runNumber() const
uint32_t globalAnalysisVersion() const
void print(std::stringstream &, bool using_db=false) const
Log< level::Error, false > LogError
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:167
void update(const SiStripConfigDb *const)
#define LogTrace(id)
static std::string const input
Definition: EdmProvDump.cc:47
static const char mlConfigDb_[]
static std::string runType(const sistrip::RunType &)
Versions apvTimingVersion() const
Versions apvLatencyVersion() const
void pset(const edm::ParameterSet &)
Versions versions(const std::vector< uint32_t > &)
An interface class to the DeviceFactory.
Container class for database partition parameters.
std::vector< std::string > inputFedXml_
Versions runTableVersion() const
std::vector< std::string > inputFecXml() const
bool forceCurrentState() const
Versions pedsFullNoiseVersion() const
std::string inputDcuInfoXml_
std::pair< uint32_t, uint32_t > Versions
std::string inputModuleXml_
Versions apvCalibVersion() const
std::vector< std::string > inputFecXml_
bool operator==(const SiStripPartition &) const
std::vector< std::string > inputFedXml() const
Versions dcuVersion() const
bool forceVersions() const
Log< level::Warning, false > LogWarning
SiStripPartition & operator=(const SiStripPartition &)
Versions psuVersion() const
sistrip::RunType runType() const
Versions fecVersion() const
Versions cabVersion() const
Versions fedVersion() const
std::string inputDcuInfoXml() const
std::string inputModuleXml() const
Versions fastCablingVersion() const