Project
Loading...
Searching...
No Matches
Detector.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
12#ifndef ALICEO2_ZDC_DETECTOR_H_
13#define ALICEO2_ZDC_DETECTOR_H_
14
15#include <vector> // for vector
16#include "TGeoManager.h" // for gGeoManager, TGeoManager (ptr only)
17#include "DetectorsBase/GeometryManager.h" // for getSensID
18#include "DetectorsBase/Detector.h" // for Detector
19#include "DetectorsCommonDataFormats/DetID.h" // for Detector
20#include "ZDCBase/Geometry.h"
21#include "DataFormatsZDC/Hit.h"
23#include "TParticle.h"
24#include <utility>
25#include "ZDCBase/Constants.h"
26
27// inclusions and forward decl for fast sim
28#ifdef ZDC_FASTSIM_ONNX
29
30#if __has_include(<onnxruntime/core/session/onnxruntime_cxx_api.h>)
31#include <onnxruntime/core/session/onnxruntime_cxx_api.h>
32#else
33#include <onnxruntime_cxx_api.h>
34#endif
35
36namespace o2::zdc
37{
38namespace fastsim
39{
40class NeuralFastSimulation;
41namespace processors
42{
43class StandardScaler;
44}
45} // namespace fastsim
46} // namespace o2::zdc
47#endif
48
49class FairVolume;
50
51namespace o2::zdc
52{
53
54class Detector : public o2::base::DetImpl<Detector>
55{
56 public:
59 kCuZn = 2,
62 kPb = 5,
63 kCu = 6,
64 kFe = 7,
69 kAir = 12,
70 kAl = 13,
71 kGraphite = 14
72 };
73
74 Detector(Bool_t active = true);
75
76// if building fastsim non trivial destructor is required
77#ifdef ZDC_FASTSIM_ONNX
78 ~Detector() override;
79#endif
80#ifndef ZDC_FASTSIM_ONNX
81 ~Detector() override = default;
82#endif
83
84 void InitializeO2Detector() final;
85 bool isMTSafe() const override { return true; }
86
87 Bool_t ProcessHits(FairVolume* v = nullptr) final;
88
89 bool createHitsFromImage(SpatialPhotonResponse const& image, int detector);
90
91 void Register() override;
92
94 std::vector<o2::zdc::Hit>* getHits(int32_t iColl) const
95 {
96 if (iColl == 0) {
97 return mHits;
98 }
99 return nullptr;
100 }
101
102 void Reset() final;
103 void EndOfEvent() final;
104 void FinishPrimary() final;
105
106 void BeginPrimary() final;
107
108 void ConstructGeometry() final;
109
110 void createMaterials();
111 void addAlignableVolumes() const override {}
112
113 o2::zdc::Hit* addHit(int32_t trackID, int32_t parentID, int32_t sFlag, float primaryEnergy, int32_t detID, int32_t secID,
114 math_utils::Vector3D<float> pos, math_utils::Vector3D<float> mom, float tof, math_utils::Vector3D<float> xImpact, double energyloss,
115 int32_t nphePMC, int32_t nphePMQ);
116
117 private:
119 Detector(const Detector& rhs);
120
121 void createAsideBeamLine();
122 void createCsideBeamLine();
123 void createMagnets();
124 void createDetectors();
125 void createZNZP();
126 void createZEM();
127
130 static Bool_t withZEM();
131
132 // determine detector; sector/tower and impact coordinates given volumename and position
133 void getDetIDandSecID(TString const& volname, math_utils::Vector3D<float> const& x,
134 math_utils::Vector3D<float>& xDet, int& detector, int& sector) const;
135
136 // Define sensitive volumes
137 void defineSensitiveVolumes();
138
139 // Methods to calculate the light outpu
140 Bool_t calculateTableIndexes(int& ibeta, int& iangle, int& iradius);
141
142 void resetHitIndices();
143
145 void setupFastSim();
146
147 // common function for hit creation (can be called from multiple interfaces)
148 bool createOrAddHit(int detector,
149 int sector,
150 int currentMediumid,
151 bool issecondary,
152 int nphe,
153 int trackn,
154 int parent,
155 float tof,
156 float trackenergy,
157 math_utils::Vector3D<float> const& xImp,
158 float eDep, float x, float y, float z, float px, float py, float pz)
159 {
160 // A new hit is created when there is nothing yet for this det + sector
161 if (mCurrentHitsIndices[detector - 1][sector] == -1) {
162 mTotLightPMC = mTotLightPMQ = 0;
163 if (currentMediumid == mMediumPMCid) {
164 mTotLightPMC = nphe;
165 } else if (currentMediumid == mMediumPMQid) {
166 mTotLightPMQ = nphe;
167 }
168
169 math_utils::Vector3D<float> pos(x, y, z);
170 math_utils::Vector3D<float> mom(px, py, pz);
171 addHit(trackn, parent, issecondary, trackenergy, detector, sector,
172 pos, mom, tof, xImp, eDep, mTotLightPMC, mTotLightPMQ);
173 // stack->addHit(GetDetId());
174 mCurrentHitsIndices[detector - 1][sector] = mHits->size() - 1;
175
176 mXImpact = xImp;
177 return true;
178 } else {
179 auto& curHit = (*mHits)[mCurrentHitsIndices[detector - 1][sector]];
180 // summing variables that needs to be updated (Eloss and light yield)
181 curHit.setNoNumContributingSteps(curHit.getNumContributingSteps() + 1);
182 int nPMC{0}, nPMQ{0};
183 if (currentMediumid == mMediumPMCid) {
184 mTotLightPMC += nphe;
185 nPMC = nphe;
186 } else if (currentMediumid == mMediumPMQid) {
187 mTotLightPMQ += nphe;
188 nPMQ = nphe;
189 }
190 if (nphe > 0) {
191 curHit.SetEnergyLoss(curHit.GetEnergyLoss() + eDep);
192 curHit.setPMCLightYield(curHit.getPMCLightYield() + nPMC);
193 curHit.setPMQLightYield(curHit.getPMQLightYield() + nPMQ);
194 }
195 return true;
196 }
197 }
198
199 // helper function taking care of writing the photon response pattern at certain moments
200 void flushSpatialResponse();
201
202 float mTrackEta;
203 float mPrimaryEnergy;
204 math_utils::Vector3D<float> mXImpact;
205 float mTotLightPMC;
206 float mTotLightPMQ;
207 int32_t mMediumPMCid = -1;
208 int32_t mMediumPMQid = -2;
209
210 //
212 std::vector<o2::zdc::Hit>* mHits;
213
214 float mLumiLength = 0; // TODO: make part of configurable params
215 float mTCLIAAPERTURE = 3.5; // TODO: make part of configurable params
216 float mTCLIAAPERTURENEG = 3.5; // TODO: make part of configurable params
217 float mVCollSideCCentreY = 0.; // TODO: make part of configurable params
218
219 int mZNENVVolID = -1; // the volume id for the neutron det envelope volume
220 int mZPENVVolID = -1; // the volume id for the proton det envelope volume
221 int mZEMVolID = -1; // the volume id for the e-m envelope volume
222
223 // last principal track entered for each of the 5 detectors
224 // this is the main trackID causing showering/response in the detectors
225 int mLastPrincipalTrackEntered = -1;
226
227 static constexpr int NUMDETS = 5; // number of detectors
228 static constexpr int NUMSECS = 5; // number of (max) possible sectors (including COMMON one)
229
230 // current hits per detector and per sector FOR THE CURRENT track first entering a detector
231 // (as given by mLastPrincipalTrackEntered)
232 // This is given as index where to find in mHits container
233 int mCurrentHitsIndices[NUMDETS][NUMSECS] = {-1};
234
235 static constexpr int ZNRADIUSBINS = 18;
236 static constexpr int ZPRADIUSBINS = 28;
237 static constexpr int ANGLEBINS = 90;
238
239 float mLightTableZN[4][ANGLEBINS][ZNRADIUSBINS] = {1.};
240 float mLightTableZP[4][ANGLEBINS][ZPRADIUSBINS] = {1.};
241
242 SpatialPhotonResponse mNeutronResponseImage;
243 // there is only one proton detector per side
244 SpatialPhotonResponse mProtonResponseImage;
245
246 TParticle mCurrentPrincipalParticle{};
247
248 // collecting the responses for the current event
249 using ParticlePhotonResponse = std::vector<std::pair<TParticle,
250 std::pair<SpatialPhotonResponse, SpatialPhotonResponse>>>;
251
252 ParticlePhotonResponse mResponses;
253 ParticlePhotonResponse* mResponsesPtr = &mResponses;
254
255// fastsim model wrapper
256#ifdef ZDC_FASTSIM_ONNX
257 fastsim::NeuralFastSimulation* mFastSimClassifier = nullptr;
258 fastsim::NeuralFastSimulation* mFastSimModelNeutron = nullptr;
259 fastsim::NeuralFastSimulation* mFastSimModelProton = nullptr;
260
261 // Scalers for models inputs
262 fastsim::processors::StandardScaler* mClassifierScaler = nullptr;
263 fastsim::processors::StandardScaler* mModelScalerNeutron = nullptr;
264 fastsim::processors::StandardScaler* mModelScalerProton = nullptr;
265
266 // container for fastsim model responses
267 using FastSimResults = std::vector<std::array<long, 5>>;
268 FastSimResults mFastSimResults;
269
270 // converts FastSim model results to Hit
271 bool FastSimToHits(const Ort::Value& response, const TParticle& particle, int detector);
272
273 // determines detector geometry "pixel sizes"
274 constexpr std::pair<const int, const int> determineDetectorSize(int detector)
275 {
276 if (detector == ZNA || detector == ZNC) {
278 } else if (detector == ZPA || detector == ZPC) {
280 } else {
281 return {-1, -1};
282 }
283 }
284#endif
285
286 template <typename Det>
287 friend class o2::base::DetImpl;
288 ClassDefOverride(Detector, 1);
289};
290} // namespace o2::zdc
291
292#ifdef USESHM
293namespace o2
294{
295namespace base
296{
297template <>
298struct UseShm<o2::zdc::Detector> {
299 static constexpr bool value = true;
300};
301} // namespace base
302} // namespace o2
303#endif
304
305#endif
Definition of the Detector class.
Definition of the ZDC Hit class.
Definition of the GeometryManager class.
configStandalone Light OpenGL display display_light Apply smoothing to points Enable Z buffer Highlight links Highlight seeds Highlight sector tracks Highlight final tracks Show individual sector
configStandalone Reconstruction rec_tpc multiplier for the combined cluster track error during track following area in cm for the search of for z only used if decrease removal by when above this local occupancy rowx Shift of TPC revert cluster flag edge bit distance to edge exceeds this ZOffset for secondary multiple of radius max P of electron K BB bands crossing max P of electron p BB bands crossing max P of electron d BB bands crossing max P of electron t BB bands crossing min accepted dEdxMaxTPC of the track Additive extra cluster error for Y2 if edge flag set Additive extra cluster error for Y2 if single set Additive extra cluster error for Y2 if or single set Additive extra cluster error for Z2 if or single set Extra errors to add to track when crossing depending on addErrorsCECrossing Inner portion of y range in sector that is not used in searching for extrapolated track candidates factor2YS for track merging factor2K for track merging Margin in cm of Y position when rejecting edge clusters based on uncorrected track Y Max fraction of shared clusters for tracklet Except pad from cluster finding if total number of charges in a fragment is above this Except pad from cluster finding if number of consecutive charges in a fragment is above this Threshold where a timebin is considered disabling the noisy pad check for that pad Treat signal above this minimum as saturated Smoothing factor for the exponential Highly Ionising Particle tail filter Number of timebins to use for the averaging Add additional custom track errors when crossing relative as fraction of Do N fit passes in final fit of< 0:reject at max -n hits") AddOptionRTC(rejectIFCLowRadiusCluster, uint8_t, 1, "", 0, "Reject clusters that get the IFC mask error during refit") AddOptionRTC(dEdxTruncLow, uint8_t, 2, "", 0, "Low truncation threshold, fraction of 128") AddOptionRTC(dEdxTruncHigh, uint8_t, 77, "", 0, "High truncation threshold, fraction of 128") AddOptionRTC(extrapolationTracking, int8_t, 1, "", 0, "Enable Extrapolation Tracking(prolong tracks to adjacent sectors to find short segments)") AddOptionRTC(disableRefitAttachment, uint8_t, 0, "", 0, "Bitmask to disable certain attachment steps during refit(1:attachment, 2:propagation, 4:loop following, 8:mirroring)") AddOptionRTC(rejectionStrategy, uint8_t, o2::gpu::GPUSettings::RejectionStrategyA, "", 0, "Enable rejection of TPC clusters for compression(0=no, 1=strategy A, 2=strategy B)") AddOptionRTC(mergeLoopersAfterburner, uint8_t, 1, "", 0, "Run afterburner for additional looper merging") AddOptionRTC(compressionTypeMask, uint8_t, o2::gpu::GPUSettings::CompressionFull, "", 0, "TPC Compression mode bits(1=truncate charge/width LSB, 2=differences, 4=track-model)") AddOptionRTC(compressionSortOrder, uint8_t, o2::gpu::GPUSettings::SortTime, "", 0, "Sort order of TPC compression(0=time, 1=pad, 2=Z-time-pad, 3=Z-pad-time, 4=no sorting(use incoming order))") AddOptionRTC(sigBitsCharge, uint8_t, 4, "", 0, "Number of significant bits for TPC cluster charge in compression mode 1") AddOptionRTC(sigBitsWidth, uint8_t, 3, "", 0, "Number of significant bits for TPC cluster width in compression mode 1") AddOptionRTC(dropLoopers, uint8_t, 0, "", 0, "Drop looping tracks starting from second loop") AddOptionRTC(mergerInterpolateErrors, uint8_t, 1, "", 0, "Use interpolation instead of extrapolation for chi2 based cluster rejection") AddOptionRTC(mergerInterpolateRejectAlsoOnCurrentPosition, uint8_t, 1, "", 0, "When using mergerInterpolateErrors, reject based on chi2 twice computed with interpolated and current track position starting from NDF > mergerNonInterpolateRejectMinNDF Merge tracks accross the central electrode Enable PID response Add sub threshold clusters in TPC dEdx computation OR mask of TPC flags that will reject the cluster in alternative dEdx Reject edge clusters based on uncorrected track Y during track fit Increase decrease removal by when on this number of pads from the edge h configStandalone Reconstruction rec_trd Max chi2 for TRD tracklets to be matched to a track Chi2 cut for strict matching mode Number of sigmas for ITS TPC track time error estimate Addition to search road around track prolongation along Y in cm Optimal tracklet rphi resolution in maximum chi2 per attached tracklet for TRD tracks take into account the full likelihood of the slope including exponential tails Tracks with less attached tracklets are discarded after the tracking Post trigger Pile up integration time in BCs fits all iterations but the last one in projections Use material lookup table for TPC refit Apply workarounds to avoid cyclic merge should not be needed tpc dyn configStandalone Processing proc_rtc Replace constant variables static by constexpr expressions Compile RTC in deterministic with NO_FAST_MATH flags and GPUCA_DETERMINISTIC_MODE define Use RTC to optimize GPU code h configStandalone Processing proc_rtctech Use a file lock to serialize access to the cache folder int32_t
uint16_t pos
Definition RawData.h:3
Visualizing spatial photon response in ZDC neutron and proton calorimeters.
Detector()
Default Constructor.
Definition Detector.cxx:36
std::vector< o2::zdc::Hit > * getHits(int32_t iColl) const
Gets the produced collections.
Definition Detector.h:94
o2::zdc::Hit * addHit(int32_t trackID, int32_t parentID, int32_t sFlag, float primaryEnergy, int32_t detID, int32_t secID, math_utils::Vector3D< float > pos, math_utils::Vector3D< float > mom, float tof, math_utils::Vector3D< float > xImpact, double energyloss, int32_t nphePMC, int32_t nphePMQ)
Definition Detector.cxx:633
void BeginPrimary() final
bool isMTSafe() const override
whether this detector may run in multithreaded Geant4, with one clone per worker thread
Definition Detector.h:85
void addAlignableVolumes() const override
declare alignable volumes of detector
Definition Detector.h:111
void ConstructGeometry() final
Definition Detector.cxx:365
void Register() override
Definition Detector.cxx:343
void InitializeO2Detector() final
Definition Detector.cxx:201
void FinishPrimary() final
~Detector() override=default
Bool_t ProcessHits(FairVolume *v=nullptr) final
Definition Detector.cxx:412
void EndOfEvent() final
Definition Detector.cxx:331
bool createHitsFromImage(SpatialPhotonResponse const &image, int detector)
Definition Detector.cxx:559
void Reset() final
Definition Detector.cxx:357
static constexpr double ZNDIVISION[2]
Definition Geometry.h:30
static constexpr double ZPSECTORS[2]
Definition Geometry.h:38
static constexpr double ZNSECTORS[2]
Definition Geometry.h:29
static constexpr double ZPDIVISION[2]
Definition Geometry.h:39
GLeglImageOES image
Definition glcorearb.h:4021
GLint GLenum GLint x
Definition glcorearb.h:403
const GLdouble * v
Definition glcorearb.h:832
GLint y
Definition glcorearb.h:270
GLsizei const GLfloat * value
Definition glcorearb.h:819
GLdouble GLdouble GLdouble z
Definition glcorearb.h:843
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...