Skip to content

Commit

Permalink
Change names after Carl's comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunanda committed Apr 29, 2020
1 parent db247f0 commit 7134f71
Show file tree
Hide file tree
Showing 11 changed files with 98 additions and 96 deletions.
19 changes: 0 additions & 19 deletions Geometry/MuonNumbering/interface/MuonDDDConstantsBuild.h

This file was deleted.

@@ -1,7 +1,7 @@
#ifndef Geometry_MuonNumbering_MuonDDDParameters_h
#define Geometry_MuonNumbering_MuonDDDParameters_h
#ifndef Geometry_MuonNumbering_MuonGeometryConstants_h
#define Geometry_MuonNumbering_MuonGeometryConstants_h

/** \class MuonDDDParameters
/** \class MuonGeometryConstants
*
* this class reads the constant section of
* the muon-numbering xml-file
Expand All @@ -17,9 +17,9 @@
#include <iostream>
#include "CondFormats/Serialization/interface/Serializable.h"

class MuonDDDParameters {
class MuonGeometryConstants {
public:
MuonDDDParameters() {}
MuonGeometryConstants() {}

int getValue(const std::string& name) const;
void addValue(const std::string& name, const int& value);
Expand All @@ -36,6 +36,8 @@ class MuonDDDParameters {

private:
std::map<std::string, int> namesAndValues_;
COND_SERIALIZABLE;
};

#endif

19 changes: 19 additions & 0 deletions Geometry/MuonNumbering/interface/MuonGeometryConstantsBuild.h
@@ -0,0 +1,19 @@
#ifndef MuonNumbering_MuonGeometryConstantsBuild_h
#define MuonNumbering_MuonGeometryConstantsBuild_h

#include <string>
#include <vector>
#include "DetectorDescription/Core/interface/DDCompactView.h"
#include "DetectorDescription/DDCMS/interface/DDCompactView.h"

class MuonGeometryConstants;

class MuonGeometryConstantsBuild {
public:
MuonGeometryConstantsBuild() {}

bool build(const DDCompactView* cpv, MuonGeometryConstants& php);
bool build(const cms::DDCompactView* cpv, MuonGeometryConstants& php);
};

#endif
@@ -1,5 +1,5 @@
#include "Geometry/MuonNumbering/interface/MuonDDDConstantsBuild.h"
#include "Geometry/MuonNumbering/interface/MuonDDDParameters.h"
#include "Geometry/MuonNumbering/interface/MuonGeometryConstantsBuild.h"
#include "Geometry/MuonNumbering/interface/MuonGeometryConstants.h"

#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/Utilities/interface/Exception.h"
Expand All @@ -10,9 +10,9 @@

//#define EDM_ML_DEBUG

bool MuonDDDConstantsBuild::build(const DDCompactView* cpv, MuonDDDParameters& php) {
bool MuonGeometryConstantsBuild::build(const DDCompactView* cpv, MuonGeometryConstants& php) {
#ifdef EDM_ML_DEBUG
edm::LogVerbatim("Geometry") << "MuonDDDConstantsBuild;:build (const DDCompactView* cpv, MuonDDDParameters& php)";
edm::LogVerbatim("Geometry") << "MuonGeometryConstantsBuild;:build (const DDCompactView* cpv, MuonGeometryConstants& php)";
#endif
std::string attribute = "OnlyForMuonNumbering";

Expand All @@ -26,12 +26,12 @@ bool MuonDDDConstantsBuild::build(const DDCompactView* cpv, MuonDDDParameters& p

const DDsvalues_type mySpecs(fview.mergedSpecifics());
#ifdef EDM_ML_DEBUG
edm::LogVerbatim("Geometry") << "MuonDDDConstantsBuild::mySpecs.size() = " << mySpecs.size();
edm::LogVerbatim("Geometry") << "MuonGeometryConstantsBuild::mySpecs.size() = " << mySpecs.size();
#endif
if (mySpecs.size() < 25) {
edm::LogError("MuonDDDConstantsBuild") << " MuonDDDConstantsBuild: Missing SpecPars from DetectorDescription.";
edm::LogError("MuonGeometryConstantsBuild") << " MuonGeometryConstantsBuild: Missing SpecPars from DetectorDescription.";
std::string msg =
"MuonDDDConstantsBuild does not have the appropriate number of SpecPars associated with the part //MUON.";
"MuonGeometryConstantsBuild does not have the appropriate number of SpecPars associated with the part //MUON.";
throw cms::Exception("GeometryBuildFailure", msg);
}

Expand All @@ -41,18 +41,18 @@ bool MuonDDDConstantsBuild::build(const DDCompactView* cpv, MuonDDDParameters& p
if (bit->second.isEvaluated()) {
php.addValue(bit->second.name(), int(bit->second.doubles()[0]));
#ifdef EDM_ML_DEBUG
edm::LogVerbatim("Geometry") << "MuonDDDConstantsBuild::adding DDConstant of " << bit->second.name() << " = "
edm::LogVerbatim("Geometry") << "MuonGeometryConstantsBuild::adding DDConstant of " << bit->second.name() << " = "
<< int(bit->second.doubles()[0]);
#endif
}
}
return true;
}

bool MuonDDDConstantsBuild::build(const cms::DDCompactView* cpv, MuonDDDParameters& php) {
bool MuonGeometryConstantsBuild::build(const cms::DDCompactView* cpv, MuonGeometryConstants& php) {
#ifdef EDM_ML_DEBUG
edm::LogVerbatim("Geometry")
<< "MuonDDDConstantsBuild;:build (const cms::DDCompactView* cpv, MuonDDDParameters& php)";
<< "MuonGeometryConstantsBuild;:build (const cms::DDCompactView* cpv, MuonGeometryConstants& php)";
#endif

return false;
Expand Down
Expand Up @@ -6,18 +6,18 @@
#include "DetectorDescription/Core/interface/DDCompactView.h"
#include "DetectorDescription/DDCMS/interface/DDCompactView.h"
#include "Geometry/Records/interface/IdealGeometryRecord.h"
#include "Geometry/MuonNumbering/interface/MuonDDDParameters.h"
#include "Geometry/MuonNumbering/interface/MuonDDDConstantsBuild.h"
#include "Geometry/MuonNumbering/interface/MuonGeometryConstants.h"
#include "Geometry/MuonNumbering/interface/MuonGeometryConstantsBuild.h"

#include <memory>

//#define EDM_ML_DEBUG

class MuonDDDConstantsESModule : public edm::ESProducer {
class MuonGeometryConstantsESModule : public edm::ESProducer {
public:
MuonDDDConstantsESModule(const edm::ParameterSet&);
MuonGeometryConstantsESModule(const edm::ParameterSet&);

using ReturnType = std::unique_ptr<MuonDDDParameters>;
using ReturnType = std::unique_ptr<MuonGeometryConstants>;

static void fillDescriptions(edm::ConfigurationDescriptions&);

Expand All @@ -29,39 +29,39 @@ class MuonDDDConstantsESModule : public edm::ESProducer {
bool fromDD4Hep_;
};

MuonDDDConstantsESModule::MuonDDDConstantsESModule(const edm::ParameterSet& ps) {
MuonGeometryConstantsESModule::MuonGeometryConstantsESModule(const edm::ParameterSet& ps) {
fromDD4Hep_ = ps.getParameter<bool>("fromDD4Hep");
auto cc = setWhatProduced(this);
cpvTokenDD4Hep_ = cc.consumesFrom<cms::DDCompactView, IdealGeometryRecord>(edm::ESInputTag());
cpvTokenDDD_ = cc.consumesFrom<DDCompactView, IdealGeometryRecord>(edm::ESInputTag());

#ifdef EDM_ML_DEBUG
edm::LogVerbatim("Geometry") << "MuonDDDConstantsESModule::MuonDDDConstantsESModule called with dd4hep: "
edm::LogVerbatim("Geometry") << "MuonGeometryConstantsESModule::MuonGeometryConstantsESModule called with dd4hep: "
<< fromDD4Hep_;
#endif
}

void MuonDDDConstantsESModule::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
void MuonGeometryConstantsESModule::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.add<bool>("fromDD4Hep", false);
descriptions.add("muonDDDConstants", desc);
descriptions.add("muonGeometryConstants", desc);
}

MuonDDDConstantsESModule::ReturnType MuonDDDConstantsESModule::produce(const IdealGeometryRecord& iRecord) {
edm::LogInfo("Geometry") << "MuonDDDConstantsESModule::produce(const IdealGeometryRecord& iRecord)";
MuonGeometryConstantsESModule::ReturnType MuonGeometryConstantsESModule::produce(const IdealGeometryRecord& iRecord) {
edm::LogInfo("Geometry") << "MuonGeometryConstantsESModule::produce(const IdealGeometryRecord& iRecord)";

auto ptp = std::make_unique<MuonDDDParameters>();
MuonDDDConstantsBuild builder;
auto ptp = std::make_unique<MuonGeometryConstants>();
MuonGeometryConstantsBuild builder;

if (fromDD4Hep_) {
#ifdef EDM_ML_DEBUG
edm::LogVerbatim("Geometry") << "MuonDDDConstantsESModule::Try to access cms::DDCompactView";
edm::LogVerbatim("Geometry") << "MuonGeometryConstantsESModule::Try to access cms::DDCompactView";
#endif
edm::ESTransientHandle<cms::DDCompactView> cpv = iRecord.getTransientHandle(cpvTokenDD4Hep_);
builder.build(&(*cpv), *ptp);
} else {
#ifdef EDM_ML_DEBUG
edm::LogVerbatim("Geometry") << "MuonDDDConstantsESModule::Try to access DDCompactView";
edm::LogVerbatim("Geometry") << "MuonGeometryConstantsESModule::Try to access DDCompactView";
#endif
edm::ESTransientHandle<DDCompactView> cpv = iRecord.getTransientHandle(cpvTokenDDD_);
builder.build(&(*cpv), *ptp);
Expand All @@ -70,4 +70,4 @@ MuonDDDConstantsESModule::ReturnType MuonDDDConstantsESModule::produce(const Ide
return ptp;
}

DEFINE_FWK_EVENTSETUP_MODULE(MuonDDDConstantsESModule);
DEFINE_FWK_EVENTSETUP_MODULE(MuonGeometryConstantsESModule);
@@ -1,9 +1,9 @@
import FWCore.ParameterSet.Config as cms

from Geometry.MuonNumbering.muonDDDConstants_cfi import *
from Geometry.MuonNumbering.muonGeometryConstants_cfi import *

from Configuration.ProcessModifiers.dd4hep_cff import dd4hep

dd4hep.toModify(muonDDDConstants,
dd4hep.toModify(muonGeometryConstants,
fromDD4Hep = cms.bool(True),
)
29 changes: 0 additions & 29 deletions Geometry/MuonNumbering/src/MuonDDDParameters.cc

This file was deleted.

29 changes: 29 additions & 0 deletions Geometry/MuonNumbering/src/MuonGeometryParameters.cc
@@ -0,0 +1,29 @@
#include "Geometry/MuonNumbering/interface/MuonGeometryConstants.h"

#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/Utilities/interface/Exception.h"

#define EDM_ML_DEBUG

int MuonGeometryConstants::getValue(const std::string& name) const {
#ifdef EDM_ML_DEBUG
edm::LogVerbatim("Geometry") << "about to look for ... " << name << std::endl;
#endif
if (namesAndValues_.empty())
throw cms::Exception("GeometryBuildFailure", "MuonGeometryConstants does not have requested value for " + name);

std::map<std::string, int>::const_iterator findIt = namesAndValues_.find(name);
if (findIt == namesAndValues_.end())
throw cms::Exception("GeometryBuildFailure", "MuonGeometryConstants does not have requested value for " + name);

#ifdef EDM_ML_DEBUG
edm::LogVerbatim("Geometry") << "MuonGeometryConstants::Value for " << name << " is " << findIt->second;
#endif
return findIt->second;
}

void MuonGeometryConstants::addValue(const std::string& name, const int& value) { namesAndValues_[name] = value; }

#include "FWCore/Utilities/interface/typelookup.h"

TYPELOOKUP_DATA_REG(MuonGeometryConstants);
Expand Up @@ -6,28 +6,28 @@
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"

#include "Geometry/MuonNumbering/interface/MuonDDDParameters.h"
#include "Geometry/MuonNumbering/interface/MuonGeometryConstants.h"
#include "Geometry/Records/interface/IdealGeometryRecord.h"

class MuonConstantsTester : public edm::one::EDAnalyzer<> {
class MuonGeometryConstantsTester : public edm::one::EDAnalyzer<> {
public:
explicit MuonConstantsTester(const edm::ParameterSet&);
explicit MuonGeometryConstantsTester(const edm::ParameterSet&);

void beginJob() override {}
void analyze(edm::Event const& iEvent, edm::EventSetup const&) override;
void endJob() override {}

private:
edm::ESGetToken<MuonDDDParameters, IdealGeometryRecord> token_;
edm::ESGetToken<MuonGeometryConstants, IdealGeometryRecord> token_;
};

MuonConstantsTester::MuonConstantsTester(const edm::ParameterSet&) {
token_ = esConsumes<MuonDDDParameters, IdealGeometryRecord>(edm::ESInputTag{});
MuonGeometryConstantsTester::MuonGeometryConstantsTester(const edm::ParameterSet&) {
token_ = esConsumes<MuonGeometryConstants, IdealGeometryRecord>(edm::ESInputTag{});
}

void MuonConstantsTester::analyze(const edm::Event&, const edm::EventSetup& iS) {
void MuonGeometryConstantsTester::analyze(const edm::Event&, const edm::EventSetup& iS) {
const auto& par = iS.getData(token_);
const MuonDDDParameters* parMuon = &par;
const MuonGeometryConstants* parMuon = &par;
if (parMuon != nullptr) {
std::cout << "\n\nMuonDDDConstants found with " << parMuon->size() << " contents\n";
for (unsigned int k = 0; k < parMuon->size(); ++k) {
Expand All @@ -39,4 +39,4 @@ void MuonConstantsTester::analyze(const edm::Event&, const edm::EventSetup& iS)
}
}

DEFINE_FWK_MODULE(MuonConstantsTester);
DEFINE_FWK_MODULE(MuonGeometryConstantsTester);
Expand Up @@ -3,7 +3,7 @@
process = cms.Process("MuonConstantsTest")
process.load("SimGeneral.HepPDTESSource.pdt_cfi")
process.load("Geometry.CMSCommonData.cmsExtendedGeometry2026D46XML_cfi")
process.load("Geometry.MuonNumbering.muonDDDConstants_cff")
process.load("Geometry.MuonNumbering.muonGeometryConstants_cff")
process.load('FWCore.MessageService.MessageLogger_cfi')

if hasattr(process,'MessageLogger'):
Expand All @@ -24,8 +24,8 @@
input = cms.untracked.int32(1)
)

process.muonDDDConstants.fromDD4Hep = True
process.muonGeometryConstants.fromDD4Hep = True

process.test = cms.EDAnalyzer("MuonConstantsTester")
process.test = cms.EDAnalyzer("MuonGeometryConstantsTester")

process.p1 = cms.Path(process.test)
Expand Up @@ -3,7 +3,7 @@
process = cms.Process("MuonConstantsTest")
process.load("SimGeneral.HepPDTESSource.pdt_cfi")
process.load("Geometry.CMSCommonData.cmsExtendedGeometry2026D46XML_cfi")
process.load("Geometry.MuonNumbering.muonDDDConstants_cff")
process.load("Geometry.MuonNumbering.muonGeometryConstants_cff")
process.load('FWCore.MessageService.MessageLogger_cfi')

if hasattr(process,'MessageLogger'):
Expand All @@ -15,8 +15,8 @@
input = cms.untracked.int32(1)
)

process.muonDDDConstants.fromDD4Hep = False
process.muonGeometryConstants.fromDD4Hep = False

process.test = cms.EDAnalyzer("MuonConstantsTester")
process.test = cms.EDAnalyzer("MuonGeometryConstantsTester")

process.p1 = cms.Path(process.test)

0 comments on commit 7134f71

Please sign in to comment.