ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Simulation
G4Atlas
G4AtlasTests
src
ALFA_SimHitsTestTool.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
ALFA_SimHitsTestTool.h
"
6
7
#include "
ALFA_SimEv/ALFA_HitCollection.h
"
8
9
10
#include <TH2D.h>
11
#include <TH1.h>
12
#include <TProfile.h>
13
14
#include <iostream>
15
#include <fstream>
16
#include <sstream>
17
#include <string>
18
#include <memory>
19
#include <array>
20
21
namespace
{
22
template
<
class
T, std::
size_t
N>
using
A
= std::array<T,N>;
23
}
24
25
26
ALFA_SimHitsTestTool::ALFA_SimHitsTestTool
(
const
std::string&
type
,
const
std::string& name,
const
IInterface* parent)
27
:
SimTestToolBase
(
type
, name, parent)
28
{
29
for
(
int
i(0); i<8; ++i) {
30
m_E_full_sum_h
[i]=
nullptr
;
31
m_E_layer_sum_h
[i]=
nullptr
;
32
m_hit_map_h
[i]=
nullptr
;
33
}
34
}
35
36
StatusCode
ALFA_SimHitsTestTool::initialize
()
37
{
38
m_path
+=
"ALFA/"
;
39
40
_TH1D
(
m_E_gvs
,
"edep_full_in_gvs"
, 8, -0.5, 7.5);
41
_SET_TITLE
(
m_E_gvs
,
"Energy deposit in GVS"
,
"Station"
,
"E (MeV)"
);
42
43
std::stringstream s;
44
for
(
unsigned
int
j=0; j<8; j++) {
45
s.str(
""
);
46
s << j+1;
47
48
_TH1D
(
m_E_full_sum_h
[j],(
"edep_full_in_det_no."
+s.str()), 100, 0., 5.);
49
_SET_TITLE
(
m_E_full_sum_h
[j],
"Energy deposit in full detector"
,
"E (MeV)"
,
"N"
);
50
51
_TH2D
(
m_E_layer_sum_h
[j],(
"edep_per_layer_detector_no."
+s.str()), 100, 0., 0.5, 22, 0., 21.);
52
_SET_TITLE
(
m_E_layer_sum_h
[j],
"Energy deposit in layers"
,
"E (MeV)"
,
"layer"
);
53
54
_TH2D
(
m_hit_map_h
[j],(
"hitmap_det_no."
+s.str()), 22, 0., 21., 66, 0., 65.);
55
_SET_TITLE
(
m_hit_map_h
[j],
"hit map - layer vs fiber"
,
"layer"
,
"fiber"
);
56
}
57
58
return
StatusCode::SUCCESS;
59
}
60
61
StatusCode
ALFA_SimHitsTestTool::processEvent
() {
62
63
int
fiber{}, plate{},
sign
{}, station{};
64
//
65
// cleaning
66
constexpr
int
station_max{8};
67
constexpr
int
plate_max{10};
68
constexpr
int
fiber_max{64};
69
70
//avoid large stack use; E_fiber_sum would use 81920 bytes
71
using
FiberArr =
A<A<A<A<double,2>
, fiber_max>, plate_max>,station_max>;
72
auto
pE_fiber_sum = std::make_unique<FiberArr>();
73
auto
& E_fiber_sum = *pE_fiber_sum;
74
double
E_full_sum[station_max]{};
75
double
E_layer_sum[station_max][20]{};
76
77
78
const
ALFA_HitCollection
* coll_handle =
nullptr
;
79
CHECK
( evtStore()->retrieve(coll_handle,
"ALFA_HitCollection"
) );
80
81
82
for
(
const
ALFA_Hit
&
hit
: *coll_handle) {
83
84
station =
hit
.GetStationNumber();
85
plate =
hit
.GetPlateNumber();
86
fiber =
hit
.GetFiberNumber();
87
sign
=
hit
.GetSignFiber();
88
if
(plate==100) {
89
// Treat hits in GVS separately.
90
m_E_gvs
->Fill(station,(
hit
.GetEnergyDeposit()));
91
continue
;
92
}
93
E_fiber_sum[station-1][plate-1][fiber-1][(1-
sign
)/2] += (
hit
.GetEnergyDeposit());
94
}
95
96
for
(
int
l = 0; l < station_max; l++ ) {
97
for
(
int
i = 0; i < plate_max; i++ ){
98
for
(
int
j = 0; j < fiber_max; j++ ) {
99
for
(
int
k = 0; k < 2; k++ ) {
100
E_full_sum[l] += E_fiber_sum[l][i][j][k];
101
E_layer_sum[l][2*i+k] += E_fiber_sum[l][i][j][k];
102
if
(E_fiber_sum[l][i][j][k] > 0.) {
103
m_hit_map_h
[l]->Fill(2*i+k+1,j+1);
104
}
105
}
106
}
107
}
108
}
109
110
for
(
int
l = 0; l < station_max; l++ ) {
111
m_E_full_sum_h
[l]->Fill(E_full_sum[l]);
112
for
(
int
i = 0; i < 2*plate_max; i++ ) {
113
m_E_layer_sum_h
[l]->Fill(E_layer_sum[l][i],i+1);
114
}
115
}
116
117
return
StatusCode::SUCCESS;
118
}
ALFA_HitCollection.h
ALFA_HitCollection
AtlasHitsVector< ALFA_Hit > ALFA_HitCollection
Definition
ALFA_HitCollection.h:13
ALFA_SimHitsTestTool.h
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition
Control/AthenaKernel/AthenaKernel/errorcheck.h:422
hit
bool hit(const Container &ids, int pdgId)
Definition
JetIRCSafeLabelTool.cxx:64
_TH2D
#define _TH2D(var, name, nbinx, xmin, xmax, nbiny, ymin, ymax)
Definition
SimTestHisto.h:91
_TH1D
#define _TH1D(var, name, nbin, xmin, xmax)
Definition
SimTestHisto.h:52
_SET_TITLE
#define _SET_TITLE(var, title, xaxis, yaxis)
Definition
SimTestHisto.h:107
sign
int sign(int a)
Definition
TRT_StrawNeighbourSvc.h:108
ALFA_Hit
Definition
ALFA_Hit.h:10
ALFA_SimHitsTestTool::processEvent
StatusCode processEvent()
Definition
ALFA_SimHitsTestTool.cxx:61
ALFA_SimHitsTestTool::m_E_gvs
TH1 * m_E_gvs
Definition
ALFA_SimHitsTestTool.h:27
ALFA_SimHitsTestTool::m_E_full_sum_h
TH1 * m_E_full_sum_h[8]
Definition
ALFA_SimHitsTestTool.h:26
ALFA_SimHitsTestTool::initialize
StatusCode initialize()
Definition
ALFA_SimHitsTestTool.cxx:36
ALFA_SimHitsTestTool::ALFA_SimHitsTestTool
ALFA_SimHitsTestTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition
ALFA_SimHitsTestTool.cxx:26
ALFA_SimHitsTestTool::m_hit_map_h
TH2 * m_hit_map_h[8]
Definition
ALFA_SimHitsTestTool.h:24
ALFA_SimHitsTestTool::m_E_layer_sum_h
TH2 * m_E_layer_sum_h[8]
Definition
ALFA_SimHitsTestTool.h:25
SimTestHisto::m_path
std::string m_path
Definition
SimTestHisto.h:34
SimTestToolBase::SimTestToolBase
SimTestToolBase(const std::string &type, const std::string &name, const IInterface *parent)
Definition
SimTestToolBase.cxx:11
A
hold the test vectors and ease the comparison
type
Generated on
for ATLAS Offline Software by
1.17.0