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

MTD geometry: add test for pixel acceptance in module #42739

Merged
merged 2 commits into from
Sep 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions Geometry/MTDGeometryBuilder/test/MTDDigiGeometryAnalyzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

#include <fstream>

#include "CLHEP/Random/RandFlat.h"

// class declaration

class MTDDigiGeometryAnalyzer : public edm::one::EDAnalyzer<> {
Expand All @@ -41,6 +43,7 @@ class MTDDigiGeometryAnalyzer : public edm::one::EDAnalyzer<> {
void analyseRectangle(const GeomDetUnit& det);
void checkRotation(const GeomDetUnit& det);
void checkRectangularMTDTopology(const RectangularMTDTopology&);
void checkPixelsAcceptance(const GeomDetUnit& det);

std::stringstream sunitt;

Expand Down Expand Up @@ -116,6 +119,13 @@ void MTDDigiGeometryAnalyzer::analyze(const edm::Event& iEvent, const edm::Event
}
}

edm::LogInfo("MTDDigiGeometryAnalyzer") << "Acceptance of BTL module:";
auto const& btldet = *(dynamic_cast<const MTDGeomDetUnit*>(pDD->detsBTL().front()));
checkPixelsAcceptance(btldet);
edm::LogInfo("MTDDigiGeometryAnalyzer") << "Acceptance of ETL module:";
auto const& etldet = *(dynamic_cast<const MTDGeomDetUnit*>(pDD->detsETL().front()));
checkPixelsAcceptance(etldet);

edm::LogInfo("MTDDigiGeometryAnalyzer") << "Additional MTD geometry content:"
<< "\n"
<< " # dets = " << pDD->dets().size() << "\n"
Expand Down Expand Up @@ -209,5 +219,33 @@ void MTDDigiGeometryAnalyzer::checkRotation(const GeomDetUnit& det) {
}
}

void MTDDigiGeometryAnalyzer::checkPixelsAcceptance(const GeomDetUnit& det) {
const Bounds& bounds = det.surface().bounds();
const RectangularPlaneBounds* tb = dynamic_cast<const RectangularPlaneBounds*>(&bounds);
if (tb == nullptr)
return; // not trapezoidal

double length = tb->length();
double width = tb->width();
edm::LogVerbatim("MTDDigiGeometryAnalyzer") << "X (width) = " << width << " Y (length) = " << length;

const ProxyMTDTopology& topoproxy = static_cast<const ProxyMTDTopology&>(det.topology());
const RectangularMTDTopology& topo = static_cast<const RectangularMTDTopology&>(topoproxy.specificTopology());

const size_t maxindex = 100000;
size_t inpixel(0);
for (size_t index = 0; index < maxindex; index++) {
double ax = CLHEP::RandFlat::shoot(-width * 0.5, width * 0.5);
double ay = CLHEP::RandFlat::shoot(-length * 0.5, length * 0.5);
LocalPoint hit(ax, ay, 0);
if (topo.isInPixel(hit)) {
inpixel++;
}
}
double acc = (double)inpixel / (double)maxindex;
double accerr = std::sqrt(acc * (1. - acc) / (double)maxindex);
edm::LogVerbatim("MTDDigiGeometryAnalyzer") << "Acceptance: " << acc << " +/- " << accerr;
}

//define this as a plug-in
DEFINE_FWK_MODULE(MTDDigiGeometryAnalyzer);