25 using PrimitivesVec_t = MuonValR4::TrackVisualizationTool::PrimitivesVec_t;
26 constexpr int truthColor = kOrange +2;
28 constexpr int ColorBarrel = kRed;
29 constexpr int ColorEndcapA = kBlue;
30 constexpr int ColorEndcapC = kGreen +2;
31 constexpr double inM = 1./ Gaudi::Units::m;
33 constexpr double extraMargin = 50.*Gaudi::Units::cm * inM;
38 std::unique_ptr<TMarker> drawMarker(
const Amg::Vector2D& pos,
const int mStyle,
const int mColor,
const int mSize = 2) {
39 auto marker = std::make_unique<TMarker>(
pos.x(),
pos.y(), mStyle);
40 marker->SetMarkerColor(mColor);
41 marker->SetMarkerSize(mSize);
46 constexpr double arrowLength = 2.*Gaudi::Units::m;
48 auto arrow = std::make_unique<TArrow>(
start.x(),
start.y(),
end.x(),
end.y(),0.01);
49 arrow->SetLineColor(
color);
50 arrow->SetLineWidth(2);
51 arrow->SetLineStyle(lineStyle);
57 const bool openMarker,
const bool onSeed) {
63 return onSeed ? (openMarker ? kOpenTriangleUp : kFullTriangleUp)
64 : (openMarker ? kOpenTriangleDown : kFullTriangleDown);
66 return onSeed ? (openMarker ? kOpenCrossX : kFullCrossX)
67 : (openMarker ? kOpenCross : kFullCross);
69 return onSeed ? (openMarker ? kOpenFourTrianglesX: kFullFourTrianglesX)
70 : (openMarker ? kOpenThreeTriangles : kFullThreeTriangles);
82 constexpr double phi = 0.6180339887498949;
83 const double h = 360 * std::fmod(0.13 +
phi *
double(iSeed), 1.0);
84 constexpr double s = 0.75;
85 constexpr double v = 0.95;
87 float r=0.f, g=0.f, b=0.f;
88 TColor::HLS2RGB(
h, s, v,
r, g, b);
89 return TColor::GetColor(
r, g, b);
98 colors.insert(std::make_pair(
color, std::move(box)));
105 legend->AddEntry(tMarker.get(),
label.c_str(),
"P");
106 markers.insert(std::make_pair(marker, std::move(tMarker)));
111 canvas.add(std::move(
legend));
112 for (
auto&[i, obj] :
colors){
113 canvas.add(std::move(obj));
116 canvas.add(std::move(obj));
124 return Amg::Vector2D{ posOnCylinder[1]*inM, posOnCylinder[0]*inM};
144 return StatusCode::SUCCESS;
150 displaySeeds(ctx, seederObj, segments, seeds, PrimitivesVec_t{});
156 PrimitivesVec_t && extPrimitives)
const {
174 const EventContext& ctx,
180 std::format(
"SeedSegsGlobalTruth{:}", view ==
DisplayView::XY ?
"XY" :
"RZ"));
189 PrimitivesVec_t primitives{};
204 const auto chIdx = seg->chamberIndex();
205 const int mStyleTruth = stationMarkerSyle(chIdx,
true,
true);
208 const double x = p.x() * inM;
209 const double y = p.y() * inM;
210 const double z = p.z() * inM;
211 const double r = std::hypot(
x,
y);
215 primitives.emplace_back(drawMarker(plotPos, mStyleTruth, truthColor, 3));
218 const double dir_x = seg->direction().x() * inM;
219 const double dir_y = seg->direction().y() * inM;
220 const double dir_z = seg->direction().z() * inM;
224 primitives.emplace_back(drawArrow2D(plotPos, plotDir, truthColor));
231 canvas->expandPad(plotPos.x() - extraMargin, plotPos.y() - extraMargin);
232 canvas->expandPad(plotPos.x() + extraMargin, plotPos.y() + extraMargin);
240 for (std::size_t iSeed = 0; iSeed < seeds.size(); ++iSeed) {
244 std::string seedLabel = std::format(
"s{:d}: ",
static_cast<int>(iSeed));
249 const auto chIdx = seg->chamberIndex();
250 const int mStyle = stationMarkerSyle(chIdx,
false,
true);
253 const double x = p.x() * inM;
254 const double y = p.y() * inM;
255 const double z = p.z() * inM;
256 const double r = std::hypot(
x,
y);
261 primitives.emplace_back(drawMarker(plotPos, mStyle,
color));
264 const double dir_x = seg->direction().x() * inM;
265 const double dir_y = seg->direction().y() * inM;
266 const double dir_z = seg->direction().z() * inM;
270 primitives.emplace_back(drawArrow2D(plotPos, plotDir,
color));
273 seedLabel +=
label +
"_";
282 canvas->expandPad(plotPos.x() - extraMargin, plotPos.y() - extraMargin);
283 canvas->expandPad(plotPos.x() + extraMargin, plotPos.y() + extraMargin);
290 if (!drewAny) { canvas->trash();
return; }
292 for (
auto& p : primitives) canvas->add(std::move(p));
293 legend.fillPrimitives(*canvas);
304 PrimitivesVec_t&& extPrimitives)
const{
322 return std::ranges::any_of(seeds,[segment, loc](
const MsTrackSeed& seed){
323 return seed.location() == loc && std::ranges::find(seed.segments(), segment) != seed.segments().end();
331 bool drawnPoint{
false};
336 using namespace Muon;
339 const int mColor = msSector->
barrel() ? ColorBarrel : (msSector->
side() > 0 ? ColorEndcapA : ColorEndcapC);
341 for (
const auto secProj : {leftOverlap, center, rightOverlap}) {
353 const bool isGood = onSeed(segment, loc);
354 const int mStyle = stationMarkerSyle(chIdx,
true, isGood);
357 extPrimitives.emplace_back( drawMarker(markerPos, mStyle, mColor));
358 canvas->add( drawMarker(markerPos, mStyle, mColor));
361 const double r = markerPos.mag() + extraMargin;
362 canvas->expandPad(
r,
r);
363 canvas->expandPad(-
r, -
r);
365 canvas->expandPad(markerPos[0] - extraMargin, markerPos[1] - extraMargin);
366 canvas->expandPad(markerPos[0] + extraMargin, markerPos[1] + extraMargin);
369 isGood ?
"" :
" (discarded)"), mColor);
370 legend.addColor(mColor, msSector->
barrel() ?
"Barrel" : msSector->
side() > 0 ?
"Endcap A" :
"Endcap C");
381 kFullDiamond, kBlack));
382 legend.addMarker(kFullDiamond,
"track seed");
385 for (
unsigned int s = 1; s<=16 ; ++s) {
392 const int lStyle = s%2 ? kDashed : kDotted;
393 const double r = canvas->corner(Edges::xHigh);
398 auto theLine = std::make_unique<TLine>(0.,0., e1.x(), e1.y());
399 theLine->SetLineStyle(lStyle);
400 extPrimitives.insert(extPrimitives.begin(), std::move(theLine));
401 theLine = std::make_unique<TLine>(0.,0., e2.x(), e2.y());
402 theLine->SetLineStyle(lStyle);
403 extPrimitives.insert(extPrimitives.begin(), std::move(theLine));
404 theLine = std::make_unique<TLine>(e1.x(), e1.y(), e2.x(), e2.y());
405 theLine->SetLineStyle(lStyle);
406 extPrimitives.insert(extPrimitives.begin(), std::move(theLine));
408 legend.fillPrimitives(*canvas);
427 bool addedEntry{
false};
429 const auto chIdx = segment->chamberIndex();
430 const int mStyle = stationMarkerSyle(chIdx,
true,
true);
434 for (
const auto secProj : {leftOverlap, center, rightOverlap}) {
435 if (!sectorMap.
insideSector(segment->sector() + Acts::toUnderlying(secProj),
436 segment->position().phi())){
445 canvas.add(drawMarker(
viewVector(
phi, projected, view), mStyle, truthColor, 3));
452 legend.addColor(truthColor,
"truth");
457 const OptBoundPars_t& parsToExt,
458 const std::string& objName)
const {
465 Acts::ObjVisualization3D visualHelper{};
466 const std::string subDir = std::format(
"./ObjDisplays/{:}/",
m_subDir.value());
470 if (stepsResult.ok()) {
473 ATH_MSG_WARNING(
"Failed to extrapolate the seed for visualization: " << stepsResult.error().message());
483 unsigned fileVersion{0};
484 std::string finalStr{};
485 while (finalStr.empty() || std::filesystem::exists(finalStr)) {
486 finalStr = std::format(
"{:}/{:}_{:}_{:}_{:}.obj", subDir,
487 m_clientToken.preFixName, ctx.eventID().event_number(), ++fileVersion, segStr);
489 visualHelper.write(finalStr);
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
bool empty() const noexcept
Returns true if the collection is empty.
A spectrometer sector forms the envelope of all chambers that are placed in the same MS sector & laye...
int8_t side() const
Returns the side of the MS-sector 1 -> A side ; -1 -> C side.
bool barrel() const
Returns whether the sector is placed in the barrel.
Helper class to group muon sgements that may belong to a muon trajectory.
bool withinBounds(const Amg::Vector2D &projPos, const Location loc) const
Returns whether the expression on the cylinder is within the surface bounds.
Amg::Vector2D expressOnCylinder(const ActsTrk::GeometryContext &gctx, const xAOD::MuonSegment &segment, const Location loc, const SectorProjector proj) const
Expresses the segment on the cylinder surface.
static double projectedPhi(const int sector, const SectorProjector proj)
Returns the projected phi for a given sector and projector.
SectorProjector
Enumeration to select the sector projection.
const MuonGMR4::SpectrometerSector * msSector() const
Returns the associated MS sector.
double sectorPhi(int sector) const
returns the centeral phi position of a sector in radians
double sectorWidth(int sector) const
sector width (with overlap) in radians
bool insideSector(int sector, double phi) const
checks whether the phi position is consistent with sector
::Muon::MuonStationIndex::ChIndex chamberIndex() const
Returns the chamber index.
Amg::Vector3D position() const
Returns the position as Amg::Vector.
std::string label(const std::string &format, int i)
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Matrix< double, 3, 1 > Vector3D
This header ties the generic definitions in this package.
std::vector< MsTrackSeed > MsTrackSeedContainer
std::string printID(const xAOD::MuonSegment &seg)
Print the chamber ID of a segment, e.g.
const Segment * detailedSegment(const xAOD::MuonSegment &seg)
Helper function to navigate from the xAOD::MuonSegment to the MuonR4::Segment.
Lightweight algorithm to read xAOD MDT sim hits and (fast-digitised) drift circles from SG and fill a...
void ensureDirectory(const std::string &path)
Ensures that the subdirectory in the path is created.
std::unique_ptr< TLatex > drawLabel(const std::string &text, const double xPos, const double yPos, const double textSize=18, const bool useNDC=true, const int color=kBlack)
Create a TLatex label,.
std::vector< std::unique_ptr< TObject > > clone(const std::vector< std::unique_ptr< TObject > > &cloneMe)
int seedColorIdx(std::size_t iSeed)
void drawPropagation(const std::vector< Acts::detail::Step > &steps, Acts::ObjVisualization3D &visualHelper, const Acts::ViewConfig &viewConfig=Acts::s_viewLine)
Draws the recorded propagation steps as a polygon line.
constexpr int fullFilling
std::string removeNonAlphaNum(std::string str)
Removes all non-alpha numerical characters from a string.
void drawSegmentMeasurements(const ActsTrk::GeometryContext &gctx, const xAOD::MuonSegment &segment, Acts::ObjVisualization3D &visualHelper, const Acts::ViewConfig &viewConfig=Acts::s_viewSensitive)
Draw all uncalibrated measurements associated to the segment.
void drawSegmentLine(const ActsTrk::GeometryContext &gctx, const xAOD::MuonSegment &segment, Acts::ObjVisualization3D &visualHelper, const Acts::ViewConfig &viewConfig=Acts::s_viewLine, const double standardLength=1.*Gaudi::Units::m)
Draw a segment line inside the obj file.
std::unique_ptr< TBox > drawBox(const Amg::Vector3D &boxCenter, const double boxWidth, const double boxHeight, const int color=kGreen+2, const int fillStyle=hollowFilling, const int view=objViewEta)
Creates a box for drawing, e.g strip measurements.
const std::string & layerName(LayerIndex index)
convert LayerIndex into a string
LayerIndex
enum to classify the different layers in the muon spectrometer
LayerIndex toLayerIndex(ChIndex index)
convert ChIndex into LayerIndex
ChIndex
enum to classify the different chamber layers in the muon spectrometer
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
MuonSegmentContainer_v1 MuonSegmentContainer
Definition of the current "MuonSegment container version".
MuonSegment_v1 MuonSegment
Reference the current persistent version:
Helper to simultaneously calculate sin and cos of the same angle.
#define THROW_EXCEPTION(MESSAGE)