Skip to content

Commit 2fdf62c

Browse files
committed
Added trk::Hit + fixed unsigned short ID
1 parent 5bb1a4f commit 2fdf62c

File tree

8 files changed

+230
-36
lines changed

8 files changed

+230
-36
lines changed

Detectors/Upgrades/ALICE3/TRK/base/include/TRKBase/GeometryTGeo.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class GeometryTGeo : public o2::detectors::DetMatrixCache
101101
/// \param int halfstave The half stave number for MLOT. Can be 0 or 1
102102
/// \param int module The module number for MLOT, from 0 to 10 (or 20)
103103
/// \param int chip The chip number for MLOT, from 0 to 8
104-
int getChipIndex(int subDetID, int petalcase, int disk, int lay, int stave, int halfstave, int mod, int chip) const;
104+
unsigned short getChipIndex(int subDetID, int petalcase, int disk, int lay, int stave, int halfstave, int mod, int chip) const;
105105

106106
/// This routine computes the chip index number from the subDetID, volume, layer, stave, half stave, module, chip
107107
/// \param int subDetID The subdetector ID, 0 for VD, 1 for MLOT
@@ -111,7 +111,7 @@ class GeometryTGeo : public o2::detectors::DetMatrixCache
111111
/// \param int halfstave The half stave number for MLOT. Can be 0 or 1
112112
/// \param int module The module number for MLOT, from 0 to 10 (or 20)
113113
/// \param int chip The chip number for MLOT, from 0 to 8
114-
int getChipIndex(int subDetID, int volume, int lay, int stave, int halfstave, int mod, int chip) const;
114+
unsigned short getChipIndex(int subDetID, int volume, int lay, int stave, int halfstave, int mod, int chip) const;
115115

116116
/// This routine computes subDetID, petal, disk, layer, stave, half stave, module, chip, given the chip index number
117117
/// \param int index The chip index number, starting from 0
@@ -125,8 +125,8 @@ class GeometryTGeo : public o2::detectors::DetMatrixCache
125125
/// \param int chip The chip number for MLOT, from 0 to 8
126126
bool getChipID(int index, int& subDetID, int& petalcase, int& disk, int& lay, int& stave, int& halfstave, int& mod, int& chip) const;
127127

128-
int getLastChipIndex(int lay) const { return mLastChipIndex[lay]; }
129-
int getFirstChipIndex(int lay, int petalcase, int subDetID) const
128+
unsigned short getLastChipIndex(int lay) const { return mLastChipIndex[lay]; }
129+
unsigned short getFirstChipIndex(int lay, int petalcase, int subDetID) const
130130
{
131131
/// Get the first chip index of the active petal (VD) or layer (MLOT)
132132
if (subDetID == 0) { // VD
@@ -190,9 +190,9 @@ class GeometryTGeo : public o2::detectors::DetMatrixCache
190190
// std::vector<int> mNumberOfChipsPerStave; ///< number of chips per stave in ML/OT
191191
// std::vector<int> mNumberOfChipsPerHalfStave; ///< number of chips per half stave in ML/OT
192192
// std::vector<int> mNumberOfChipsPerModule; ///< number of chips per module in ML/OT
193-
std::vector<int> mLastChipIndex; ///< max ID of the detctor in the petal(VD) or layer(MLOT)
194-
std::vector<int> mLastChipIndexVD; ///< max ID of the detctor in the layer for the VD
195-
std::vector<int> mLastChipIndexMLOT; ///< max ID of the detctor in the layer for the MLOT
193+
std::vector<unsigned short> mLastChipIndex; ///< max ID of the detctor in the petal(VD) or layer(MLOT)
194+
std::vector<unsigned short> mLastChipIndexVD; ///< max ID of the detctor in the layer for the VD
195+
std::vector<unsigned short> mLastChipIndexMLOT; ///< max ID of the detctor in the layer for the MLOT
196196

197197
std::array<char, MAXLAYERS> mLayerToWrapper; ///< Layer to wrapper correspondence, not implemented yet
198198

Detectors/Upgrades/ALICE3/TRK/base/src/GeometryTGeo.cxx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include <TGeoManager.h>
1414
#include "TRKBase/SegmentationChip.h"
1515

16+
#include <limits>
17+
1618
using Segmentation = o2::trk::SegmentationChip;
1719

1820
namespace o2
@@ -304,7 +306,7 @@ int GeometryTGeo::getChip(int index) const
304306
}
305307

306308
//__________________________________________________________________________
307-
int GeometryTGeo::getChipIndex(int subDetID, int petalcase, int disk, int lay, int stave, int halfstave, int mod, int chip) const
309+
unsigned short GeometryTGeo::getChipIndex(int subDetID, int petalcase, int disk, int lay, int stave, int halfstave, int mod, int chip) const
308310
{
309311
if (subDetID == 0) { // VD
310312
if (lay == -1) { // disk
@@ -328,11 +330,13 @@ int GeometryTGeo::getChipIndex(int subDetID, int petalcase, int disk, int lay, i
328330
return getFirstChipIndex(lay, petalcase, subDetID) + stave * chipsPerStave + mod * chipsPerModule + chip;
329331
}
330332
}
331-
return -1; // not found
333+
334+
LOGP(warning, "Chip index not found for subDetID %d, petalcase %d, disk %d, layer %d, stave %d, halfstave %d, module %d, chip %d, returning numeric limit", subDetID, petalcase, disk, lay, stave, halfstave, mod, chip);
335+
return std::numeric_limits<unsigned short>::max(); // not found
332336
}
333337

334338
//__________________________________________________________________________
335-
int GeometryTGeo::getChipIndex(int subDetID, int volume, int lay, int stave, int halfstave, int mod, int chip) const
339+
unsigned short GeometryTGeo::getChipIndex(int subDetID, int volume, int lay, int stave, int halfstave, int mod, int chip) const
336340
{
337341
if (subDetID == 0) { // VD
338342
return volume; /// In the current configuration for VD, each volume is the sensor element = chip. // TODO: when the geometry naming scheme will be changed, change this method
@@ -353,7 +357,9 @@ int GeometryTGeo::getChipIndex(int subDetID, int volume, int lay, int stave, int
353357
return getFirstChipIndex(lay, -1, subDetID) + stave * chipsPerStave + mod * chipsPerModule + chip;
354358
}
355359
}
356-
return -1; // not found
360+
361+
LOGP(warning, "Chip index not found for subDetID %d, volume %d, layer %d, stave %d, halfstave %d, module %d, chip %d, returning numeric limit", subDetID, volume, lay, stave, halfstave, mod, chip);
362+
return std::numeric_limits<unsigned short>::max(); // not found
357363
}
358364

359365
//__________________________________________________________________________

Detectors/Upgrades/ALICE3/TRK/simulation/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
# or submit itself to any jurisdiction.
1111

1212
o2_add_library(TRKSimulation
13-
SOURCES src/TRKLayer.cxx
13+
SOURCES src/Hit.cxx
14+
src/TRKLayer.cxx
1415
src/ChipDigitsContainer.cxx
1516
src/ChipSimResponse.cxx
1617
src/Detector.cxx
@@ -27,7 +28,8 @@ o2_add_library(TRKSimulation
2728
O2::SimulationDataFormat)
2829

2930
o2_target_root_dictionary(TRKSimulation
30-
HEADERS include/TRKSimulation/ChipDigitsContainer.h
31+
HEADERS include/TRKSimulation/Hit.h
32+
include/TRKSimulation/ChipDigitsContainer.h
3133
include/TRKSimulation/ChipSimResponse.h
3234
include/TRKSimulation/DigiParams.h
3335
include/TRKSimulation/Digitizer.h

Detectors/Upgrades/ALICE3/TRK/simulation/include/TRKSimulation/Detector.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#define ALICEO2_TRK_DETECTOR_H
1414

1515
#include "DetectorsBase/Detector.h"
16-
#include "ITSMFTSimulation/Hit.h"
16+
#include "TRKSimulation/Hit.h"
1717

1818
#include "TRKSimulation/TRKLayer.h"
1919
#include "TRKSimulation/TRKServices.h"
@@ -42,9 +42,9 @@ class Detector : public o2::base::DetImpl<Detector>
4242

4343
void ConstructGeometry() override;
4444

45-
o2::itsmft::Hit* addHit(int trackID, int detID, const TVector3& startPos, const TVector3& endPos,
46-
const TVector3& startMom, double startE, double endTime, double eLoss,
47-
unsigned char startStatus, unsigned char endStatus);
45+
o2::trk::Hit* addHit(int trackID, unsigned short detID, const TVector3& startPos, const TVector3& endPos,
46+
const TVector3& startMom, double startE, double endTime, double eLoss,
47+
unsigned char startStatus, unsigned char endStatus);
4848

4949
// Mandatory overrides
5050
void BeginPrimary() override { ; }
@@ -57,8 +57,8 @@ class Detector : public o2::base::DetImpl<Detector>
5757
void Register() override;
5858
void Reset() override;
5959

60-
// Custom memer functions
61-
std::vector<o2::itsmft::Hit>* getHits(int iColl) const
60+
// Custom member functions
61+
std::vector<o2::trk::Hit>* getHits(int iColl) const
6262
{
6363
if (!iColl) {
6464
return mHits;
@@ -81,14 +81,14 @@ class Detector : public o2::base::DetImpl<Detector>
8181

8282
// Transient data about track passing the sensor
8383
struct TrackData {
84-
bool mHitStarted; // hit creation started
85-
unsigned char mTrkStatusStart; // track status flag
86-
TLorentzVector mPositionStart; // position at entrance
87-
TLorentzVector mMomentumStart; // momentum
88-
double mEnergyLoss; // energy loss
89-
} mTrackData; //! transient data
90-
GeometryTGeo* mGeometryTGeo; //!
91-
std::vector<o2::itsmft::Hit>* mHits; // ITSMFT ones for the moment
84+
bool mHitStarted; // hit creation started
85+
unsigned char mTrkStatusStart; // track status flag
86+
TLorentzVector mPositionStart; // position at entrance
87+
TLorentzVector mMomentumStart; // momentum
88+
double mEnergyLoss; // energy loss
89+
} mTrackData; //! transient data
90+
GeometryTGeo* mGeometryTGeo; //!
91+
std::vector<o2::trk::Hit>* mHits; // ITSMFT ones for the moment
9292
std::vector<TRKLayer> mLayers;
9393
TRKServices mServices; // Houses the services of the TRK, but not the Iris tracker
9494

@@ -109,7 +109,7 @@ class Detector : public o2::base::DetImpl<Detector>
109109

110110
template <typename Det>
111111
friend class o2::base::DetImpl;
112-
ClassDefOverride(Detector, 1);
112+
ClassDefOverride(Detector, 2);
113113
};
114114
} // namespace trk
115115
} // namespace o2
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
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+
/// \file Hit.h
13+
/// \brief Definition of the TRK Hit class
14+
15+
#ifndef ALICEO2_TRK_POINT_H_
16+
#define ALICEO2_TRK_POINT_H_
17+
18+
#include "SimulationDataFormat/BaseHits.h" // for BasicXYZEHit
19+
#include "Rtypes.h" // for Bool_t, Double_t, Int_t, Double32_t, etc
20+
#include "TVector3.h" // for TVector3
21+
#include <iosfwd>
22+
#include "CommonUtils/ShmAllocator.h"
23+
24+
namespace o2
25+
{
26+
namespace trk
27+
{
28+
29+
class Hit : public o2::BasicXYZEHit<Float_t, Float_t>
30+
{
31+
32+
public:
33+
enum HitStatus_t {
34+
kTrackEntering = 0x1,
35+
kTrackInside = 0x1 << 1,
36+
kTrackExiting = 0x1 << 2,
37+
kTrackOut = 0x1 << 3,
38+
kTrackStopped = 0x1 << 4,
39+
kTrackAlive = 0x1 << 5
40+
};
41+
42+
/// Default constructor
43+
Hit() = default;
44+
45+
/// Class Constructor
46+
/// \param trackID Index of MCTrack
47+
/// \param detID Detector ID
48+
/// \param startPos Coordinates at entrance to active volume [cm]
49+
/// \param pos Coordinates to active volume [cm]
50+
/// \param mom Momentum of track at entrance [GeV]
51+
/// \param endTime Time at entrance [ns]
52+
/// \param time Time since event start [ns]
53+
/// \param eLoss Energy deposit [GeV]
54+
/// \param startStatus: status at entrance
55+
/// \param endStatus: status at exit
56+
inline Hit(int trackID, unsigned short detID, const TVector3& startPos, const TVector3& pos, const TVector3& mom, double startE,
57+
double endTime, double eLoss, unsigned char statusStart, unsigned char status);
58+
59+
// Entrance position getters
60+
math_utils::Point3D<Float_t> GetPosStart() const { return mPosStart; }
61+
Float_t GetStartX() const { return mPosStart.X(); }
62+
Float_t GetStartY() const { return mPosStart.Y(); }
63+
Float_t GetStartZ() const { return mPosStart.Z(); }
64+
template <typename F>
65+
void GetStartPosition(F& x, F& y, F& z) const
66+
{
67+
x = GetStartX();
68+
y = GetStartY();
69+
z = GetStartZ();
70+
}
71+
// momentum getters
72+
math_utils::Vector3D<Float_t> GetMomentum() const { return mMomentum; }
73+
math_utils::Vector3D<Float_t>& GetMomentum() { return mMomentum; }
74+
Float_t GetPx() const { return mMomentum.X(); }
75+
Float_t GetPy() const { return mMomentum.Y(); }
76+
Float_t GetPz() const { return mMomentum.Z(); }
77+
Float_t GetE() const { return mE; }
78+
Float_t GetTotalEnergy() const { return GetE(); }
79+
80+
UChar_t GetStatusEnd() const { return mTrackStatusEnd; }
81+
UChar_t GetStatusStart() const { return mTrackStatusStart; }
82+
83+
Bool_t IsEntering() const { return mTrackStatusEnd & kTrackEntering; }
84+
Bool_t IsInside() const { return mTrackStatusEnd & kTrackInside; }
85+
Bool_t IsExiting() const { return mTrackStatusEnd & kTrackExiting; }
86+
Bool_t IsOut() const { return mTrackStatusEnd & kTrackOut; }
87+
Bool_t IsStopped() const { return mTrackStatusEnd & kTrackStopped; }
88+
Bool_t IsAlive() const { return mTrackStatusEnd & kTrackAlive; }
89+
90+
Bool_t IsEnteringStart() const { return mTrackStatusStart & kTrackEntering; }
91+
Bool_t IsInsideStart() const { return mTrackStatusStart & kTrackInside; }
92+
Bool_t IsExitingStart() const { return mTrackStatusStart & kTrackExiting; }
93+
Bool_t IsOutStart() const { return mTrackStatusStart & kTrackOut; }
94+
Bool_t IsStoppedStart() const { return mTrackStatusStart & kTrackStopped; }
95+
Bool_t IsAliveStart() const { return mTrackStatusStart & kTrackAlive; }
96+
97+
// Entrance position setter
98+
void SetPosStart(const math_utils::Point3D<Float_t>& p) { mPosStart = p; }
99+
100+
/// Output to screen
101+
void Print(const Option_t* opt) const;
102+
friend std::ostream& operator<<(std::ostream& of, const Hit& point)
103+
{
104+
of << "-I- Hit: O2its point for track " << point.GetTrackID() << " in detector " << point.GetDetectorID() << std::endl;
105+
/*
106+
of << " Position (" << point.fX << ", " << point.fY << ", " << point.fZ << ") cm" << std::endl;
107+
of << " Momentum (" << point.fPx << ", " << point.fPy << ", " << point.fPz << ") GeV" << std::endl;
108+
of << " Time " << point.fTime << " ns, Length " << point.fLength << " cm, Energy loss "
109+
<< point.fELoss * 1.0e06 << " keV" << std::endl;
110+
*/
111+
return of;
112+
}
113+
114+
private:
115+
math_utils::Vector3D<Float_t> mMomentum; ///< momentum at entrance
116+
math_utils::Point3D<Float_t> mPosStart; ///< position at entrance (base mPos give position on exit)
117+
Float_t mE; ///< total energy at entrance
118+
UChar_t mTrackStatusEnd; ///< MC status flag at exit
119+
UChar_t mTrackStatusStart; ///< MC status at starting point
120+
121+
ClassDefNV(Hit, 1);
122+
};
123+
124+
Hit::Hit(int trackID, unsigned short detID, const TVector3& startPos, const TVector3& endPos, const TVector3& startMom,
125+
double startE, double endTime, double eLoss, unsigned char startStatus, unsigned char endStatus)
126+
: BasicXYZEHit(endPos.X(), endPos.Y(), endPos.Z(), endTime, eLoss, trackID, detID),
127+
mMomentum(startMom.Px(), startMom.Py(), startMom.Pz()),
128+
mPosStart(startPos.X(), startPos.Y(), startPos.Z()),
129+
mE(startE),
130+
mTrackStatusEnd(endStatus),
131+
mTrackStatusStart(startStatus)
132+
{
133+
}
134+
135+
} // namespace trk
136+
} // namespace o2
137+
138+
#ifdef USESHM
139+
namespace std
140+
{
141+
template <>
142+
class allocator<o2::trk::Hit> : public o2::utils::ShmAllocator<o2::trk::Hit>
143+
{
144+
};
145+
} // namespace std
146+
147+
#endif
148+
149+
#endif

Detectors/Upgrades/ALICE3/TRK/simulation/src/Detector.cxx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@
1616
#include <TGeoVolume.h>
1717

1818
#include "DetectorsBase/Stack.h"
19-
#include "ITSMFTSimulation/Hit.h"
19+
#include "TRKSimulation/Hit.h"
2020
#include "TRKSimulation/Detector.h"
2121
#include "TRKBase/TRKBaseParam.h"
2222
#include "TRKSimulation/VDGeometryBuilder.h"
2323
#include "TRKSimulation/VDSensorRegistry.h"
2424

2525
#include <string>
2626

27-
using o2::itsmft::Hit;
27+
using o2::trk::Hit;
2828

2929
namespace o2
3030
{
@@ -39,14 +39,14 @@ float getDetLengthFromEta(const float eta, const float radius)
3939
Detector::Detector()
4040
: o2::base::DetImpl<Detector>("TRK", true),
4141
mTrackData(),
42-
mHits(o2::utils::createSimVector<o2::itsmft::Hit>())
42+
mHits(o2::utils::createSimVector<o2::trk::Hit>())
4343
{
4444
}
4545

4646
Detector::Detector(bool active)
4747
: o2::base::DetImpl<Detector>("TRK", true),
4848
mTrackData(),
49-
mHits(o2::utils::createSimVector<o2::itsmft::Hit>())
49+
mHits(o2::utils::createSimVector<o2::trk::Hit>())
5050
{
5151
auto& trkPars = TRKBaseParam::Instance();
5252

@@ -473,7 +473,7 @@ bool Detector::ProcessHits(FairVolume* vol)
473473
}
474474
} /// if VD, for the moment the volume is the "chipID" so no need to retrieve other elments
475475

476-
int chipID = mGeometryTGeo->getChipIndex(subDetID, volume, layer, stave, halfstave, mod, chip);
476+
unsigned short chipID = mGeometryTGeo->getChipIndex(subDetID, volume, layer, stave, halfstave, mod, chip);
477477

478478
Print(vol, volume, subDetID, layer, stave, halfstave, mod, chip, chipID);
479479

@@ -492,9 +492,9 @@ bool Detector::ProcessHits(FairVolume* vol)
492492
return true;
493493
}
494494

495-
o2::itsmft::Hit* Detector::addHit(int trackID, int detID, const TVector3& startPos, const TVector3& endPos,
496-
const TVector3& startMom, double startE, double endTime, double eLoss, unsigned char startStatus,
497-
unsigned char endStatus)
495+
o2::trk::Hit* Detector::addHit(int trackID, unsigned short detID, const TVector3& startPos, const TVector3& endPos,
496+
const TVector3& startMom, double startE, double endTime, double eLoss, unsigned char startStatus,
497+
unsigned char endStatus)
498498
{
499499
mHits->emplace_back(trackID, detID, startPos, endPos, startMom, startE, endTime, eLoss, startStatus, endStatus);
500500
return &(mHits->back());

0 commit comments

Comments
 (0)