ATLAS Offline Software
TgcRawDataMonitorTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 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");
20  ATH_MSG_DEBUG("TgcRawDataMonitorTool::initialize(): End");
21  return StatusCode::SUCCESS;
22 }
23 std::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 = (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 }
TgcRawDataMonitorTool::m_M3Mod1Pl1L1_offsetZ
DoubleProperty m_M3Mod1Pl1L1_offsetZ
Definition: TgcRawDataMonitorTool.h:36
TgcIdHelper::stationPhiMin
static int stationPhiMin(bool endcap)
Definition: TgcIdHelper.cxx:657
TgcRawDataMonitorTool::m_M1Mod2Pl2L3_offsetZ
DoubleProperty m_M1Mod2Pl2L3_offsetZ
Definition: TgcRawDataMonitorTool.h:31
TrapezoidBounds.h
TGC::TgcChamber::initChamber
void initChamber(const std::string &chamber_name)
Definition: TgcChamber.cxx:8
MuonGM::MuonClusterReadoutElement::transform
virtual const Amg::Transform3D & transform() const override
Return local to global transform.
Definition: MuonClusterReadoutElement.h:124
TGC::TgcChamber::cham_name
const std::string & cham_name() const
Definition: TgcChamber.h:43
TGC::TgcChamber::iSec
const int & iSec() const
Definition: TgcChamber.h:46
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
TgcRawDataMonitorTool::initialize
virtual StatusCode initialize() override
Definition: TgcRawDataMonitorTool.cxx:17
Amg::Vector2D
Eigen::Matrix< double, 2, 1 > Vector2D
Definition: GeoPrimitives.h:48
TgcRawDataMonitorTool::getPassedChambers
virtual std::set< std::string > getPassedChambers(const Amg::Vector3D &extVec) const override
Definition: TgcRawDataMonitorTool.cxx:23
TgcRawDataMonitorTool::m_fiduciFrame
DoubleProperty m_fiduciFrame
Definition: TgcRawDataMonitorTool.h:28
TgcRawDataMonitorTool::m_EIMod2Pl1L2_offsetZ
DoubleProperty m_EIMod2Pl1L2_offsetZ
Definition: TgcRawDataMonitorTool.h:40
isValid
bool isValid(const T &p)
Definition: AtlasPID.h:214
TgcRawDataMonitorTool::m_DetectorManagerKey
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_DetectorManagerKey
Definition: TgcRawDataMonitorTool.h:45
TgcRawDataMonitorTool::~TgcRawDataMonitorTool
virtual ~TgcRawDataMonitorTool()
Definition: TgcRawDataMonitorTool.cxx:16
TGC::TgcHit::gasGap
const int & gasGap() const
Definition: TgcHit.h:63
PUfitVar::maxEta
constexpr float maxEta
Definition: GepMETPufitAlg.cxx:13
TgcRawDataMonitorTool::m_M3Mod2Pl2L2_offsetZ
DoubleProperty m_M3Mod2Pl2L2_offsetZ
Definition: TgcRawDataMonitorTool.h:37
MuonGM::MuonDetectorManager::getTgcReadoutElement
const TgcReadoutElement * getTgcReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonDetectorManager.cxx:247
Execution.tb
tb
Definition: Execution.py:15
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
TgcIdHelper::stationPhiMax
static int stationPhiMax(bool endcap)
Definition: TgcIdHelper.cxx:659
MuonGM::TgcReadoutElement
A TgcReadoutElement corresponds to a single TGC chamber; therefore typically a TGC station contains s...
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/TgcReadoutElement.h:42
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
TgcRawDataMonitorTool::m_M1Mod1Pl1L1_offsetZ
DoubleProperty m_M1Mod1Pl1L1_offsetZ
Definition: TgcRawDataMonitorTool.h:30
TgcRawDataMonitorTool::m_EIMod1Pl1L1_offsetZ
DoubleProperty m_EIMod1Pl1L1_offsetZ
Definition: TgcRawDataMonitorTool.h:39
TgcIdHelper::elementID
Identifier elementID(int stationName, int stationEta, int stationPhi) const
Definition: TgcIdHelper.cxx:556
TGC::TgcChamber
Definition: TgcChamber.h:10
MuonGM::MuonDetectorManager::tgcIdHelper
const TgcIdHelper * tgcIdHelper() const
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonDetectorManager.h:230
TGC::TgcChamber::iPhi
const int & iPhi() const
Definition: TgcChamber.h:48
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
Trk::TrapezoidBounds
Definition: TrapezoidBounds.h:43
TgcRawDataMonitorTool.h
TgcRawDataMonitorTool::m_FIMod1Pl1L1_offsetZ
DoubleProperty m_FIMod1Pl1L1_offsetZ
Definition: TgcRawDataMonitorTool.h:42
TgcRawDataMonitorTool::m_M2Mod1Pl1L1_offsetZ
DoubleProperty m_M2Mod1Pl1L1_offsetZ
Definition: TgcRawDataMonitorTool.h:33
TGC::TgcChamber::iM
const int & iM() const
Definition: TgcChamber.h:47
TgcRawDataMonitorTool::m_M2Mod2Pl2L2_offsetZ
DoubleProperty m_M2Mod2Pl2L2_offsetZ
Definition: TgcRawDataMonitorTool.h:34
MuonGM::MuonDetectorManager
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonDetectorManager.h:49
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
TgcReadoutElement.h
TgcRawDataMonitorTool::m_FIMod2Pl1L2_offsetZ
DoubleProperty m_FIMod2Pl1L2_offsetZ
Definition: TgcRawDataMonitorTool.h:43
TgcRawDataMonitorTool::TgcRawDataMonitorTool
TgcRawDataMonitorTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: TgcRawDataMonitorTool.cxx:9
MuonGM::MuonClusterReadoutElement::bounds
virtual const Trk::SurfaceBounds & bounds() const override
Return the boundaries of the element.
Definition: MuonClusterReadoutElement.h:127
TGC::TgcHit
Definition: TgcHit.h:11
TgcRawDataMonitorTool::getMapIndex
virtual bool getMapIndex(const TGC::TgcHit &tgcHit, int &etamapindex, int &phimapindex, int &globalphimapindex) const override
Definition: TgcRawDataMonitorTool.cxx:78
TGC::TgcChamber::iEta
const int & iEta() const
Definition: TgcChamber.h:49