ATLAS Offline Software
Loading...
Searching...
No Matches
TgcRawDataMonitorTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
5#include "TVector2.h"
8
10 const std::string& name,
11 const IInterface* parent)
12 : base_class(type,name,parent)
13{
14}
15
18 ATH_MSG_DEBUG("TgcRawDataMonitorTool::initialize(): Start");
19 ATH_CHECK(m_DetectorManagerKey.initialize());
20 ATH_MSG_DEBUG("TgcRawDataMonitorTool::initialize(): End");
21 return StatusCode::SUCCESS;
22}
23std::set<std::string> TgcRawDataMonitorTool::getPassedChambers(const Amg::Vector3D& extVec) const {
24 ATH_MSG_DEBUG("TgcRawDataMonitorTool::getPassedChambers(): Start");
25 double ext_x = extVec[0];
26 double ext_y = extVec[1];
27 double ext_z = extVec[2];
28 std::set<std::string> passed_chambers;
29 SG::ReadCondHandle<MuonGM::MuonDetectorManager> DetectorManagerHandle{m_DetectorManagerKey,Gaudi::Hive::currentContext()};
30 const MuonGM::MuonDetectorManager* muonMgr = DetectorManagerHandle.cptr();
31 if(muonMgr==nullptr){
32 ATH_MSG_ERROR("Null pointer to the read MuonDetectorManager conditions object.");
33 return passed_chambers;
34 }
35 for(int iStationName = 41 ; iStationName <= 48 ; iStationName++){
36 if ( (iStationName==41 || iStationName==42) && // M1
37 ( std::abs(ext_z)<m_M1Mod1Pl1L1_offsetZ-10. || std::abs(ext_z)>m_M1Mod2Pl2L3_offsetZ+10. ) )continue;
38 if ( (iStationName==43 || iStationName==44) && // M2
39 ( std::abs(ext_z)<m_M2Mod1Pl1L1_offsetZ-10. || std::abs(ext_z)>m_M2Mod2Pl2L2_offsetZ+10. ) )continue;
40 if ((iStationName==45 || iStationName==46) && // M3
41 ( std::abs(ext_z)<m_M3Mod1Pl1L1_offsetZ-10. || std::abs(ext_z)>m_M3Mod2Pl2L2_offsetZ+10. ) )continue;
42 if ( iStationName==48 && // EI
43 ( std::abs(ext_z)<m_EIMod1Pl1L1_offsetZ-10. || std::abs(ext_z)>m_EIMod2Pl1L2_offsetZ+10. ) )continue;
44 if ( iStationName==47 && // FI
45 ( std::abs(ext_z)<m_FIMod1Pl1L1_offsetZ-10. || std::abs(ext_z)>m_FIMod2Pl1L2_offsetZ+10. ) )continue;
46 bool endcap = (iStationName%2==0);
47 int maxEta = 1;
48 if(endcap && iStationName==42) maxEta = 4;
49 else if(endcap && (iStationName==44 || iStationName==46)) maxEta = 5;
50 for(int iStationEta = -maxEta ; iStationEta <= maxEta ; iStationEta++){
51 if(iStationEta==0)continue;
52 if(ext_z > 0 && iStationEta < 0)continue;
53 if(ext_z < 0 && iStationEta > 0)continue;
54 for(int iStationPhi = muonMgr->tgcIdHelper()->stationPhiMin(endcap) ;
55 iStationPhi <= muonMgr->tgcIdHelper()->stationPhiMax(endcap) ; iStationPhi++){
56 if(iStationName==48 && iStationPhi>21)continue;
57 TGC::TgcChamber tgcChamber; tgcChamber.initChamber(iStationEta, iStationPhi, iStationName);
58 bool isValid{false};
59 const Identifier id = muonMgr->tgcIdHelper()->elementID(iStationName, iStationEta, iStationPhi, isValid);
60 if (!isValid) continue;
61
62 const MuonGM::TgcReadoutElement* detEle = muonMgr->getTgcReadoutElement(id);
63 const Trk::TrapezoidBounds* tb = static_cast<const Trk::TrapezoidBounds*>(&detEle->bounds());
64 Amg::Vector3D trkLocVec3D = detEle->transform().inverse() * Amg::Vector3D(ext_x,ext_y,ext_z);
65 if(std::abs(trkLocVec3D.x())>1000.)continue;
66 if(std::abs(trkLocVec3D.y())>1500.)continue;
67 Amg::Vector2D trkvec(trkLocVec3D.x(),trkLocVec3D.y());
68 if( tb->minDistance(trkvec) < m_fiduciFrame ) passed_chambers.insert(tgcChamber.cham_name());
69 }
70 }
71 }
72
73 ATH_MSG_DEBUG("TgcRawDataMonitorTool::getPassedChambers(): End");
74 ATH_MSG_DEBUG("Number of passed TGC chambers: " << passed_chambers.size());
75 return passed_chambers;
76}
77
79 int& etamap_index, int& phimap_index, int& phimap_global_index ) const {
80
81 ATH_MSG_DEBUG("TgcRawDataMonitorTool::getMapIndex(const TGC::TgcHit& tgcHit,: Start");
82 return getMapIndex(tgcHit,tgcHit.gasGap(),etamap_index,phimap_index,phimap_global_index);
83 ATH_MSG_DEBUG("TgcRawDataMonitorTool::getMapIndex(const TGC::TgcHit& tgcHit,: End");
84}
86 int& etamap_index, int& phimap_index, int& phimap_global_index ) const {
87 ATH_MSG_DEBUG("TgcRawDataMonitorTool::getMapIndex(const TGC::TgcChamber& tgcCham,: Start");
88 if (tgcCham.iM() > 1 && iLay > 2){
89 ATH_MSG_DEBUG("tgcCham.iM() > 1 && iLay > 2");
90 return false;
91 }
92 int nLay = (tgcCham.iM()==1)?(3):(2);
93 if (tgcCham.iM() == 4) { // EI/FI
94 etamap_index = tgcCham.iEta() * nLay + iLay; // 1..4
95 if(tgcCham.iEta() == 0){ //FI
96 phimap_index = tgcCham.iPhi(); // 1..24
97 }else{ // EI
98 phimap_index = tgcCham.iPhi() + int(tgcCham.iSec() / 2) + tgcCham.iSec(); // 1..24
99 }
100 phimap_global_index = tgcCham.iEta() * 24*nLay + (phimap_index - 1) * nLay + iLay; // 1..96
101 }else{ // BigWheel
102 etamap_index = tgcCham.iEta() * nLay + iLay; // 1..15 for M1, 1..12 for M2M3
103 phimap_index = (tgcCham.iSec() - 1) * 4 + tgcCham.iPhi() + 1; // 1..48
104 phimap_global_index = tgcCham.iEta() * 48*nLay + (phimap_index - 1) * nLay + iLay; // 1..720 for M1, 1..576 for M2M3
105 }
106 ATH_MSG_DEBUG("TgcRawDataMonitorTool::getMapIndex(const TGC::TgcChamber& tgcCham,: End");
107 return true;
108}
109
110bool TgcRawDataMonitorTool::getMapIndexOnline(const std::string& chamber_type_name, // e.g. A01M01f00E01L03W
111 int& etamap_index, int& phimap_index, int& phimap_global_index) const {
112 etamap_index=-1;
113 phimap_index=-1;
114 phimap_global_index=-1;
115 if( chamber_type_name.size() != 16 ) return false; // e.g. A01M01f01E01L01S
116
117 const int offset = (chamber_type_name[5]=='1')?(0):((chamber_type_name[5]=='2')?(3):((chamber_type_name[5]=='3')?(5):(7)));
118 const int layerNumber = std::atoi(chamber_type_name.substr(14,1).c_str())-1 + offset;/*0..6..8*/
119 const bool isEndcap = chamber_type_name[9] == 'E';
120 const int phiId =// 0..47 for E, 0..23 for F, A/M1/sector01/phi0/E1 is 0, A/M1/sector01/phi2/F is also 1
121 (chamber_type_name[5]=='4')
122 ?( std::atoi(chamber_type_name.substr(8,1).c_str()) + (std::atoi(chamber_type_name.substr(1,2).c_str())/2)*3 ) /*0..23*/
123 :( (isEndcap)
124 ?( std::atoi(chamber_type_name.substr(8,1).c_str()) + (std::atoi(chamber_type_name.substr(1,2).c_str())-1)*4 ) /*0..47*/
125 :( std::atoi(chamber_type_name.substr(8,1).c_str())/2 + (std::atoi(chamber_type_name.substr(1,2).c_str())-1)*2 ) /*0..23*/ );
126 const int eNumber = std::atoi(chamber_type_name.substr(11,1).c_str())-1;/*0..4*/
127 const bool isStrip = chamber_type_name[15] == 'S';
128
129 int sector = isEndcap ? phiId/4+1 : phiId/2+1;
130 int phi = isEndcap ? phiId%4 : (phiId%2)*2;
131 int efNumber = (isEndcap) ? eNumber : ( (layerNumber<3)?(4):(5)) ; // 0..3 or 4, plus 1 for forward
132
133 phimap_index = (!isEndcap || chamber_type_name[5]=='4') ? (phiId*2+1) : (phiId+1);
134
135 int station = 0;
136 int iLay = 0;
137 if(layerNumber<3){ // M1
138 station=1;
139 iLay = layerNumber+1;
140 etamap_index = ((isStrip)?(2):(3)) * efNumber + ((isStrip)?(iLay/2+1):(iLay));
141 }else if(layerNumber<5){ // M2
142 station=2;
143 iLay = layerNumber+1-3;
144 etamap_index = 2 * efNumber + iLay + ((isStrip)?(10):(15));
145 }else if(layerNumber<7){ // M3
146 station=3;
147 iLay = layerNumber+1-5;
148 etamap_index = 2 * efNumber + iLay + ((isStrip)?(22):(27));
149 }else{ // M4
150 station=4;
151 iLay = layerNumber+1-7;
152 etamap_index = iLay + ((isStrip)?(34):(39));
153 }
154
155 if(layerNumber<7){
156 phimap_global_index = iLay + efNumber*3 + phi*18 + (station-1)*72 + (sector-1)*216;
157 }else{
158 phimap_global_index = 2592 + iLay + phiId*2;
159 }
160
161 return true;
162}
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
bool isValid(const T &p)
Av: we implement here an ATLAS-sepcific convention: all particles which are 99xxxxx are fine.
Definition AtlasPID.h:878
virtual const Trk::SurfaceBounds & bounds() const override
Return the boundaries 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)
A TgcReadoutElement corresponds to a single TGC chamber; therefore typically a TGC station contains s...
const_pointer_type cptr()
const int & iM() const
Definition TgcChamber.h:47
void initChamber(const std::string &chamber_name)
Definition TgcChamber.cxx:8
const int & iSec() const
Definition TgcChamber.h:46
const int & iEta() const
Definition TgcChamber.h:49
const int & iPhi() const
Definition TgcChamber.h:48
const std::string & cham_name() const
Definition TgcChamber.h:43
const int & gasGap() const
Definition TgcHit.h:63
Identifier elementID(int stationName, int stationEta, int stationPhi) const
static int stationPhiMin(bool endcap)
DoubleProperty m_EIMod1Pl1L1_offsetZ
TgcRawDataMonitorTool(const std::string &type, const std::string &name, const IInterface *parent)
DoubleProperty m_M1Mod2Pl2L3_offsetZ
virtual bool getMapIndex(const TGC::TgcHit &tgcHit, int &etamapindex, int &phimapindex, int &globalphimapindex) const override
DoubleProperty m_M1Mod1Pl1L1_offsetZ
DoubleProperty m_M2Mod1Pl1L1_offsetZ
DoubleProperty m_FIMod2Pl1L2_offsetZ
DoubleProperty m_M3Mod1Pl1L1_offsetZ
DoubleProperty m_FIMod1Pl1L1_offsetZ
virtual std::set< std::string > getPassedChambers(const Amg::Vector3D &extVec) const override
DoubleProperty m_M2Mod2Pl2L2_offsetZ
virtual StatusCode initialize() override
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_DetectorManagerKey
virtual bool getMapIndexOnline(const std::string &chamber_type_name, int &etamap_index, int &phimap_index, int &phimap_global_index) const override
DoubleProperty m_M3Mod2Pl2L2_offsetZ
DoubleProperty m_EIMod2Pl1L2_offsetZ
Bounds for a trapezoidal, planar Surface.
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Matrix< double, 3, 1 > Vector3D