|
| 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_BASE_HIT_H |
| 13 | +#define ALICEO2_BASE_HIT_H |
| 14 | +#include "MathUtils/Cartesian.h" |
| 15 | + |
| 16 | +namespace o2 |
| 17 | +{ |
| 18 | + |
| 19 | +// Mother class of all hit classes for AliceO2 |
| 20 | +// just defines what is absolutely necessary to have |
| 21 | +// as common interface |
| 22 | +// at the moment ony GetTrackID() used by Stack.h |
| 23 | +// eventually we could add some interfaces to retrieve |
| 24 | +// the coordinates as floats or something |
| 25 | +class BaseHit |
| 26 | +{ |
| 27 | + public: |
| 28 | + BaseHit() = default; |
| 29 | + BaseHit(int id) : mTrackID{id} {} |
| 30 | + int GetTrackID() const { return mTrackID; } |
| 31 | + void SetTrackID(int id) { mTrackID = id; } |
| 32 | + |
| 33 | + private: |
| 34 | + int mTrackID = 0; // track_id |
| 35 | + ClassDefNV(BaseHit, 1); |
| 36 | +}; |
| 37 | + |
| 38 | +// a set of configurable classes to define basic hit types |
| 39 | +// these are meant to be an alternative to FairMCPoint |
| 40 | +// which always includes the momentum and is purely based on double values |
| 41 | + |
| 42 | +// Generic class to keep position, time and hit value |
| 43 | +// T is basic type for position, |
| 44 | +// E is basic type for time, |
| 45 | +// V is basic type for hit value. |
| 46 | +template <typename T, typename E, typename V = float, typename U = short int > |
| 47 | +class BasicXYZVHit : public BaseHit |
| 48 | +{ |
| 49 | + math_utils::Point3D<T> mPos; // cartesian position of Hit |
| 50 | + E mTime; // time of flight |
| 51 | + V mHitValue; // hit value |
| 52 | + U mDetectorID; // the detector/sensor id |
| 53 | + |
| 54 | + public: |
| 55 | + BasicXYZVHit() = default; // for ROOT IO |
| 56 | + |
| 57 | + // constructor |
| 58 | + BasicXYZVHit(T x, T y, T z, E time, V val, int trackid, short did) |
| 59 | + : mPos(x, y, z), mTime(time), mHitValue(val), BaseHit(trackid), mDetectorID(did) |
| 60 | + { |
| 61 | + } |
| 62 | + |
| 63 | + // getting the cartesian coordinates |
| 64 | + T GetX() const { return mPos.X(); } |
| 65 | + T GetY() const { return mPos.Y(); } |
| 66 | + T GetZ() const { return mPos.Z(); } |
| 67 | + math_utils::Point3D<T> GetPos() const { return mPos; } |
| 68 | + // getting hit value |
| 69 | + V GetHitValue() const { return mHitValue; } |
| 70 | + // getting the time |
| 71 | + E GetTime() const { return mTime; } |
| 72 | + // get detector + track information |
| 73 | + short GetDetectorID() const { return mDetectorID; } |
| 74 | + |
| 75 | + // modifiers |
| 76 | + void SetTime(E time) { mTime = time; } |
| 77 | + void SetHitValue(V val) { mHitValue = val; } |
| 78 | + void SetDetectorID(U detID) { mDetectorID = detID; } |
| 79 | + void SetX(T x) { mPos.SetX(x); } |
| 80 | + void SetY(T y) { mPos.SetY(y); } |
| 81 | + void SetZ(T z) { mPos.SetZ(z); } |
| 82 | + void SetXYZ(T x, T y, T z) |
| 83 | + { |
| 84 | + SetX(x); |
| 85 | + SetY(y); |
| 86 | + SetZ(z); |
| 87 | + } |
| 88 | + void SetPos(math_utils::Point3D<T> const& p) { mPos = p; } |
| 89 | + |
| 90 | + ClassDefNV(BasicXYZVHit, 1); |
| 91 | +}; |
| 92 | + |
| 93 | +// Class for a hit containing energy loss as hit value |
| 94 | +// T is basic type for position, |
| 95 | +// E is basic type for time (float as default), |
| 96 | +// V is basic type for hit value (float as default). |
| 97 | +template <typename T, typename E = float, typename V = float> |
| 98 | +class BasicXYZEHit : public BasicXYZVHit<T, E, V> |
| 99 | +{ |
| 100 | + public: |
| 101 | + using BasicXYZVHit<T, E, V>::BasicXYZVHit; |
| 102 | + |
| 103 | + V GetEnergyLoss() const { return BasicXYZVHit<T, E, V>::GetHitValue(); } |
| 104 | + void SetEnergyLoss(V val) { BasicXYZVHit<T, E, V>::SetHitValue(val); } |
| 105 | + |
| 106 | + ClassDefNV(BasicXYZEHit, 1); |
| 107 | +}; |
| 108 | + |
| 109 | +// Class for a hit containing charge as hit value |
| 110 | +// T is basic type for position, |
| 111 | +// E is basic type for time (float as default), |
| 112 | +// V is basic type for hit value (int as default). |
| 113 | +template <typename T, typename E = float, typename V = int> |
| 114 | +class BasicXYZQHit : public BasicXYZVHit<T, E, V> |
| 115 | +{ |
| 116 | + public: |
| 117 | + using BasicXYZVHit<T, E, V>::BasicXYZVHit; |
| 118 | + |
| 119 | + V GetCharge() const { return BasicXYZVHit<T, E, V>::GetHitValue(); } |
| 120 | + void SetCharge(V val) { BasicXYZVHit<T, E, V>::SetHitValue(val); } |
| 121 | + |
| 122 | + ClassDefNV(BasicXYZQHit, 1); |
| 123 | +}; |
| 124 | + |
| 125 | +} // namespace o2 |
| 126 | +#endif |
0 commit comments