Skip to content

Commit 31aa627

Browse files
authored
Merge pull request #49158 from rdelliga/occupancy_ETL
ETL occupancy study
2 parents 66c19aa + 966f0ed commit 31aa627

File tree

2 files changed

+370
-6
lines changed

2 files changed

+370
-6
lines changed

Geometry/MTDGeometryBuilder/test/MTDDigiGeometryAnalyzer.cc

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,24 @@ class MTDDigiGeometryAnalyzer : public edm::one::EDAnalyzer<> {
5656

5757
void checkRectangularMTDTopology(const RectangularMTDTopology&);
5858
void checkPixelsAcceptance(const GeomDetUnit& det);
59+
void CheckETLstructure(const MTDGeometry&);
5960

6061
std::stringstream sunitt_;
6162

6263
edm::ESGetToken<MTDGeometry, MTDDigiGeometryRecord> mtdgeoToken_;
64+
65+
// Constants to define the bins for Eta
66+
static constexpr int n_bin_Eta = 3;
67+
static constexpr double eta_bins_edges_neg[n_bin_Eta + 1] = {-3.0, -2.5, -2.1, -1.5};
68+
static constexpr double eta_bins_edges_pos[n_bin_Eta + 1] = {1.5, 2.1, 2.5, 3.0};
69+
70+
// LGAD counter per Disc, DiscSide, and Sector: [disk][discSide][sector]
71+
static constexpr int n_discSide = 2;
72+
static constexpr int n_sector = 3; // Use size 3 to allow 1-based indexing (1 to 2)
73+
uint32_t LGADsPerDiscSideSector_[4][n_discSide][n_sector] = {};
74+
75+
// Counter for total LGADs per disk per eta bin: [disk][eta_bin]
76+
uint32_t LGADsPerDiskperEtaBin_[4][n_bin_Eta] = {{0}};
6377
};
6478

6579
MTDDigiGeometryAnalyzer::MTDDigiGeometryAnalyzer(const edm::ParameterSet& iConfig) {
@@ -128,6 +142,10 @@ void MTDDigiGeometryAnalyzer::analyze(const edm::Event& iEvent, const edm::Event
128142
auto const& etldet = *(dynamic_cast<const MTDGeomDetUnit*>(pDD->detsETL().front()));
129143
checkPixelsAcceptance(etldet);
130144

145+
// ETL structure prints
146+
edm::LogVerbatim("MTDDigiGeometryAnalyzer") << "\n";
147+
CheckETLstructure(*pDD);
148+
131149
edm::LogVerbatim("MTDUnitTest") << sunitt_.str();
132150
}
133151

@@ -178,5 +196,106 @@ void MTDDigiGeometryAnalyzer::checkPixelsAcceptance(const GeomDetUnit& det) {
178196
sunitt_ << " Acceptance: " << fround(acc, 3) << " +/- " << fround(accerr, 3);
179197
}
180198

199+
void MTDDigiGeometryAnalyzer::CheckETLstructure(const MTDGeometry& geom) {
200+
edm::LogVerbatim("MTDDigiGeometryAnalyzer") << "\n--- ETL Structure Validation ---";
201+
202+
// Reset counters
203+
for (int d = 0; d < 4; ++d) {
204+
for (int eta = 0; eta < n_bin_Eta; ++eta) {
205+
LGADsPerDiskperEtaBin_[d][eta] = 0;
206+
}
207+
for (int k = 0; k < n_discSide; ++k) {
208+
for (int l = 0; l < n_sector; ++l) {
209+
LGADsPerDiscSideSector_[d][k][l] = 0;
210+
}
211+
}
212+
}
213+
214+
uint32_t totalETLdets = 0;
215+
for (const auto& det : geom.detsETL()) {
216+
const GeomDet* thedet = det;
217+
ETLDetId detId(thedet->geographicalId());
218+
219+
// Get the global position of the detector center
220+
const GlobalPoint& global_point = thedet->position();
221+
double eta = global_point.eta();
222+
223+
int discSide = detId.discSide(); // 0 to 1
224+
int sector = detId.sector(); // 1 to 2
225+
226+
int idet = 999;
227+
if ((detId.zside() == -1) && (detId.nDisc() == 1)) {
228+
idet = 0;
229+
} else if ((detId.zside() == -1) && (detId.nDisc() == 2)) {
230+
idet = 1;
231+
} else if ((detId.zside() == 1) && (detId.nDisc() == 1)) {
232+
idet = 2;
233+
} else if ((detId.zside() == 1) && (detId.nDisc() == 2)) {
234+
idet = 3;
235+
} else {
236+
edm::LogWarning("EtlDigiHitsValidation") << "Unknown ETL DetId configuration: " << detId;
237+
continue;
238+
}
239+
240+
totalETLdets++;
241+
242+
// Count LGADs per Disc, Side, Sector
243+
LGADsPerDiscSideSector_[idet][discSide][sector]++;
244+
245+
// Count LGADs per disk per eta bin
246+
const double* eta_edges = (idet < 2) ? eta_bins_edges_neg : eta_bins_edges_pos;
247+
248+
for (int j = 0; j < n_bin_Eta; j++) {
249+
double lower_edge = eta_edges[j];
250+
double upper_edge = eta_edges[j + 1];
251+
252+
// Check if the center of the LGAD is within the bin
253+
if ((eta >= lower_edge && eta < upper_edge) || (idet < 2 && j == n_bin_Eta - 1 && eta <= upper_edge)) {
254+
LGADsPerDiskperEtaBin_[idet][j]++;
255+
break; // Found the bin
256+
}
257+
}
258+
}
259+
260+
// --- Print Summary ---
261+
262+
edm::LogVerbatim("MTDDigiGeometryAnalyzer") << " Total ETL Detectors (LGADs): " << totalETLdets << "\n";
263+
const char* diskNames[4] = {"Disc 1 (-Z)", "Disc 2 (-Z)", "Disc 1 (+Z)", "Disc 2 (+Z)"};
264+
265+
edm::LogVerbatim("MTDDigiGeometryAnalyzer") << "\n--- LGADs per Eta Bin and per Disk, DiscSide, Sector ---\n";
266+
for (int d = 0; d < 4; ++d) { // Physical Disk loop (0-3)
267+
std::string disk_name = diskNames[d];
268+
uint32_t total_disk = 0;
269+
for (int k = 0; k < n_discSide; ++k) {
270+
for (int l = 1; l < n_sector; ++l) {
271+
total_disk += LGADsPerDiscSideSector_[d][k][l];
272+
}
273+
}
274+
edm::LogVerbatim("MTDDigiGeometryAnalyzer") << "Region: " << disk_name << " | Total LGADs: " << total_disk << "\n";
275+
edm::LogVerbatim("MTDDigiGeometryAnalyzer") << " - LGADs per Eta Bin:\n";
276+
const double* eta_edges = (d < 2) ? eta_bins_edges_neg : eta_bins_edges_pos;
277+
for (int j = 0; j < n_bin_Eta; ++j) {
278+
edm::LogVerbatim("MTDDigiGeometryAnalyzer")
279+
<< " Eta [" << std::setprecision(1) << std::fixed << eta_edges[j] << ", " << eta_edges[j + 1]
280+
<< "): " << LGADsPerDiskperEtaBin_[d][j] << "\n";
281+
}
282+
for (int k = 0; k < n_discSide; ++k) {
283+
uint32_t total_discside = 0;
284+
for (int l = 1; l < n_sector; ++l) {
285+
total_discside += LGADsPerDiscSideSector_[d][k][l];
286+
}
287+
edm::LogVerbatim("MTDDigiGeometryAnalyzer") << " - Side: " << k << " | Total LGADs: " << total_discside << "\n";
288+
edm::LogVerbatim("MTDDigiGeometryAnalyzer") << " - Sectors: ";
289+
for (int l = 1; l < n_sector; ++l) {
290+
if (LGADsPerDiscSideSector_[d][k][l] > 0) {
291+
edm::LogVerbatim("MTDDigiGeometryAnalyzer")
292+
<< "Sec " << l << ": " << LGADsPerDiscSideSector_[d][k][l] << " | ";
293+
}
294+
}
295+
edm::LogVerbatim("MTDDigiGeometryAnalyzer") << "\n";
296+
}
297+
}
298+
}
299+
181300
//define this as a plug-in
182301
DEFINE_FWK_MODULE(MTDDigiGeometryAnalyzer);

0 commit comments

Comments
 (0)