File indexing completed on 2024-04-06 12:15:30
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/one/EDAnalyzer.h"
0025
0026 #include "FWCore/Framework/interface/Event.h"
0027 #include "FWCore/Framework/interface/EventSetup.h"
0028 #include "FWCore/Framework/interface/ESHandle.h"
0029 #include "FWCore/Framework/interface/MakerMacros.h"
0030
0031 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0032 #include "DetectorDescription/Core/interface/DDCompactView.h"
0033 #include "Geometry/Records/interface/IdealGeometryRecord.h"
0034 #include "Geometry/TrackerNumberingBuilder/interface/GeometricDet.h"
0035 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0036
0037
0038 #include <CLHEP/Vector/ThreeVector.h>
0039
0040
0041
0042
0043
0044
0045 class GeometricDetAnalyzer : public edm::one::EDAnalyzer<> {
0046 public:
0047 explicit GeometricDetAnalyzer(const edm::ParameterSet&);
0048 ~GeometricDetAnalyzer() override;
0049
0050 void beginJob() override {}
0051 void analyze(edm::Event const& iEvent, edm::EventSetup const&) override;
0052 void endJob() override {}
0053
0054 private:
0055 const edm::ESGetToken<GeometricDet, IdealGeometryRecord> tokGeo_;
0056 };
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069 GeometricDetAnalyzer::GeometricDetAnalyzer(const edm::ParameterSet& iConfig)
0070 : tokGeo_(esConsumes<GeometricDet, IdealGeometryRecord>()) {
0071
0072 }
0073
0074 GeometricDetAnalyzer::~GeometricDetAnalyzer() {
0075
0076
0077 }
0078
0079
0080
0081
0082
0083
0084 void GeometricDetAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0085 using namespace edm;
0086
0087 edm::LogInfo("GeometricDetAnalyzer") << "Here I am ";
0088
0089
0090
0091 auto const& pDD = iSetup.getHandle(tokGeo_);
0092 edm::LogInfo("GeometricDetAnalyzer") << " Top node is " << pDD.product();
0093 edm::LogInfo("GeometricDetAnalyzer") << " And Contains Daughters: " << pDD->deepComponents().size();
0094 std::vector<const GeometricDet*> det = pDD->deepComponents();
0095 for (auto& it : det) {
0096 const DDRotationMatrix& res = it->rotation();
0097 DD3Vector x, y, z;
0098 res.GetComponents(x, y, z);
0099 DD3Vector colx(x.X(), x.Y(), x.Z());
0100 DD3Vector coly(y.X(), y.Y(), y.Z());
0101 DD3Vector colz(z.X(), z.Y(), z.Z());
0102
0103 DDRotationMatrix result(colx, coly, colz);
0104
0105 DD3Vector cx, cy, cz;
0106 result.GetComponents(cx, cy, cz);
0107 if (cx.Cross(cy).Dot(cz) < 0.5) {
0108 edm::LogInfo("GeometricDetAnalyzer")
0109 << "Left Handed Rotation Matrix detected; making it right handed: " << it->name();
0110 }
0111 }
0112 }
0113
0114
0115 DEFINE_FWK_MODULE(GeometricDetAnalyzer);