40 auto translateTokenList = [
this, &idHelper](
const std::vector<std::string>& chNames){
42 std::set<Identifier> transcriptedIds{};
43 for (
const std::string& token : chNames) {
44 if (token.size() != 6) {
45 ATH_MSG_WARNING(
"Wrong format given for "<<token<<
". Expecting 6 characters");
49 const std::string statName = token.substr(0, 3);
50 const unsigned statEta = std::atoi(token.substr(3, 1).c_str()) * (token[4] ==
'A' ? 1 : -1);
51 const unsigned statPhi = std::atoi(token.substr(5, 1).c_str());
58 transcriptedIds.insert(eleId);
61 transcriptedIds.insert(secMlId);
64 return transcriptedIds;
67 std::vector <std::string>& selectedSt =
m_selectStat.value();
68 const std::vector <std::string>& excludedSt =
m_excludeStat.value();
69 selectedSt.erase(
std::remove_if(selectedSt.begin(), selectedSt.end(),
70 [&excludedSt](
const std::string& token){
71 return std::ranges::find(excludedSt, token) != excludedSt.end();
72 }), selectedSt.end());
74 if (selectedSt.size()) {
76 std::stringstream sstr{};
80 ATH_MSG_INFO(
"Test only the following stations "<<std::endl<<sstr.str());
82 const std::set<Identifier> excluded = translateTokenList(excludedSt);
86 if (!excluded.count(*itr)) {
91 if (!excluded.empty()) {
92 std::stringstream excluded_report{};
94 excluded_report <<
" *** " <<
m_idHelperSvc->toStringDetEl(
id) << std::endl;
96 ATH_MSG_INFO(
"Test all station except the following excluded ones " << std::endl << excluded_report.str());
100 return StatusCode::SUCCESS;
104 const unsigned layer)
const {
115 const std::string chName = std::format(
"{:}{:}{:}{:}M{:}T{:}",
122 canvas->expandPad(-0.5*wL, -0.5*
h);
123 canvas->expandPad( 0.5*wL, 0.5*
h);
124 canvas->setAxisTitles(
"x [mm]",
"y [mm]");
125 canvas->setRangeScale(1.1);
132 for (
unsigned int tube = 1 ; tube <= reEle.
numTubesInLay(); ++ tube) {
134 if (!reEle.
isValid(measHash)) {
139 canvas->add(
drawLabel(std::format(
"{:}, layer: {:}",
m_idHelperSvc->toStringDetEl(detId), layer), 0.2, 0.05));
146 return StatusCode::SUCCESS;
149 std::unordered_map<Identifier, std::shared_ptr<MuonValR4::IRootVisualizationService::ICanvasObject>> canvases{};
153 ATH_MSG_DEBUG(
"Preparing canvases to draw the tube mapping per chamber");
159 if(canvases.count(chamberId))
continue;
160 const std::string canName = std::format(
"{:}{:}{:}{:}",
165 canvases.insert(std::make_pair(chamberId,
179 auto canvas = canvases[chamberId];
183 for(
uint layer = 1 ; layer <= readEle->
numLayers() ; ++ layer){
184 bool is_valid{
false};
186 layer, tube, is_valid);
188 if (!readEle->
isValid(tube_hash)) {
194 cabling->convert(tube_id,cabling_data);
196 if (!cabling->getOnlineId(cabling_data, msgStream())) {
200 return StatusCode::FAILURE;
211 Amg::toString(chamber->localToGlobalTrans(gctx).linear() * locDir));
213 if(tube==1 && layer ==1 && idHelper.
stationPhi(tube_id)==1){
219 const double x{tubePos.y() * -1. * tubePos.x()/std::abs(tubePos.x()) * std::copysign(1.0, idHelper.
stationEta(tube_id)) };
220 const double y{tubePos.z()};
221 canvas->expandPad(
x -
r ,
y -
r);
222 canvas->expandPad(
x +
r ,
y +
r);
223 if (tube == 1 && layer == 1) {
233 return StatusCode::SUCCESS;
238 return StatusCode::SUCCESS;
241 const EventContext& ctx{Gaudi::Hive::currentContext()};
253 const std::string detStr =
m_idHelperSvc->toStringDetEl(test_me);
254 ATH_MSG_DEBUG(
"Test retrieval of Mdt detector element "<<detStr);
260 if (reElement->
identify() != test_me) {
262 return StatusCode::FAILURE;
271 return StatusCode::FAILURE;
273 for (
unsigned int lay = 1 ; lay <= reElement->
numLayers() ; ++lay ) {
275 for (
unsigned int tube = 1; tube <=reElement->
numTubesInLay(); ++tube ){
280 if (tube_id != cnv_tube_id) {
282 return StatusCode::FAILURE;
288 return StatusCode::SUCCESS;
293 if (!swapReadXML.good()) {
297 std::set<Identifier> chamberIDs{};
299 swapReadXML<<
"<Table name=\"MdtTubeROSides\">"<<std::endl;
300 unsigned int counter{1};
306 if(!readoutEle)
continue;
307 if (!chamberIDs.insert(idHelper.
elementID(
swap)).second)
continue;
309 swapReadXML<<
" <Row ";
310 swapReadXML<<
"MDTTUBEROSIDES_DATA_ID=\""<<counter<<
"\" ";
314 swapReadXML<<
"side=\""<<side<<
"\" ";
315 swapReadXML<<
"/>"<<std::endl;
318 swapReadXML<<
"</Table>"<<std::endl;
346 for (
unsigned int lay = 1; lay <= readoutEle->
numLayers(); ++lay) {
347 for (
unsigned int tube = 1; tube <= readoutEle->
numTubesInLay(); ++tube) {
349 if (!readoutEle->
isValid(measHash))
continue;
355 readoutEle->
center(gctx, measHash));
362 if (!cabling->convert(readoutEle->
measurementId(measHash), translation) ||
363 !cabling->getOnlineId(translation, msgStream())){
365 return StatusCode::FAILURE;
375 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
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.
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
static IdentifierHash measurementHash(unsigned int layerNumber, unsigned int tubeNumber)
Transform the layer and tube number to the measurementHash.
double activeTubeLength(const IdentifierHash &hash) const
double tubeLength(const IdentifierHash &hash) const
double tubeRadius() const
Adds the thickness of the tube wall onto the radius.
bool isValid(const IdentifierHash &measHash) const
Amg::Vector3D readOutPos(const ActsTrk::GeometryContext &ctx, const Identifier &measId) const
Returns the global position of the readout card.
const parameterBook & getParameters() const
double moduleHeight() const
Returns the height of the chamber (Distance bottom - topWidth)
unsigned int numTubesInLay() const
Returns the number of tubes per layer.
double innerTubeRadius() const
Returns the inner tube radius.
double moduleWidthS() const
Returns the length of the bottom edge of the chamber (short width)
unsigned int multilayer() const
Returns the multi layer of the MdtReadoutElement.
Identifier measurementId(const IdentifierHash &measHash) const override final
Converts the measurement hash back to the full Identifier.
double tubePitch() const
Returns the pitch between 2 tubes in a layer.
unsigned int numLayers() const
Returns the number of tube layer.
int stationEta() const
Returns the stationEta (positive A site, negative O site)
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 detector center (Which is the same as the detector center of the first measurement layer)
const Amg::Transform3D & localToGlobalTrans(const ActsTrk::GeometryContext &ctx) const
Returns the local to global transformation into the ATLAS coordinate system.
const std::string & chamberDesign() const
The chamber design refers to the construction parameters of a readout element.
Identifier identify() const override final
Return the athena 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
Returnsthe alignable transform of the readout element.
Amg::Transform3D globalToLocalTrans(const ActsTrk::GeometryContext &ctx) const
Transformations to translate between local <-> global coordinates.
Amg::Transform3D globalToLocalTrans(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)
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.
constexpr int fullFilling
std::unique_ptr< TLatex > drawLabel(const std::string &text, const double xPos, const double yPos, const unsigned int fontSize=18)
Create a TLatex label,.
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.
std::unique_ptr< TLatex > drawLabelNDC(const std::string &text, const double xPos, const double yPos, const unsigned int fontSize=18)
Create a TLatex label,.
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?