24 using PrimitivesVec_t = MuonValR4::TrackVisualizationTool::PrimitivesVec_t;
25 constexpr int truthColor = kOrange +2;
27 constexpr int ColorBarrel = kRed;
28 constexpr int ColorEndcapA = kBlue;
29 constexpr int ColorEndcapC = kGreen +2;
30 constexpr double inM = 1./ Gaudi::Units::m;
32 constexpr double extraMargin = 50.*Gaudi::Units::cm * inM;
37 std::unique_ptr<TMarker> drawMarker(
const Amg::Vector2D& pos,
const int mStyle,
const int mColor,
const int mSize = 2) {
38 auto marker = std::make_unique<TMarker>(
pos.x(),
pos.y(), mStyle);
39 marker->SetMarkerColor(mColor);
40 marker->SetMarkerSize(mSize);
45 constexpr double arrowLength = 2.*Gaudi::Units::m;
47 auto arrow = std::make_unique<TArrow>(
start.x(),
start.y(),
end.x(),
end.y(),0.01);
48 arrow->SetLineColor(
color);
49 arrow->SetLineWidth(2);
50 arrow->SetLineStyle(lineStyle);
56 const bool openMarker,
const bool onSeed) {
62 return onSeed ? (openMarker ? kOpenTriangleUp : kFullTriangleUp)
63 : (openMarker ? kOpenTriangleDown : kFullTriangleDown);
65 return onSeed ? (openMarker ? kOpenCrossX : kFullCrossX)
66 : (openMarker ? kOpenCross : kFullCross);
68 return onSeed ? (openMarker ? kOpenFourTrianglesX: kFullFourTrianglesX)
69 : (openMarker ? kOpenThreeTriangles : kFullThreeTriangles);
81 constexpr double phi = 0.6180339887498949;
82 const double h = 360 * std::fmod(0.13 +
phi *
double(iSeed), 1.0);
83 constexpr double s = 0.75;
84 constexpr double v = 0.95;
86 float r=0.f, g=0.f, b=0.f;
87 TColor::HLS2RGB(
h, s, v,
r, g, b);
88 return TColor::GetColor(
r, g, b);
97 colors.insert(std::make_pair(
color, std::move(box)));
104 legend->AddEntry(tMarker.get(),
label.c_str(),
"P");
105 markers.insert(std::make_pair(marker, std::move(tMarker)));
110 canvas.add(std::move(
legend));
111 for (
auto&[i, obj] :
colors){
112 canvas.add(std::move(obj));
115 canvas.add(std::move(obj));
123 return Amg::Vector2D{ posOnCylinder[1]*inM, posOnCylinder[0]*inM};
145 return StatusCode::SUCCESS;
153 PrimitivesVec_t && extPrimitives)
const {
172 const EventContext& ctx,
178 std::format(
"SeedSegsGlobalTruth{:}", view ==
DisplayView::XY ?
"XY" :
"RZ"));
187 PrimitivesVec_t primitives{};
202 const auto chIdx = seg->chamberIndex();
203 const int mStyleTruth = stationMarkerSyle(chIdx,
true,
true);
206 const double x = p.x() * inM;
207 const double y = p.y() * inM;
208 const double z = p.z() * inM;
209 const double r = std::hypot(
x,
y);
213 primitives.emplace_back(drawMarker(plotPos, mStyleTruth, truthColor, 3));
216 const double dir_x = seg->direction().x() * inM;
217 const double dir_y = seg->direction().y() * inM;
218 const double dir_z = seg->direction().z() * inM;
222 primitives.emplace_back(drawArrow2D(plotPos, plotDir, truthColor));
229 canvas->expandPad(plotPos.x() - extraMargin, plotPos.y() - extraMargin);
230 canvas->expandPad(plotPos.x() + extraMargin, plotPos.y() + extraMargin);
238 for (std::size_t iSeed = 0; iSeed < seeds.size(); ++iSeed) {
242 std::string seedLabel = std::format(
"s{:d}: ",
static_cast<int>(iSeed));
247 const auto chIdx = seg->chamberIndex();
248 const int mStyle = stationMarkerSyle(chIdx,
false,
true);
251 const double x = p.x() * inM;
252 const double y = p.y() * inM;
253 const double z = p.z() * inM;
254 const double r = std::hypot(
x,
y);
259 primitives.emplace_back(drawMarker(plotPos, mStyle,
color));
262 const double dir_x = seg->direction().x() * inM;
263 const double dir_y = seg->direction().y() * inM;
264 const double dir_z = seg->direction().z() * inM;
268 primitives.emplace_back(drawArrow2D(plotPos, plotDir,
color));
271 seedLabel +=
label +
"_";
280 canvas->expandPad(plotPos.x() - extraMargin, plotPos.y() - extraMargin);
281 canvas->expandPad(plotPos.x() + extraMargin, plotPos.y() + extraMargin);
288 if (!drewAny) { canvas->trash();
return; }
290 for (
auto& p : primitives) canvas->add(std::move(p));
291 legend.fillPrimitives(*canvas);
301 PrimitivesVec_t&& extPrimitives)
const{
319 return std::ranges::any_of(seeds,[segment, loc](
const MsTrackSeed& seed){
320 return seed.location() == loc && std::ranges::find(seed.segments(), segment) != seed.segments().end();
328 const Acts::GeometryContext tgContext = gctx->
context();
329 bool drawnPoint{
false};
334 using namespace Muon;
337 const int mColor = msSector->
barrel() ? ColorBarrel : (msSector->
side() > 0 ? ColorEndcapA : ColorEndcapC);
339 for (
const auto secProj : {leftOverlap, center, rightOverlap}) {
351 const bool isGood = onSeed(segment, loc);
352 const int mStyle = stationMarkerSyle(chIdx,
true, isGood);
354 extPrimitives.emplace_back( drawMarker(markerPos, mStyle, mColor));
355 canvas->add( drawMarker(markerPos, mStyle, mColor));
358 const double r = markerPos.mag() + extraMargin;
359 canvas->expandPad(
r,
r);
360 canvas->expandPad(-
r, -
r);
362 canvas->expandPad(markerPos[0] - extraMargin, markerPos[1] - extraMargin);
363 canvas->expandPad(markerPos[0] + extraMargin, markerPos[1] + extraMargin);
366 isGood ?
"" :
" (discarded)"), mColor);
367 legend.addColor(mColor, msSector->
barrel() ?
"Barrel" : msSector->
side() > 0 ?
"Endcap A" :
"Endcap C");
378 kFullDiamond, kBlack));
379 legend.addMarker(kFullDiamond,
"track seed");
382 for (
unsigned int s = 1; s<=16 ; ++s) {
389 const int lStyle = s%2 ? kDashed : kDotted;
390 const double r = canvas->corner(Edges::xHigh);
395 auto theLine = std::make_unique<TLine>(0.,0., e1.x(), e1.y());
396 theLine->SetLineStyle(lStyle);
397 extPrimitives.insert(extPrimitives.begin(), std::move(theLine));
398 theLine = std::make_unique<TLine>(0.,0., e2.x(), e2.y());
399 theLine->SetLineStyle(lStyle);
400 extPrimitives.insert(extPrimitives.begin(), std::move(theLine));
401 theLine = std::make_unique<TLine>(e1.x(), e1.y(), e2.x(), e2.y());
402 theLine->SetLineStyle(lStyle);
403 extPrimitives.insert(extPrimitives.begin(), std::move(theLine));
405 legend.fillPrimitives(*canvas);
422 const Acts::GeometryContext tgContext = gctx->
context();
423 bool addedEntry{
false};
425 const auto chIdx = segment->chamberIndex();
426 const int mStyle = stationMarkerSyle(chIdx,
true,
true);
436 canvas.add(drawMarker(
viewVector(sector.
phi(), projected, view), mStyle, truthColor, 3));
442 legend.addColor(truthColor,
"truth");
447 const OptBoundPars_t& parsToExt,
448 const std::string& objName)
const {
455 Acts::ObjVisualization3D visualHelper{};
456 const std::string subDir = std::format(
"./ObjDisplays/{:}/",
m_subDir.value());
460 if (stepsResult.ok()) {
463 ATH_MSG_WARNING(
"Failed to extrapolate the seed for visualization: " << stepsResult.error().message());
473 unsigned fileVersion{0};
474 std::string finalStr{};
475 while (finalStr.empty() || std::filesystem::exists(finalStr)) {
476 finalStr = std::format(
"{:}/{:}_{:}_{:}_{:}.obj", subDir,
477 m_clientToken.preFixName, ctx.eventID().event_number(), ++fileVersion, segStr);
479 visualHelper.write(finalStr);
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
Acts::GeometryContext context() const
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.
double phi() const
Returns the phi angle of the expanded sector.
SectorProjector
Enumeration to select the sector projection of the regular MS sector.
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
::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.
void drawSegmentMeasurements(const Acts::GeometryContext &tgContext, const xAOD::MuonSegment &segment, Acts::ObjVisualization3D &visualHelper, const Acts::ViewConfig &viewConfig=Acts::s_viewSensitive)
Draw all uncalibrated measurements associated to the segment.
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.
void drawSegmentLine(const Acts::GeometryContext &tgContext, 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.
constexpr int fullFilling
std::string removeNonAlphaNum(std::string str)
Removes all non-alpha numerical characters from a string.
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)