File indexing completed on 2024-04-06 11:58:37
0001 #include "CondFormats/PPSObjects/interface/CTPPSRPAlignmentCorrectionsData.h"
0002 #include "CondFormats/PPSObjects/interface/CTPPSRPAlignmentCorrectionsDataSequence.h"
0003
0004 #include "CondFormats/PPSObjects/interface/CTPPSRPAlignmentCorrectionsMethods.h"
0005
0006 #include "DataFormats/CTPPSDetId/interface/CTPPSDetId.h"
0007 #include "DataFormats/CTPPSDetId/interface/TotemRPDetId.h"
0008 #include "DataFormats/CTPPSDetId/interface/CTPPSPixelDetId.h"
0009 #include "DataFormats/CTPPSDetId/interface/CTPPSDiamondDetId.h"
0010
0011
0012
0013 int CompareCorrections(const CTPPSRPAlignmentCorrectionData &c1, const CTPPSRPAlignmentCorrectionData c2) {
0014 if (c1.getShX() != c2.getShX())
0015 return 2;
0016 if (c1.getShY() != c2.getShY())
0017 return 2;
0018 if (c1.getShZ() != c2.getShZ())
0019 return 2;
0020
0021 if (c1.getRotX() != c2.getRotX())
0022 return 2;
0023 if (c1.getRotY() != c2.getRotY())
0024 return 2;
0025 if (c1.getRotZ() != c2.getRotZ())
0026 return 2;
0027
0028 return 0;
0029 }
0030
0031
0032
0033 int main() {
0034
0035 CTPPSRPAlignmentCorrectionsData ad;
0036
0037 ad.addRPCorrection(TotemRPDetId(1, 0, 3),
0038 CTPPSRPAlignmentCorrectionData(1., 2., 3., 1e-3, 2e-3, 3e-3));
0039 ad.addSensorCorrection(TotemRPDetId(1, 0, 3, 2),
0040 CTPPSRPAlignmentCorrectionData(4., 5., 6., 4e-3, 5e-3, 6e-3));
0041
0042 ad.addRPCorrection(CTPPSPixelDetId(1, 2, 3), CTPPSRPAlignmentCorrectionData(1., -2., 0., 0., 0., 3e-3));
0043 ad.addSensorCorrection(CTPPSPixelDetId(1, 2, 3, 1),
0044 CTPPSRPAlignmentCorrectionData(-1., +0.5, 0., 0., 0., -0.2e-3));
0045
0046 ad.addRPCorrection(CTPPSDiamondDetId(1, 2, 4),
0047 CTPPSRPAlignmentCorrectionData(1., -2., 0., 0., 0., 3.));
0048 ad.addSensorCorrection(CTPPSDiamondDetId(1, 2, 4, 3),
0049 CTPPSRPAlignmentCorrectionData(-1., +0.5, 0., 0., 0., -0.2e-3));
0050
0051 ad.addRPCorrection(
0052 TotemRPDetId(0, 0, 2),
0053 CTPPSRPAlignmentCorrectionData(1., -2., 0., 0., 0., 3e-3));
0054 ad.addRPCorrection(TotemRPDetId(0, 0, 3), CTPPSRPAlignmentCorrectionData(1., -2., 0., 0., 0., 3e-3));
0055
0056
0057 CTPPSRPAlignmentCorrectionsDataSequence ads;
0058 edm::EventID event_end(123, 456, 1);
0059 ads.insert(edm::ValidityInterval(edm::IOVSyncValue::beginOfTime(), edm::IOVSyncValue(event_end)), ad);
0060
0061
0062 CTPPSRPAlignmentCorrectionsMethods::writeToXML(
0063 ads, "alignment_xml_io_test.xml", false, false, true, true, true, true);
0064
0065
0066 const CTPPSRPAlignmentCorrectionsDataSequence &adsl =
0067 CTPPSRPAlignmentCorrectionsMethods::loadFromXML("alignment_xml_io_test.xml");
0068
0069
0070 if (adsl.size() != 1)
0071 return 1;
0072
0073
0074 const auto &iovl = adsl.begin()->first;
0075 if (iovl.first() != edm::IOVSyncValue::beginOfTime() || iovl.last().eventID().run() != event_end.run() ||
0076 iovl.last().eventID().luminosityBlock() != event_end.luminosityBlock())
0077 return 2;
0078
0079
0080 {
0081 unsigned int id = TotemRPDetId(1, 0, 3);
0082 const CTPPSRPAlignmentCorrectionData &a = ad.getRPCorrection(id);
0083 const CTPPSRPAlignmentCorrectionData &al = adsl.begin()->second.getRPCorrection(id);
0084
0085 if (CompareCorrections(a, al) != 0)
0086 return 3;
0087 }
0088
0089
0090 {
0091 unsigned int id = TotemRPDetId(1, 0, 3, 2);
0092 const CTPPSRPAlignmentCorrectionData &a = ad.getSensorCorrection(id);
0093 const CTPPSRPAlignmentCorrectionData &al = adsl.begin()->second.getSensorCorrection(id);
0094
0095 if (CompareCorrections(a, al) != 0)
0096 return 4;
0097 }
0098
0099 return 0;
0100 }