Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:50:14

0001 // -*- C++ -*-
0002 //
0003 // Package:    GeometricDetAnalyzer
0004 // Class:      GeometricDetAnalyzer
0005 //
0006 /**\class GeometricDetAnalyzer GeometricDetAnalyzer.cc test/GeometricDetAnalyzer/src/GeometricDetAnalyzer.cc
0007 
0008  Description: <one line class summary>
0009 
0010  Implementation:
0011      <Notes on implementation>
0012 */
0013 //
0014 // Original Author:  Tommaso Boccali
0015 //         Created:  Tue Jul 26 08:47:57 CEST 2005
0016 //
0017 //
0018 
0019 // system include files
0020 #include <memory>
0021 
0022 // user include files
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 // CLHEP Dependency
0038 #include <CLHEP/Vector/ThreeVector.h>
0039 
0040 //
0041 //
0042 // class decleration
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 // constants, enums and typedefs
0060 //
0061 
0062 //
0063 // static data member definitions
0064 //
0065 
0066 //
0067 // constructors and destructor
0068 //
0069 GeometricDetAnalyzer::GeometricDetAnalyzer(const edm::ParameterSet& iConfig)
0070     : tokGeo_(esConsumes<GeometricDet, IdealGeometryRecord>()) {
0071   //now do what ever initialization is needed
0072 }
0073 
0074 GeometricDetAnalyzer::~GeometricDetAnalyzer() {
0075   // do anything here that needs to be done at desctruction time
0076   // (e.g. close files, deallocate resources etc.)
0077 }
0078 
0079 //
0080 // member functions
0081 //
0082 
0083 // ------------ method called to produce the data  ------------
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   // get the GeometricDet
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 //define this as a plug-in
0115 DEFINE_FWK_MODULE(GeometricDetAnalyzer);