43 auto translateTokenList = [
this, &idHelper](
const std::vector<std::string>& chNames){
45 std::set<Identifier> transcriptedIds{};
46 for (
const std::string& token : chNames) {
47 if (token.size() != 6) {
48 ATH_MSG_WARNING(
"Wrong format given for "<<token<<
". Expecting 6 characters");
52 const std::string statName = token.substr(0, 3);
53 const unsigned statEta = std::atoi(token.substr(3, 1).c_str()) * (token[4] ==
'A' ? 1 : -1);
54 const unsigned statPhi = std::atoi(token.substr(5, 1).c_str());
61 transcriptedIds.insert(eleId);
64 transcriptedIds.insert(secMlId);
67 return transcriptedIds;
70 std::vector <std::string>& selectedSt =
m_selectStat.value();
71 const std::vector <std::string>& excludedSt =
m_excludeStat.value();
72 selectedSt.erase(
std::remove_if(selectedSt.begin(), selectedSt.end(),
73 [&excludedSt](
const std::string& token){
74 return std::ranges::find(excludedSt, token) != excludedSt.end();
75 }), selectedSt.end());
77 if (selectedSt.size()) {
79 std::stringstream sstr{};
83 ATH_MSG_INFO(
"Test only the following stations "<<std::endl<<sstr.str());
85 const std::set<Identifier> excluded = translateTokenList(excludedSt);
89 if (!excluded.count(*itr)) {
94 if (!excluded.empty()) {
95 std::stringstream excluded_report{};
97 excluded_report <<
" *** " <<
m_idHelperSvc->toStringDetEl(
id) << std::endl;
99 ATH_MSG_INFO(
"Test all station except the following excluded ones " << std::endl << excluded_report.str());
103 return StatusCode::SUCCESS;
107 const unsigned layer)
const {
118 const std::string chName = std::format(
"{:}{:}{:}{:}M{:}T{:}",
125 canvas->expandPad(-0.5*wL, -0.5*
h);
126 canvas->expandPad( 0.5*wL, 0.5*
h);
127 canvas->setAxisTitles(
"x [mm]",
"y [mm]");
128 canvas->setRangeScale(1.1);
135 for (
unsigned int tube = 1 ; tube <= reEle.
numTubesInLay(); ++ tube) {
137 if (!reEle.
isValid(measHash)) {
142 canvas->add(
drawLabel(std::format(
"{:}, layer: {:}",
m_idHelperSvc->toStringDetEl(detId), layer), 0.2, 0.05));
149 return StatusCode::SUCCESS;
152 std::unordered_map<Identifier, std::shared_ptr<MuonValR4::IRootVisualizationService::ICanvasObject>> canvases{};
156 ATH_MSG_DEBUG(
"Preparing canvases to draw the tube mapping per chamber");
162 if(canvases.count(chamberId))
continue;
163 const std::string canName = std::format(
"{:}{:}{:}{:}",
168 canvases.insert(std::make_pair(chamberId,
182 auto canvas = canvases[chamberId];
186 for(
uint layer = 1 ; layer <= readEle->
numLayers() ; ++ layer){
187 bool is_valid{
false};
189 layer, tube, is_valid);
191 if (!readEle->
isValid(tube_hash)) {
197 cabling->convert(tube_id,cabling_data);
199 if (!cabling->getOnlineId(cabling_data, msgStream())) {
202 return StatusCode::FAILURE;
213 Amg::toString(chamber->localToGlobalTransform(gctx).linear() * locDir));
215 if(tube==1 && layer ==1 && idHelper.
stationPhi(tube_id)==1){
221 const double x{tubePos.y() * -1. * tubePos.x()/std::abs(tubePos.x()) * std::copysign(1.0, idHelper.
stationEta(tube_id)) };
222 const double y{tubePos.z()};
223 canvas->expandPad(
x -
r ,
y -
r);
224 canvas->expandPad(
x +
r ,
y +
r);
225 if (tube == 1 && layer == 1) {
232 label->SetTextColor(kBlue);
233 canvas->add(std::move(
label));
235 label2->SetTextColor(kRed);
236 canvas->add(std::move(label2));
241 return StatusCode::SUCCESS;
246 return StatusCode::SUCCESS;
249 const EventContext& ctx{Gaudi::Hive::currentContext()};
261 const std::string detStr =
m_idHelperSvc->toStringDetEl(test_me);
262 ATH_MSG_DEBUG(
"Test retrieval of Mdt detector element "<<detStr);
268 if (reElement->
identify() != test_me) {
270 return StatusCode::FAILURE;
279 return StatusCode::FAILURE;
281 for (
unsigned int lay = 1 ; lay <= reElement->
numLayers() ; ++lay ) {
283 for (
unsigned int tube = 1; tube <=reElement->
numTubesInLay(); ++tube ){
288 if (tube_id != cnv_tube_id) {
290 return StatusCode::FAILURE;
296 return StatusCode::SUCCESS;
301 if (!swapReadXML.good()) {
305 std::set<Identifier> chamberIDs{};
307 swapReadXML<<
"<Table name=\"MdtTubeROSides\">"<<std::endl;
308 unsigned int counter{1};
314 if(!readoutEle)
continue;
315 if (!chamberIDs.insert(idHelper.
elementID(
swap)).second)
continue;
317 swapReadXML<<
" <Row ";
318 swapReadXML<<
"MDTTUBEROSIDES_DATA_ID=\""<<counter<<
"\" ";
322 swapReadXML<<
"side=\""<<side<<
"\" ";
323 swapReadXML<<
"/>"<<std::endl;
326 swapReadXML<<
"</Table>"<<std::endl;
354 for (
unsigned int lay = 1; lay <= readoutEle->
numLayers(); ++lay) {
355 for (
unsigned int tube = 1; tube <= readoutEle->
numTubesInLay(); ++tube) {
357 if (!readoutEle->
isValid(measHash))
continue;
363 readoutEle->
center(gctx, measHash));
370 if (!cabling->convert(readoutEle->
measurementId(measHash), translation) ||
371 !cabling->getOnlineId(translation, msgStream())){
373 return StatusCode::FAILURE;
383 return m_tree.fill(ctx) ? StatusCode::SUCCESS : StatusCode::FAILURE;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
bool isValid(const T &p)
Av: we implement here an ATLAS-sepcific convention: all particles which are 99xxxxx are fine.
void swap(DataVector< T > &a, DataVector< T > &b)
See DataVector<T, BASE>::swap().
void drawLine(std::ostream &os)
const ServiceHandle< StoreGateSvc > & detStore() const
This is a "hash" representation of an Identifier.
Identifier multilayerID(const Identifier &channeldID) const
int multilayer(const Identifier &id) const
Access to components of the ID.
Identifier elementID(int stationName, int stationEta, int stationPhi) const
Identifier channelID(int stationName, int stationEta, int stationPhi, int multilayer, int tubeLayer, int tube) const
Chamber represent the volume enclosing a muon station.
Gaudi::Property< std::vector< std::string > > m_selectStat
String should be formated like <stationName><stationEta><A/C><stationPhi>
StatusCode visualizeTubeStaggering(const EventContext &ctx, const ActsTrk::GeometryContext &gctx) const
Visualize the tube staggering on a canvas.
Gaudi::Property< bool > m_visualStaggering
@briefGlag toggeling whether the tube staggering shall be visualized
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
SG::ReadCondHandleKey< MuonMDT_CablingMap > m_cablingKey
MuonVal::VectorBranch< double > & m_wireLength
MuonVal::ThreeVectorBranch m_tubePosInCh
Position of the tube in the sector frame.
MuonVal::VectorBranch< unsigned short > & m_tubeLay
Readout each tube specifically.
MuonVal::ScalarBranch< double > & m_tubePitch
MuonVal::ThreeVectorBranch m_roPos
Position of the readout.
const MuonDetectorManager * m_detMgr
Gaudi::Property< std::vector< std::string > > m_excludeStat
MuonVal::VectorBranch< unsigned short > & m_tubeNum
MuonVal::ScalarBranch< short > & m_stPhi
MuonVal::ScalarBranch< short > & m_stML
StatusCode execute() override
MuonVal::ScalarBranch< short > & m_stEta
MuonVal::CoordTransformBranch m_readoutTransform
Transformation of the readout element (Translation, ColX, ColY, ColZ)
MuonVal::VectorBranch< uint8_t > & m_cablingMROD
MuonVal::ScalarBranch< double > & m_tubeRad
StatusCode dumpToTree(const EventContext &ctx, const ActsTrk::GeometryContext &gctx, const MdtReadoutElement *readoutEle)
MuonValR4::IRootVisualizationService::ClientToken m_clientTokenLayerVis
Token to be presented to the visualization service.
void visualizeTubeLayer(const EventContext &ctx, const MuonGMR4::MdtReadoutElement &reEle, const unsigned layer) const
Visualize the tube layer on a Canvas.
MuonVal::VectorBranch< double > & m_tubeLength
StatusCode finalize() override
MuonVal::CoordTransformBranch m_alignableNode
MuonVal::CoordSystemsBranch m_tubeTransform
Transformation to each tube.
Gaudi::Property< std::string > m_swapRead
std::set< Identifier > m_testStations
Set of stations to be tested.
MuonVal::VectorBranch< uint8_t > & m_cablingTdcCh
StatusCode initialize() override
void dumpReadoutSideXML() const
Create a xml indicating on which side of the chamber is the tube-readout card.
MuonVal::VectorBranch< double > & m_activeTubeLength
MuonVal::ScalarBranch< unsigned short > & m_numTubes
Number of tubes per layer.
MuonVal::VectorBranch< uint8_t > & m_cablingCSM
Cabling information.
MuonVal::ScalarBranch< unsigned short > & m_stIndex
Identifier of the readout element.
MuonVal::MuonTesterTree m_tree
Gaudi::Property< bool > m_visualTubes
Flag toggling whether the tubes shall be printed.
SG::ReadHandleKey< ActsTrk::GeometryContext > m_geoCtxKey
MuonVal::ScalarBranch< std::string > & m_chamberDesign
MuonVal::VectorBranch< uint8_t > & m_cablingTdcId
ServiceHandle< MuonValR4::IRootVisualizationService > m_visualSvc
Service handle of the visualization service.
MuonValR4::IRootVisualizationService::ClientToken m_clientTokenStaggeringVis
MuonVal::ScalarBranch< unsigned short > & m_numLayers
Number of tubes per layer.
Readout element to describe the Monitored Drift Tube (Mdt) chambers Mdt chambers usually comrpise out...
double moduleWidthL() const
Returns the length of the top edge of the chamber (top width)
Amg::Vector3D localTubePos(const IdentifierHash &hash) const
Returns the tube position in the chamber coordinate frame (Not applying the B-line corrections)
double wireLength(const IdentifierHash &hash) const
double activeTubeLength(const IdentifierHash &hash) const
double tubeLength(const IdentifierHash &hash) const
unsigned numLayers() const
Returns how many tube layers are inside the multi layer [1;4].
double tubeRadius() const
Adds the thickness of the tube wall onto the radius.
bool isValid(const IdentifierHash &measHash) const
Checks whether the passed meaurement hash corresponds to a valid tube described by the readout elemen...
Amg::Vector3D readOutPos(const ActsTrk::GeometryContext &ctx, const Identifier &measId) const
Returns the endpoint of the tube where the readout card is mounted in the ATLAS coordinate frame.
const parameterBook & getParameters() const
Get a const reference to the parameter book.
double moduleHeight() const
Returns the height of the chamber (Distance bottom - topWidth)
double innerTubeRadius() const
Returns the inner tube radius.
double moduleWidthS() const
Returns the length of the bottom edge of the chamber (short width)
unsigned numTubesInLay() const
Returns the number of tubes in a layer.
static IdentifierHash measurementHash(unsigned layerNumber, unsigned tubeNumber)
Constructs a Measurement hash from layer && tube number.
Identifier measurementId(const IdentifierHash &measHash) const override final
Back conversion of the measurement hash towards a full identifier Tube & layer number are extracted f...
double tubePitch() const
Returns the pitch between 2 tubes in a layer.
unsigned multilayer() const
Returns the multi layer of the readout element [1;\2].
const Amg::Transform3D & localToGlobalTransform(const ActsTrk::GeometryContext &ctx) const
Returns the transformation from the local coordinate system of the readout element into the global AT...
int stationEta() const
Returns the stationEta (positive A site, negative C site)
Amg::Transform3D globalToLocalTransform(const ActsTrk::GeometryContext &ctx) const
Returns the transformation from the global ATLAS coordinate system into the local coordinate system o...
const SpectrometerSector * msSector() const
Returns the pointer to the envelope volume enclosing all chambers in the sector.
Amg::Vector3D center(const ActsTrk::GeometryContext &ctx) const
Returns the geometrical center point of the readout element.
const std::string & chamberDesign() const
The chamber design refers to the construction parameters of a readout element.
Identifier identify() const override final
Return the ATLAS identifier.
int stationName() const
Returns the stationName (BIS, BOS, etc) encoded into the integer.
int stationPhi() const
Returns the stationPhi (1-8) -> sector (2*phi - (isSmall))
const GeoAlignableTransform * alignableTransform() const
Return the alignable transform node of the readout element.
Amg::Transform3D globalToLocalTransform(const ActsTrk::GeometryContext &gctx) const
Returns the global -> local transformation from the ATLAS global.
std::vector< Identifier >::const_iterator const_id_iterator
int stationEta(const Identifier &id) const
const_id_iterator detectorElement_begin() const
Iterators over full set of ids.
int stationPhi(const Identifier &id) const
const_id_iterator detectorElement_end() const
bool add(const std::string &hname, TKey *tobj)
std::string label(const std::string &format, int i)
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
bool doesNotDeform(const Amg::Transform3D &trans)
Checks whether the linear part of the transformation rotates or stetches any of the basis vectors.
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 3, 1 > Vector3D
The ReadoutGeomCnvAlg converts the Run4 Readout geometry build from the GeoModelXML into the legacy M...
Lightweight algorithm to read xAOD MDT sim hits and (fast-digitised) drift circles from SG and fill a...
constexpr int hollowFilling
Filling codes for hollow / fullFilling / hatched filling.
std::unique_ptr< TEllipse > drawDriftCircle(const Amg::Vector3D ¢er, const double radius, const int color=kViolet, const int fillStyle=hollowFilling)
Create a TEllipse for drawing a drift circle.
std::unique_ptr< TLatex > drawLabel(const std::string &text, const double xPos, const double yPos, const unsigned int fontSize=18, const bool useNDC=true)
Create a TLatex label,.
constexpr int fullFilling
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 T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
DataModel_detail::iterator< DVL > remove_if(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end, Predicate pred)
Specialization of remove_if for DataVector/List.
uint8_t tdcId
Mezzanine type.
uint8_t channelId
Identifier of the corresponding tdc.
uint8_t & csm
MROD number.
double readoutSide
Is the readout chip at positive or negative Z in the tube coordinate frame.