ATLAS Offline Software
Loading...
Searching...
No Matches
VP1RawDataHandle_sTGC_RDO.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
6// //
7// Implementation of class VP1RawDataHandle_sTGC_RDO //
8// //
9// Author: Riccardo Maria BIANCHI <riccardo.maria.bianchi@cern.ch>
10// Initial version: January 2025
11// //
13
16
19
21#include "VP1Utils/VP1DetInfo.h"
23
24#include "VP1Base/VP1Msg.h"
25
27
28#include <Inventor/nodes/SoTransform.h>
29#include <Inventor/nodes/SoGroup.h>
30#include <Inventor/nodes/SoMaterial.h>
31
32#include "GaudiKernel/SystemOfUnits.h"
33
34//____________________________________________________________________
39
40//____________________________________________________________________
44
45//____________________________________________________________________
47{
48 const Identifier id = m_data->identify();
49 const sTgcIdHelper* idhelper = VP1DetInfo::stgcIDHelper();
50 const bool valid = idhelper && m_data->is_valid(idhelper);
51 QStringList ll;
52 ll << " ===> sTGC Digit data";
53 ll << " Identifier: " + QString::fromStdString(id.getString());
54 if (valid) {
55 const int type = idhelper->channelType(id);
56 const QString typeName = type == sTgcIdHelper::Pad ? "PAD" :
57 type == sTgcIdHelper::Strip ? "STRIP" : "WIRE";
58 ll << " type: " + typeName;
59 } else {
60 ll << " type: unavailable";
61 }
62 ll << " is_valid(idhelper): " + (idhelper ? QString::number(valid) : QString("unavailable"));
63 ll << " bcTag: " + QString::number(m_data->bcTag());
64 ll << " charge: " + QString::number(m_data->charge());
65 ll << " charge_6bit: " + QString::number(m_data->charge_6bit());
66 ll << " charge_10bit: " + QString::number(m_data->charge_10bit());
67 ll << " time: " + QString::number(m_data->time());
68 ll << " isDead: " + QString::number(m_data->isDead());
69 ll << " isPileup: " + QString::number(m_data->isPileup());
70 if (verbose) {
71 if (valid) {
72 ll << " Station name: " + QString::fromStdString(idhelper->stationNameString(id));
73 ll << " Station eta index: " + QString::number(idhelper->stationEta(id));
74 ll << " Station phi index: " + QString::number(idhelper->stationPhi(id));
75 ll << " Multilayer: " + QString::number(idhelper->multilayer(id));
76 ll << " Gas gap: " + QString::number(idhelper->gasGap(id));
77 ll << " Channel type index: " + QString::number(idhelper->channelType(id));
78 ll << " Channel: " + QString::number(idhelper->channel(id));
79 if (idhelper->channelType(id) == sTgcIdHelper::Pad) {
80 ll << " Pad eta index: " + QString::number(idhelper->padEta(id));
81 ll << " Pad phi index: " + QString::number(idhelper->padPhi(id));
82 }
83 } else {
84 ll << " Decoded identifier unavailable";
85 }
86 const MuonGM::sTgcReadoutElement* elem = valid ? element() : nullptr;
87 Amg::Vector3D position = Amg::Vector3D::Zero();
88 if (elem && elem->stripGlobalPosition(id, position)) {
89 ll << QString(" Global position [mm] (x, y, z): (%1, %2, %3)")
90 .arg(position.x() / Gaudi::Units::mm, 0, 'g', 10)
91 .arg(position.y() / Gaudi::Units::mm, 0, 'g', 10)
92 .arg(position.z() / Gaudi::Units::mm, 0, 'g', 10);
93 } else {
94 ll << " Global position unavailable";
95 }
96 }
97 return ll;
98}
99
100//____________________________________________________________________
102{
103
104 SoNode * node{nullptr};
105
106
107 const MuonGM::sTgcReadoutElement * elem = element();
108 Identifier id(m_data->identify());
109
110 static const sTgcIdHelper * idhelper = VP1DetInfo::stgcIDHelper();
111 const int channel = idhelper->channel(id);
112 m_channelType = idhelper->channelType(id);
113
114 // element's local and global positions
115 Amg::Vector3D globalPos{Amg::Vector3D::Zero()};
116 Amg::Vector2D pos{Amg::Vector2D::Zero()};
117 elem->stripGlobalPosition(id, globalPos);
118 elem->stripPosition(id, pos);
119
120 // sTGC element's geometry
121 double shortWidth=0, longWidth=0, length=0;
122 const Trk::PlaneSurface surface = elem->surface(id);
123
124 // PAD geometry
125 if (m_channelType == 0) {
126 m_channelTypeStr = "PAD";
127 length = elem->channelPitch(id); // Height of a pad
128 std::array<Amg::Vector2D, 4> corners{
129 make_array<Amg::Vector2D, 4>(Amg::Vector2D::Zero())};
130 elem->padCorners(id, corners); // BotLeft, BotRight, TopLeft, TopRight
131 shortWidth = (corners.at(1) - corners.at(0)).norm();
132 longWidth = (corners.at(3) - corners.at(2)).norm();
133
134 node = common()->nodeManager()->getShapeNode_Pad(length,shortWidth,longWidth,10*Gaudi::Units::mm/*Dummy depth*/);
135 }
136 // STRIP geometry
137 else if (m_channelType == 1) {
138 m_channelTypeStr = "STRIP";
139 const MuonGM::MuonChannelDesign* design = elem->getDesign(id);
140 length = design->channelLength(channel);
141 shortWidth = elem->channelPitch(id); // Full pitch of strips
142 longWidth = shortWidth;
143
144 node = common()->nodeManager()->getShapeNode_Strip(length,longWidth,10*Gaudi::Units::mm/*Dummy depth*/);
145 }
146 // WIRE geometry
147 else {
148 m_channelTypeStr = "WIRE";
149 const MuonGM::MuonChannelDesign* design = elem->getDesign(id);
150 if (!design) {
151 // VP1Msg::messageVerbose("No wire design for hit " + id.getString());
152 std::cout << "No wire design for hit " << id << std::endl;;
153 return node;
154 }
155
156 // recalculate length and globalPos for wires, because
157 // design->channelLength(channel) doesn't look sensible
158 double fulllength = design->xSize();
159 double locY = design->firstPos() +
160 (channel - 1) * design->inputPitch * design->groupWidth;
161 if (std::abs(locY) > 0.5 * design->minYSize()) { // triangle region
162 double dY = 0.5 * (design->maxYSize() - design->minYSize());
163 length = (0.5 * design->maxYSize() - std::abs(locY)) / dY * fulllength;
164 if (std::abs(locY) > 873) { // trapezoid region in the outter most part
165 // of the large sector
166 length += 0.5 * fulllength;
167 }
168 elem->surface(id).localToGlobal(
169 Amg::Vector2D(pos.x(), pos.y() + 0.5 * (fulllength - length)),
170 Amg::Vector3D::Zero(), globalPos);
171 } else { // rectangular region
172 length = fulllength;
173 }
174
175 shortWidth = elem->channelPitch(id); // Width of a full wire group
176 longWidth = shortWidth;
177
178 node = common()->nodeManager()->getShapeNode_Wire(length,longWidth,10*Gaudi::Units::mm/*Dummy depth*/);
179 }
180 return node;
181}
182
183//____________________________________________________________________
185{
186 const MuonGM::sTgcReadoutElement * elem = element();
187 if (!elem)
188 return new SoTransform;//fixme
189 Identifier id(m_data->identify());
190 Amg::Vector3D globalPos;
191 elem->stripGlobalPosition(id, globalPos);
192
194}
195
196//____________________________________________________________________
198{
199
201
202 if (!detmgr)
203 return 0;
204 return detmgr->getsTgcReadoutElement(m_data->identify());
205}
206
208{
209 return m_data->charge();
210}
211
213{
214 return m_data->time();
215}
216
218{
219 const sTgcIdHelper* helper = VP1DetInfo::stgcIDHelper();
220 return helper ? helper->channelType(m_data->identify()) : -1;
221}
222
224{
225 return m_data->isDead();
226}
227
229{
230 return m_data->isPileup();
231}
constexpr std::array< T, N > make_array(const T &def_val)
Helper function to initialize in-place arrays with non-zero values.
Definition ArrayHelper.h:10
double length(const pvec &v)
SoNode * getShapeNode_Wire(double length, double minWidth=0, double maxWidth=0, double depth=0)
SoNode * getShapeNode_Strip(double length, double width=0, double depth=0)
SoNode * getShapeNode_Pad(double length, double minWidth=0, double maxWidth=0, double depth=0)
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
const sTgcReadoutElement * getsTgcReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
An sTgcReadoutElement corresponds to a single STGC module; therefore typicaly a barrel muon station c...
int stationEta(const Identifier &id) const
const std::string & stationNameString(const Identifier &id) const
int stationPhi(const Identifier &id) const
Class for a planaer rectangular or trapezoidal surface in the ATLAS detector.
static const sTgcIdHelper * stgcIDHelper()
static const MuonGM::MuonDetectorManager * muonDetMgr()
static SoTransform * toSoTransform(const HepGeom::Transform3D &, SoTransform *t=0)
HitsSoNodeManager * nodeManager() const
VP1RawDataCommonData * common() const
VP1RawDataHandleBase(VP1RawDataCollBase *)
VP1RawDataCollBase * coll() const
const MuonGM::sTgcReadoutElement * element() const
QStringList clicked(bool verbose) const
VP1RawDataHandle_sTGC_RDO(VP1RawDataCollBase *, const sTgcDigit *)
Definition node.h:24
int padPhi(const Identifier &id) const
int multilayer(const Identifier &id) const
int channelType(const Identifier &id) const
int padEta(const Identifier &id) const
int channel(const Identifier &id) const override
int gasGap(const Identifier &id) const override
get the hashes
bool verbose
Definition hcg.cxx:75
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Matrix< double, 3, 1 > Vector3D
double firstPos() const
Returns the position of the first strip along the x-axis.
double channelLength(int channel) const
STRIPS ONLY: calculate channel length for a given strip number.