Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-12-24 02:19:03

0001 // -*- C++ -*-
0002 //
0003 // Package:    TestSpecParAnalyzer
0004 // Class:      TestSpecParAnalyzer
0005 //
0006 /**\class TestSpecParAnalyzer TestSpecParAnalyzer.cc test/TestSpecParAnalyzer/src/TestSpecParAnalyzer.cc
0007 
0008  Description: <one line class summary>
0009 
0010  Implementation:
0011      <Notes on implementation>
0012 */
0013 //
0014 
0015 #include <memory>
0016 #include <iostream>
0017 #include <fstream>
0018 
0019 #include "FWCore/Framework/interface/Frameworkfwd.h"
0020 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0021 
0022 #include "FWCore/Framework/interface/Event.h"
0023 #include "FWCore/Framework/interface/EventSetup.h"
0024 #include "FWCore/Framework/interface/ESTransientHandle.h"
0025 #include "FWCore/Framework/interface/MakerMacros.h"
0026 
0027 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0028 #include "DetectorDescription/Core/interface/DDCompactView.h"
0029 #include "DetectorDescription/Core/interface/DDRoot.h"
0030 #include "DetectorDescription/Core/interface/DDFilter.h"
0031 #include "DetectorDescription/Core/interface/DDFilteredView.h"
0032 #include "DetectorDescription/Parser/interface/DDLParser.h"
0033 #include "Geometry/Records/interface/IdealGeometryRecord.h"
0034 #include "DetectorDescription/OfflineDBLoader/interface/GeometryInfoDump.h"
0035 
0036 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
0037 
0038 #include "CondFormats/Common/interface/FileBlob.h"
0039 #include "Geometry/Records/interface/GeometryFileRcd.h"
0040 
0041 class TestSpecParAnalyzer : public edm::one::EDAnalyzer<> {
0042 public:
0043   explicit TestSpecParAnalyzer(const edm::ParameterSet&);
0044   ~TestSpecParAnalyzer() override;
0045 
0046   void beginJob() override {}
0047   void analyze(edm::Event const&, edm::EventSetup const&) override;
0048   void endJob() override {}
0049 
0050 private:
0051   const std::string specName_;
0052   const std::string specStrValue_;
0053   const double specDblValue_;
0054   const edm::ESGetToken<DDCompactView, IdealGeometryRecord> ddToken_;
0055 };
0056 
0057 TestSpecParAnalyzer::TestSpecParAnalyzer(const edm::ParameterSet& iConfig)
0058     : specName_(iConfig.getParameter<std::string>("specName")),
0059       specStrValue_(iConfig.getUntrackedParameter<std::string>("specStrValue", "frederf")),
0060       specDblValue_(iConfig.getUntrackedParameter<double>("specDblValue", 0.0)),
0061       ddToken_(esConsumes<DDCompactView, IdealGeometryRecord>()) {}
0062 
0063 TestSpecParAnalyzer::~TestSpecParAnalyzer() {}
0064 
0065 void TestSpecParAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0066   using namespace edm;
0067 
0068   std::cout << "Here I am " << std::endl;
0069   edm::ESTransientHandle<DDCompactView> pDD = iSetup.getTransientHandle(ddToken_);
0070   const DDCompactView& cpv(*pDD);
0071   if (specStrValue_ != "frederf") {
0072     std::cout << "specName = " << specName_ << " and specStrValue = " << specStrValue_ << std::endl;
0073     DDSpecificsMatchesValueFilter filter{DDValue(specName_, specStrValue_, 0.0)};
0074     DDFilteredView fv(cpv, filter);
0075     bool doit = fv.firstChild();
0076     std::vector<const DDsvalues_type*> spec = fv.specifics();
0077     std::vector<const DDsvalues_type*>::const_iterator spit = spec.begin();
0078     while (doit) {
0079       spec = fv.specifics();
0080       spit = spec.begin();
0081       std::cout << fv.geoHistory() << std::endl;
0082       for (; spit != spec.end(); ++spit) {
0083         DDsvalues_type::const_iterator it = (**spit).begin();
0084         for (; it != (**spit).end(); it++) {
0085           std::cout << "\t" << it->second.name() << std::endl;
0086           if (it->second.isEvaluated()) {
0087             for (double i : it->second.doubles()) {
0088               std::cout << "\t\t" << i << std::endl;
0089             }
0090           } else {
0091             for (const auto& i : it->second.strings()) {
0092               std::cout << "\t\t" << i << std::endl;
0093             }
0094           }
0095         }
0096       }
0097       doit = fv.next();
0098     }
0099 
0100   } else {
0101     std::cout << "double spec value not implemented" << std::endl;
0102   }
0103 
0104   std::cout << "finished" << std::endl;
0105 }
0106 
0107 DEFINE_FWK_MODULE(TestSpecParAnalyzer);