File indexing completed on 2024-04-06 12:00:01
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #include <memory>
0021
0022
0023 #include "FWCore/Framework/interface/Frameworkfwd.h"
0024 #include "FWCore/Framework/interface/global/EDAnalyzer.h"
0025
0026 #include "FWCore/Framework/interface/Event.h"
0027 #include "FWCore/Framework/interface/MakerMacros.h"
0028
0029 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0030 #include "FWCore/Utilities/interface/InputTag.h"
0031
0032 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
0033 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
0034 #include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
0035 #include "Geometry/Records/interface/TrackerTopologyRcd.h"
0036 #include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h"
0037 #include "CalibTracker/StandaloneTrackerTopology/interface/StandaloneTrackerTopology.h"
0038
0039
0040
0041
0042
0043 class StandaloneTrackerTopologyTest : public edm::global::EDAnalyzer<> {
0044 public:
0045 explicit StandaloneTrackerTopologyTest(const edm::ParameterSet&);
0046 ~StandaloneTrackerTopologyTest() override = default;
0047
0048 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0049
0050 private:
0051 void analyze(edm::StreamID, edm::Event const& iEvent, edm::EventSetup const& iSetup) const override;
0052 void testTopology(const TrackerGeometry* pDD,
0053 const TrackerTopology* tTopoFromDB,
0054 const TrackerTopology* tTopoStandalone) const;
0055
0056
0057 const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> geomEsToken_;
0058 const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> topoToken_;
0059 };
0060
0061
0062
0063
0064 StandaloneTrackerTopologyTest::StandaloneTrackerTopologyTest(const edm::ParameterSet& iConfig)
0065 : geomEsToken_(esConsumes()), topoToken_(esConsumes()) {}
0066
0067
0068
0069
0070 void StandaloneTrackerTopologyTest::testTopology(const TrackerGeometry* pDD,
0071 const TrackerTopology* tTopoFromDB,
0072 const TrackerTopology* tTopoStandalone) const {
0073
0074 for (auto det : pDD->detsPXB()) {
0075 const PixelGeomDetUnit* pixelDet = dynamic_cast<const PixelGeomDetUnit*>(det);
0076 const auto& layerA = tTopoFromDB->pxbLayer(pixelDet->geographicalId());
0077 const auto& ladderA = tTopoFromDB->pxbLadder(pixelDet->geographicalId());
0078 const auto& moduleA = tTopoFromDB->pxbModule(pixelDet->geographicalId());
0079
0080 const auto& layerB = tTopoStandalone->pxbLayer(pixelDet->geographicalId());
0081 const auto& ladderB = tTopoStandalone->pxbLadder(pixelDet->geographicalId());
0082 const auto& moduleB = tTopoStandalone->pxbModule(pixelDet->geographicalId());
0083
0084 if (layerA != layerB || ladderA != ladderB || moduleA != moduleB) {
0085 throw cms::Exception("ConfigurationMismatch")
0086 << "PXB: Topology from DB doesn't match with Topology from XML file!"
0087 << " DetId: " << pixelDet->geographicalId() << " layerA: " << layerA << " layerB: " << layerB
0088 << " ladderA :" << ladderA << " ladderB :" << ladderB << " moduleA :" << moduleA << " moduleB :" << moduleB
0089 << std::endl;
0090 }
0091 }
0092
0093
0094 for (auto det : pDD->detsPXF()) {
0095 const PixelGeomDetUnit* pixelDet = dynamic_cast<const PixelGeomDetUnit*>(det);
0096 const auto& diskA = tTopoFromDB->pxfDisk(pixelDet->geographicalId());
0097 const auto& bladeA = tTopoFromDB->pxfBlade(pixelDet->geographicalId());
0098 const auto& moduleA = tTopoFromDB->pxfModule(pixelDet->geographicalId());
0099
0100 const auto& diskB = tTopoStandalone->pxfDisk(pixelDet->geographicalId());
0101 const auto& bladeB = tTopoStandalone->pxfBlade(pixelDet->geographicalId());
0102 const auto& moduleB = tTopoStandalone->pxfModule(pixelDet->geographicalId());
0103
0104 if (diskA != diskB || bladeA != bladeB || moduleA != moduleB) {
0105 throw cms::Exception("ConfigurationMismatch")
0106 << "PXF: Topology from DB doesn't match with Topology from XML file"
0107 << " DetId: " << pixelDet->geographicalId() << " diskA: " << diskA << " diskB: " << diskB
0108 << " bladeA :" << bladeA << " bladeB :" << bladeB << " moduleA :" << moduleA << " moduleB :" << moduleB
0109 << std::endl;
0110 }
0111 }
0112
0113
0114 for (auto det : pDD->detsTIB()) {
0115 const GeomDetUnit* Det = dynamic_cast<const GeomDetUnit*>(det);
0116 const auto& sideA = tTopoFromDB->tibSide(Det->geographicalId());
0117 const auto& layerA = tTopoFromDB->tibLayer(Det->geographicalId());
0118 const auto& moduleA = tTopoFromDB->tibModule(Det->geographicalId());
0119
0120 const auto& sideB = tTopoStandalone->tibSide(Det->geographicalId());
0121 const auto& layerB = tTopoStandalone->tibLayer(Det->geographicalId());
0122 const auto& moduleB = tTopoStandalone->tibModule(Det->geographicalId());
0123
0124 if (sideA != sideB || layerA != layerB || moduleA != moduleB) {
0125 throw cms::Exception("ConfigurationMismatch")
0126 << "TIB: Topology from DB doesn't match with Topology from XML file"
0127 << " DetId: " << Det->geographicalId() << " sideA: " << sideA << " sideB: " << sideB << " layerA :" << layerA
0128 << " layerB :" << layerB << " moduleA :" << moduleA << " moduleB :" << moduleB << std::endl;
0129 }
0130 }
0131
0132
0133 for (auto det : pDD->detsTID()) {
0134 const GeomDetUnit* Det = dynamic_cast<const GeomDetUnit*>(det);
0135 const auto& sideA = tTopoFromDB->tidSide(Det->geographicalId());
0136 const auto& wheelA = tTopoFromDB->tidWheel(Det->geographicalId());
0137 const auto& moduleA = tTopoFromDB->tidModule(Det->geographicalId());
0138
0139 const auto& sideB = tTopoStandalone->tidSide(Det->geographicalId());
0140 const auto& wheelB = tTopoStandalone->tidWheel(Det->geographicalId());
0141 const auto& moduleB = tTopoStandalone->tidModule(Det->geographicalId());
0142
0143 if (sideA != sideB || wheelA != wheelB || moduleA != moduleB) {
0144 throw cms::Exception("ConfigurationMismatch")
0145 << "TID: Topology from DB doesn't match with Topology from XML file"
0146 << " DetId: " << Det->geographicalId() << " sideA: " << sideA << " sideB: " << sideB << " wheelA :" << wheelA
0147 << " wheelB :" << wheelB << " moduleA :" << moduleA << " moduleB :" << moduleB << std::endl;
0148 }
0149 }
0150
0151
0152 for (auto det : pDD->detsTOB()) {
0153 const GeomDetUnit* Det = dynamic_cast<const GeomDetUnit*>(det);
0154
0155 const auto& layerA = tTopoFromDB->tobLayer(Det->geographicalId());
0156 const auto& rodA = tTopoFromDB->tobRod(Det->geographicalId());
0157 const auto& moduleA = tTopoFromDB->tobModule(Det->geographicalId());
0158
0159 const auto& layerB = tTopoStandalone->tobLayer(Det->geographicalId());
0160 const auto& rodB = tTopoStandalone->tobRod(Det->geographicalId());
0161 const auto& moduleB = tTopoStandalone->tobModule(Det->geographicalId());
0162
0163 if (layerA != layerB || rodA != rodB || moduleA != moduleB) {
0164 throw cms::Exception("ConfigurationMismatch")
0165 << "TOB: Topology from DB doesn't match with Topology from XML file"
0166 << " DetId: " << Det->geographicalId() << " layerA :" << layerA << " layerB :" << layerB << " rodA: " << rodA
0167 << " rodB: " << rodB << " moduleA :" << moduleA << " moduleB :" << moduleB << std::endl;
0168 }
0169 }
0170
0171
0172 for (auto det : pDD->detsTEC()) {
0173 const GeomDetUnit* Det = dynamic_cast<const GeomDetUnit*>(det);
0174 const auto& sideA = tTopoFromDB->tecSide(Det->geographicalId());
0175 const auto& wheelA = tTopoFromDB->tecWheel(Det->geographicalId());
0176 const auto& moduleA = tTopoFromDB->tecModule(Det->geographicalId());
0177
0178 const auto& sideB = tTopoStandalone->tecSide(Det->geographicalId());
0179 const auto& wheelB = tTopoStandalone->tecWheel(Det->geographicalId());
0180 const auto& moduleB = tTopoStandalone->tecModule(Det->geographicalId());
0181
0182 if (sideA != sideB || wheelA != wheelB || moduleA != moduleB) {
0183 throw cms::Exception("ConfigurationMismatch")
0184 << "TEC: Topology from DB doesn't match with Topology from XML file"
0185 << " DetId: " << Det->geographicalId() << " sideA: " << sideA << " sideB: " << sideB << " wheelA :" << wheelA
0186 << " wheelB :" << wheelB << " moduleA :" << moduleA << " moduleB :" << moduleB << std::endl;
0187 }
0188 }
0189 }
0190
0191
0192 void StandaloneTrackerTopologyTest::analyze(edm::StreamID,
0193 edm::Event const& iEvent,
0194 edm::EventSetup const& iSetup) const {
0195 using namespace edm;
0196
0197
0198 const TrackerGeometry* pDD = &iSetup.getData(geomEsToken_);
0199 const TrackerTopology* tTopo = &iSetup.getData(topoToken_);
0200
0201 const char* pathToTopologyXML;
0202 if ((pDD->isThere(GeomDetEnumerators::P2PXB)) || (pDD->isThere(GeomDetEnumerators::P2PXEC))) {
0203 edm::LogPrint("StandaloneTrackerTopologyTest") << "===== Testing Phase-2 Pixel Tracker geometry =====" << std::endl;
0204 pathToTopologyXML = "Geometry/TrackerCommonData/data/PhaseII/trackerParameters.xml";
0205 } else if ((pDD->isThere(GeomDetEnumerators::P1PXB)) || (pDD->isThere(GeomDetEnumerators::P1PXEC))) {
0206 edm::LogPrint("StandaloneTrackerTopologyTest") << "===== Testing Phase-1 Pixel Tracker geometry =====" << std::endl;
0207 pathToTopologyXML = "Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml";
0208 } else {
0209 edm::LogPrint("StandaloneTrackerTopologyTest") << "===== Testing Phase-0 Pixel Tracker geometry =====" << std::endl;
0210 pathToTopologyXML = "Geometry/TrackerCommonData/data/trackerParameters.xml";
0211 }
0212
0213 edm::LogPrint("StandaloneTrackerTopologyTest") << "parameters file" << pathToTopologyXML << std::endl;
0214
0215 TrackerTopology tTopoStandalone =
0216 StandaloneTrackerTopology::fromTrackerParametersXMLFile(edm::FileInPath(pathToTopologyXML).fullPath());
0217
0218
0219 testTopology(pDD, tTopo, &tTopoStandalone);
0220 }
0221
0222
0223 void StandaloneTrackerTopologyTest::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0224 edm::ParameterSetDescription desc;
0225 descriptions.addDefault(desc);
0226 }
0227
0228
0229 DEFINE_FWK_MODULE(StandaloneTrackerTopologyTest);