Skip to content

Commit f1e6517

Browse files
authored
Merge pull request #48011 from bsunanda/Phase2-hgx363Y
Phase2-hgx363Y Add an example to list cell IDs of a given wafer type
2 parents c9fa672 + 82cdbac commit f1e6517

File tree

4 files changed

+211
-1
lines changed

4 files changed

+211
-1
lines changed

Geometry/HGCalGeometry/plugins/HGCalGeometryESProducer.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,9 @@ HGCalGeometryESProducer::~HGCalGeometryESProducer() {}
6868
// ------------ method called to produce the data ------------
6969
HGCalGeometryESProducer::ReturnType HGCalGeometryESProducer::produce(const IdealGeometryRecord& iRecord) {
7070
const auto& topo = iRecord.get(topologyToken_);
71+
#ifdef EDM_ML_DEBUG
7172
edm::LogVerbatim("HGCalGeom") << "Create HGCalGeometry (*topo) for " << name_;
72-
73+
#endif
7374
HGCalGeometryLoader builder;
7475
return ReturnType(builder.build(topo));
7576
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import FWCore.ParameterSet.Config as cms
2+
3+
from Geometry.HGCalGeometry.hgcalListValidCellsEE_cfi import *
4+
5+
hgcalListValidCellsHE = hgcalListValidCellsEE.clone(
6+
detector = "HGCalHESiliconSensitive",
7+
)
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
// -*- C++ -*-
2+
//
3+
// Package: HGCalListValidCells
4+
// Class: HGCalListValidCells
5+
//
6+
/**\class HGCalListValidCells HGCalListValidCells.cc
7+
test/HGCalListValidCells.cc
8+
9+
Description: <one line class summary>
10+
11+
Implementation:
12+
<Notes on implementation>
13+
*/
14+
//
15+
// Original Author: Sunanda Banerjee
16+
// Created: Mon 2025/05/02
17+
//
18+
//
19+
20+
// system include files
21+
#include <algorithm>
22+
#include <iostream>
23+
#include <memory>
24+
#include <string>
25+
#include <vector>
26+
27+
// user include files
28+
#include "FWCore/Framework/interface/Frameworkfwd.h"
29+
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
30+
#include "FWCore/Framework/interface/Event.h"
31+
#include "FWCore/Framework/interface/EventSetup.h"
32+
#include "FWCore/Framework/interface/MakerMacros.h"
33+
#include "FWCore/MessageLogger/interface/MessageLogger.h"
34+
#include "FWCore/ParameterSet/interface/ParameterSet.h"
35+
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
36+
37+
#include "DataFormats/DetId/interface/DetId.h"
38+
#include "DataFormats/GeometryVector/interface/GlobalPoint.h"
39+
#include "Geometry/HGCalGeometry/interface/HGCalGeometry.h"
40+
#include "Geometry/Records/interface/IdealGeometryRecord.h"
41+
42+
class HGCalListValidCells : public edm::one::EDAnalyzer<> {
43+
public:
44+
explicit HGCalListValidCells(const edm::ParameterSet&);
45+
~HGCalListValidCells() override = default;
46+
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
47+
48+
void beginJob() override {}
49+
void analyze(edm::Event const& iEvent, edm::EventSetup const&) override;
50+
void endJob() override {}
51+
52+
private:
53+
const std::string name_;
54+
const int partialType_, verbosity_;
55+
const edm::ESGetToken<HGCalGeometry, IdealGeometryRecord> geomToken_;
56+
};
57+
58+
HGCalListValidCells::HGCalListValidCells(const edm::ParameterSet& iC)
59+
: name_(iC.getParameter<std::string>("detector")),
60+
partialType_(iC.getParameter<int>("partialType")),
61+
verbosity_(iC.getParameter<int>("verbosity")),
62+
geomToken_(esConsumes<HGCalGeometry, IdealGeometryRecord>(edm::ESInputTag("", name_))) {}
63+
64+
void HGCalListValidCells::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
65+
edm::ParameterSetDescription desc;
66+
desc.add<std::string>("detector", "HGCalEESensitive");
67+
desc.add<int>("partialType", 16);
68+
desc.add<int>("verbosity", 0);
69+
descriptions.add("hgcalListValidCellsEE", desc);
70+
}
71+
72+
// ------------ method called to produce the data ------------
73+
void HGCalListValidCells::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
74+
const auto& geom = &iSetup.getData(geomToken_);
75+
DetId::Detector det = (name_ == "HGCalHESiliconSensitive") ? DetId::HGCalHSi : DetId::HGCalEE;
76+
edm::LogVerbatim("HGCalGeom") << "Perform test for " << name_ << " Detector " << det;
77+
78+
std::string parts[26] = {"Full", "Five", "ChopTwo", "ChopTwoM", "Half", "Semi", "Semi2", "Three", "Half2",
79+
"Five2", "????", "LDTop", "LDBottom", "LDLeft", "LDRight", "LDFive", "LDThree", "????",
80+
"????", "????", "????", "HDTop", "HDBottom", "HDLeft", "HDRight", "HDFive"};
81+
const std::vector<DetId>& ids = geom->getValidDetIds();
82+
edm::LogVerbatim("HGCalGeom") << "Find the list of valid DetIds of type " << partialType_ << ":"
83+
<< parts[partialType_] << " among a list of " << ids.size() << " valid ids of "
84+
<< geom->cellElement();
85+
std::vector<HGCSiliconDetId> detIds;
86+
87+
for (auto const& id : ids) {
88+
if ((id.det() == DetId::HGCalEE) || (id.det() == DetId::HGCalHSi)) {
89+
HGCSiliconDetId detId(id);
90+
HGCalParameters::waferInfo info =
91+
geom->topology().dddConstants().waferInfo(detId.layer(), detId.waferU(), detId.waferV());
92+
if (info.part == partialType_) {
93+
if (std::find(detIds.begin(), detIds.end(), detId) == detIds.end())
94+
detIds.emplace_back(detId);
95+
}
96+
} else {
97+
edm::LogVerbatim("HGCalGeom") << "Illegal Det " << id.det() << " in " << std::hex << id.rawId() << std::dec
98+
<< " ERROR";
99+
}
100+
}
101+
edm::LogVerbatim("HGCalGeom") << "There are " << detIds.size() << " valid Ids with partial type " << partialType_
102+
<< ":" << parts[partialType_];
103+
if (verbosity_ > 0) {
104+
for (auto const detId : detIds)
105+
edm::LogVerbatim("HGCalGeom") << " " << detId;
106+
}
107+
108+
if (detIds.size() > 0) {
109+
std::vector<int> cellPatterns;
110+
for (auto const& detId : detIds) {
111+
int iuv = (100 * detId.cellU() + detId.cellV());
112+
if (std::find(cellPatterns.begin(), cellPatterns.end(), iuv) == cellPatterns.end())
113+
cellPatterns.emplace_back(iuv);
114+
}
115+
std::sort(cellPatterns.begin(), cellPatterns.end());
116+
edm::LogVerbatim("HGCalGeom") << "There are " << cellPatterns.size() << " different cell patterns:";
117+
for (const auto& iuv : cellPatterns) {
118+
int u = ((iuv / 100) % 100);
119+
int v = (iuv % 100);
120+
edm::LogVerbatim("HGCalGeom") << "u = " << std::setw(3) << u << " v = " << std::setw(3) << v;
121+
}
122+
}
123+
}
124+
125+
// define this as a plug-in
126+
DEFINE_FWK_MODULE(HGCalListValidCells);
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
###############################################################################
2+
# Way to use this:
3+
# cmsRun testHGCalListValidCells_cfg.py geometry=D110
4+
#
5+
# Options for geometry D110, D120
6+
#
7+
###############################################################################
8+
import FWCore.ParameterSet.Config as cms
9+
import os, sys, imp, re
10+
import FWCore.ParameterSet.VarParsing as VarParsing
11+
12+
####################################################################
13+
### SETUP OPTIONS
14+
options = VarParsing.VarParsing('standard')
15+
options.register('geometry',
16+
"D110",
17+
VarParsing.VarParsing.multiplicity.singleton,
18+
VarParsing.VarParsing.varType.string,
19+
"geometry of operations: D110, D120")
20+
21+
### get and parse the command line arguments
22+
options.parseArguments()
23+
print(options)
24+
25+
####################################################################
26+
# Use the options
27+
28+
geomName = "Run4" + options.geometry
29+
geomFile = "Configuration.Geometry.GeometryExtended" + geomName + "Reco_cff"
30+
import Configuration.Geometry.defaultPhase2ConditionsEra_cff as _settings
31+
GLOBAL_TAG, ERA = _settings.get_era_and_conditions(geomName)
32+
33+
print("Geometry Name: ", geomName)
34+
print("Geom file Name: ", geomFile)
35+
print("Global Tag Name: ", GLOBAL_TAG)
36+
print("Era Name: ", ERA)
37+
38+
process = cms.Process('PROD',ERA)
39+
40+
process.load(geomFile)
41+
process.load("SimGeneral.HepPDTESSource.pdt_cfi")
42+
process.load("Geometry.HGCalGeometry.hgcalListValidCells_cff")
43+
44+
process.load('FWCore.MessageService.MessageLogger_cfi')
45+
if hasattr(process,'MessageLogger'):
46+
process.MessageLogger.HGCalGeom=dict()
47+
process.MessageLogger.HGCalGeomX=dict()
48+
49+
process.load("IOMC.RandomEngine.IOMC_cff")
50+
process.RandomNumberGeneratorService.generator.initialSeed = 456789
51+
52+
process.source = cms.Source("EmptySource")
53+
54+
process.generator = cms.EDProducer("FlatRandomEGunProducer",
55+
PGunParameters = cms.PSet(
56+
PartID = cms.vint32(14),
57+
MinEta = cms.double(-3.5),
58+
MaxEta = cms.double(3.5),
59+
MinPhi = cms.double(-3.14159265359),
60+
MaxPhi = cms.double(3.14159265359),
61+
MinE = cms.double(9.99),
62+
MaxE = cms.double(10.01)
63+
),
64+
AddAntiParticle = cms.bool(False),
65+
Verbosity = cms.untracked.int32(0),
66+
firstRun = cms.untracked.uint32(1)
67+
)
68+
69+
process.maxEvents = cms.untracked.PSet(
70+
input = cms.untracked.int32(1)
71+
)
72+
73+
#process.hgcalListValidCellsEE.verbosity = 1
74+
#process.hgcalListValidCellsHE.verbosity = 1
75+
76+
process.p1 = cms.Path(process.generator*process.hgcalListValidCellsEE*process.hgcalListValidCellsHE)

0 commit comments

Comments
 (0)