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
61 const std::map<Int_t, Int_t>& indexMap) override {
62 for (auto& point : *fDetPoints) {
63 Int_t oldTrackID = point.GetTrackID();
64 auto iter = indexMap.find(oldTrackID);
65 if (iter != indexMap.end()) {
66 point.SetTrackID(iter->second);
67 }
68 }
69 }
70
71 void SetSpecialPhysicsCuts() override { ; }
72 void FinishPrimary() override { ; }
73 void FinishRun() override { ; }
74 void BeginPrimary() override { ; }
75 void PostTrack() override { ; }
76 void PreTrack() override { ; }
77 void BeginEvent() override { ; }
78 void CopyClones(TClonesArray* cl1, TClonesArray* cl2, Int_t offset) override {
79 ;
80 }
81
82 protected:
84 Int_t fEventID;
85 Int_t fTrackID;
86 Int_t fVolumeID;
87 TLorentzVector fPos;
88 TLorentzVector fMom;
89 Double_t fTime;
90 Double_t fLength;
91 Double_t fELoss;
92 std::vector<PointType>* fDetPoints = nullptr;
93
94 TGeoVolume* fDetector = nullptr; // Detector object
95};
96} // namespace SHiP
97
98#endif // DETECTOR_DETECTOR_H_
Interface for detectors using STL containers (std::vector) for MC points.
void BeginPrimary() override
Definition: Detector.h:74
Int_t fTrackID
event index
Definition: Detector.h:85
void Reset() override
Definition: Detector.h:48
std::vector< PointType > * fDetPoints
energy loss
Definition: Detector.h:92
void Register() override
Definition: Detector.h:52
void EndOfEvent() override
Definition: Detector.h:50
Int_t fVolumeID
track index
Definition: Detector.h:86
void PostTrack() override
Definition: Detector.h:75
void CopyClones(TClonesArray *cl1, TClonesArray *cl2, Int_t offset) override
Definition: Detector.h:78
void UpdatePointTrackIndices(const std::map< Int_t, Int_t > &indexMap) override
Update track indices in point collection after track filtering.
Definition: Detector.h:60
TLorentzVector fPos
volume id
Definition: Detector.h:87
void ConstructGeometry() override=0
Double_t fTime
momentum at entrance
Definition: Detector.h:89
~Detector() override=default
Double_t fELoss
length
Definition: Detector.h:91
Detector(const char *Name, Bool_t Active, Int_t detID)
Definition: Detector.h:24
void FinishPrimary() override
Definition: Detector.h:72
Detector(const char *Name, Bool_t Active)
Definition: Detector.h:35
void BeginEvent() override
Definition: Detector.h:77
void PreTrack() override
Definition: Detector.h:76
TGeoVolume * fDetector
Definition: Detector.h:94
PointType * AddHit(Args &&... args)
Definition: Detector.h:38
TLorentzVector fMom
position at entrance
Definition: Detector.h:88
TClonesArray * GetCollection(Int_t iColl) const override
Definition: Detector.h:58
void SetSpecialPhysicsCuts() override
Definition: Detector.h:71
void Initialize() override
Definition: Detector.h:46
Int_t fEventID
Definition: Detector.h:84
void FinishRun() override
Definition: Detector.h:73
Double_t fLength
time
Definition: Detector.h:90
Detector()=default
Definition: Detector.h:18