File indexing completed on 2024-04-06 12:23:18
0001
0002 #include "OnlineDB/SiStripConfigDb/interface/SiStripPartition.h"
0003 #include "DataFormats/SiStripCommon/interface/SiStripEnumsAndStrings.h"
0004 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0005 #include "OnlineDB/SiStripConfigDb/interface/SiStripConfigDb.h"
0006 #include <iostream>
0007 #include <cmath>
0008
0009 using namespace sistrip;
0010
0011
0012
0013 const std::string SiStripPartition::defaultPartitionName_ = "DefaultPartition";
0014
0015
0016
0017 SiStripPartition::SiStripPartition()
0018 : partitionName_(defaultPartitionName_),
0019 runNumber_(0),
0020 runType_(sistrip::UNDEFINED_RUN_TYPE),
0021 forceVersions_(false),
0022 forceCurrentState_(false),
0023 cabVersion_(0, 0),
0024 fedVersion_(0, 0),
0025 fecVersion_(0, 0),
0026 dcuVersion_(0, 0),
0027 psuVersion_(0, 0),
0028
0029 maskVersion_(0, 0),
0030
0031 globalAnalysisV_(0),
0032 runTableVersion_(0, 0),
0033 fastCablingV_(0, 0),
0034 apvTimingV_(0, 0),
0035 optoScanV_(0, 0),
0036 vpspScanV_(0, 0),
0037 apvCalibV_(0, 0),
0038 pedestalsV_(0, 0),
0039 pedsFullNoiseV_(0, 0),
0040 apvLatencyV_(0, 0),
0041 fineDelayV_(0, 0),
0042 inputModuleXml_(""),
0043 inputDcuInfoXml_(""),
0044 inputFecXml_(),
0045 inputFedXml_() {
0046 ;
0047 }
0048
0049
0050
0051 SiStripPartition::SiStripPartition(std::string partition)
0052 : partitionName_(partition),
0053 runNumber_(0),
0054 runType_(sistrip::UNDEFINED_RUN_TYPE),
0055 forceVersions_(false),
0056 forceCurrentState_(false),
0057 cabVersion_(0, 0),
0058 fedVersion_(0, 0),
0059 fecVersion_(0, 0),
0060 dcuVersion_(0, 0),
0061 psuVersion_(0, 0),
0062
0063 maskVersion_(0, 0),
0064
0065 globalAnalysisV_(0),
0066 runTableVersion_(0, 0),
0067 fastCablingV_(0, 0),
0068 apvTimingV_(0, 0),
0069 optoScanV_(0, 0),
0070 vpspScanV_(0, 0),
0071 apvCalibV_(0, 0),
0072 pedestalsV_(0, 0),
0073 pedsFullNoiseV_(0, 0),
0074 apvLatencyV_(0, 0),
0075 fineDelayV_(0, 0),
0076 inputModuleXml_(""),
0077 inputDcuInfoXml_(""),
0078 inputFecXml_(),
0079 inputFedXml_() {
0080 if (partitionName_.empty()) {
0081 partitionName_ = defaultPartitionName_;
0082 }
0083 }
0084
0085
0086
0087 SiStripPartition::SiStripPartition(const SiStripPartition& input)
0088 : partitionName_(input.partitionName()),
0089 runNumber_(input.runNumber()),
0090 runType_(input.runType()),
0091 forceVersions_(input.forceVersions()),
0092 forceCurrentState_(input.forceCurrentState()),
0093 cabVersion_(input.cabVersion()),
0094 fedVersion_(input.fedVersion()),
0095 fecVersion_(input.fecVersion()),
0096 dcuVersion_(input.dcuVersion()),
0097 psuVersion_(input.psuVersion()),
0098
0099 maskVersion_(input.maskVersion()),
0100
0101 globalAnalysisV_(input.globalAnalysisVersion()),
0102 runTableVersion_(input.runTableVersion()),
0103 fastCablingV_(input.fastCablingVersion()),
0104 apvTimingV_(input.apvTimingVersion()),
0105 optoScanV_(input.optoScanVersion()),
0106 vpspScanV_(input.vpspScanVersion()),
0107 apvCalibV_(input.apvCalibVersion()),
0108 pedestalsV_(input.pedestalsVersion()),
0109 pedsFullNoiseV_(input.pedsFullNoiseVersion()),
0110 apvLatencyV_(input.apvLatencyVersion()),
0111 fineDelayV_(input.fineDelayVersion()),
0112 inputModuleXml_(input.inputModuleXml()),
0113 inputDcuInfoXml_(input.inputDcuInfoXml()),
0114 inputFecXml_(input.inputFecXml()),
0115 inputFedXml_(input.inputFedXml()) {
0116 ;
0117 }
0118
0119
0120
0121 SiStripPartition& SiStripPartition::operator=(const SiStripPartition& input) {
0122 if (this == &input) {
0123 return *this;
0124 }
0125 partitionName_ = input.partitionName();
0126 runNumber_ = input.runNumber();
0127 runType_ = input.runType();
0128 forceVersions_ = input.forceVersions();
0129 forceCurrentState_ = input.forceCurrentState();
0130 cabVersion_ = input.cabVersion();
0131 fedVersion_ = input.fedVersion();
0132 fecVersion_ = input.fecVersion();
0133 dcuVersion_ = input.dcuVersion();
0134 psuVersion_ = input.psuVersion();
0135
0136 maskVersion_ = input.maskVersion();
0137
0138 globalAnalysisV_ = input.globalAnalysisVersion();
0139 runTableVersion_ = input.runTableVersion();
0140 fastCablingV_ = input.fastCablingVersion();
0141 apvTimingV_ = input.apvTimingVersion();
0142 optoScanV_ = input.optoScanVersion();
0143 vpspScanV_ = input.vpspScanVersion();
0144 apvCalibV_ = input.apvCalibVersion();
0145 pedestalsV_ = input.pedestalsVersion();
0146 pedsFullNoiseV_ = input.pedsFullNoiseVersion();
0147 apvLatencyV_ = input.apvLatencyVersion();
0148 fineDelayV_ = input.fineDelayVersion();
0149 inputModuleXml_ = input.inputModuleXml();
0150 inputDcuInfoXml_ = input.inputDcuInfoXml();
0151 inputFecXml_ = input.inputFecXml();
0152 inputFedXml_ = input.inputFedXml();
0153 return *this;
0154 }
0155
0156
0157
0158 bool SiStripPartition::operator==(const SiStripPartition& input) const {
0159 return (partitionName_ == input.partitionName() && runNumber_ == input.runNumber() && runType_ == input.runType() &&
0160 forceVersions_ == input.forceVersions() && forceCurrentState_ == input.forceCurrentState() &&
0161 cabVersion_ == input.cabVersion() && fedVersion_ == input.fedVersion() && fecVersion_ == input.fecVersion() &&
0162 dcuVersion_ == input.dcuVersion() && psuVersion_ == input.psuVersion() &&
0163
0164 maskVersion_ == input.maskVersion() &&
0165
0166 globalAnalysisV_ == input.globalAnalysisVersion() && runTableVersion_ == input.runTableVersion() &&
0167 fastCablingV_ == input.fastCablingVersion() && apvTimingV_ == input.apvTimingVersion() &&
0168 optoScanV_ == input.optoScanVersion() && vpspScanV_ == input.vpspScanVersion() &&
0169 apvCalibV_ == input.apvCalibVersion() && pedestalsV_ == input.pedestalsVersion() &&
0170 pedsFullNoiseV_ == input.pedsFullNoiseVersion() && apvLatencyV_ == input.apvLatencyVersion() &&
0171 fineDelayV_ == input.fineDelayVersion() && inputModuleXml_ == input.inputModuleXml() &&
0172 inputDcuInfoXml_ == input.inputDcuInfoXml() && inputFecXml_ == input.inputFecXml() &&
0173 inputFedXml_ == input.inputFedXml());
0174 }
0175
0176
0177
0178 bool SiStripPartition::operator!=(const SiStripPartition& input) const { return !(*this == input); }
0179
0180
0181
0182 SiStripPartition::~SiStripPartition() {
0183 inputFecXml_.clear();
0184 inputFedXml_.clear();
0185 }
0186
0187
0188
0189 void SiStripPartition::reset() {
0190 partitionName_ = "";
0191 runNumber_ = 0;
0192 runType_ = sistrip::UNDEFINED_RUN_TYPE;
0193 forceVersions_ = false;
0194 forceCurrentState_ = false;
0195
0196 cabVersion_ = std::make_pair(0, 0);
0197 fedVersion_ = std::make_pair(0, 0);
0198 fecVersion_ = std::make_pair(0, 0);
0199 dcuVersion_ = std::make_pair(0, 0);
0200 psuVersion_ = std::make_pair(0, 0);
0201
0202 maskVersion_ = std::make_pair(0, 0);
0203
0204
0205 globalAnalysisV_ = 0;
0206 runTableVersion_ = std::make_pair(0, 0);
0207 fastCablingV_ = std::make_pair(0, 0);
0208 apvTimingV_ = std::make_pair(0, 0);
0209 optoScanV_ = std::make_pair(0, 0);
0210 vpspScanV_ = std::make_pair(0, 0);
0211 apvCalibV_ = std::make_pair(0, 0);
0212 pedestalsV_ = std::make_pair(0, 0);
0213 pedsFullNoiseV_ = std::make_pair(0, 0);
0214 apvLatencyV_ = std::make_pair(0, 0);
0215 fineDelayV_ = std::make_pair(0, 0);
0216
0217 inputModuleXml_ = "";
0218 inputDcuInfoXml_ = "";
0219 inputFecXml_.clear();
0220 inputFecXml_.push_back("");
0221 inputFedXml_.clear();
0222 inputFedXml_.push_back("");
0223 }
0224
0225
0226
0227 void SiStripPartition::pset(const edm::ParameterSet& pset) {
0228 partitionName_ = pset.getUntrackedParameter<std::string>("PartitionName", "");
0229 runNumber_ = pset.getUntrackedParameter<unsigned int>("RunNumber", 0);
0230 forceVersions_ = pset.getUntrackedParameter<bool>("ForceVersions", false);
0231 forceCurrentState_ = pset.getUntrackedParameter<bool>("ForceCurrentState", false);
0232
0233 std::vector<uint32_t> tmp1(2, 0);
0234 cabVersion_ = versions(pset.getUntrackedParameter<std::vector<uint32_t> >("CablingVersion", tmp1));
0235 fedVersion_ = versions(pset.getUntrackedParameter<std::vector<uint32_t> >("FedVersion", tmp1));
0236 fecVersion_ = versions(pset.getUntrackedParameter<std::vector<uint32_t> >("FecVersion", tmp1));
0237 dcuVersion_ = versions(pset.getUntrackedParameter<std::vector<uint32_t> >("DcuDetIdsVersion", tmp1));
0238 psuVersion_ = versions(pset.getUntrackedParameter<std::vector<uint32_t> >("DcuPsuMapVersion", tmp1));
0239
0240 maskVersion_ = versions(pset.getUntrackedParameter<std::vector<uint32_t> >("MaskVersion", tmp1));
0241
0242
0243 std::vector<uint32_t> tmp2(2, 0);
0244 globalAnalysisV_ = pset.getUntrackedParameter<uint32_t>("GlobalAnalysisVersion", 0);
0245 fastCablingV_ = versions(pset.getUntrackedParameter<std::vector<uint32_t> >("FastCablingVersion", tmp2));
0246 apvTimingV_ = versions(pset.getUntrackedParameter<std::vector<uint32_t> >("ApvTimingVersion", tmp2));
0247 optoScanV_ = versions(pset.getUntrackedParameter<std::vector<uint32_t> >("OptoScanVersion", tmp2));
0248 vpspScanV_ = versions(pset.getUntrackedParameter<std::vector<uint32_t> >("VpspScanVersion", tmp2));
0249 apvCalibV_ = versions(pset.getUntrackedParameter<std::vector<uint32_t> >("ApvCalibVersion", tmp2));
0250 pedestalsV_ = versions(pset.getUntrackedParameter<std::vector<uint32_t> >("PedestalsVersion", tmp2));
0251 pedsFullNoiseV_ = versions(pset.getUntrackedParameter<std::vector<uint32_t> >("PedsFullNoiseVersion", tmp2));
0252 apvLatencyV_ = versions(pset.getUntrackedParameter<std::vector<uint32_t> >("ApvLatencyVersion", tmp2));
0253 fineDelayV_ = versions(pset.getUntrackedParameter<std::vector<uint32_t> >("FineDelayVersion", tmp2));
0254
0255 std::vector<std::string> tmp3(1, "");
0256 inputModuleXml_ = pset.getUntrackedParameter<std::string>("InputModuleXml", "");
0257 inputDcuInfoXml_ = pset.getUntrackedParameter<std::string>("InputDcuInfoXml", "");
0258 inputFecXml_ = pset.getUntrackedParameter<std::vector<std::string> >("InputFecXml", tmp3);
0259 inputFedXml_ = pset.getUntrackedParameter<std::vector<std::string> >("InputFedXml", tmp3);
0260 }
0261
0262
0263
0264 void SiStripPartition::update(const SiStripConfigDb* const db) {
0265
0266 if (!db) {
0267 edm::LogError(mlConfigDb_) << "[SiStripPartition::" << __func__ << "]"
0268 << " NULL pointer to SiStripConfigDb object!"
0269 << " Aborting update...";
0270 return;
0271 }
0272
0273
0274 DeviceFactory* const df = db->deviceFactory(__func__);
0275 if (!df) {
0276 edm::LogError(mlConfigDb_) << "[SiStripPartition::" << __func__ << "]"
0277 << " NULL pointer to DeviceFactory object!"
0278 << " Aborting update...";
0279 return;
0280 }
0281
0282
0283 if (partitionName_ == defaultPartitionName_) {
0284 return;
0285 }
0286
0287
0288 std::stringstream ss;
0289 ss << "[SiStripPartition::" << __func__ << "]"
0290 << " Updating description versions for partition \"" << partitionName_ << "\"...";
0291 LogTrace(mlConfigDb_) << ss.str();
0292
0293 try {
0294
0295 runTableVersion_ = Versions(0, 0);
0296
0297
0298 if (forceCurrentState_ || forceVersions_) {
0299
0300 tkStateVector states;
0301 states = df->getCurrentStates();
0302 tkStateVector::const_iterator istate = states.begin();
0303 tkStateVector::const_iterator jstate = states.end();
0304 while (istate != jstate) {
0305 if (*istate && partitionName_ == (*istate)->getPartitionName()) {
0306 break;
0307 }
0308 istate++;
0309 }
0310
0311
0312 if (istate != states.end()) {
0313 if (!cabVersion_.first && !cabVersion_.second) {
0314 cabVersion_.first = (*istate)->getConnectionVersionMajorId();
0315 cabVersion_.second = (*istate)->getConnectionVersionMinorId();
0316 }
0317 if (!fecVersion_.first && !fecVersion_.second) {
0318 fecVersion_.first = (*istate)->getFecVersionMajorId();
0319 fecVersion_.second = (*istate)->getFecVersionMinorId();
0320 }
0321 if (!fedVersion_.first && !fedVersion_.second) {
0322 fedVersion_.first = (*istate)->getFedVersionMajorId();
0323 fedVersion_.second = (*istate)->getFedVersionMinorId();
0324 }
0325 if (!dcuVersion_.first && !dcuVersion_.second) {
0326 dcuVersion_.first = (*istate)->getDcuInfoVersionMajorId();
0327 dcuVersion_.second = (*istate)->getDcuInfoVersionMinorId();
0328 }
0329 if (!psuVersion_.first && !psuVersion_.second) {
0330 psuVersion_.first = (*istate)->getDcuPsuMapVersionMajorId();
0331 psuVersion_.second = (*istate)->getDcuPsuMapVersionMinorId();
0332 }
0333
0334 if (!forceVersions_ && !maskVersion_.first && !maskVersion_.second) {
0335 maskVersion_.first = (*istate)->getMaskVersionMajorId();
0336 maskVersion_.second = (*istate)->getMaskVersionMinorId();
0337 }
0338
0339
0340
0341 if (forceCurrentState_ || globalAnalysisV_) {
0342
0343
0344 if (forceCurrentState_) {
0345 globalAnalysisV_ = (*istate)->getAnalysisVersionMapPointerId();
0346 }
0347
0348
0349 HashMapAnalysisVersions local_versions = df->getLocalAnalysisVersions(globalAnalysisV_);
0350
0351
0352 HashMapAnalysisVersions::const_iterator ivers = local_versions.begin();
0353 HashMapAnalysisVersions::const_iterator jvers = local_versions.end();
0354 for (; ivers != jvers; ++ivers) {
0355 if (ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_FASTFEDCABLING) {
0356 fastCablingV_.first = ivers->second.first;
0357 fastCablingV_.second = ivers->second.second;
0358 } else if (ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_TIMING) {
0359 apvTimingV_.first = ivers->second.first;
0360 apvTimingV_.second = ivers->second.second;
0361 } else if (ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_OPTOSCAN) {
0362 optoScanV_.first = ivers->second.first;
0363 optoScanV_.second = ivers->second.second;
0364 } else if (ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_VPSPSCAN) {
0365 vpspScanV_.first = ivers->second.first;
0366 vpspScanV_.second = ivers->second.second;
0367 } else if (ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_CALIBRATION) {
0368 apvCalibV_.first = ivers->second.first;
0369 apvCalibV_.second = ivers->second.second;
0370 } else if (ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_PEDESTALS) {
0371 pedestalsV_.first = ivers->second.first;
0372 pedestalsV_.second = ivers->second.second;
0373 } else if (ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_PEDSFULLNOISE) {
0374 pedsFullNoiseV_.first = ivers->second.first;
0375 pedsFullNoiseV_.second = ivers->second.second;
0376 } else if (ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_APVLATENCY) {
0377 apvLatencyV_.first = ivers->second.first;
0378 apvLatencyV_.second = ivers->second.second;
0379 } else if (ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_FINEDELAY) {
0380 fineDelayV_.first = ivers->second.first;
0381 fineDelayV_.second = ivers->second.second;
0382 } else if (ivers->first == CommissioningAnalysisDescription::T_UNKNOWN) {
0383 std::stringstream ss;
0384 edm::LogError(mlConfigDb_) << "[SiStripPartition::" << __func__ << "]"
0385 << " Found UNKNOWN AnalysisType!";
0386 edm::LogWarning(mlConfigDb_) << ss.str();
0387 } else {
0388 std::stringstream ss;
0389 edm::LogError(mlConfigDb_) << "[SiStripPartition::" << __func__ << "]"
0390 << " Unable to match content to any AnalysisType!";
0391 edm::LogWarning(mlConfigDb_) << ss.str();
0392 }
0393 }
0394
0395 } else if (!globalAnalysisV_) {
0396
0397
0398 globalAnalysisV_ = (*istate)->getAnalysisVersionMapPointerId();
0399 HashMapAnalysisVersions local_versions = df->getLocalAnalysisVersions(globalAnalysisV_);
0400
0401
0402 HashMapAnalysisVersions::const_iterator ivers = local_versions.begin();
0403 HashMapAnalysisVersions::const_iterator jvers = local_versions.end();
0404 for (; ivers != jvers; ++ivers) {
0405 if (ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_FASTFEDCABLING) {
0406 if (!fastCablingV_.first && !fastCablingV_.second) {
0407 fastCablingV_.first = ivers->second.first;
0408 fastCablingV_.second = ivers->second.second;
0409 }
0410 } else if (ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_TIMING) {
0411 if (!apvTimingV_.first && !apvTimingV_.second) {
0412 apvTimingV_.first = ivers->second.first;
0413 apvTimingV_.second = ivers->second.second;
0414 }
0415 } else if (ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_OPTOSCAN) {
0416 if (!optoScanV_.first && !optoScanV_.second) {
0417 optoScanV_.first = ivers->second.first;
0418 optoScanV_.second = ivers->second.second;
0419 }
0420 } else if (ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_VPSPSCAN) {
0421 if (!vpspScanV_.first && !vpspScanV_.second) {
0422 vpspScanV_.first = ivers->second.first;
0423 vpspScanV_.second = ivers->second.second;
0424 }
0425 } else if (ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_CALIBRATION) {
0426 if (!apvCalibV_.first && !apvCalibV_.second) {
0427 apvCalibV_.first = ivers->second.first;
0428 apvCalibV_.second = ivers->second.second;
0429 }
0430 } else if (ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_PEDESTALS) {
0431 if (!pedestalsV_.first && !pedestalsV_.second) {
0432 pedestalsV_.first = ivers->second.first;
0433 pedestalsV_.second = ivers->second.second;
0434 }
0435 } else if (ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_PEDSFULLNOISE) {
0436 if (!pedsFullNoiseV_.first && !pedsFullNoiseV_.second) {
0437 pedsFullNoiseV_.first = ivers->second.first;
0438 pedsFullNoiseV_.second = ivers->second.second;
0439 }
0440 } else if (ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_APVLATENCY) {
0441 if (!apvLatencyV_.first && !apvLatencyV_.second) {
0442 apvLatencyV_.first = ivers->second.first;
0443 apvLatencyV_.second = ivers->second.second;
0444 }
0445 } else if (ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_FINEDELAY) {
0446 if (!fineDelayV_.first && !fineDelayV_.second) {
0447 fineDelayV_.first = ivers->second.first;
0448 fineDelayV_.second = ivers->second.second;
0449 }
0450 } else if (ivers->first == CommissioningAnalysisDescription::T_UNKNOWN) {
0451 std::stringstream ss;
0452 edm::LogError(mlConfigDb_) << "[SiStripPartition::" << __func__ << "]"
0453 << " Found UNKNOWN AnalysisType!";
0454 edm::LogWarning(mlConfigDb_) << ss.str();
0455 } else {
0456 std::stringstream ss;
0457 edm::LogError(mlConfigDb_) << "[SiStripPartition::" << __func__ << "]"
0458 << " Unable to match content to any AnalysisType!";
0459 edm::LogWarning(mlConfigDb_) << ss.str();
0460 }
0461 }
0462 }
0463
0464 } else {
0465 std::stringstream ss;
0466 edm::LogError(mlConfigDb_) << "[SiStripPartition::" << __func__ << "]"
0467 << " Unable to find \"current state\" for partition \"" << partitionName_ << "\"";
0468 }
0469
0470 } else {
0471
0472
0473 TkRun* run = nullptr;
0474 if (!runNumber_) {
0475 run = df->getLastRun(partitionName_);
0476 } else {
0477 run = df->getRun(partitionName_, runNumber_);
0478 }
0479
0480
0481 if (run) {
0482 if (run->getRunNumber()) {
0483 if (!runNumber_) {
0484 runNumber_ = run->getRunNumber();
0485 }
0486
0487 if (runNumber_ == run->getRunNumber()) {
0488 cabVersion_.first = run->getConnectionVersionMajorId();
0489 cabVersion_.second = run->getConnectionVersionMinorId();
0490
0491 fecVersion_.first = run->getFecVersionMajorId();
0492 fecVersion_.second = run->getFecVersionMinorId();
0493
0494 fedVersion_.first = run->getFedVersionMajorId();
0495 fedVersion_.second = run->getFedVersionMinorId();
0496
0497 dcuVersion_.first = run->getDcuInfoVersionMajorId();
0498 dcuVersion_.second = run->getDcuInfoVersionMinorId();
0499
0500 psuVersion_.first = run->getDcuPsuMapVersionMajorId();
0501 psuVersion_.second = run->getDcuPsuMapVersionMinorId();
0502
0503
0504 maskVersion_.first = run->getMaskVersionMajorId();
0505 maskVersion_.second = run->getMaskVersionMinorId();
0506
0507
0508
0509 uint16_t type = run->getModeId(run->getMode());
0510 if (type == 1) {
0511 runType_ = sistrip::PHYSICS;
0512 } else if (type == 2) {
0513 runType_ = sistrip::PEDESTALS;
0514 } else if (type == 3) {
0515 runType_ = sistrip::CALIBRATION;
0516 } else if (type == 4) {
0517 runType_ = sistrip::OPTO_SCAN;
0518 } else if (type == 5) {
0519 runType_ = sistrip::APV_TIMING;
0520 } else if (type == 6) {
0521 runType_ = sistrip::APV_LATENCY;
0522 } else if (type == 7) {
0523 runType_ = sistrip::FINE_DELAY_PLL;
0524 } else if (type == 8) {
0525 runType_ = sistrip::FINE_DELAY_TTC;
0526 } else if (type == 10) {
0527 runType_ = sistrip::MULTI_MODE;
0528 } else if (type == 12) {
0529 runType_ = sistrip::FED_TIMING;
0530 } else if (type == 13) {
0531 runType_ = sistrip::FED_CABLING;
0532 } else if (type == 14) {
0533 runType_ = sistrip::VPSP_SCAN;
0534 } else if (type == 15) {
0535 runType_ = sistrip::DAQ_SCOPE_MODE;
0536 } else if (type == 16) {
0537 runType_ = sistrip::QUITE_FAST_CABLING;
0538 } else if (type == 17) {
0539 runType_ = sistrip::FINE_DELAY;
0540 } else if (type == 18) {
0541 runType_ = sistrip::PHYSICS_ZS;
0542 } else if (type == 19) {
0543 runType_ = sistrip::CALIBRATION_SCAN;
0544 } else if (type == 20) {
0545 runType_ = sistrip::CALIBRATION_SCAN_DECO;
0546 } else if (type == 21) {
0547 runType_ = sistrip::FAST_CABLING;
0548 } else if (type == 22) {
0549 runType_ = sistrip::PEDS_ONLY;
0550 } else if (type == 23) {
0551 runType_ = sistrip::NOISE;
0552 } else if (type == 24) {
0553 runType_ = sistrip::PEDS_FULL_NOISE;
0554 } else if (type == 33) {
0555 runType_ = sistrip::CALIBRATION_DECO;
0556 } else if (type == 0) {
0557 runType_ = sistrip::UNDEFINED_RUN_TYPE;
0558 edm::LogWarning(mlConfigDb_) << "[SiStripPartition::" << __func__ << "]"
0559 << " NULL run type returned!"
0560 << " for partition \"" << partitionName_ << "\"";
0561 } else {
0562 runType_ = sistrip::UNKNOWN_RUN_TYPE;
0563 edm::LogWarning(mlConfigDb_) << "[SiStripPartition::" << __func__ << "]"
0564 << " UNKNOWN run type (" << type << ") returned!"
0565 << " for partition \"" << partitionName_ << "\"";
0566 }
0567
0568
0569 globalAnalysisV_ = run->getAnalysisVersionMapPointerId();
0570 HashMapAnalysisVersions local_versions = df->getLocalAnalysisVersions(globalAnalysisV_);
0571 HashMapAnalysisVersions::const_iterator ivers = local_versions.begin();
0572 HashMapAnalysisVersions::const_iterator jvers = local_versions.end();
0573 for (; ivers != jvers; ++ivers) {
0574 if (ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_FASTFEDCABLING) {
0575 fastCablingV_.first = ivers->second.first;
0576 fastCablingV_.second = ivers->second.second;
0577 } else if (ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_TIMING) {
0578 apvTimingV_.first = ivers->second.first;
0579 apvTimingV_.second = ivers->second.second;
0580 } else if (ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_OPTOSCAN) {
0581 optoScanV_.first = ivers->second.first;
0582 optoScanV_.second = ivers->second.second;
0583 } else if (ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_VPSPSCAN) {
0584 vpspScanV_.first = ivers->second.first;
0585 vpspScanV_.second = ivers->second.second;
0586 } else if (ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_CALIBRATION) {
0587 apvCalibV_.first = ivers->second.first;
0588 apvCalibV_.second = ivers->second.second;
0589 } else if (ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_PEDESTALS) {
0590 pedestalsV_.first = ivers->second.first;
0591 pedestalsV_.second = ivers->second.second;
0592 } else if (ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_PEDSFULLNOISE) {
0593 pedsFullNoiseV_.first = ivers->second.first;
0594 pedsFullNoiseV_.second = ivers->second.second;
0595 } else if (ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_APVLATENCY) {
0596 apvLatencyV_.first = ivers->second.first;
0597 apvLatencyV_.second = ivers->second.second;
0598 } else if (ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_FINEDELAY) {
0599 fineDelayV_.first = ivers->second.first;
0600 fineDelayV_.second = ivers->second.second;
0601 } else if (ivers->first == CommissioningAnalysisDescription::T_UNKNOWN) {
0602 std::stringstream ss;
0603 edm::LogError(mlConfigDb_) << "[SiStripPartition::" << __func__ << "]"
0604 << " Found UNKNOWN AnalysisType!";
0605 edm::LogWarning(mlConfigDb_) << ss.str();
0606 } else {
0607 std::stringstream ss;
0608 edm::LogError(mlConfigDb_) << "[SiStripPartition::" << __func__ << "]"
0609 << " Unable to match content to any AnalysisType!";
0610 edm::LogWarning(mlConfigDb_) << ss.str();
0611 }
0612 }
0613
0614
0615 if (runType_ != sistrip::PHYSICS && runType_ != sistrip::UNDEFINED_RUN_TYPE &&
0616 runType_ != sistrip::UNKNOWN_RUN_TYPE) {
0617
0618 CommissioningAnalysisDescription::commissioningType type = CommissioningAnalysisDescription::T_UNKNOWN;
0619 if (runType_ == sistrip::FAST_CABLING) {
0620 type = CommissioningAnalysisDescription::T_ANALYSIS_FASTFEDCABLING;
0621 } else if (runType_ == sistrip::APV_TIMING) {
0622 type = CommissioningAnalysisDescription::T_ANALYSIS_TIMING;
0623 } else if (runType_ == sistrip::OPTO_SCAN) {
0624 type = CommissioningAnalysisDescription::T_ANALYSIS_OPTOSCAN;
0625 } else if (runType_ == sistrip::VPSP_SCAN) {
0626 type = CommissioningAnalysisDescription::T_ANALYSIS_VPSPSCAN;
0627 } else if (runType_ == sistrip::CALIBRATION) {
0628 type = CommissioningAnalysisDescription::T_ANALYSIS_CALIBRATION;
0629 } else if (runType_ == sistrip::CALIBRATION_SCAN) {
0630 type = CommissioningAnalysisDescription::T_ANALYSIS_CALIBRATION;
0631 } else if (runType_ == sistrip::CALIBRATION_DECO) {
0632 type = CommissioningAnalysisDescription::T_ANALYSIS_CALIBRATION;
0633 } else if (runType_ == sistrip::CALIBRATION_SCAN_DECO) {
0634 type = CommissioningAnalysisDescription::T_ANALYSIS_CALIBRATION;
0635 } else if (runType_ == sistrip::PEDESTALS) {
0636 type = CommissioningAnalysisDescription::T_ANALYSIS_PEDESTALS;
0637 } else if (runType_ == sistrip::PEDS_FULL_NOISE) {
0638 type = CommissioningAnalysisDescription::T_ANALYSIS_PEDSFULLNOISE;
0639 } else if (runType_ == sistrip::APV_LATENCY) {
0640 type = CommissioningAnalysisDescription::T_ANALYSIS_APVLATENCY;
0641 } else if (runType_ == sistrip::FINE_DELAY_TTC) {
0642 type = CommissioningAnalysisDescription::T_ANALYSIS_FINEDELAY;
0643 }
0644
0645
0646 HashMapRunVersion local_versions = df->getAnalysisHistory(partitionName_, type);
0647
0648
0649 HashMapRunVersion::const_iterator ivers = local_versions.end();
0650 if (runNumber_ == 0) {
0651 ivers = --(local_versions.end());
0652 } else {
0653 ivers = local_versions.find(runNumber_);
0654 }
0655
0656
0657 if (ivers != local_versions.end()) {
0658 if (type == CommissioningAnalysisDescription::T_ANALYSIS_FASTFEDCABLING) {
0659 runTableVersion_ = fastCablingV_;
0660 fastCablingV_.first = ivers->second.back().first;
0661 fastCablingV_.second = ivers->second.back().second;
0662
0663
0664
0665 } else if (type == CommissioningAnalysisDescription::T_ANALYSIS_TIMING) {
0666 runTableVersion_ = apvTimingV_;
0667 apvTimingV_.first = ivers->second.back().first;
0668 apvTimingV_.second = ivers->second.back().second;
0669 } else if (type == CommissioningAnalysisDescription::T_ANALYSIS_OPTOSCAN) {
0670 runTableVersion_ = optoScanV_;
0671 optoScanV_.first = ivers->second.back().first;
0672 optoScanV_.second = ivers->second.back().second;
0673 } else if (type == CommissioningAnalysisDescription::T_ANALYSIS_VPSPSCAN) {
0674 runTableVersion_ = vpspScanV_;
0675 vpspScanV_.first = ivers->second.back().first;
0676 vpspScanV_.second = ivers->second.back().second;
0677 } else if (type == CommissioningAnalysisDescription::T_ANALYSIS_CALIBRATION) {
0678 runTableVersion_ = apvCalibV_;
0679 apvCalibV_.first = ivers->second.back().first;
0680 apvCalibV_.second = ivers->second.back().second;
0681 } else if (type == CommissioningAnalysisDescription::T_ANALYSIS_PEDESTALS) {
0682 runTableVersion_ = pedestalsV_;
0683 pedestalsV_.first = ivers->second.back().first;
0684 pedestalsV_.second = ivers->second.back().second;
0685 } else if (type == CommissioningAnalysisDescription::T_ANALYSIS_PEDSFULLNOISE) {
0686 runTableVersion_ = pedsFullNoiseV_;
0687 pedsFullNoiseV_.first = ivers->second.back().first;
0688 pedsFullNoiseV_.second = ivers->second.back().second;
0689 } else if (type == CommissioningAnalysisDescription::T_ANALYSIS_APVLATENCY) {
0690 runTableVersion_ = apvLatencyV_;
0691 apvLatencyV_.first = ivers->second.back().first;
0692 apvLatencyV_.second = ivers->second.back().second;
0693 } else if (type == CommissioningAnalysisDescription::T_ANALYSIS_FINEDELAY) {
0694 runTableVersion_ = fineDelayV_;
0695 fineDelayV_.first = ivers->second.back().first;
0696 fineDelayV_.second = ivers->second.back().second;
0697 } else if (type == CommissioningAnalysisDescription::T_UNKNOWN) {
0698 std::stringstream ss;
0699 edm::LogError(mlConfigDb_) << "[SiStripPartition::" << __func__ << "]"
0700 << " Found UNKNOWN AnalysisType!";
0701 edm::LogWarning(mlConfigDb_) << ss.str();
0702 } else {
0703 std::stringstream ss;
0704 edm::LogError(mlConfigDb_) << "[SiStripPartition::" << __func__ << "]"
0705 << " Unable to match content to any AnalysisType!";
0706 edm::LogWarning(mlConfigDb_) << ss.str();
0707 }
0708 } else {
0709 std::stringstream ss;
0710 edm::LogError(mlConfigDb_)
0711 << "[SiStripPartition::" << __func__ << "]"
0712 << " Unable to find run number " << runNumber_ << " in \"history\" hash map ";
0713 edm::LogWarning(mlConfigDb_) << ss.str();
0714 }
0715 }
0716
0717 } else {
0718 edm::LogError(mlConfigDb_) << "[SiStripPartition::" << __func__ << "]"
0719 << " Mismatch of run number requested (" << runNumber_ << ") and received ("
0720 << run->getRunNumber() << ")"
0721 << " to/from database for partition \"" << partitionName_ << "\"";
0722 }
0723
0724 } else {
0725 edm::LogError(mlConfigDb_) << "[SiStripPartition::" << __func__ << "]"
0726 << " NULL run number returned!"
0727 << " for partition \"" << partitionName_ << "\"";
0728 }
0729
0730 } else {
0731 edm::LogError(mlConfigDb_) << "[SiStripPartition::" << __func__ << "]"
0732 << " NULL pointer to TkRun object!"
0733 << " Unable to retrieve versions for run number " << runNumber_
0734 << ". Run number may not be consistent with partition \"" << partitionName_
0735 << "\"!";
0736 }
0737 }
0738
0739 } catch (...) {
0740 db->handleException(__func__, "");
0741 }
0742 }
0743
0744
0745
0746 void SiStripPartition::print(std::stringstream& ss, bool using_db) const {
0747 ss << " Partition : \"" << partitionName_ << "\"" << std::endl;
0748
0749 if (using_db) {
0750 ss << " Run number : ";
0751 if (forceCurrentState_) {
0752 ss << "Forced \"current state\"! (equivalent to versions below)";
0753 } else if (forceVersions_) {
0754 ss << "Forced versions specified below!";
0755 } else {
0756 ss << runNumber_;
0757 }
0758
0759 ss << std::endl;
0760 if (!forceVersions_) {
0761 ss << " Run type : " << SiStripEnumsAndStrings::runType(runType_) << std::endl;
0762 }
0763
0764 ss << " Cabling major/minor vers : " << cabVersion_.first << "." << cabVersion_.second << std::endl
0765 << " FEC major/minor vers : " << fecVersion_.first << "." << fecVersion_.second << std::endl
0766 << " FED major/minor vers : " << fedVersion_.first << "." << fedVersion_.second << std::endl
0767 << " DCU-DetId map maj/min vers : " << dcuVersion_.first << "." << dcuVersion_.second
0768 << std::endl
0769
0770 << " DCU-PSU map maj/min vers : " << psuVersion_.first << "." << psuVersion_.second << std::endl
0771 << " Mask maj/min vers : " << maskVersion_.first << "." << maskVersion_.second << std::endl;
0772
0773
0774
0775
0776 ss << " Global analysis version : " << globalAnalysisV_ << std::endl;
0777
0778 if (runType_ == sistrip::PHYSICS || runType_ == sistrip::UNDEFINED_RUN_TYPE ||
0779 runType_ == sistrip::UNKNOWN_RUN_TYPE) {
0780 ss << " FED cabling maj/min vers : " << fastCablingV_.first << "." << fastCablingV_.second << std::endl;
0781 ss << " APV timing maj/min vers : " << apvTimingV_.first << "." << apvTimingV_.second << std::endl;
0782 ss << " Opto scan maj/min vers : " << optoScanV_.first << "." << optoScanV_.second << std::endl;
0783 ss << " VPSP scan maj/min vers : " << vpspScanV_.first << "." << vpspScanV_.second << std::endl;
0784 ss << " APV calib maj/min vers : " << apvCalibV_.first << "." << apvCalibV_.second << std::endl;
0785 ss << " Pedestals maj/min vers : " << pedestalsV_.first << "." << pedestalsV_.second << std::endl;
0786 ss << " PedsFullNoise maj/min vers : " << pedsFullNoiseV_.first << "." << pedsFullNoiseV_.second
0787 << std::endl;
0788 ss << " APV latency maj/min vers : " << apvLatencyV_.first << "." << apvLatencyV_.second << std::endl;
0789 ss << " Fine delay maj/min vers : " << fineDelayV_.first << "." << fineDelayV_.second << std::endl;
0790
0791 } else {
0792 if (runType_ != sistrip::FAST_CABLING) {
0793 ss << " FED cabling maj/min vers : " << fastCablingV_.first << "." << fastCablingV_.second << std::endl;
0794 } else {
0795 ss << " FED cabling maj/min vers : " << runTableVersion_.first << "." << runTableVersion_.second
0796 << " <= This \"state\" version overriden by \"history\" version " << fastCablingV_.first << "."
0797 << fastCablingV_.second << " for this FED cabling run!" << std::endl;
0798 }
0799
0800 if (runType_ != sistrip::APV_TIMING) {
0801 ss << " APV timing maj/min vers : " << apvTimingV_.first << "." << apvTimingV_.second << std::endl;
0802 } else {
0803 ss << " APV timing maj/min vers : " << runTableVersion_.first << "." << runTableVersion_.second
0804 << " <= This \"state\" version overriden by \"history\" version " << apvTimingV_.first << "."
0805 << apvTimingV_.second << " for this APV timing run!" << std::endl;
0806 }
0807
0808 if (runType_ != sistrip::OPTO_SCAN) {
0809 ss << " Opto scan maj/min vers : " << optoScanV_.first << "." << optoScanV_.second << std::endl;
0810 } else {
0811 ss << " Opto scan maj/min vers : " << runTableVersion_.first << "." << runTableVersion_.second
0812 << " <= This \"state\" version overriden by \"history\" version " << optoScanV_.first << "."
0813 << optoScanV_.second << " for this opto scan run!" << std::endl;
0814 }
0815
0816 if (runType_ != sistrip::VPSP_SCAN) {
0817 ss << " VPSP scan maj/min vers : " << vpspScanV_.first << "." << vpspScanV_.second << std::endl;
0818 } else {
0819 ss << " VPSP scan maj/min vers : " << runTableVersion_.first << "." << runTableVersion_.second
0820 << " <= This \"state\" version overriden by \"history\" version " << vpspScanV_.first << "."
0821 << vpspScanV_.second << " for this VPSP scan run!" << std::endl;
0822 }
0823
0824 if (runType_ != sistrip::CALIBRATION and runType_ != sistrip::CALIBRATION_SCAN and
0825 runType_ != sistrip::CALIBRATION_DECO and runType_ != sistrip::CALIBRATION_SCAN_DECO) {
0826 ss << " APV calib maj/min vers : " << apvCalibV_.first << "." << apvCalibV_.second << std::endl;
0827 } else {
0828 ss << " APV calib maj/min vers : " << runTableVersion_.first << "." << runTableVersion_.second
0829 << " <= This \"state\" version overriden by \"history\" version " << apvCalibV_.first << "."
0830 << apvCalibV_.second << " for this APV calib run!" << std::endl;
0831 }
0832
0833 if (runType_ != sistrip::PEDESTALS) {
0834 ss << " Pedestals maj/min vers : " << pedestalsV_.first << "." << pedestalsV_.second << std::endl;
0835 } else {
0836 ss << " Pedestals maj/min vers : " << runTableVersion_.first << "." << runTableVersion_.second
0837 << " <= This \"state\" version overriden by \"history\" version " << pedestalsV_.first << "."
0838 << pedestalsV_.second << " for this pedestals run!" << std::endl;
0839 }
0840
0841 if (runType_ != sistrip::PEDS_FULL_NOISE) {
0842 ss << " PedsFullNoise maj/min vers : " << pedsFullNoiseV_.first << "." << pedsFullNoiseV_.second
0843 << std::endl;
0844 } else {
0845 ss << " Pedestals maj/min vers : " << runTableVersion_.first << "." << runTableVersion_.second
0846 << " <= This \"state\" version overriden by \"history\" version " << pedsFullNoiseV_.first << "."
0847 << pedsFullNoiseV_.second << " for this pedestals run!" << std::endl;
0848 }
0849
0850 if (runType_ != sistrip::APV_LATENCY) {
0851 ss << " APV latency maj/min vers : " << apvLatencyV_.first << "." << apvLatencyV_.second << std::endl;
0852 } else {
0853 ss << " APV latency maj/min vers : " << runTableVersion_.first << "." << runTableVersion_.second
0854 << " <= This \"state\" version overriden by \"history\" version " << apvLatencyV_.first << "."
0855 << apvLatencyV_.second << " for this APV latency run!" << std::endl;
0856 }
0857
0858 if (runType_ != sistrip::FINE_DELAY_TTC) {
0859 ss << " Fine delay maj/min vers : " << fineDelayV_.first << "." << fineDelayV_.second << std::endl;
0860 } else {
0861 ss << " Fine delay maj/min vers : " << runTableVersion_.first << "." << runTableVersion_.second
0862 << " <= This \"state\" version overriden by \"history\" version " << fineDelayV_.first << "."
0863 << fineDelayV_.second << " for this fine delay run!" << std::endl;
0864 }
0865 }
0866
0867 } else {
0868 ss << " Input \"module.xml\" file : " << inputModuleXml_ << std::endl
0869 << " Input \"dcuinfo.xml\" file : " << inputDcuInfoXml_ << std::endl
0870 << " Input \"fec.xml\" file(s) : ";
0871 std::vector<std::string>::const_iterator ifec = inputFecXml_.begin();
0872 for (; ifec != inputFecXml_.end(); ifec++) {
0873 ss << *ifec << ", ";
0874 }
0875 ss << std::endl;
0876 ss << " Input \"fed.xml\" file(s) : ";
0877 std::vector<std::string>::const_iterator ifed = inputFedXml_.begin();
0878 for (; ifed != inputFedXml_.end(); ifed++) {
0879 ss << *ifed << ", ";
0880 }
0881 ss << std::endl;
0882 }
0883 }
0884
0885
0886
0887 std::ostream& operator<<(std::ostream& os, const SiStripPartition& params) {
0888 std::stringstream ss;
0889 params.print(ss);
0890 os << ss.str();
0891 return os;
0892 }
0893
0894
0895
0896 SiStripPartition::Versions SiStripPartition::versions(const std::vector<uint32_t>& _input) {
0897 std::vector<uint32_t> input = _input;
0898 if (input.size() != 2) {
0899 edm::LogWarning(mlConfigDb_) << "[SiStripPartition::" << __func__ << "]"
0900 << " Unexpected size (" << input.size()
0901 << ") for vector containing version numbers (major,minor)!"
0902 << " Resizing to 2 elements (default values will be 0,0)...";
0903 input.resize(2, 0);
0904 }
0905 return std::make_pair(input[0], input[1]);
0906 }