diff --git a/Geometry/ForwardGeometry/src/ZdcTopology.cc b/Geometry/ForwardGeometry/src/ZdcTopology.cc
index e0b92ccff8ae3..83a704f3382ee 100644
--- a/Geometry/ForwardGeometry/src/ZdcTopology.cc
+++ b/Geometry/ForwardGeometry/src/ZdcTopology.cc
@@ -22,7 +22,7 @@ ZdcTopology::ZdcTopology(const HcalDDDRecConstants* hcons)
firstRPDModule_(1),
lastRPDModule_(HcalZDCDetId::kDepRPD) {
mode_ = (HcalTopologyMode::Mode)(hcons_->getTopoMode());
- excludeRPD_ = (mode_ < HcalTopologyMode::Mode::Run3);
+ excludeRPD_ = ((mode_ != HcalTopologyMode::Mode::Run3) && (mode_ != HcalTopologyMode::Mode::Run4));
edm::LogVerbatim("ForwardGeom") << "ZdcTopology : Mode " << mode_ << ":" << HcalTopologyMode::Mode::Run3
<< " ExcludeRPD " << excludeRPD_;
}
diff --git a/Geometry/ForwardGeometry/test/BuildFile.xml b/Geometry/ForwardGeometry/test/BuildFile.xml
index 5021eae6332f0..5cc59f6aa5657 100644
--- a/Geometry/ForwardGeometry/test/BuildFile.xml
+++ b/Geometry/ForwardGeometry/test/BuildFile.xml
@@ -1,5 +1,7 @@
+
+
diff --git a/Geometry/ForwardGeometry/test/ZdcTopologyTester.cc b/Geometry/ForwardGeometry/test/ZdcTopologyTester.cc
new file mode 100644
index 0000000000000..27a232418cfd4
--- /dev/null
+++ b/Geometry/ForwardGeometry/test/ZdcTopologyTester.cc
@@ -0,0 +1,137 @@
+#include
+#include
+#include
+#include
+
+#include "FWCore/Framework/interface/Frameworkfwd.h"
+#include "FWCore/Framework/interface/one/EDAnalyzer.h"
+#include "FWCore/Framework/interface/Event.h"
+#include "FWCore/Framework/interface/EventSetup.h"
+#include "FWCore/Framework/interface/ESTransientHandle.h"
+#include "FWCore/Framework/interface/MakerMacros.h"
+#include "FWCore/MessageLogger/interface/MessageLogger.h"
+#include "FWCore/ParameterSet/interface/ParameterSet.h"
+#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
+
+#include "Geometry/Records/interface/HcalRecNumberingRecord.h"
+#include "Geometry/ForwardGeometry/interface/ZdcTopology.h"
+#include "DataFormats/HcalDetId/interface/HcalZDCDetId.h"
+
+class ZdcTopologyTester : public edm::one::EDAnalyzer {
+public:
+ explicit ZdcTopologyTester(const edm::ParameterSet&);
+
+ static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
+
+private:
+ void analyze(edm::Event const&, edm::EventSetup const&) override;
+ void beginJob() override {}
+ void beginRun(edm::Run const&, edm::EventSetup const&) override {}
+ void endRun(edm::Run const&, edm::EventSetup const&) override {}
+ void doTest(const ZdcTopology& topology);
+
+ // ----------member data ---------------------------
+ const edm::ESGetToken tokTopo_;
+};
+
+ZdcTopologyTester::ZdcTopologyTester(const edm::ParameterSet&)
+ : tokTopo_{esConsumes(edm::ESInputTag{})} {}
+
+void ZdcTopologyTester::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
+ edm::ParameterSetDescription desc;
+ desc.setUnknown();
+ descriptions.add("zdcTopologyTester", desc);
+}
+
+void ZdcTopologyTester::analyze(edm::Event const&, edm::EventSetup const& iSetup) { doTest(iSetup.getData(tokTopo_)); }
+
+void ZdcTopologyTester::doTest(const ZdcTopology& topology) {
+ // Total number of valid cells
+ for (int idet = 0; idet < 4; idet++) {
+ int ndet(0);
+ std::string det = "EM";
+ HcalZDCDetId::Section section = HcalZDCDetId::EM;
+ if (idet == 1) {
+ det = "HAD";
+ section = HcalZDCDetId::HAD;
+ } else if (idet == 2) {
+ det ="LUM";
+ section = HcalZDCDetId::LUM;
+ } else if (idet == 3) {
+ det = "RPD";
+ section = HcalZDCDetId::RPD;
+ }
+ for (int depth = 1; depth <= HcalZDCDetId::kDepTot; ++depth) {
+ for (int zside = 0; zside <= 1; ++zside) {
+ bool forward = (zside == 0) ? true : false;
+ const HcalZDCDetId id(section, forward, depth);
+ if (topology.valid(id))
+ ++ndet;
+ }
+ }
+ edm::LogVerbatim("HCalGeom") << "Number of valid cells in " << det << ": " << ndet;
+ }
+
+ // First test on movements along eta/phi directions
+ edm::LogVerbatim("HCalGeom") << "\nTest on movements along transverse/longiudnal directions"
+ << "\n========================================================";
+ for (int idet = 0; idet < 4; idet++) {
+ HcalZDCDetId::Section section = HcalZDCDetId::EM;
+ if (idet == 1)
+ section = HcalZDCDetId::HAD;
+ else if (idet == 2)
+ section = HcalZDCDetId::LUM;
+ else if (idet == 3)
+ section = HcalZDCDetId::RPD;
+ for (int depth = 1; depth <= HcalZDCDetId::kDepTot; ++depth) {
+ for (int zside = 0; zside <= 1; ++zside) {
+ bool forward = (zside == 0) ? true : false;
+ const HcalZDCDetId id(section, forward, depth);
+ if (topology.valid(id)) {
+ std::vector idT = topology.transverse(id);
+ std::vector idL = topology.longitudinal(id);
+ edm::LogVerbatim("HCalGeom") << "Neighbours for : Tower " << id;
+ std::ostringstream st1;
+ st1 << " " << idT.size() << " sets transverse:";
+ for (auto& i : idT)
+ st1 << " " << (HcalZDCDetId)(i());
+ edm::LogVerbatim("HCalGeom") << st1.str();
+ std::ostringstream st2;
+ st2 << " " << idL.size() << " sets along Longitunal:";
+ for (auto& i : idL)
+ st2 << " " << (HcalZDCDetId)(i());
+ edm::LogVerbatim("HCalGeom") << st2.str();
+ }
+ }
+ }
+ }
+
+ // Check on Dense Index
+ edm::LogVerbatim("HCalGeom") << "\nCheck on Dense Index"
+ << "\n=====================";
+ for (int idet = 0; idet < 4; idet++) {
+ HcalZDCDetId::Section section = HcalZDCDetId::EM;
+ if (idet == 1)
+ section = HcalZDCDetId::HAD;
+ else if (idet == 2)
+ section = HcalZDCDetId::LUM;
+ else if (idet == 3)
+ section = HcalZDCDetId::RPD;
+ for (int depth = 1; depth <= HcalZDCDetId::kDepTot; ++depth) {
+ for (int zside = 0; zside <= 1; ++zside) {
+ bool forward = (zside == 0) ? true : false;
+ HcalZDCDetId cell(section, forward, depth);
+ if (topology.valid(cell)) {
+ unsigned int dense = topology.detId2DenseIndex(DetId(cell));
+ DetId id = topology.denseId2detId(dense);
+ std::string cherr = (cell.rawId() != id.rawId()) ? " **** ERROR *****" : "";
+ edm::LogVerbatim("HCalGeom") << cell << " Dense " << std::hex << dense << std::dec << " o/p "
+ << HcalZDCDetId(id) << cherr;
+ }
+ }
+ }
+ }
+}
+
+//define this as a plug-in
+DEFINE_FWK_MODULE(ZdcTopologyTester);
diff --git a/Geometry/ForwardGeometry/test/testZdcTopology_cfg.py b/Geometry/ForwardGeometry/test/testZdcTopology_cfg.py
new file mode 100644
index 0000000000000..c8adad4127255
--- /dev/null
+++ b/Geometry/ForwardGeometry/test/testZdcTopology_cfg.py
@@ -0,0 +1,67 @@
+###############################################################################
+# Way to use this:
+# cmsRun testZdcTopology_cfg.py type=2024
+#
+# Options for type 2021, 2023, 2024
+#
+###############################################################################
+import FWCore.ParameterSet.Config as cms
+import os, sys, imp, re
+import FWCore.ParameterSet.VarParsing as VarParsing
+
+####################################################################
+### SETUP OPTIONS
+options = VarParsing.VarParsing('standard')
+options.register('type',
+ "2024",
+ VarParsing.VarParsing.multiplicity.singleton,
+ VarParsing.VarParsing.varType.string,
+ "type of operations:2021, 2023, 2024")
+
+### get and parse the command line arguments
+options.parseArguments()
+
+geomFile = "Configuration.Geometry.GeometryExtended" + options.type + "Reco_cff"
+
+print(options)
+print("Geometry file: ", geomFile)
+
+####################################################################
+# Use the options
+
+from Configuration.Eras.Era_Run3_DDD_cff import Run3_DDD
+process = cms.Process('TestZdcTopology',Run3_DDD)
+
+process.load("SimGeneral.HepPDTESSource.pdt_cfi")
+process.load(geomFile)
+process.load("Geometry.ForwardGeometry.zdcTopologyTester_cfi")
+process.load('FWCore.MessageService.MessageLogger_cfi')
+
+if hasattr(process,'MessageLogger'):
+ process.MessageLogger.HCalGeom=dict()
+
+process.load("IOMC.RandomEngine.IOMC_cff")
+process.RandomNumberGeneratorService.generator.initialSeed = 456789
+
+process.source = cms.Source("EmptySource")
+
+process.generator = cms.EDProducer("FlatRandomEGunProducer",
+ PGunParameters = cms.PSet(
+ PartID = cms.vint32(14),
+ MinEta = cms.double(-3.5),
+ MaxEta = cms.double(3.5),
+ MinPhi = cms.double(-3.14159265359),
+ MaxPhi = cms.double(3.14159265359),
+ MinE = cms.double(9.99),
+ MaxE = cms.double(10.01)
+ ),
+ AddAntiParticle = cms.bool(False),
+ Verbosity = cms.untracked.int32(0),
+ firstRun = cms.untracked.uint32(1)
+)
+
+process.maxEvents = cms.untracked.PSet(
+ input = cms.untracked.int32(1)
+)
+
+process.p1 = cms.Path(process.generator*process.zdcTopologyTester)