ATLAS Offline Software
RPCHitsTestTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "RPCHitsTestTool.h"
6 
7 #include "Identifier/Identifier.h"
9 
12 
14 #include "MuonSimEvent/RPCSimHit.h"
15 
18 
20 #include "CLHEP/Vector/LorentzVector.h"
21 
22 #include <TH2D.h>
23 #include "TTree.h"
24 
27  std::string rpc_stname = rpchelper->GetStationName(rpchit);
28  int rpc_steta = rpchelper->GetZSector(rpchit);
29  int rpc_stphi = rpchelper->GetPhiSector(rpchit);
30  int rpc_dbr = rpchelper->GetDoubletR(rpchit);
31  int rpc_dbz = rpchelper->GetDoubletZ(rpchit);
32  int rpc_dbp = rpchelper->GetDoubletPhi(rpchit);
33  int rpc_gg = rpchelper->GetGasGapLayer(rpchit);
34  int rpc_mfi = rpchelper->GetMeasuresPhi(rpchit);
35  int rpc_strip = 1;//rpchelper->GetStrip(rpchit);
36 
37  // Create the offline identifiers, fill them with hit info. Ready to be
38  // accessed and retrieve info. Currently not used in this code except for
39  // some checks.
40  Identifier offid = m_pRpcIdHelper->channelID(rpc_stname, rpc_steta, rpc_stphi, rpc_dbr, rpc_dbz, rpc_dbp, rpc_gg, rpc_mfi, rpc_strip);
41  if (offid == 0) {
42  ATH_MSG_FATAL("RPC : Cannot build a valid Identifier; skip ");
43  }
44 
45  return offid;
46 }
47 
49 
50  const MuonGM::RpcReadoutElement* descriptor = m_pMuonMgr->getRpcReadoutElement(offid);
51  if (!descriptor) {
52  ATH_MSG_FATAL("RPC readout element not found for Id = " << m_pRpcIdHelper->show_to_string(offid));
53  return StatusCode::FAILURE;
54  }
55 
56  // Testing Sim to Offline ID conversion
57  Amg::Vector3D rpc_gPos = descriptor->stripPos(offid);
58  double rpc_strip_phi = rpc_gPos.phi();
59  if (rpc_strip_phi < 0.) rpc_strip_phi += 2.*M_PI;
60 
61  return StatusCode::SUCCESS;
62 }
63 
64 
67 
68  // MuonSpectrometer
69  // Get the generic MuonSpectrometer (MDT,RPC,CSC,TGC) histograms
70  // Short description:
71  // MuonSpectrometer cross section
72  // MuonSpectrometer longitudinal
73  // Number of events processed from truth
74  // Event specific run number
75  // Eta, Theta, Phi, z residual (...), phi residual (...) of hits in MuonSpectrometer
76 
77  if (m_DoRPCTest) {
78 
79  const RPCSimHitCollection* p_collection = nullptr;
80  if (evtStore()->retrieve(p_collection,"RPC_Hits") == StatusCode::SUCCESS) {
81  for (const RPCSimHit& hit : *p_collection) {
82  // Check the Hits identifiers, access the functions that give:
83  // Station name, station eta, station phi, doublet Z, doublet phi, doublet R, GasGap, Measures Phi.
84  HitID rpchit= (hit).RPCid();
85  Identifier offid= getIdentifier(rpchit);
86  CHECK(checkIdentifier(offid));
87 
88  // Check Hits
89  // For every hit within the event, get the global position Amg::Vector3D u and then retrieve all releveant info
90  // either from the Amg::Vector3D or from the MC vector (direction)
91  GeoRPCHit ghit(hit);
92 
93  if (!ghit) continue;
96  }
97  }
98  }
99 
100  return StatusCode::SUCCESS;
101 }
102 
103 
107  return StatusCode::SUCCESS;
108 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
MuonGM::MuonDetectorManager::getRpcReadoutElement
const RpcReadoutElement * getRpcReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonDetectorManager.cxx:168
RpcHitIdHelper::GetStationName
std::string GetStationName(const int &hid) const
Definition: RpcHitIdHelper.cxx:58
RpcHitIdHelper::GetHelper
static const RpcHitIdHelper * GetHelper(unsigned int nGasGaps=2)
Definition: RpcHitIdHelper.cxx:23
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
RPCHitsTestTool::checkIdentifier
StatusCode checkIdentifier(Identifier offid)
Definition: RPCHitsTestTool.cxx:48
MuonHitTestToolBase::executeCheckEventInfo
StatusCode executeCheckEventInfo()
Definition: MuonHitTestToolBase.cxx:35
RpcHitIdHelper::GetDoubletPhi
int GetDoubletPhi(const int &hid) const
Definition: RpcHitIdHelper.cxx:88
RpcHitIdHelper::GetMeasuresPhi
int GetMeasuresPhi(const int &hid) const
Definition: RpcHitIdHelper.cxx:96
GeoRPCHit::getGlobalPosition
Amg::Vector3D getGlobalPosition() const
RPCHitsTestTool::m_DoRPCTest
bool m_DoRPCTest
Definition: RPCHitsTestTool.h:36
AtlasHitsVector
Definition: AtlasHitsVector.h:33
M_PI
#define M_PI
Definition: ActiveFraction.h:11
GeoMuonHits.h
RpcHitIdHelper::GetDoubletZ
int GetDoubletZ(const int &hid) const
Definition: RpcHitIdHelper.cxx:92
RPCHitsTestTool.h
MuonGM::RpcReadoutElement
An RpcReadoutElement corresponds to a single RPC module; therefore typicaly a barrel muon station con...
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/RpcReadoutElement.h:55
RpcIdHelper::channelID
Identifier channelID(int stationName, int stationEta, int stationPhi, int doubletR, int doubletZ, int doubletPhi, int gasGap, int measuresPhi, int strip) const
Definition: RpcIdHelper.cxx:939
RpcHitIdHelper.h
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:77
RpcIdHelper.h
RPCHitsTestTool::initialize
StatusCode initialize()
Definition: RPCHitsTestTool.cxx:104
RpcHitIdHelper::GetPhiSector
int GetPhiSector(const int &hid) const
Definition: RpcHitIdHelper.cxx:69
McEventCollection.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
RPCSimHitCollection.h
MuonGM::MuonDetectorManager::rpcIdHelper
const RpcIdHelper * rpcIdHelper() const
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonDetectorManager.h:235
RpcHitIdHelper::GetGasGapLayer
int GetGasGapLayer(const int &hid) const
Definition: RpcHitIdHelper.cxx:84
RpcIdHelper::gasGapMax
int gasGapMax() const
Definition: RpcIdHelper.cxx:1097
MuonGM::RpcReadoutElement::stripPos
Amg::Vector3D stripPos(const Identifier &id) const
Definition: MuonDetDescr/MuonReadoutGeometry/src/RpcReadoutElement.cxx:177
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
MuonHitTestToolBase::executeFillHistos
StatusCode executeFillHistos(const Amg::Vector3D &)
Definition: MuonHitTestToolBase.cxx:70
MuonDetectorManager.h
RpcHitIdHelper::GetDoubletR
int GetDoubletR(const int &hid) const
Definition: RpcHitIdHelper.cxx:80
MuonHitTestToolBase::initialize
virtual StatusCode initialize() override
Definition: MuonHitTestToolBase.cxx:111
AtlasDetectorID::show_to_string
std::string show_to_string(Identifier id, const IdContext *context=0, char sep='.') const
or provide the printout in string form
Definition: AtlasDetectorID.cxx:574
MuonHitTestToolBase::m_pMuonMgr
const MuonGM::MuonDetectorManager * m_pMuonMgr
Definition: MuonHitTestToolBase.h:38
RPCHitsTestTool::processEvent
StatusCode processEvent()
Definition: RPCHitsTestTool.cxx:65
RPCSimHit.h
RPCSimHit
Definition: RPCSimHit.h:19
RpcHitIdHelper
Definition: RpcHitIdHelper.h:13
GeoRPCHit
Definition: GeoMuonHits.h:85
HitID
int HitID
Definition: GenericMuonSimHit.h:13
RPCHitsTestTool::m_pRpcIdHelper
const RpcIdHelper * m_pRpcIdHelper
Definition: RPCHitsTestTool.h:38
RPCHitsTestTool::getIdentifier
Identifier getIdentifier(HitID rpchit)
Definition: RPCHitsTestTool.cxx:25
RpcHitIdHelper::GetZSector
int GetZSector(const int &hid) const
Definition: RpcHitIdHelper.cxx:74
RpcReadoutElement.h
Identifier
Definition: IdentifierFieldParser.cxx:14