forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDetector.h
More file actions
240 lines (198 loc) · 8.22 KB
/
Detector.h
File metadata and controls
240 lines (198 loc) · 8.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
#ifndef ALICEO2_FOCAL_DETECTOR_H_
#define ALICEO2_FOCAL_DETECTOR_H_
#include <vector>
#include "DetectorsBase/Detector.h"
#include "FOCALBase/Hit.h"
#include "FOCALBase/Geometry.h"
#include "TGeoManager.h"
class FairVolume;
namespace o2::focal
{
class Hit;
class Geometry;
/// \struct Parent
/// \brief Information about superparent (particle entering any FOCAL volume)
/// \ingroup FOCALsimulation
struct Parent {
int mPDG; ///< PDG code
double mEnergy; ///< Total energy
bool mHasTrackReference; ///< Flag indicating whether parent has a track reference
};
/// \class Detector
/// \brief FOCAL detector simulation
/// \ingroup FOCALsimulation
/// \author Markus Fasel <markus.fasel@cern.ch>, Oak Ridge National Laboratory
/// \since June 6, 2024
/// \author Adam Matyja <adam.tomasz.matyja@cern.ch>, Institute of Nuclear Physics, PAN, Cracov, Poland
/// \since June 24, 2024
/// class based on AliFOCALv2.h in aliroot
/// It builds the ECAL (Adam) and HCAL (Hadi) seperately
/// For the ECAL: it builds it tower by tower
/// For the HCAL:
///
/// The detector class handles the implementation of the FOCAL detector
/// within the virtual Monte-Carlo framework and the simulation of the
/// FOCAL detector up to hit generation
class Detector : public o2::base::DetImpl<Detector>
{
public:
enum MediumType_t { ID_TUNGSTEN = 0,
ID_SIPAD = 1,
ID_SIPIX = 2,
ID_G10 = 3,
ID_COPPER = 4,
ID_STEEL = 5,
ID_ALLOY = 6,
ID_CERAMIC = 7,
ID_PB = 8,
ID_SC = 9,
ID_SIINSENS = 10,
ID_ALUMINIUM = 11,
ID_VAC = 12,
ID_AIR = 13 };
/// \brief Dummy constructor
Detector() = default;
/// \brief Main constructor
///
/// \param isActive Switch whether detector is active in simulation
Detector(Bool_t isActive, std::string geofilename = "default");
/// \brief Destructor
~Detector() override;
/// \brief Initializing detector
void InitializeO2Detector() override;
/// \brief Processing hit creation in the FOCAL sensitive volume
/// \param v Current sensitive volume
Bool_t ProcessHits(FairVolume* v = nullptr) final;
/// \brief Add FOCAL hit
/// \param trackID Index of the track in the MC stack
/// \param primary Index of the primary particle in the MC stack
/// \param initialEnergy Energy of the particle entering the FOCAL
/// \param detID Index of the detector (cell) for which the hit is created
/// \param pos Position vector of the particle at the hit
/// \param mom Momentum vector of the particle at the hit
/// \param time Time of the hit
/// \param energyloss Energy deposit in FOCAL
/// \return Pointer to the current hit
///
/// Internally adding hits coming from the same track
Hit* AddHit(int trackID, int primary, double initialEnergy, int detID, o2::focal::Hit::Subsystem_t subsystem,
const math_utils::Point3D<float>& pos, double time, double energyloss);
/// \brief register container with hits
void Register() override;
/// \brief Get access to the hits
/// \return Hit collection
std::vector<Hit>* getHits(Int_t iColl) const
{
if (iColl == 0) {
return mHits;
}
return nullptr;
}
/// \brief Clean point collection
void Reset() final;
/// \brief Steps to be carried out at the end of the event
///
/// For FOCAL cleaning the hit collection and the lookup table
void EndOfEvent() final;
/// \brief Begin primaray
///
/// Caching current primary ID and set current parent ID to the
/// current primary ID
void BeginPrimary() override;
/// \brief Finish current primary
///
/// Reset caches for current primary, current parent and current cell
void FinishPrimary() override;
/// \brief Get the FOCAL geometry desciption
/// \return Access to the FOCAL Geometry description
///
/// Will be created the first time the function is called
Geometry* getGeometry(std::string name = "");
/// \brief Try to find hit with same cell and parent track ID
/// \param parentID ID of the parent track
/// \param col Column of the cell
/// \param row Row of the cell
/// \param Layer Layer of cell
Hit* FindHit(int parentID, int col, int row, int layer);
protected:
/// \brief Creating detector materials for the FOCAL detector
void CreateMaterials();
virtual void addAlignableVolumes() const override;
void addAlignableVolumesHCAL() const;
void addAlignableVolumesECAL() const;
void ConstructGeometry() override;
virtual void CreateHCALSpaghetti();
virtual void CreateHCALSandwich();
virtual void CreateHCALSheets();
TGeoVolumeAssembly* CreatePitchAssembly(double Lx = 498.1,
double Ly1 = 2.0,
double Ly2 = 1.5,
double Lz = 1100.0,
double hole_diameter = 1.1,
double hole_spacing = 4.0,
int nholes = 124,
double fiber_radius = 0.5,
std::string suffix = "");
/// \brief Generate ECAL geometry
void CreateECALGeometry();
/// \brief Add new superparent to the container
/// \param trackID Track ID of the superparent
/// \param pdg PDG code of the superparent
/// \param energy Energy of the superparent
Parent* AddSuperparent(int trackID, int pdg, double energy);
/// \brief Processing hit creation in the ECAL Pad sensitive volume
/// \param v Current sensitive volume
bool ProcessHitsEPad(FairVolume* v = nullptr);
/// \brief Processing hit creation in the ECAL Pixel sensitive volume
/// \param v Current sensitive volume
bool ProcessHitsEPix(FairVolume* v = nullptr);
/// \brief Processing hit creation in the HCAL sensitive volume
/// \param v Current sensitive volume
bool ProcessHitsHCAL(FairVolume* v = nullptr);
private:
/// \brief Copy constructor (used in MT)
Detector(const Detector& rhs);
Geometry* mGeometry; //!<! Geometry pointer
int mMedSensHCal = 0; //!<! Sensitive Medium for HCal
int mMedSensECalPad = 0; //!<! Sensitive Medium for ECal Pads
int mMedSensECalPix = 0; //!<! Sensitive Medium for ECal Pixels
std::vector<const Composition*> mGeoCompositions; //!<! list of FOCAL compositions
std::vector<o2::focal::Hit>* mHits; ///< Container with hits
std::unordered_map<Hit::HitID, unsigned int, Hit::HitIDHasher> mHitIndexMapping; ///< Mapping the hits to a cell in the detector
std::unordered_map<int, int> mSuperParentsIndices; //!<! Super parent indices (track index - superparent index)
std::unordered_map<int, Parent> mSuperParents; //!<! Super parent kine info (superparent index - superparent object)
Parent* mCurrentSuperparent; //!<! Pointer to the current superparent
// Worker variables during hit creation
Int_t mCurrentTrack; //!<! Current track
Int_t mCurrentPrimaryID; //!<! ID of the current primary
Int_t mCurrentParentID; //!<! ID of the current parent
std::vector<std::string> mSensitive; //!<! List of sensitive volumes
int mVolumeIDScintillator = -1; //!<! Volume ID of the scintillator volume
template <typename Det>
friend class o2::base::DetImpl;
ClassDefOverride(Detector, 1);
};
} // namespace o2::focal
#ifdef USESHM
namespace o2
{
namespace base
{
template <>
struct UseShm<o2::focal::Detector> {
static constexpr bool value = true;
};
} // namespace base
} // namespace o2
#endif
#endif // ALICEO2_FOCAL_DETECTOR_H_