FairShip
Loading...
Searching...
No Matches
SHiP::ScoringPlane< PointType > Class Template Reference

Thin vacuum planes that record every track entering them. More...

#include <ScoringPlane.h>

Inheritance diagram for SHiP::ScoringPlane< PointType >:
[legend]
Collaboration diagram for SHiP::ScoringPlane< PointType >:
[legend]

Classes

struct  Plane
 colour of the planes in the event display More...

Public Member Functions

void AddPlane (const char *name, Double_t x, Double_t y, Double_t z, Double_t sizeX, Double_t sizeY, Double_t sizeZ, const std::vector< Int_t > &absPdgCodes={}, Bool_t keepTracks=kTRUE)
Bool_t ProcessHits (FairVolume *=nullptr) override
void ConstructGeometry () override
Public Member Functions inherited from SHiP::Detector< PointType >
 Detector ()=default
 ~Detector () override=default
 Detector (const char *Name, Bool_t Active, Int_t detID)
 Detector (const char *Name, Bool_t Active)
template<typename... Args>
PointType * AddHit (Args &&... args)
void Initialize () override
void Reset () override
void EndOfEvent () override
void Register () override
TClonesArray * GetCollection (Int_t iColl) const override
void UpdatePointTrackIndices (const std::vector< Int_t > &indexMap) override
 Update track indices in point collection after track filtering.
void SetSpecialPhysicsCuts () override
void FinishPrimary () override
void FinishRun () override
void BeginPrimary () override
void PostTrack () override
void PreTrack () override
void BeginEvent () override
void CopyClones (TClonesArray *cl1, TClonesArray *cl2, Int_t offset) override
Public Member Functions inherited from ISTLPointContainer
virtual ~ISTLPointContainer ()=default

Protected Attributes

Color_t fLineColor = kGray
Protected Attributes inherited from SHiP::Detector< PointType >
Int_t fEventID
Int_t fTrackID
 event index
Int_t fVolumeID
 track index
TLorentzVector fPos
 volume id
TLorentzVector fMom
 position at entrance
Double_t fTime
 momentum at entrance
Double_t fLength
 time
Double_t fELoss
 length
std::vector< PointType > * fDetPoints = nullptr
 energy loss
TGeoVolume * fDetector = nullptr

Private Attributes

std::vector< Plane > fPlanes

Detailed Description

template<typename PointType>
class SHiP::ScoringPlane< PointType >

Thin vacuum planes that record every track entering them.

Shared by CaloScoringPlane and UpstreamTaggerScoringPlane, which differ only in their point type (and so their output branch) and detector ID.

Every track entering a plane produces one point holding the MC-truth position, momentum, time and PDG code, with zero energy loss. No energy deposit is required (the medium is vacuum), so neutral particles are recorded too. Position, momentum and time are those at the end of the track's first step in the plane. A track crossing a plane twice (e.g. back-scattered) gives two points; the sign of Pz tells the direction.

The point detector ID is the copy number of the plane: its index + 1, in the order the planes were added. A plane can be restricted to some species, given by their absolute PDG codes.

A point counts towards keeping its track in MCTrack (ShipStack::AddPoint, MCTracksWithHitsOnly) unless the plane is added with keepTracks = false; then the points of tracks that are not kept for another reason get track ID -2, as for other secondaries below the energy cut.

Definition at line 51 of file ScoringPlane.h.

Member Function Documentation

◆ AddPlane()

template<typename PointType>
void SHiP::ScoringPlane< PointType >::AddPlane ( const char * name,
Double_t x,
Double_t y,
Double_t z,
Double_t sizeX,
Double_t sizeY,
Double_t sizeZ,
const std::vector< Int_t > & absPdgCodes = {},
Bool_t keepTracks = kTRUE )
inline

Adds a plane: the name of its volume, its centre and full sizes (cm), if not empty the absolute PDG codes of the only particles it records, and whether its points keep their tracks in MCTrack

Definition at line 58 of file ScoringPlane.h.

60 {},
62 fPlanes.push_back(
64 }
Thin vacuum planes that record every track entering them.
std::vector< Plane > fPlanes

◆ ConstructGeometry()

template<typename PointType>
void SHiP::ScoringPlane< PointType >::ConstructGeometry ( )
inlineoverridevirtual

Create the detector geometry

Implements SHiP::Detector< PointType >.

Definition at line 113 of file ScoringPlane.h.

113 {
114 TGeoVolume* top = gGeoManager->GetTopVolume();
115 ShipGeo::InitMedium("vacuum");
116 TGeoMedium* vacuum = gGeoManager->GetMedium("vacuum");
117 if (!vacuum) {
118 LOG(fatal) << this->GetName() << ": medium 'vacuum' not found.";
119 }
120 if (fPlanes.empty()) {
121 LOG(fatal) << this->GetName() << ": no scoring planes.";
122 }
123
124 for (size_t i = 0; i < fPlanes.size(); ++i) {
125 const Plane& pl = fPlanes[i];
126 if (pl.sizeX <= 0. || pl.sizeY <= 0. || pl.sizeZ <= 0.) {
127 LOG(fatal) << this->GetName() << ": invalid dimensions of " << pl.name;
128 }
129 TGeoVolume* plane = gGeoManager->MakeBox(
130 pl.name.c_str(), vacuum, pl.sizeX / 2., pl.sizeY / 2., pl.sizeZ / 2.);
131 plane->SetLineColor(fLineColor);
133 // The copy number, i + 1, is the point detector ID: node <name>_<i + 1>.
134 top->AddNode(plane, i + 1, new TGeoTranslation(pl.x, pl.y, pl.z));
135 this->fDetector = plane;
136 LOG(info) << pl.name << ": " << pl.sizeX << " x " << pl.sizeY << " x "
137 << pl.sizeZ << " cm3 centred at (" << pl.x << ", " << pl.y
138 << ", " << pl.z << ") cm"
139 << (pl.absPdgCodes.empty() ? "" : ", PDG-filtered");
140 }
141 }
TGeoVolume * fDetector
Definition Detector.h:92
Int_t InitMedium(const char *name)
Definition ShipGeoUtil.h:22
colour of the planes in the event display

◆ ProcessHits()

template<typename PointType>
Bool_t SHiP::ScoringPlane< PointType >::ProcessHits ( FairVolume * = nullptr)
inlineoverride

Definition at line 66 of file ScoringPlane.h.

66 {
67 // Score each track once, on its first step in the plane.
68 if (!gMC->IsTrackEntering()) {
69 return kFALSE;
70 }
71 Int_t copyNo = 0;
72 gMC->CurrentVolID(copyNo);
73 if (copyNo < 1 || static_cast<size_t>(copyNo) > fPlanes.size()) {
74 LOG(fatal) << this->GetName() << ": copy number " << copyNo
75 << " of the plane does not match any of the " << fPlanes.size()
76 << " configured planes; the geometry differs from the "
77 "configuration.";
78 }
79 const Plane& plane = fPlanes[copyNo - 1];
80 TParticle* p = gMC->GetStack()->GetCurrentTrack();
81 const Int_t pdgCode = p->GetPdgCode();
82 const std::vector<Int_t>& accepted = plane.absPdgCodes;
83 if (!accepted.empty() && std::find(accepted.begin(), accepted.end(),
84 std::abs(pdgCode)) == accepted.end()) {
85 return kFALSE;
86 }
87
88 this->fEventID = gMC->CurrentEvent();
89 this->fTrackID = gMC->GetStack()->GetCurrentTrackNumber();
90 this->fVolumeID = copyNo;
91 this->fTime = gMC->TrackTime() * 1.0e09; // ns
92 this->fLength = gMC->TrackLength();
93 gMC->TrackPosition(this->fPos);
94 gMC->TrackMomentum(this->fMom);
95 this->AddHit(this->fEventID, this->fTrackID, this->fVolumeID,
96 TVector3(this->fPos.X(), this->fPos.Y(), this->fPos.Z()),
97 TVector3(this->fMom.Px(), this->fMom.Py(), this->fMom.Pz()),
98 this->fTime, this->fLength, 0., pdgCode);
99
100 // Count a point for this track. ShipStack only keeps a secondary because
101 // of its points when it is configured with a minimum number of points
102 // (MCTracksWithHitsOnly / MCTracksWithHitsOrEnergyCut in
103 // run_simScript.py). With the default MCTracksWithEnergyCutOnly,
104 // secondaries below the energy cut are dropped and their points get track
105 // ID -2.
106 if (plane.keepTracks) {
107 ShipStack* stack = dynamic_cast<ShipStack*>(gMC->GetStack());
108 stack->AddPoint(static_cast<DetectorId>(this->GetDetId()));
109 }
110 return kTRUE;
111 }
Int_t fTrackID
event index
Definition Detector.h:83
Int_t fVolumeID
track index
Definition Detector.h:84
TLorentzVector fPos
volume id
Definition Detector.h:85
Double_t fTime
momentum at entrance
Definition Detector.h:87
PointType * AddHit(Args &&... args)
Definition Detector.h:38
TLorentzVector fMom
position at entrance
Definition Detector.h:86
Int_t fEventID
Definition Detector.h:82
Double_t fLength
time
Definition Detector.h:88

Member Data Documentation

◆ fLineColor

template<typename PointType>
Color_t SHiP::ScoringPlane< PointType >::fLineColor = kGray
protected

Definition at line 144 of file ScoringPlane.h.

◆ fPlanes

template<typename PointType>
std::vector<Plane> SHiP::ScoringPlane< PointType >::fPlanes
private

Definition at line 154 of file ScoringPlane.h.


The documentation for this class was generated from the following file: