File indexing completed on 2024-04-06 12:02:28
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "FWCore/Utilities/interface/typelookup.h"
0010
0011 #include "CondFormats/PPSObjects/interface/CTPPSRPAlignmentCorrectionsData.h"
0012 #include "DataFormats/CTPPSDetId/interface/CTPPSDetId.h"
0013
0014 #include <set>
0015
0016
0017
0018 CTPPSRPAlignmentCorrectionData& CTPPSRPAlignmentCorrectionsData::getRPCorrection(unsigned int id) { return rps_[id]; }
0019
0020
0021
0022 CTPPSRPAlignmentCorrectionData CTPPSRPAlignmentCorrectionsData::getRPCorrection(unsigned int id) const {
0023 CTPPSRPAlignmentCorrectionData align_corr;
0024 auto it = rps_.find(id);
0025 if (it != rps_.end())
0026 align_corr = it->second;
0027 return align_corr;
0028 }
0029
0030
0031
0032 CTPPSRPAlignmentCorrectionData& CTPPSRPAlignmentCorrectionsData::getSensorCorrection(unsigned int id) {
0033 return sensors_[id];
0034 }
0035
0036
0037
0038 CTPPSRPAlignmentCorrectionData CTPPSRPAlignmentCorrectionsData::getSensorCorrection(unsigned int id) const {
0039 CTPPSRPAlignmentCorrectionData align_corr;
0040 auto it = sensors_.find(id);
0041 if (it != sensors_.end())
0042 align_corr = it->second;
0043 return align_corr;
0044 }
0045
0046
0047
0048 CTPPSRPAlignmentCorrectionData CTPPSRPAlignmentCorrectionsData::getFullSensorCorrection(unsigned int id,
0049 bool useRPErrors) const {
0050
0051 CTPPSRPAlignmentCorrectionData align_corr;
0052
0053
0054 auto sIt = sensors_.find(id);
0055 if (sIt != sensors_.end())
0056 align_corr.add(sIt->second, true);
0057
0058
0059 auto rpIt = rps_.find(CTPPSDetId(id).rpId());
0060 if (rpIt != rps_.end())
0061 align_corr.add(rpIt->second, useRPErrors);
0062
0063 return align_corr;
0064 }
0065
0066
0067
0068 void CTPPSRPAlignmentCorrectionsData::setRPCorrection(unsigned int id, const CTPPSRPAlignmentCorrectionData& ac) {
0069 rps_[id] = ac;
0070 }
0071
0072
0073
0074 void CTPPSRPAlignmentCorrectionsData::setSensorCorrection(unsigned int id, const CTPPSRPAlignmentCorrectionData& ac) {
0075 sensors_[id] = ac;
0076 }
0077
0078
0079
0080 void CTPPSRPAlignmentCorrectionsData::addRPCorrection(
0081 unsigned int id, const CTPPSRPAlignmentCorrectionData& a, bool sumErrors, bool addSh, bool addRot) {
0082 auto it = rps_.find(id);
0083 if (it == rps_.end())
0084 rps_.insert(mapType::value_type(id, a));
0085 else
0086 it->second.add(a, sumErrors, addSh, addRot);
0087 }
0088
0089
0090
0091 void CTPPSRPAlignmentCorrectionsData::addSensorCorrection(
0092 unsigned int id, const CTPPSRPAlignmentCorrectionData& a, bool sumErrors, bool addSh, bool addRot) {
0093 auto it = sensors_.find(id);
0094 if (it == sensors_.end())
0095 sensors_.insert(mapType::value_type(id, a));
0096 else
0097 it->second.add(a, sumErrors, addSh, addRot);
0098 }
0099
0100
0101
0102 void CTPPSRPAlignmentCorrectionsData::addCorrections(const CTPPSRPAlignmentCorrectionsData& nac,
0103 bool sumErrors,
0104 bool addSh,
0105 bool addRot) {
0106 for (const auto& it : nac.rps_)
0107 addRPCorrection(it.first, it.second, sumErrors, addSh, addRot);
0108
0109 for (const auto& it : nac.sensors_)
0110 addSensorCorrection(it.first, it.second, sumErrors, addSh, addRot);
0111 }
0112
0113
0114
0115 void CTPPSRPAlignmentCorrectionsData::clear() {
0116 rps_.clear();
0117 sensors_.clear();
0118 }
0119
0120
0121
0122 std::ostream& operator<<(std::ostream& s, const CTPPSRPAlignmentCorrectionsData& corr) {
0123 for (const auto& p : corr.getRPMap()) {
0124 s << "RP " << p.first << ": " << p.second << std::endl;
0125 }
0126
0127 for (const auto& p : corr.getSensorMap()) {
0128 s << "sensor " << p.first << ": " << p.second << std::endl;
0129 }
0130
0131 return s;
0132 }
0133
0134