-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46404 from bsunanda/Run3-hcx377C
Run3-377C Add the testing code for the ZDC Topology class
- Loading branch information
Showing
4 changed files
with
207 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
#include <iostream> | ||
#include <sstream> | ||
#include <string> | ||
#include <vector> | ||
|
||
#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<edm::one::WatchRuns> { | ||
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<ZdcTopology, HcalRecNumberingRecord> tokTopo_; | ||
}; | ||
|
||
ZdcTopologyTester::ZdcTopologyTester(const edm::ParameterSet&) | ||
: tokTopo_{esConsumes<ZdcTopology, HcalRecNumberingRecord>(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<DetId> idT = topology.transverse(id); | ||
std::vector<DetId> 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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |