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);
47 const bool openMarker,
const bool onSeed) {
53 return onSeed ? (openMarker ? kOpenTriangleUp : kFullTriangleUp)
54 : (openMarker ? kOpenTriangleDown : kFullTriangleDown);
56 return onSeed ? (openMarker ? kOpenCrossX : kFullCrossX)
57 : (openMarker ? kOpenCross : kFullCross);
59 return onSeed ? (openMarker ? kOpenFourTrianglesX: kFullFourTrianglesX)
60 : (openMarker ? kOpenThreeTriangles : kFullThreeTriangles);
72 constexpr double phi = 0.6180339887498949;
73 const double h = 360 * std::fmod(0.13 +
phi *
double(iSeed), 1.0);
74 constexpr double s = 0.75;
75 constexpr double v = 0.95;
77 float r=0.f, g=0.f, b=0.f;
78 TColor::HLS2RGB(
h, s, v,
r, g, b);
79 return TColor::GetColor(
r, g, b);
88 colors.insert(std::make_pair(
color, std::move(box)));
95 legend->AddEntry(tMarker.get(),
label.c_str(),
"P");
96 markers.insert(std::make_pair(marker, std::move(tMarker)));
101 canvas.add(std::move(
legend));
102 for (
auto&[i, obj] :
colors){
103 canvas.add(std::move(obj));
106 canvas.add(std::move(obj));
114 return Amg::Vector2D{ posOnCylinder[1]*inM, posOnCylinder[0]*inM};
134 return StatusCode::SUCCESS;
140 displaySeeds(ctx, seederObj, segments, seeds, PrimitivesVec_t{});
146 PrimitivesVec_t && extPrimitives)
const {
164 const EventContext& ctx,
170 std::format(
"SeedSegsGlobalTruth{:}", view ==
DisplayView::XY ?
"XY" :
"RZ"));
179 PrimitivesVec_t primitives{};
194 const double x = p.x() * inM;
195 const double y = p.y() * inM;
196 const double z = p.z() * inM;
197 const double r = std::hypot(
x,
y);
204 const auto chIdx = seg->chamberIndex();
205 const int mStyleTruth = stationMarkerSyle(chIdx,
true,
true);
207 primitives.emplace_back(drawMarker(plotPos, mStyleTruth, truthColor, 3));
212 canvas->expandPad(plotPos.x() - extraMargin, plotPos.y() - extraMargin);
213 canvas->expandPad(plotPos.x() + extraMargin, plotPos.y() + extraMargin);
221 for (std::size_t iSeed = 0; iSeed < seeds.size(); ++iSeed) {
225 std::string seedLabel = std::format(
"s{:d}: ",
static_cast<int>(iSeed));
231 const double x = p.x() * inM;
232 const double y = p.y() * inM;
233 const double z = p.z() * inM;
234 const double r = std::hypot(
x,
y);
240 const auto chIdx = seg->chamberIndex();
241 const int mStyle = stationMarkerSyle(chIdx,
false,
true);
243 primitives.emplace_back(drawMarker(plotPos, mStyle,
color));
246 seedLabel +=
label +
"_";
255 canvas->expandPad(plotPos.x() - extraMargin, plotPos.y() - extraMargin);
256 canvas->expandPad(plotPos.x() + extraMargin, plotPos.y() + extraMargin);
263 if (!drewAny) { canvas->trash();
return; }
265 for (
auto& p : primitives) canvas->add(std::move(p));
266 legend.fillPrimitives(*canvas);
277 PrimitivesVec_t&& extPrimitives)
const{
295 return std::ranges::any_of(seeds,[segment, loc](
const MsTrackSeed& seed){
296 return seed.location() == loc && std::ranges::find(seed.segments(), segment) != seed.segments().end();
304 bool drawnPoint{
false};
309 using namespace Muon;
312 const int mColor = msSector->
barrel() ? ColorBarrel : (msSector->
side() > 0 ? ColorEndcapA : ColorEndcapC);
314 for (
const auto secProj : {leftOverlap, center, rightOverlap}) {
326 const bool isGood = onSeed(segment, loc);
327 const int mStyle = stationMarkerSyle(chIdx,
true, isGood);
330 extPrimitives.emplace_back(drawMarker(markerPos, mStyle, mColor));
333 const double r = markerPos.mag() + extraMargin;
334 canvas->expandPad(
r,
r);
335 canvas->expandPad(-
r, -
r);
337 canvas->expandPad(markerPos[0] - extraMargin, markerPos[1] - extraMargin);
338 canvas->expandPad(markerPos[0] + extraMargin, markerPos[1] + extraMargin);
341 isGood ?
"" :
" (discarded)"), mColor);
342 legend.addColor(mColor, msSector->
barrel() ?
"Barrel" : msSector->
side() > 0 ?
"Endcap A" :
"Endcap C");
353 kFullDiamond, kBlack));
354 legend.addMarker(kFullDiamond,
"track seed");
357 for (
unsigned int s = 1; s<=16 ; ++s) {
364 const int lStyle = s%2 ? kDashed : kDotted;
365 const double r = canvas->corner(Edges::xHigh);
370 auto theLine = std::make_unique<TLine>(0.,0., e1.x(), e1.y());
371 theLine->SetLineStyle(lStyle);
372 extPrimitives.insert(extPrimitives.begin(), std::move(theLine));
373 theLine = std::make_unique<TLine>(0.,0., e2.x(), e2.y());
374 theLine->SetLineStyle(lStyle);
375 extPrimitives.insert(extPrimitives.begin(), std::move(theLine));
376 theLine = std::make_unique<TLine>(e1.x(), e1.y(), e2.x(), e2.y());
377 theLine->SetLineStyle(lStyle);
378 extPrimitives.insert(extPrimitives.begin(), std::move(theLine));
380 legend.fillPrimitives(*canvas);
399 bool addedEntry{
false};
401 const auto chIdx = segment->chamberIndex();
402 const int mStyle = stationMarkerSyle(chIdx,
true,
true);
406 for (
const auto secProj : {leftOverlap, center, rightOverlap}) {
407 if (!sectorMap.
insideSector(segment->sector() + Acts::toUnderlying(secProj),
408 segment->position().phi())){
417 canvas.add(drawMarker(
viewVector(
phi, projected, view), mStyle, truthColor, 3));
424 legend.addColor(truthColor,
"truth");
429 const OptBoundPars_t& parsToExt,
430 const std::string& objName)
const {
437 Acts::ObjVisualization3D visualHelper{};
438 const std::string subDir = std::format(
"./ObjDisplays/{:}/",
m_subDir.value());
442 if (stepsResult.ok()) {
445 ATH_MSG_WARNING(
"Failed to extrapolate the seed for visualization: " << stepsResult.error().message());
455 unsigned fileVersion{0};
456 std::string finalStr{};
457 while (finalStr.empty() || std::filesystem::exists(finalStr)) {
458 finalStr = std::format(
"{:}/{:}_{:}_{:}_{:}.obj", subDir,
459 m_clientToken.preFixName, ctx.eventID().event_number(), ++fileVersion, segStr);
461 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 toLayerIndex(ChIndex index)
convert ChIndex into LayerIndex
LayerIndex
enum to classify the different layers in the muon spectrometer
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)