9#include "GaudiKernel/SystemOfUnits.h"
23 std::stringstream sstr{};
24 sstr <<
"[x,y,z]=(" <<
v.x() <<
"," <<
v.y() <<
"," <<
v.z()
25 <<
") [theta/eta/phi]=(" << (
v.theta() / Gaudi::Units::degree) <<
","
26 <<
v.eta() <<
"," <<
v.phi() <<
")";
33 auto out_file = std::make_unique<TFile>(
m_outFile.value().c_str(),
"RECREATE");
34 if (!out_file || !out_file->IsOpen() || out_file->IsZombie()) {
37 return StatusCode::FAILURE;
39 out_file->mkdir(
"SinglePads");
40 out_file->mkdir(
"ActiveSurfaces");
44 std::unique_ptr<TGraph>&
graph = id_graph.second;
49 const int lay = is_mm ? mm_helper.
gasGap(
id) : st_helper.
gasGap(
id);
50 const std::string ch_name =
53 std::to_string(std::abs(stEta)) + (stEta > 0 ?
"A" :
"C") +
55 std::to_string(ml) +
"L" + std::to_string(lay);
56 TDirectory* dir = out_file->GetDirectory(
"SinglePads");
57 dir->WriteObject(
graph.get(), ch_name.c_str());
59 const int signed_lay =
layerId(
id);
60 std::unique_ptr<TGraph>& lay_graph =
m_nswLayers[signed_lay];
63 std::string lay_name = std::string{is_mm ?
"MMG" :
"STG"} +
"W" +
64 std::to_string(ml) + (stEta > 0 ?
"A" :
"C") +
66 out_file->WriteObject(lay_graph.get(), lay_name.c_str());
71 dir = out_file->GetDirectory(
"ActiveSurfaces");
73 dir->WriteObject(active_area.get(), lay_name.c_str());
76 return StatusCode::SUCCESS;
83 return StatusCode::SUCCESS;
87 return StatusCode::SUCCESS;
88 ATH_MSG_INFO(
"Executing NSWGeoPlottingAlg for the first time");
89 const EventContext& ctx = Gaudi::Hive::currentContext();
97 std::unique_ptr<TGraph>& pad_graph = id_graph.second;
99 const int signed_lay =
layerId(
id);
100 std::unique_ptr<TGraph>& wheel_graph =
m_nswLayers[signed_lay];
115 if ((is_mm || std::abs(locPos.y()) < 1.e-3) &&
117 ATH_MSG_ALWAYS(
" Backmapping of the strip number did not work for "
119 << locPos.x() <<
" " << locPos.y() <<
" "
128 pad_graph->SetPoint(pad_graph->GetN(), globPos.x(), globPos.y());
130 wheel_graph->SetPoint(wheel_graph->GetN(), globPos.x(), globPos.y());
137 Amg::Vector2D l_cen{Amg::Vector2D::Zero()}, l_left{Amg::Vector2D::Zero()},
138 l_right{Amg::Vector2D::Zero()};
144 const int chan = id_helper.
channel(
id);
146 design->
center(chan, l_cen);
163 <<
" does not have strip "
164 <<
strip <<
"... Why?");
170 <<
" does not have strip " <<
strip
177 <<
" does not have strip "
178 <<
strip <<
"... Why?");
181 auto uv_intersects = [&]() {
184 return StatusCode::SUCCESS;
185 const int gap = id_helper.
gasGap(
id);
187 if ((ml == 1 && gap == 2) || (ml == 2 && gap == 4))
188 return StatusCode::SUCCESS;
192 const int u_gap = ml == 1 ? 3 : 1;
193 const int v_gap = ml == 1 ? 4 : 2;
198 u_center{Amg::Vector3D::Zero()}, v_center{Amg::Vector3D::Zero()};
200 u_left{Amg::Vector3D::Zero()}, v_left{Amg::Vector3D::Zero()};
202 u_right{Amg::Vector3D::Zero()}, v_right{Amg::Vector3D::Zero()};
204 global_points(x_id, x_left, x_center, x_right);
205 global_points(u_id, u_left, u_center, u_right);
206 global_points(v_id, v_left, v_center, v_right);
212 std::optional<double> uv_isect =
216 ATH_MSG_ERROR(
"Failed to intersect the uv strips for identifiers "
222 return StatusCode::FAILURE;
224 const Amg::Vector3D uv_ipoint = u_center + (*uv_isect) * u_dir;
225 const Amg::Vector2D cen_diff = (uv_ipoint - x_center).block<2, 1>(0, 0);
226 if (cen_diff.dot(cen_diff) > std::numeric_limits<float>::epsilon()) {
233 <<
" intersect at the center of the corresponding x "
234 "strip. But they don't. "
237 <<
" vs." << std::endl
243 std::optional<double> ux_isect =
246 ATH_MSG_ERROR(
"Failed to intersect the ux strips for identifiers "
252 return StatusCode::FAILURE;
255 <<
to_string(x_center + (*ux_isect) * x_dir) <<
" "
258 std::optional<double> vx_isect =
261 ATH_MSG_ERROR(
"Failed to intersect the vx strips for identifiers "
267 return StatusCode::FAILURE;
270 <<
to_string(x_center + (*vx_isect) * x_dir) <<
" "
273 return StatusCode::SUCCESS;
279 if (!surface_histo) {
285 double d = std::max(std::max(design->
xSize(), design->
maxYSize()),
287 for (
double x = surf_cent.x() - d;
x <= surf_cent.x() + d;
x += 1) {
288 for (
double y = surf_cent.y() - d;
y <= surf_cent.y() + d;
y += 1) {
297 surface_histo->Fill(
x,
y);
303 return StatusCode::SUCCESS;
309 for (
const std::string station : {
"MML",
"MMS"}) {
316 bool is_valid{
false};
325 for (
int i_layer = 1; i_layer <= 4; ++i_layer) {
327 id_helper.
channelID(module_id, ml, i_layer, 10);
328 m_nswPads[id] = std::make_unique<TGraph>();
330 int signed_layer =
layerId(
id);
332 m_nswLayers[signed_layer] = std::make_unique<TGraph>();
337 "ActiveNSW;x [mm]; y [mm]", 1000, -5001, 5001., 1000,
345 return StatusCode::SUCCESS;
352 int lay = id_helper.
gasGap(
id);
361 int lay = id_helper.
gasGap(
id);
362 return (16 + 4 * (ml - 1) + (lay - 1)) * (
eta > 0 ? 1 : -1);
370 for (
const std::string station : {
"STS",
"STL"}) {
379 bool is_valid{
false};
387 for (
int lay = 1; lay <= 4; ++lay) {
392 for (
const Identifier&
id : {strip_id, wire_id}) {
393 m_nswPads[id] = std::make_unique<TGraph>();
394 int signed_layer =
layerId(
id);
396 m_nswLayers[signed_layer] = std::make_unique<TGraph>();
401 "ActiveNSW;x [mm]; y [mm]", 1000, -5001, 5001., 1000,
410 return StatusCode::SUCCESS;
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
const PlainObject unit() const
This is a plugin that makes Eigen look like CLHEP & defines some convenience methods.
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ALWAYS(x)
#define ATH_MSG_WARNING(x)
const ServiceHandle< StoreGateSvc > & detStore() const
TGraph * graph(const std::string &graphName, const std::string &tDir="", const std::string &stream="")
Simplify the retrieval of registered TGraphs.
Identifier channelID(int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int channel) const
Identifier elementID(int stationName, int stationEta, int stationPhi) const
Identifier multilayerID(const Identifier &channeldID) const
int channel(const Identifier &id) const override
static int stationPhiMin()
int gasGap(const Identifier &id) const override
get the hashes
static int multilayerMin()
static int multilayerMax()
static int stationPhiMax()
int multilayer(const Identifier &id) const
An MMReadoutElement corresponds to a single STGC module; therefore typicaly a barrel muon station con...
virtual int numberOfStrips(const Identifier &layerId) const override final
number of strips per layer
bool insideActiveBounds(const Identifier &id, const Amg::Vector2D &locpos, double tol1=0., double tol2=0.) const
boundary check Wrapper Trk::PlaneSurface::insideBounds() taking into account the passivated width
const MuonChannelDesign * getDesign(const Identifier &id) const
returns the MuonChannelDesign class for the given identifier
virtual const Trk::PlaneSurface & surface() const override
access to chamber surface (phi orientation), uses the first gas gap
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
const MMReadoutElement * getMMReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
const sTgcReadoutElement * getsTgcReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
StatusCode initMicroMega()
std::map< int, std::unique_ptr< TGraph > > m_nswLayers
Map showing the edges of the 16 layers of the NSW.
std::map< Identifier, std::unique_ptr< TGraph > > m_nswPads
Map containing each PCB of the NSW seperately.
StatusCode execute() override
std::map< int, std::unique_ptr< TH1 > > m_nswActiveAreas
Map showing the active areas of the NSW to show the passivation.
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_DetectorManagerKey
Gaudi::Property< std::string > m_outFile
StatusCode finalize() override
StatusCode initialize() override
int layerId(const Identifier &id) const
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
An sTgcReadoutElement corresponds to a single STGC module; therefore typicaly a barrel muon station c...
const MuonChannelDesign * getDesign(const Identifier &id) const
returns the MuonChannelDesign class for the given identifier
virtual int numberOfStrips(const Identifier &layerId) const override final
number of strips per layer
const std::string & stationNameString(const Identifier &id) const
virtual bool insideBounds(const Amg::Vector2D &locpos, double tol1=0., double tol2=0.) const override
This method calls the inside() method of the Bounds.
virtual bool globalToLocal(const Amg::Vector3D &glob, const Amg::Vector3D &mom, Amg::Vector2D &loc) const =0
Specified by each surface type: GlobalToLocal method without dynamic memory allocation - boolean chec...
virtual void localToGlobal(const Amg::Vector2D &locp, const Amg::Vector3D &mom, Amg::Vector3D &glob) const =0
Specified by each surface type: LocalToGlobal method without dynamic memory allocation.
This is the base class for all tracking detector elements with read-out relevant information.
virtual const Amg::Vector3D & center() const =0
Return the center of the element.
virtual const Surface & surface() const =0
Return surface associated with this detector element.
int multilayer(const Identifier &id) const
static int stationPhiMax()
int channelType(const Identifier &id) const
Identifier elementID(int stationName, int stationEta, int stationPhi) const
static int multilayerMax()
static int stationPhiMin()
static int stationEtaMin()
static int multilayerMin()
static int stationEtaMax()
int gasGap(const Identifier &id) const override
get the hashes
Identifier channelID(int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int channelType, int channel) const
Identifier multilayerID(const Identifier &channeldID) const
std::optional< double > intersect(const AmgVector(N)&posA, const AmgVector(N)&dirA, const AmgVector(N)&posB, const AmgVector(N)&dirB)
Calculates the point B' along the line B that's closest to a second line A.
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Matrix< double, 3, 1 > Vector3D
Ensure that the Athena extensions are properly loaded.
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
bool center(int channel, Amg::Vector2D &pos) const
STRIPS ONLY: Returns the center on the strip.
bool leftEdge(int channel, Amg::Vector2D &pos) const
STRIPS ONLY: Returns the left edge of the strip.
int numberOfMissingBottomStrips() const
Returns the number of missing bottom strips.
bool rightEdge(int channel, Amg::Vector2D &pos) const
STRIPS ONLY: Returns the right edge of the strip.
double hasStereoAngle() const
returns whether the stereo angle is non-zero
int channelNumber(const Amg::Vector2D &pos) const
calculate local channel number, range 1=nstrips like identifiers. Returns -1 if out of range