13#include "GaudiKernel/SystemOfUnits.h"
18template<
typename VType>
bool isEqual(
const std::vector<VType>&
a,
19 const std::vector<VType>& b) {
20 if (
a.size() != b.size()) {
23 for (
size_t k =0 ; k <
a.size() ; ++k) {
24 if ( std::abs(
a[k] - b[k]) > std::numeric_limits<VType>::epsilon()){
30template <
typename VType> std::ostream&
operator<<(std::ostream& ostr,
const std::vector<VType>& v){
31 for (
size_t k = 0 ; k <v.size(); ++k){
33 if ( k+1 != v.size())ostr<<
",";
37template <
typename VType> std::ostream&
operator<<(std::ostream& ostr,
const std::set<VType>& s){
39 for (
const VType& ele : s){
41 if (k != s.size()) ostr<<
";";
47 return readoutEle.
nStrips(layer) > 1 ? readoutEle.
nStrips(layer) : 0;
63 std::abs(
wirePitch - other.wirePitch) < std::numeric_limits<float>::epsilon();
78 const std::map<std::string, std::set<Identifier>>&
allGaps()
const{
return m_gaps; }
83 std::map<std::string, std::set<Identifier>>
m_gaps{};
89 return StatusCode::SUCCESS;
96 auto translateTokenList = [
this, &idHelper](
const std::vector<std::string>& chNames){
98 std::set<Identifier> transcriptedIds{};
99 for (
const std::string& token : chNames) {
100 if (token.size() != 7) {
101 ATH_MSG_WARNING(
"Wrong format given for "<<token<<
". Expecting 7 characters");
105 const std::string statName = token.substr(0, 3);
106 const unsigned statEta = std::atoi(token.substr(3, 1).c_str()) * (token[4] ==
'A' ? 1 : -1);
107 const unsigned statPhi = std::atoi(token.substr(5, 2).c_str());
114 transcriptedIds.insert(eleId);
116 return transcriptedIds;
119 std::vector <std::string>& selectedSt =
m_selectStat.value();
120 const std::vector <std::string>& excludedSt =
m_excludeStat.value();
121 selectedSt.erase(
std::remove_if(selectedSt.begin(), selectedSt.end(),
122 [&excludedSt](
const std::string& token){
123 return std::ranges::find(excludedSt, token) != excludedSt.end();
124 }), selectedSt.end());
126 if (selectedSt.size()) {
128 std::stringstream sstr{};
132 ATH_MSG_INFO(
"Test only the following stations "<<std::endl<<sstr.str());
134 const std::set<Identifier> excluded = translateTokenList(excludedSt);
138 if (!excluded.count(*itr)) {
143 if (!excluded.empty()) {
144 std::stringstream excluded_report{};
146 excluded_report <<
" *** " <<
m_idHelperSvc->toStringDetEl(
id) << std::endl;
148 ATH_MSG_INFO(
"Test all station except the following excluded ones " << std::endl << excluded_report.str());
151 return StatusCode::SUCCESS;
154 const EventContext& ctx{Gaudi::Hive::currentContext()};
159 return StatusCode::FAILURE;
171 if (reElement->
identify() != test_me) {
173 <<
m_idHelperSvc->toStringDetEl(test_me) <<
". But got instead "
175 return StatusCode::FAILURE;
185 <<
" perp: "<<center.perp()
186 <<
" phi: "<<(center.phi() / Gaudi::Units::deg)
187 <<
" theta: "<<(center.theta() / Gaudi::Units::deg)
191 <<
" dPhi: "<<(prevRE->
center().deltaPhi(center) / Gaudi::Units::deg));
194 return StatusCode::SUCCESS;
227 for (
bool isStrip : {
false,
true}) {
228 for (
int layer = 1 ; layer <= readoutEle->
numberOfLayers(isStrip); ++layer){
229 const unsigned int nChan = isStrip ?
nStrips(*readoutEle, layer) :
231 if (!nChan)
continue;
239 unsigned int numWires = !isStrip ? readoutEle->
nWires(layer) : 0;
245 bool is_valid{
false};
247 if (!is_valid)
continue;
253 if (!surf.
globalToLocal(globStripPos, Amg::Vector3D::Zero(), locStripPos)){
255 return StatusCode::FAILURE;
260 const double stripHalfLength = readoutEle->
stripLength() / 2.;
282 for (
int gang = 1; gang <= readoutEle->
nWireGangs(layer); ++gang) {
287 if (!surf.
globalToLocal(globPos,Amg::Vector3D::Zero(),locPos)) {
289 return StatusCode::FAILURE;
302 return m_tree.fill(ctx) ? StatusCode::SUCCESS : StatusCode::FAILURE;
311 std::map<Identifier, TgcChamberLayout> allLayouts{};
315 if (!reEle)
continue;
316 for (
bool isStrip : {
false,
true}) {
317 for (
int layer = 1 ; layer <= reEle->
numberOfLayers(isStrip); ++layer){
322 if (isStrip &&
nStrips(*reEle, layer)) {
325 const double sign = (reEle->
getStationEta()> 0. ? -1. : 1.) *( (globToLoc*Amg::Vector3D::UnitY()).x() > 0 ? 1. : -1);
332 if (
strip != 32)
continue;
336 }
else if (!isStrip) {
337 unsigned int accumlWires{0};
344 for (
int gang = 1; gang <= reEle->
nWireGangs(layer); ++gang) {
345 unsigned int nWires = reEle->
nWires(layer , gang);
359 std::vector<ChamberGrp> groupedLayouts{};
360 for (
const auto& lay : allLayouts) {
363 if (grp.addChamber(lay.second)){
368 if (!added) groupedLayouts.emplace_back(lay.second);
373 return a.layout().techType < b.layout().techType;
376 ATH_MSG_INFO(
"Found in total "<<groupedLayouts.size()<<
" different chamber layouts");
377 xmlStream<<
"<Table name=\"TgcSensorLayout\">"<<std::endl;
378 unsigned int counter{1};
379 for (
const ChamberGrp& grp : groupedLayouts) {
380 for (
const auto& [tech_type, gapIds]: grp.allGaps()) {
381 std::set<int> gaps{};
382 std::set<char> sides{};
385 sides.insert(
m_idHelperSvc->stationEta(gapId) > 0 ?
'A' :
'C');
388 xmlStream<<
"TGCSENSORLAYOUT_DATA_ID=\""<<counter<<
"\" ";
389 xmlStream<<
"technology=\""<<tech_type<<
"\" ";
390 xmlStream<<
"gasGap=\""<<gaps<<
"\" ";
391 xmlStream<<
"side=\""<<sides<<
"\" ";
392 xmlStream<<
"wirePitch=\""<<grp.layout().wirePitch<<
"\" ";
393 xmlStream<<
"wireGangs=\""<<grp.layout().wireGangLayout<<
"\" ";
394 xmlStream<<
"bottomStrips=\""<<grp.layout().botStripPos<<
"\" ";
395 xmlStream<<
"topStrips=\""<<grp.layout().topStripPos<<
"\" ";
396 xmlStream<<
" />"<<std::endl;
400 xmlStream<<
"</Table> "<<std::endl;
#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.
StatusCode finalize() override
MuonVal::VectorBranch< float > & m_stripLength
MuonVal::ScalarBranch< float > & m_ALineRotT
MuonVal::ScalarBranch< short > & m_stEta
MuonVal::CoordSystemsBranch m_layTans
MuonVal::TwoVectorBranch m_locStripTop
MuonVal::ScalarBranch< float > & m_ALineRotZ
MuonVal::ScalarBranch< float > & m_ALineTransT
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
void dumpReadoutXML(const MuonGM::MuonDetectorManager &detMgr)
MuonVal::ScalarBranch< float > & m_shortWidth
MuonVal::ScalarBranch< float > & m_ALineRotS
MuonVal::ScalarBranch< unsigned short > & m_stIndex
Identifier of the readout element.
MuonVal::VectorBranch< unsigned int > & m_stripNum
Gaudi::Property< std::string > m_readoutXML
MuonVal::ScalarBranch< float > & m_ALineTransZ
MuonVal::ScalarBranch< short > & m_stPhi
MuonVal::ThreeVectorBranch m_gangCenter
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_detMgrKey
MuonDetectorManager from the conditions store.
MuonVal::VectorBranch< uint8_t > & m_stripGasGap
MuonVal::VectorBranch< float > & m_layShortWidth
MuonVal::ScalarBranch< std::string > & m_stLayout
MuonVal::ThreeVectorBranch m_stripTop
MuonVal::CoordTransformBranch m_alignableNode
MuonVal::VectorBranch< uint8_t > & m_layNumber
StatusCode initialize() override
MuonVal::ThreeVectorBranch m_stripBottom
Gaudi::Property< std::vector< std::string > > m_excludeStat
MuonVal::VectorBranch< uint16_t > & m_layNumWires
MuonVal::VectorBranch< float > & m_layLongWidth
MuonVal::VectorBranch< bool > & m_layMeasPhi
MuonVal::VectorBranch< unsigned int > & m_gangNum
MuonVal::ScalarBranch< uint8_t > & m_nGasGaps
MuonVal::CoordTransformBranch m_readoutTransform
Transformation of the readout element (Translation, ColX, ColY, ColZ)
StatusCode execute() override
MuonVal::TwoVectorBranch m_locStripBottom
MuonVal::VectorBranch< uint8_t > & m_gangGasGap
MuonVal::ScalarBranch< float > & m_longWidth
MuonVal::VectorBranch< float > & m_gangLength
MuonVal::ScalarBranch< float > & m_height
MuonVal::TwoVectorBranch m_locStripCenter
MuonVal::ScalarBranch< float > & m_ALineTransS
Alignment parameters.
std::set< Identifier > m_testStations
Set of stations to be tested.
MuonVal::MuonTesterTree m_tree
Write a TTree for validation purposes.
MuonVal::VectorBranch< float > & m_stripLongWidth
MuonVal::VectorBranch< uint8_t > & m_gangNumWires
MuonVal::VectorBranch< float > & m_stripShortWidth
StatusCode dumpToTree(const EventContext &ctx, const TgcReadoutElement *readoutEle)
MuonVal::ThreeVectorBranch m_stripCenter
MuonVal::ScalarBranch< float > & m_thickness
Gaudi::Property< std::vector< std::string > > m_selectStat
String should be formated like <stationName><stationEta><A/C><stationPhi>
MuonVal::VectorBranch< float > & m_layHeight
MuonVal::VectorBranch< float > & m_stripPitch
MuonVal::TwoVectorBranch m_locGangPos
virtual const Trk::PlaneSurface & surface() const override
access to chamber surface (phi orientation), uses the first gas gap
virtual const Amg::Vector3D & center() const override
Return the center of the element.
virtual const Amg::Transform3D & transform() const override
Return local to global transform.
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
const TgcReadoutElement * getTgcReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
const std::string & getTechnologyName() const
double getLongZsize() const
double getLongRsize() const
int getStationIndex() const
const Amg::Transform3D & absTransform() const
int getStationPhi() const
int getStationEta() const
double getLongSsize() const
const MuonStation * parentMuonStation() const
Identifier identify() const override final
Returns the ATLAS Identifier of the MuonReadOutElement.
double getALine_trat() const
const Amg::Transform3D & getNativeToAmdbLRS() const
double getALine_rott() const
double getALine_rots() const
const GeoAlignableTransform * getGeoTransform() const
double getALine_tras() const
double getALine_rotz() const
double getALine_traz() const
A TgcReadoutElement corresponds to a single TGC chamber; therefore typically a TGC station contains s...
double stripShortWidth(int, int) const
int nWireGangs(int gasGap) const
Returns the number of wire gangs (Random grouping of wires) in a given gas gap.
Amg::Vector3D channelPos(const Identifier &id) const
Returns the position of the active channel (wireGang or strip)
double stripLength() const
Returns the length of each strip which is equal to the height of the chamber.
double stripHighEdgeLocX(int gasGap, int strip, double radialPos) const
Returns the local X of the right edge of the strip at a given local radial position.
double stripPitch(int gasGap, int strip) const
Returns the pitch of the given strip in gasGap i.
double stripPosOnShortBase(int strip, int gasGap) const
double stripLongWidth(int, int) const
double gangShortWidth(int gasGap, int gang) const
Returns the length of the most bottom wire in the gang.
double stripPosOnLargeBase(int strip, int gasGap) const
virtual int numberOfLayers(bool isStrip) const override
number of layers in phi/eta projection
double stripLowEdgeLocX(int gasGap, int strip, double radialPos) const
Returns the local X of the left edge of the strip at a given local radial position.
double gangLongWidth(int gasGap, int gang) const
Returns the length of the most top wire in the gang.
int nGasGaps() const
Returns the number of gas gaps associated with the readout element (2 or 3)
int nWires(int gasGap) const
Returns the total number of wires in a given gas gap.
double physicalDistanceFromBase() const
int nStrips(int gasGap) const
Returns the number of strips in a given gas gap.
Amg::Vector3D wireGangPos(const Identifier &id) const
Returns the global position of a wireGang.
double wirePitch() const
Returns the pitch of the wires.
std::vector< Identifier >::const_iterator const_id_iterator
const_id_iterator module_end() const
const_id_iterator module_begin() const
Iterators over full set of ids.
const_id_iterator detectorElement_begin() const
Iterators over full set of ids.
const_id_iterator detectorElement_end() const
Identifier elementID(int stationName, int stationEta, int stationPhi) const
Identifier channelID(int stationName, int stationEta, int stationPhi, int gasGap, int isStrip, int channel) const
Abstract Base Class for tracking surfaces.
virtual bool globalToLocal(const Amg::Vector3D &glob, const Amg::Vector3D &mom, Amg::Vector2D &loc) const =0
Specified by each surface type: GlobalToLocal method without dynamic memory allocation - boolean chec...
const Amg::Transform3D & transform() const
Returns HepGeom::Transform3D by reference.
virtual void localToGlobal(const Amg::Vector2D &locp, const Amg::Vector3D &mom, Amg::Vector3D &glob) const =0
Specified by each surface type: LocalToGlobal method without dynamic memory allocation.
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Matrix< double, 3, 1 > Vector3D
Ensure that the Athena extensions are properly loaded.
int nStrips(const MuonGM::TgcReadoutElement &readoutEle, int layer)
bool isEqual(const std::vector< VType > &a, const std::vector< VType > &b)
std::ostream & operator<<(std::ostream &os, const AlignPos &p)
void stable_sort(DataModel_detail::iterator< DVL > beg, DataModel_detail::iterator< DVL > end)
Specialization of stable_sort for DataVector/List.
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.
const TgcChamberLayout & layout() const
const std::map< std::string, std::set< Identifier > > & allGaps() const
ChamberGrp(const TgcChamberLayout &grp)
std::map< std::string, std::set< Identifier > > m_gaps
bool addChamber(const TgcChamberLayout &lay)
TgcChamberLayout & layout()
std::vector< double > botStripPos
std::vector< int > wireGangLayout
std::vector< double > topStripPos
bool operator==(const TgcChamberLayout &other) const