FairShip
Loading...
Searching...
No Matches
Detector.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-3.0-or-later
2// SPDX-FileCopyrightText: Copyright CERN for the benefit of the SHiP
3// Collaboration
4
5#ifndef DETECTOR_DETECTOR_H_
6#define DETECTOR_DETECTOR_H_
7
8#include <utility>
9#include <vector>
10
11#include "DetectorPoint.h"
12#include "FairDetector.h"
13#include "FairRootManager.h"
14#include "ISTLPointContainer.h"
15#include "TLorentzVector.h"
16#include "TVector3.h"
17
18namespace SHiP {
19template <typename PointType>
20class Detector : public FairDetector, public ISTLPointContainer {
21 public:
22 Detector() = default;
23 ~Detector() override = default;
24 Detector(const char* Name, Bool_t Active, Int_t detID)
25 : FairDetector(Name, Active, detID),
26 fEventID(-1),
27 fTrackID(-1),
28 fVolumeID(-1),
29 fPos(),
30 fMom(),
31 fTime(-1.),
32 fLength(-1.),
33 fELoss(-1) {}
34
35 Detector(const char* Name, Bool_t Active) : Detector(Name, Active, 0) {}
36
37 template <typename... Args>
38 PointType* AddHit(Args&&... args) {
39 fDetPoints->emplace_back(std::forward<Args>(args)...);
40 return &(fDetPoints->back());
41 }
42
44 void ConstructGeometry() override = 0;
45
46 void Initialize() override { FairDetector::Initialize(); }
47
48 void Reset() override { fDetPoints->clear(); }
49
50 void EndOfEvent() override { fDetPoints->clear(); }
51
52 void Register() override {
53 fDetPoints = new std::vector<PointType>();
54 FairRootManager::Instance()->RegisterAny(PointType::Class()->GetName(),
55 fDetPoints, kTRUE);
56 }
57
58 TClonesArray* GetCollection(Int_t iColl) const override { return nullptr; }
59
60 void UpdatePointTrackIndices(const std::vector<Int_t>& indexMap) override {
61 for (auto& point : *fDetPoints) {
62 Int_t oldTrackID = point.GetTrackID();
63 if (oldTrackID >= 0 && oldTrackID < static_cast<Int_t>(indexMap.size())) {
64 point.SetTrackID(indexMap[oldTrackID]);
65 }
66 }
67 }
68
69 void SetSpecialPhysicsCuts() override { ; }
70 void FinishPrimary() override { ; }
71 void FinishRun() override { ; }
72 void BeginPrimary() override { ; }
73 void PostTrack() override { ; }
74 void PreTrack() override { ; }
75 void BeginEvent() override { ; }
76 void CopyClones(TClonesArray* cl1, TClonesArray* cl2, Int_t offset) override {
77 ;
78 }
79
80 protected:
82 Int_t fEventID;
83 Int_t fTrackID;
84 Int_t fVolumeID;
85 TLorentzVector fPos;
86 TLorentzVector fMom;
87 Double_t fTime;
88 Double_t fLength;
89 Double_t fELoss;
90 std::vector<PointType>* fDetPoints = nullptr;
91
92 TGeoVolume* fDetector = nullptr; // Detector object
93};
94} // namespace SHiP
95
96#endif // DETECTOR_DETECTOR_H_
Interface for detectors using STL containers (std::vector) for MC points.
void BeginPrimary() override
Definition Detector.h:72
Int_t fTrackID
event index
Definition Detector.h:83
void Reset() override
Definition Detector.h:48
std::vector< PointType > * fDetPoints
energy loss
Definition Detector.h:90
void Register() override
Definition Detector.h:52
void EndOfEvent() override
Definition Detector.h:50
Int_t fVolumeID
track index
Definition Detector.h:84
void PostTrack() override
Definition Detector.h:73
void CopyClones(TClonesArray *cl1, TClonesArray *cl2, Int_t offset) override
Definition Detector.h:76
TLorentzVector fPos
volume id
Definition Detector.h:85
void ConstructGeometry() override=0
Double_t fTime
momentum at entrance
Definition Detector.h:87
~Detector() override=default
Double_t fELoss
length
Definition Detector.h:89
Detector(const char *Name, Bool_t Active, Int_t detID)
Definition Detector.h:24
void FinishPrimary() override
Definition Detector.h:70
Detector(const char *Name, Bool_t Active)
Definition Detector.h:35
void BeginEvent() override
Definition Detector.h:75
void PreTrack() override
Definition Detector.h:74
TGeoVolume * fDetector
Definition Detector.h:92
PointType * AddHit(Args &&... args)
Definition Detector.h:38
TLorentzVector fMom
position at entrance
Definition Detector.h:86
TClonesArray * GetCollection(Int_t iColl) const override
Definition Detector.h:58
void SetSpecialPhysicsCuts() override
Definition Detector.h:69
void Initialize() override
Definition Detector.h:46
Int_t fEventID
Definition Detector.h:82
void UpdatePointTrackIndices(const std::vector< Int_t > &indexMap) override
Update track indices in point collection after track filtering.
Definition Detector.h:60
void FinishRun() override
Definition Detector.h:71
Double_t fLength
time
Definition Detector.h:88
Detector()=default