Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:15:32

0001 // -*- C++ -*-
0002 //
0003 // Package:    PerfectGeometryAnalyzer
0004 // Class:      PerfectGeometryAnalyzer
0005 //
0006 /**\class PerfectGeometryAnalyzer PerfectGeometryAnalyzer.cc test/PerfectGeometryAnalyzer/src/PerfectGeometryAnalyzer.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 #include <memory>
0020 #include <iostream>
0021 #include <fstream>
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/ESTransientHandle.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 "DetectorDescription/OfflineDBLoader/interface/GeometryInfoDump.h"
0035 
0036 #include "CondFormats/Common/interface/FileBlob.h"
0037 #include "Geometry/Records/interface/GeometryFileRcd.h"
0038 #include "DetectorDescription/Parser/interface/DDLParser.h"
0039 #include "DetectorDescription/Core/interface/DDRoot.h"
0040 
0041 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
0042 
0043 class PerfectGeometryAnalyzer : public edm::one::EDAnalyzer<> {
0044 public:
0045   explicit PerfectGeometryAnalyzer(const edm::ParameterSet&);
0046   ~PerfectGeometryAnalyzer() override;
0047 
0048   void beginJob() override {}
0049   void analyze(edm::Event const&, edm::EventSetup const&) override;
0050   void endJob() override {}
0051 
0052 private:
0053   std::string label_;
0054   bool isMagField_;
0055   bool dumpHistory_;
0056   bool dumpPosInfo_;
0057   bool dumpSpecs_;
0058   std::string fname_;
0059   int nNodes_;
0060   bool fromDB_;
0061   std::string ddRootNodeName_;
0062   edm::ESGetToken<DDCompactView, IdealGeometryRecord> geomToken1_;
0063   edm::ESGetToken<DDCompactView, IdealMagneticFieldRecord> geomToken2_;
0064 };
0065 
0066 PerfectGeometryAnalyzer::PerfectGeometryAnalyzer(const edm::ParameterSet& iConfig)
0067     : label_(iConfig.getUntrackedParameter<std::string>("label", "")),
0068       isMagField_(iConfig.getUntrackedParameter<bool>("isMagField", false)),
0069       dumpHistory_(iConfig.getUntrackedParameter<bool>("dumpGeoHistory", false)),
0070       dumpPosInfo_(iConfig.getUntrackedParameter<bool>("dumpPosInfo", false)),
0071       dumpSpecs_(iConfig.getUntrackedParameter<bool>("dumpSpecs", false)),
0072       fname_(iConfig.getUntrackedParameter<std::string>("outFileName", "GeoHistory")),
0073       nNodes_(iConfig.getUntrackedParameter<uint32_t>("numNodesToDump", 0)),
0074       fromDB_(iConfig.getUntrackedParameter<bool>("fromDB", false)),
0075       ddRootNodeName_(iConfig.getUntrackedParameter<std::string>("ddRootNodeName", "cms:OCMS")) {
0076   if (isMagField_) {
0077     label_ = "magfield";
0078   }
0079   if (!isMagField_)
0080     geomToken1_ = esConsumes<DDCompactView, IdealGeometryRecord>(edm::ESInputTag("", label_));
0081   else
0082     geomToken2_ = esConsumes<DDCompactView, IdealMagneticFieldRecord>(edm::ESInputTag("", label_));
0083 }
0084 
0085 PerfectGeometryAnalyzer::~PerfectGeometryAnalyzer() {}
0086 
0087 void PerfectGeometryAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0088   using namespace edm;
0089 
0090   std::cout << "Here I am " << std::endl;
0091 
0092   edm::ESTransientHandle<DDCompactView> pDD =
0093       (!isMagField_) ? iSetup.getTransientHandle(geomToken1_) : iSetup.getTransientHandle(geomToken2_);
0094   if (pDD.description()) {
0095     edm::LogInfo("PerfectGeometryAnalyzer") << pDD.description()->type_ << " label: " << pDD.description()->label_;
0096   } else {
0097     edm::LogWarning("PerfectGeometryAnalyzer") << "NO label found pDD.description() returned false.";
0098   }
0099   if (!pDD.isValid()) {
0100     edm::LogError("PerfectGeometryAnalyzer") << "ESTransientHandle<DDCompactView> pDD is not valid!";
0101   }
0102   GeometryInfoDump gidump;
0103   gidump.dumpInfo(dumpHistory_, dumpSpecs_, dumpPosInfo_, *pDD, fname_, nNodes_);
0104   std::cout << "finished" << std::endl;
0105 }
0106 
0107 DEFINE_FWK_MODULE(PerfectGeometryAnalyzer);