ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Simulation
G4Atlas
G4AtlasTests
src
CSCHitsTestTool.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 "
CSCHitsTestTool.h
"
6
7
#include "
GeneratorObjects/McEventCollection.h
"
8
#include "CLHEP/Vector/LorentzVector.h"
9
10
#include "
GeoAdaptors/GeoMuonHits.h
"
11
#include "
MuonReadoutGeometry/MuonDetectorManager.h
"
12
#include "
MuonReadoutGeometry/CscReadoutElement.h
"
13
#include "
MuonSimEvent/CSCSimHitCollection.h
"
14
#include "
MuonSimEvent/CSCSimHit.h
"
15
#include "
MuonIdHelpers/CscIdHelper.h
"
16
#include "
MuonSimEvent/CscHitIdHelper.h
"
17
18
#include <TH1D.h>
19
#include <TH2D.h>
20
21
22
Identifier
CSCHitsTestTool::getIdentifier
(
HitID
cschit) {
23
const
CscHitIdHelper
* cschelper =
CscHitIdHelper::GetHelper
();
24
25
const
std::string & csc_stname = cschelper->
GetStationName
(cschit);
26
int
csc_steta = cschelper->
GetZSector
(cschit);
27
int
csc_stphi = cschelper->
GetPhiSector
(cschit);
28
int
csc_cl = cschelper->
GetChamberLayer
(cschit);
29
int
csc_wl = cschelper->
GetWireLayer
(cschit);
30
int
csc_measphi = 1;
31
int
csc_strip = 1;
32
33
// Create the offline identifiers, fill them with hit info. Ready to be
34
// accessed and retrieve info. Currently not used in this code except for
35
// some checks.
36
// ======================================================================
37
Identifier
offid =
m_pCscIdHelper
->channelID(csc_stname, csc_steta,
38
csc_stphi, csc_cl, csc_wl,
39
csc_measphi, csc_strip);
40
if
(offid == 0) {
41
ATH_MSG_FATAL
(
"CSC: Cannot build a valid Identifier; skip "
);
42
}
43
// *AS* really info level? perhaps debug or verbose?
44
ATH_MSG_VERBOSE
(
" CSC: Offline Id "
<<
m_pCscIdHelper
->show_to_string(offid));
45
return
offid;
46
}
47
48
StatusCode
CSCHitsTestTool::checkIdentifier
(
Identifier
offid) {
49
const
MuonGM::CscReadoutElement
* descriptor =
m_pMuonMgr
->getCscReadoutElement(offid);
50
if
(!descriptor) {
51
ATH_MSG_FATAL
(
"CSC readout element not found for Id = "
<<
m_pCscIdHelper
->show_to_string(offid));
52
return
StatusCode::FAILURE;
53
}
54
55
// Testing Sim to Offline ID conversion
56
Amg::Vector3D
csc_gPos = descriptor->
stripPos
(offid);
57
double
csc_strip_phi = csc_gPos.phi();
58
if
(csc_strip_phi < 0.) csc_strip_phi += 2.*
M_PI
;
59
double
csc_strip_perp __attribute ((
unused
)) = csc_gPos.perp();
60
double
csc_strip_z __attribute ((
unused
)) = csc_gPos.z();
61
double
csc_strip_cot __attribute ((
unused
)) = 1./tan(csc_gPos.theta());
62
63
return
StatusCode::SUCCESS;
64
}
65
66
StatusCode
CSCHitsTestTool::processEvent
() {
67
CHECK
(
executeCheckEventInfo
());
68
69
// *AS* which direction is selected in the end?
70
// should match with truth particle using barcode (particleID)
71
72
// MuonSpectrometer
73
// Get the generic MuonSpectrometer (MDT,RPC,CSC,TGC) histograms
74
// Short description:
75
// MuonSpectrometer cross section
76
// MuonSpectrometer longitudinal
77
// Number of events processed from truth
78
// Event specific run number
79
// Eta, Theta, Phi, z residual (...), phi residual (...) of hits in MuonSpectrometer
80
81
// CSC
82
// Get the CSC histograms
83
// Short description:
84
// MuonSpectrometer RPC cross section
85
// MuonSpectrometer RPC longitudinal
86
// Eta, Theta, Phi, z residual (...), phi residual (...) of hits in CSCs
87
88
if
(
m_DoCSCTest
) {
89
// -- loop over CSC hit collection --
90
const
CSCSimHitCollection
* p_collection =
nullptr
;
91
if
(evtStore()->retrieve(p_collection,
"CSC_Hits"
) == StatusCode::SUCCESS) {
92
for
(
const
CSCSimHit
&
hit
: *p_collection) {
93
94
// Check the Hits identifiers, access the functions that give:
95
// Station name, station eta, station phi, chamber layer, wire layer.
96
HitID
cschit=
hit
.CSCid();
97
Identifier
offid=
getIdentifier
(cschit);
98
CHECK
(
checkIdentifier
(offid));
99
100
// Check Hits. For every hit within the event, get the global position
101
// Amg::Vector3D u and then retrieve all releveant info either from the
102
// Amg::Vector3D or from the MC vector (direction)
103
GeoCSCHit
ghit(
hit
);
104
if
(!ghit)
continue
;
105
Amg::Vector3D
u = ghit.
getGlobalPosition
();
106
CHECK
(
executeFillHistos
(u));
107
}
108
}
109
}
110
111
return
StatusCode::SUCCESS;
112
}
113
114
StatusCode
CSCHitsTestTool::initialize
() {
115
// initialise general histograms
116
CHECK
(
MuonHitTestToolBase::initialize
());
117
118
m_pCscIdHelper
=
m_pMuonMgr
->cscIdHelper();
119
120
return
StatusCode::SUCCESS;
121
}
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
CSCHitsTestTool.h
CSCSimHitCollection.h
CSCSimHitCollection
AtlasHitsVector< CSCSimHit > CSCSimHitCollection
Definition
CSCSimHitCollection.h:14
CSCSimHit.h
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition
Control/AthenaKernel/AthenaKernel/errorcheck.h:422
CscHitIdHelper.h
CscIdHelper.h
CscReadoutElement.h
HitID
int HitID
Definition
GenericMuonSimHit.h:13
GeoMuonHits.h
hit
bool hit(const Container &ids, int pdgId)
Definition
JetIRCSafeLabelTool.cxx:64
McEventCollection.h
MuonDetectorManager.h
unused
void unused(Args &&...)
Definition
VP1ExpertSettings.cxx:39
CSCHitsTestTool::initialize
StatusCode initialize()
Definition
CSCHitsTestTool.cxx:114
CSCHitsTestTool::processEvent
StatusCode processEvent()
Definition
CSCHitsTestTool.cxx:66
CSCHitsTestTool::m_pCscIdHelper
const CscIdHelper * m_pCscIdHelper
Definition
CSCHitsTestTool.h:36
CSCHitsTestTool::getIdentifier
Identifier getIdentifier(HitID)
Definition
CSCHitsTestTool.cxx:22
CSCHitsTestTool::checkIdentifier
StatusCode checkIdentifier(Identifier)
Definition
CSCHitsTestTool.cxx:48
CSCHitsTestTool::m_DoCSCTest
bool m_DoCSCTest
Definition
CSCHitsTestTool.h:34
CSCSimHit
Definition
CSCSimHit.h:18
CscHitIdHelper
Definition
CscHitIdHelper.h:13
CscHitIdHelper::GetWireLayer
int GetWireLayer(const int &hid) const
Definition
CscHitIdHelper.cxx:83
CscHitIdHelper::GetZSector
int GetZSector(const int &hid) const
Definition
CscHitIdHelper.cxx:72
CscHitIdHelper::GetPhiSector
int GetPhiSector(const int &hid) const
Definition
CscHitIdHelper.cxx:67
CscHitIdHelper::GetStationName
std::string GetStationName(const int &hid) const
Definition
CscHitIdHelper.cxx:56
CscHitIdHelper::GetChamberLayer
int GetChamberLayer(const int &hid) const
Definition
CscHitIdHelper.cxx:78
CscHitIdHelper::GetHelper
static const CscHitIdHelper * GetHelper()
Definition
CscHitIdHelper.cxx:23
GeoCSCHit
Definition
GeoMuonHits.h:131
GeoCSCHit::getGlobalPosition
Amg::Vector3D getGlobalPosition() const
MuonGM::CscReadoutElement
Definition
CscReadoutElement.h:56
MuonGM::CscReadoutElement::stripPos
Amg::Vector3D stripPos(const Identifier &id) const
takes into account internal alignment parameters, hence gives accurate answer
Definition
CscReadoutElement.cxx:227
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
Generated on
for ATLAS Offline Software by
1.17.0