ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Simulation
G4Atlas
G4AtlasTests
src
MDTHitsTestTool.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 "
MDTHitsTestTool.h
"
6
7
#include "Identifier/Identifier.h"
8
9
#include "
GeoAdaptors/GeoMuonHits.h
"
10
11
#include "
MuonReadoutGeometry/MuonDetectorManager.h
"
12
#include "
MuonReadoutGeometry/MdtReadoutElement.h
"
13
14
#include "
MuonIdHelpers/MdtIdHelper.h
"
15
#include "
MuonSimEvent/MdtHitIdHelper.h
"
16
17
#include "
MuonSimEvent/MDTSimHitCollection.h
"
18
#include "
MuonSimEvent/MDTSimHit.h
"
19
20
#include "
GeneratorObjects/McEventCollection.h
"
21
#include "CLHEP/Vector/LorentzVector.h"
22
23
#include "GaudiKernel/NTuple.h"
24
#include "GaudiKernel/SmartDataPtr.h"
25
#include "GaudiKernel/IDataProviderSvc.h"
26
#include "GaudiKernel/ITHistSvc.h"
27
#include "GaudiKernel/INTupleSvc.h"
28
29
#include "TH2D.h"
30
#include "TTree.h"
31
#include "TROOT.h"
32
#include "TFile.h"
33
#include "TF1.h"
34
#include "TH1F.h"
35
36
using namespace
MuonGM
;
37
38
Identifier
MDTHitsTestTool::getIdentifier
(
HitID
mdthit
)
39
{
40
const
MdtHitIdHelper
* mdthelper =
MdtHitIdHelper::GetHelper
(
m_pMdtIdHelper
->tubeMax());
41
std::string mdt_stname = mdthelper->
GetStationName
(
mdthit
);
42
int
mdt_steta = mdthelper->
GetZSector
(
mdthit
);
43
int
mdt_stphi = mdthelper->
GetPhiSector
(
mdthit
);
44
int
mdt_ml = mdthelper->
GetMultiLayer
(
mdthit
);
45
int
mdt_tl = mdthelper->
GetLayer
(
mdthit
);
46
int
mdt_tube = mdthelper->
GetTube
(
mdthit
);
47
48
// Create the offline identifiers, fill them with hit info. Ready to be
49
// accessed and retrieve info. Currently not used in this code except
50
// for some checks.
51
Identifier
offid =
m_pMdtIdHelper
->channelID(mdt_stname, mdt_steta, mdt_stphi,mdt_ml,mdt_tl,mdt_tube);
52
if
(offid == 0){
53
ATH_MSG_FATAL
(
"MDT: Cannot build a valid Identifier; skip "
);
54
}
55
56
ATH_MSG_VERBOSE
(
" MDT: Offline Id "
<<
m_pMdtIdHelper
->show_to_string(offid));
57
return
offid;
58
}
59
60
StatusCode
MDTHitsTestTool::checkIdentifier
(
Identifier
offid) {
61
const
MuonGM::MdtReadoutElement
* descriptor =
m_pMuonMgr
->getMdtReadoutElement(offid);
62
if
(descriptor == NULL) {
63
ATH_MSG_FATAL
(
"MDT readout element not found for Id = "
<<
m_pMdtIdHelper
->show_to_string(offid));
64
return
StatusCode::FAILURE;
65
}
66
67
// Testing Sim to Offline ID conversion
68
Amg::Vector3D
mdt_gPos = descriptor->
tubePos
(offid);
69
// double mdt_tube_pos = sqrt(mdt_gPos.perp()*mdt_gPos.perp()+mdt_gPos.z()*mdt_gPos.z());
70
double
mdt_tube_phi = mdt_gPos.phi();
71
if
(mdt_tube_phi < 0.) mdt_tube_phi += 2.*
M_PI
;
72
// double mdt_tube_perp = mdt_gPos.perp();
73
// double mdt_tube_z = mdt_gPos.z();
74
// double mdt_tube_cot = 1./tan(mdt_gPos.theta());
75
//Amg::Transform3D xf = descriptor->getMaterialGeom()->getAbsoluteTransform(); //FIXME in the future??
76
//*AS* Amg::Vector3D xU = xf*Amg::Vector3D((*i_hit).localPosition().x(),-(*i_hit).localPosition().z(), (*i_hit).localPosition().y());
77
//*AS*Amg::Vector3D gx = mdt_gPos + xU;
78
79
return
StatusCode::SUCCESS;
80
}
81
82
StatusCode
MDTHitsTestTool::processEvent
() {
83
CHECK
(
executeCheckEventInfo
());
84
85
// MuonSpectrometer
86
// Get the generic MuonSpectrometer (MDT,RPC,CSC,TGC) histograms
87
// Short description:
88
// MuonSpectrometer cross section
89
// MuonSpectrometer longitudinal
90
// Number of events processed from truth
91
// Event specific run number
92
// Eta, Theta, Phi, z residual (...), phi residual (...) of hits in MuonSpectrometer
93
94
// MDT
95
// Get the MDT histograms
96
// Short description:
97
// MuonSpectrometer MDT cross section (affected by m_BarrelEtaCut)
98
// MuonSpectrometer MDT longitudinal
99
// Eta, Theta, Phi, z residual (...), phi residual (...) of hits in MDTs
100
101
102
if
(
m_DoMDTTest
) {
103
const
MDTSimHitCollection
* p_collection =
nullptr
;
104
if
(evtStore()->retrieve(p_collection,
"MDT_Hits"
) == StatusCode::SUCCESS) {
105
for
(
const
MDTSimHit
&
hit
: *p_collection) {
106
// Check the Hits identifiers, access the functions that give:
107
// Station name, station eta, station phi, multilayer ID, layer ID, tube ID.
108
HitID
mdthit
= (
hit
).MDTid();
109
Identifier
offid=
getIdentifier
(
mdthit
);
110
CHECK
(
checkIdentifier
(offid));
111
112
113
114
// Check Hits
115
// For every hit within the event, get the global position Amg::Vector3D u and then retrieve all releveant info
116
// either from the Amg::Vector3D or from the MC vector (direction)
117
GeoMDTHit
ghit(
hit
);
118
if
(!ghit)
continue
;
119
Amg::Vector3D
u = ghit.
getGlobalPosition
();
120
CHECK
(
executeFillHistos
(u));
121
}
122
}
123
}
124
125
return
StatusCode::SUCCESS;
126
}
127
128
129
StatusCode
MDTHitsTestTool::initialize
() {
130
CHECK
(
MuonHitTestToolBase::initialize
());
131
// CHECK(detStore()->retrieve(m_pMuonMgr));
132
m_pMdtIdHelper
=
m_pMuonMgr
->mdtIdHelper();
133
return
StatusCode::SUCCESS;
134
}
M_PI
#define M_PI
Definition
ActiveFraction.h:14
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition
AthMsgStreamMacros.h:34
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition
AthMsgStreamMacros.h:28
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition
Control/AthenaKernel/AthenaKernel/errorcheck.h:422
HitID
int HitID
Definition
GenericMuonSimHit.h:13
GeoMuonHits.h
hit
bool hit(const Container &ids, int pdgId)
Definition
JetIRCSafeLabelTool.cxx:64
MDTHitsTestTool.h
MDTSimHitCollection.h
MDTSimHitCollection
AtlasHitsVector< MDTSimHit > MDTSimHitCollection
Definition
MDTSimHitCollection.h:14
MDTSimHit.h
McEventCollection.h
MdtHitIdHelper.h
MdtIdHelper.h
MdtReadoutElement.h
MuonDetectorManager.h
GeoMDTHit
Definition
GeoMuonHits.h:64
GeoMDTHit::getGlobalPosition
Amg::Vector3D getGlobalPosition() const
MDTHitsTestTool::initialize
StatusCode initialize()
Definition
MDTHitsTestTool.cxx:129
MDTHitsTestTool::checkIdentifier
StatusCode checkIdentifier(Identifier offid)
Definition
MDTHitsTestTool.cxx:60
MDTHitsTestTool::getIdentifier
Identifier getIdentifier(HitID cschit)
Definition
MDTHitsTestTool.cxx:38
MDTHitsTestTool::m_pMdtIdHelper
const MdtIdHelper * m_pMdtIdHelper
Definition
MDTHitsTestTool.h:39
MDTHitsTestTool::processEvent
StatusCode processEvent()
Definition
MDTHitsTestTool.cxx:82
MDTHitsTestTool::m_DoMDTTest
bool m_DoMDTTest
Definition
MDTHitsTestTool.h:37
MDTSimHit
Definition
MDTSimHit.h:21
MdtHitIdHelper
Definition
MdtHitIdHelper.h:13
MdtHitIdHelper::GetHelper
static const MdtHitIdHelper * GetHelper(unsigned int nTubes=78)
Definition
MdtHitIdHelper.cxx:24
MdtHitIdHelper::GetPhiSector
int GetPhiSector(const int &hid) const
Definition
MdtHitIdHelper.cxx:68
MdtHitIdHelper::GetMultiLayer
int GetMultiLayer(const int &hid) const
Definition
MdtHitIdHelper.cxx:79
MdtHitIdHelper::GetStationName
std::string GetStationName(const int &hid) const
Definition
MdtHitIdHelper.cxx:57
MdtHitIdHelper::GetZSector
int GetZSector(const int &hid) const
Definition
MdtHitIdHelper.cxx:73
MdtHitIdHelper::GetLayer
int GetLayer(const int &hid) const
Definition
MdtHitIdHelper.cxx:84
MdtHitIdHelper::GetTube
int GetTube(const int &hid) const
Definition
MdtHitIdHelper.cxx:89
MuonGM::MdtReadoutElement
Definition
MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MdtReadoutElement.h:51
MuonGM::MdtReadoutElement::tubePos
Amg::Vector3D tubePos(const Identifier &id) const
Returns the global position of the given tube.
MuonHitTestToolBase::executeFillHistos
StatusCode executeFillHistos(const Amg::Vector3D &)
Definition
MuonHitTestToolBase.cxx:70
MuonHitTestToolBase::m_pMuonMgr
const MuonGM::MuonDetectorManager * m_pMuonMgr
Definition
MuonHitTestToolBase.h:38
MuonHitTestToolBase::executeCheckEventInfo
StatusCode executeCheckEventInfo()
Definition
MuonHitTestToolBase.cxx:35
MuonHitTestToolBase::initialize
virtual StatusCode initialize() override
Definition
MuonHitTestToolBase.cxx:111
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition
GeoPrimitives.h:47
Identifier
Definition
IdentifierFieldParser.cxx:14
MuonGM
Ensure that the Athena extensions are properly loaded.
Definition
GeoMuonHits.h:27
mdthit
Definition
MuonFeatureDetails_p2.h:26
Generated on
for ATLAS Offline Software by
1.17.0