Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run3-sim48 First step to remove access of DDCompactView in SimG4CMS/Calo for ECAL #28327

Merged
merged 4 commits into from Nov 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 27 additions & 0 deletions CondFormats/GeometryObjects/interface/EcalSimulationParameters.h
@@ -0,0 +1,27 @@
#ifndef CondFormats_GeometryObjects_EcalSimulationParameters_h
#define CondFormats_GeometryObjects_EcalSimulationParameters_h

#include "CondFormats/Serialization/interface/Serializable.h"

class EcalSimulationParameters {
public:
EcalSimulationParameters(void) = default;
~EcalSimulationParameters(void) = default;

int nxtalEta_;
int nxtalPhi_;
int phiBaskets_;
std::vector<int> etaBaskets_;
int ncrys_;
int nmods_;
bool useWeight_;
std::string depth1Name_;
std::string depth2Name_;
std::vector<std::string> lvNames_;
std::vector<std::string> matNames_;
std::vector<double> dzs_;

COND_SERIALIZABLE;
};

#endif
@@ -0,0 +1,4 @@
#include "CondFormats/GeometryObjects/interface/EcalSimulationParameters.h"
#include "FWCore/Utilities/interface/typelookup.h"

TYPELOOKUP_DATA_REG(EcalSimulationParameters);
1 change: 1 addition & 0 deletions CondFormats/GeometryObjects/src/classes.h
Expand Up @@ -10,4 +10,5 @@
#include "CondFormats/GeometryObjects/interface/HcalParameters.h"
#include "CondFormats/GeometryObjects/interface/HcalSimulationParameters.h"
#include "CondFormats/GeometryObjects/interface/CaloSimulationParameters.h"
#include "CondFormats/GeometryObjects/interface/EcalSimulationParameters.h"
#include "CondFormats/GeometryObjects/interface/PHGCalParameters.h"
15 changes: 15 additions & 0 deletions CondFormats/GeometryObjects/src/classes_def.xml
Expand Up @@ -192,5 +192,20 @@
<field name="fCaloNames_" mapping="blob"/>
<field name="fLevels_" mapping="blob"/>
</class>
<class name="EcalSimulationParameters" class_version="0">
<field name="nxtalEta_" mapping="blob"/>
<field name="nxtalPhi_" mapping="blob"/>
<field name="phiBaskets_" mapping="blob"/>
<field name="etaBaskets_" mapping="blob"/>
<field name="ncrys_" mapping="blob"/>
<field name="nmods_" mapping="blob"/>
<field name="useWeight_" mapping="blob"/>
<field name="depth1Name_" mapping="blob"/>
<field name="depth2Name_" mapping="blob"/>
<field name="lvNames_" mapping="blob"/>
<field name="matNames_" mapping="blob"/>
<field name="dzs_" mapping="blob"/>
</class>

</lcgdict>

2 changes: 2 additions & 0 deletions Geometry/EcalCommonData/BuildFile.xml
@@ -1,5 +1,7 @@
<use name="DataFormats/EcalDetId"/>
<use name="Geometry/CaloGeometry"/>
<use name="DetectorDescription/Core"/>
<use name="DetectorDescription/DDCMS"/>
<export>
<lib name="1"/>
</export>
66 changes: 66 additions & 0 deletions Geometry/EcalCommonData/data/dd4hep/cms-ecal-geometry-dump.xml
@@ -0,0 +1,66 @@
<?xml version="1.0"?>
<DDDefinition>
<debug>
<debug_shapes/>
<debug_includes/>
<debug_rotations/>
<debug_includes/>
<debug_volumes/>
<debug_constants/>
<debug_materials/>
<debug_namespaces/>
<debug_placements/>
<debug_algorithms/>
<debug_materials/>
<debug_visattr/>
<debug_specpars/>
</debug>

<open_geometry/>
<close_geometry/>

<ConstantsSection label="" eval="true">
<Constant name="world_x" value="100*m"/>
<Constant name="world_y" value="100*m"/>
<Constant name="world_z" value="100*m"/>
<Constant name="fm" value="1e-12*m"/>
<Constant name="mum" value="1.e-3*mm"/>
<Constant name="Air" value="materials:Air" type="string"/>
<Constant name="Vacuum" value="materials:Vacuum" type="string"/>
</ConstantsSection>

<IncludeSection>
<Include ref='Geometry/CMSCommonData/data/materials/2021/v1/materials.xml'/>
<Include ref='Geometry/CMSCommonData/data/rotations.xml'/>
<Include ref='Geometry/CMSCommonData/data/extend/v2/cmsextent.xml'/>
<Include ref='Geometry/CMSCommonData/data/cms/2021/v1/cms.xml'/>
<Include ref='Geometry/CMSCommonData/data/eta3/etaMax.xml'/>
<Include ref='Geometry/CMSCommonData/data/cmsMother.xml'/>
<Include ref='Geometry/CMSCommonData/data/caloBase/2017/v1/caloBase.xml'/>
<Include ref='Geometry/CMSCommonData/data/cmsCalo.xml'/>
<Include ref='Geometry/CMSCommonData/data/muonBase/2018/v1/muonBase.xml'/>
<Include ref='Geometry/CMSCommonData/data/cmsMuon.xml'/>
<Include ref='Geometry/CMSCommonData/data/mgnt.xml'/>
<Include ref='Geometry/CMSCommonData/data/beampipe/2017/v1/beampipe.xml'/>
<Include ref='Geometry/CMSCommonData/data/cmsBeam.xml'/>
<Include ref='Geometry/CMSCommonData/data/muonMB.xml'/>
<Include ref='Geometry/CMSCommonData/data/muonMagnet.xml'/>
<Include ref='Geometry/CMSCommonData/data/cavern/2017/v2/cavern.xml'/>
<Include ref='Geometry/CMSCommonData/data/cavernData/2017/v1/cavernData.xml'/>
<Include ref='Geometry/CMSCommonData/data/cavernFloor/2017/v1/cavernFloor.xml'/>
<Include ref='Geometry/TrackerCommonData/data/trackermaterial.xml'/>
<Include ref='Geometry/EcalCommonData/data/ectkcable.xml'/>
<Include ref='Geometry/EcalCommonData/data/eregalgo/2017/v1/eregalgo.xml'/>
<Include ref='Geometry/EcalCommonData/data/ebalgo/2021/v1/ebalgo.xml'/>
<Include ref='Geometry/EcalCommonData/data/eeF.xml'/>
<Include ref='Geometry/EcalCommonData/data/eeB.xml'/>
<Include ref='Geometry/EcalCommonData/data/eealgo.xml'/>
<Include ref='Geometry/EcalCommonData/data/ebcon.xml'/>
<Include ref='Geometry/EcalCommonData/data/ebrot.xml'/>
<Include ref='Geometry/EcalCommonData/data/eecon.xml'/>
<Include ref='Geometry/EcalCommonData/data/eehier.xml'/>
<Include ref='Geometry/EcalCommonData/data/eefixed.xml'/>
<Include ref='Geometry/EcalCommonData/data/escon.xml'/>
<Include ref='Geometry/EcalCommonData/data/esalgo/2021/v1/esalgo.xml'/>
</IncludeSection>
</DDDefinition>
12 changes: 3 additions & 9 deletions Geometry/EcalCommonData/data/dd4hep/cms-ecal-geometry.xml
Expand Up @@ -30,7 +30,7 @@
</ConstantsSection>

<IncludeSection>
<Include ref='Geometry/CMSCommonData/data/materials.xml'/>
<Include ref='Geometry/CMSCommonData/data/materials/2021/v1/materials.xml'/>
<Include ref='Geometry/CMSCommonData/data/rotations.xml'/>
<Include ref='Geometry/CMSCommonData/data/extend/v2/cmsextent.xml'/>
<Include ref='Geometry/CMSCommonData/data/cms/2021/v1/cms.xml'/>
Expand All @@ -48,6 +48,7 @@
<Include ref='Geometry/CMSCommonData/data/cavern/2017/v2/cavern.xml'/>
<Include ref='Geometry/CMSCommonData/data/cavernData/2017/v1/cavernData.xml'/>
<Include ref='Geometry/CMSCommonData/data/cavernFloor/2017/v1/cavernFloor.xml'/>
<Include ref='Geometry/TrackerCommonData/data/trackermaterial.xml'/>
<Include ref='Geometry/EcalCommonData/data/ectkcable.xml'/>
<Include ref='Geometry/EcalCommonData/data/eregalgo/2017/v1/eregalgo.xml'/>
<Include ref='Geometry/EcalCommonData/data/ebalgo/2021/v1/ebalgo.xml'/>
Expand All @@ -61,13 +62,6 @@
<Include ref='Geometry/EcalCommonData/data/eefixed.xml'/>
<Include ref='Geometry/EcalCommonData/data/escon.xml'/>
<Include ref='Geometry/EcalCommonData/data/esalgo/2021/v1/esalgo.xml'/>
<Include ref='Geometry/TrackerCommonData/data/trackermaterial.xml'/>
<Include ref='Geometry/EcalSimData/data/ecalsens.xml'/>
</IncludeSection>

<PosPartSection label="">
<PosPart copyNumber="1">
<rParent name=":world_volume"/>
<rChild name="cms:OCMS"/>
</PosPart>
</PosPartSection>
</DDDefinition>
27 changes: 27 additions & 0 deletions Geometry/EcalCommonData/interface/EcalSimParametersFromDD.h
@@ -0,0 +1,27 @@
#ifndef EcalCommonData_EcalSimParametersFromDD_h
#define EcalCommonData_EcalSimParametersFromDD_h

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

class DDFilteredView;
class EcalSimulationParameters;

class EcalSimParametersFromDD {
public:
EcalSimParametersFromDD() = default;

bool build(const DDCompactView*, const std::string& name, EcalSimulationParameters&);
bool build(const cms::DDCompactView*, const std::string& name, EcalSimulationParameters&);

private:
bool buildParameters(const EcalSimulationParameters&);
std::vector<std::string> getStringArray(const std::string&, const DDsvalues_type&);
std::vector<double> getDDDArray(const std::string&, const DDsvalues_type&);
};

#endif
4 changes: 4 additions & 0 deletions Geometry/EcalCommonData/plugins/BuildFile.xml
@@ -1,6 +1,10 @@
<library file="*.cc" name="GeometryEcalCommonDataPlugins">
<use name="DetectorDescription/Core"/>
<use name="DetectorDescription/DDCMS"/>
<use name="Geometry/EcalCommonData"/>
<use name="Geometry/Records"/>
<use name="Geometry/EcalCommonData"/>
<use name="CondFormats/GeometryObjects"/>
<flags EDM_PLUGIN="1"/>
</library>

Expand Down
75 changes: 75 additions & 0 deletions Geometry/EcalCommonData/plugins/EcalSimParametersESModule.cc
@@ -0,0 +1,75 @@
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "FWCore/Framework/interface/ModuleFactory.h"
#include "FWCore/Framework/interface/ESProducer.h"
#include "FWCore/Framework/interface/ESTransientHandle.h"
#include "CondFormats/GeometryObjects/interface/EcalSimulationParameters.h"
#include "DetectorDescription/Core/interface/DDCompactView.h"
#include "DetectorDescription/DDCMS/interface/DDCompactView.h"
#include "Geometry/Records/interface/IdealGeometryRecord.h"
#include "Geometry/EcalCommonData/interface/EcalSimParametersFromDD.h"

#include <memory>

//#define EDM_ML_DEBUG

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

using ReturnType = std::unique_ptr<EcalSimulationParameters>;

static void fillDescriptions(edm::ConfigurationDescriptions&);

ReturnType produce(const IdealGeometryRecord&);

private:
edm::ESGetToken<DDCompactView, IdealGeometryRecord> cpvTokenDDD_;
edm::ESGetToken<cms::DDCompactView, IdealGeometryRecord> cpvTokenDD4Hep_;
const bool fromDD4Hep_;
const std::string name_;
};

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

#ifdef EDM_ML_DEBUG
edm::LogVerbatim("EcalGeom") << "EcalSimParametersESModule::EcalSimParametersESModule called with dd4hep: "
<< fromDD4Hep_ << " for " << name_;
#endif
}

void EcalSimParametersESModule::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.add<bool>("fromDD4Hep", false);
desc.add<std::string>("name", "EcalHitsEB");
descriptions.add("ecalSimulationParametersEB", desc);
}

EcalSimParametersESModule::ReturnType EcalSimParametersESModule::produce(const IdealGeometryRecord& iRecord) {
#ifdef EDM_ML_DEBUG
edm::LogVerbatim("EcalGeom") << "EcalSimParametersESModule::produce(const IdealGeometryRecord& iRecord)";
#endif

auto ptp = std::make_unique<EcalSimulationParameters>();
EcalSimParametersFromDD builder;
if (fromDD4Hep_) {
#ifdef EDM_ML_DEBUG
edm::LogVerbatim("EcalGeom") << "EcalSimParametersESModule::Try to access cms::DDCompactView";
#endif
edm::ESTransientHandle<cms::DDCompactView> cpv = iRecord.getTransientHandle(cpvTokenDD4Hep_);
builder.build(&(*cpv), name_, *ptp);
} else {
#ifdef EDM_ML_DEBUG
edm::LogVerbatim("EcalGeom") << "EcalSimParametersESModule::Try to access DDCompactView";
#endif
edm::ESTransientHandle<DDCompactView> cpv = iRecord.getTransientHandle(cpvTokenDDD_);
builder.build(&(*cpv), name_, *ptp);
}
return ptp;
}

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

from Geometry.EcalCommonData.ecalSimulationParametersAnalyzerEB_cfi import *

ecalSimulationParametersAnalyzerEE = ecalSimulationParametersAnalyzerEB.clone(
name = "EcalHitsEE")

ecalSimulationParametersAnalyzerES = ecalSimulationParametersAnalyzerEB.clone(
name = "EcalHitsES")
15 changes: 15 additions & 0 deletions Geometry/EcalCommonData/python/ecalSimulationParameters_cff.py
@@ -0,0 +1,15 @@
import FWCore.ParameterSet.Config as cms

from Geometry.EcalCommonData.ecalSimulationParametersEB_cfi import *

from Configuration.Eras.Modifier_dd4hep_cff import dd4hep

dd4hep.toModify(ecalSimulationParametersEB,
fromDD4Hep = cms.bool(True)
)

ecalSimulationParametersEE = ecalSimulationParametersEB.clone(
name = cms.string("EcalHitsEE"))

ecalSimulationParametersES = ecalSimulationParametersEB.clone(
name = cms.string("EcalHitsES"))