|
| 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 |
0 commit comments