FairShip
Loading...
Searching...
No Matches
UpstreamTagger Class Reference

Upstream Background Tagger (UBT) detector. More...

#include <UpstreamTagger.h>

Inheritance diagram for UpstreamTagger:
[legend]
Collaboration diagram for UpstreamTagger:
[legend]

Classes

struct  Region
 z-position of the active tile plane More...

Public Member Functions

 UpstreamTagger (const char *Name, Bool_t Active)
 UpstreamTagger ()
Bool_t ProcessHits (FairVolume *v=nullptr) override
void SetZposition (Double_t z)
void SetBoxDimensions (Double_t x, Double_t y, Double_t z)
void SetBoxCenter (Double_t x, Double_t y)
void AddRegion (Int_t id, Double_t x, Double_t y, Double_t sizeX, Double_t sizeY, Double_t constituentTileSize, Double_t thickness)
void ConstructGeometry () override
Public Member Functions inherited from SHiP::Detector< UpstreamTaggerPoint >
 Detector ()=default
 ~Detector () override=default
UpstreamTaggerPoint * 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

Public Attributes

Double_t det_zPos

Private Member Functions

 UpstreamTagger (const UpstreamTagger &)=delete
 current track entered the region (not born in it)
UpstreamTagger & operator= (const UpstreamTagger &)=delete

Private Attributes

std::vector< Region > fRegions
Double_t fSizeX = 0.
 coarse regions loaded from detector map
Double_t fSizeY = 0.
 detector width
Double_t fCenterX = 0.
 detector height
Double_t fCenterY = 0.
 detector centre x
Double_t fEnvelopeZ = 0.
 detector centre y
Bool_t fEntered
 allocated longitudinal space

Additional Inherited Members

Protected Attributes inherited from SHiP::Detector< UpstreamTaggerPoint >
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< UpstreamTaggerPoint > * fDetPoints
 energy loss
TGeoVolume * fDetector

Detailed Description

Upstream Background Tagger (UBT) detector.

The active plane is split into coarse regions, generated on the UBT box from the rule in geometry/UpstreamTagger_config.yaml (see shipDet_conf.configure_upstream_tagger). Each region records whether it represents 20 x 20 or 40 x 40 mm^2 polystyrene scintillator tiles. Optical photon production and transport are deliberately not simulated here: an MC point stores the energy deposited in a mapped region, identified by its copy number. Only points of tracks entering a region count towards keeping their track in MCTrack, not those of secondaries created in the plastic.

Definition at line 32 of file UpstreamTagger.h.

Constructor & Destructor Documentation

◆ UpstreamTagger() [1/3]

UpstreamTagger::UpstreamTagger ( const char * Name,
Bool_t Active )

Name : Detector Name Active: kTRUE for active detectors (ProcessHits() will be called) kFALSE for inactive detectors

Definition at line 29 of file UpstreamTagger.cxx.

30 : Detector(name, active, kUpstreamTagger), det_zPos(0) {}
@ kUpstreamTagger

◆ UpstreamTagger() [2/3]

UpstreamTagger::UpstreamTagger ( )

default constructor

Definition at line 26 of file UpstreamTagger.cxx.

27 : Detector("UpstreamTagger", kTRUE, kUpstreamTagger), det_zPos(0) {}

◆ UpstreamTagger() [3/3]

UpstreamTagger::UpstreamTagger ( const UpstreamTagger & )
privatedelete

current track entered the region (not born in it)

Member Function Documentation

◆ AddRegion()

void UpstreamTagger::AddRegion ( Int_t id,
Double_t x,
Double_t y,
Double_t sizeX,
Double_t sizeY,
Double_t constituentTileSize,
Double_t thickness )
inline

Add one coarse simulation region from the UBT detector map. constituentTileSize, the side of its tiles, is retained in centimetres so that the same detector ID can later select the digitization response of its tiles; thickness is that of its tiles.

Definition at line 65 of file UpstreamTagger.h.

67 {
68 fRegions.push_back(
69 {id, x, y, sizeX, sizeY, constituentTileSize, thickness});
70 }
std::vector< Region > fRegions

◆ ConstructGeometry()

void UpstreamTagger::ConstructGeometry ( )
overridevirtual

Create the detector geometry

Implements SHiP::Detector< UpstreamTaggerPoint >.

Definition at line 92 of file UpstreamTagger.cxx.

92 {
93 TGeoVolume* top = gGeoManager->GetTopVolume();
94
95 ShipGeo::InitMedium("Scintillator");
96 TGeoMedium* scintillator = gGeoManager->GetMedium("Scintillator");
97 if (!scintillator) {
98 Fatal("ConstructGeometry", "Medium 'Scintillator' not found.");
99 }
100 if (fRegions.empty()) {
101 Fatal("ConstructGeometry", "No regions loaded from the UBT detector map.");
102 }
103 if (fSizeX <= 0. || fSizeY <= 0. || fEnvelopeZ <= 0.) {
104 Fatal("ConstructGeometry", "UBT box dimensions not set.");
105 }
106
107 fDetector = new TGeoVolumeAssembly("Upstream_Tagger");
108
109 std::map<Double_t, Int_t> regionsPerTileSize;
110 // Regions of the same shape share one volume, placed with the region ID as
111 // copy number: most regions are full 20 x 20 cm2 squares, and only the
112 // regions cut by the box edges differ. Sizes are keyed in um so that
113 // rounding differences between equal regions do not split them.
114 using ShapeKey = std::tuple<Long64_t, Long64_t, Long64_t, Long64_t>;
115 const auto um = [](Double_t length) { return std::llround(length * 1.0e4); };
116 std::map<ShapeKey, TGeoVolume*> volumes;
117 for (const Region& region : fRegions) {
118 if (region.sizeX <= 0. || region.sizeY <= 0.) {
119 Fatal("ConstructGeometry", "UBT region %d has a non-positive size.",
120 region.id);
121 }
122 if (region.thickness <= 0. || region.thickness > fEnvelopeZ) {
123 Fatal("ConstructGeometry",
124 "UBT region %d: the thickness %g cm of its %g cm tiles is not in "
125 "(0, %g] cm, the space reserved for the UBT.",
126 region.id, region.thickness, region.constituentTileSize,
127 fEnvelopeZ);
128 }
129 if (std::abs(region.x - fCenterX) + region.sizeX / 2. > fSizeX / 2. ||
130 std::abs(region.y - fCenterY) + region.sizeY / 2. > fSizeY / 2.) {
131 Fatal("ConstructGeometry", "UBT region %d lies outside the UBT box.",
132 region.id);
133 }
134 const ShapeKey shape{um(region.sizeX), um(region.sizeY),
135 um(region.thickness), um(region.constituentTileSize)};
136 TGeoVolume*& regionVolume = volumes[shape];
137 if (!regionVolume) {
138 // UpstreamTaggerRegion_<tile size>cm_<shape number>: the tile size is
139 // read back by UpstreamTaggerDetector.validate_stored_geometry.
140 const TString volumeName = TString::Format(
141 "UpstreamTaggerRegion_%dcm_%zu",
142 static_cast<Int_t>(region.constituentTileSize), volumes.size() - 1);
143 regionVolume =
144 gGeoManager->MakeBox(volumeName, scintillator, region.sizeX / 2.,
145 region.sizeY / 2., region.thickness / 2.);
146 // A shade of blue per tile size in the event display.
147 regionVolume->SetLineColor(
148 kBlue - static_cast<Int_t>(region.constituentTileSize));
149 AddSensitiveVolume(regionVolume);
150 }
151 fDetector->AddNode(regionVolume, region.id,
152 new TGeoTranslation(region.x, region.y, 0.));
153 ++regionsPerTileSize[region.constituentTileSize];
154 }
155
156 top->AddNode(fDetector, 1, new TGeoTranslation(0., 0., det_zPos));
157 cout << " Z Position (Upstream Tagger) " << det_zPos << ", "
158 << fRegions.size() << " mapped regions (";
159 for (auto it = regionsPerTileSize.begin(); it != regionsPerTileSize.end();
160 ++it) {
161 cout << (it == regionsPerTileSize.begin() ? "" : ", ") << it->second
162 << " with " << it->first << " cm tiles";
163 }
164 cout << ") in " << volumes.size() << " region shapes" << endl;
165}
constexpr double um
Definition ShipUnit.h:26
Double_t fSizeX
coarse regions loaded from detector map
Double_t fCenterY
detector centre x
Double_t fCenterX
detector height
Double_t fSizeY
detector width
Double_t fEnvelopeZ
detector centre y
Int_t InitMedium(const char *name)
Definition ShipGeoUtil.h:22
z-position of the active tile plane

◆ operator=()

UpstreamTagger & UpstreamTagger::operator= ( const UpstreamTagger & )
privatedelete

◆ ProcessHits()

Bool_t UpstreamTagger::ProcessHits ( FairVolume * v = nullptr)
override

this method is called for each step during simulation (see FairMCApplication::Stepping())

This method is called from the MC stepping

Definition at line 32 of file UpstreamTagger.cxx.

32 {
34 // Set parameters at entrance of volume, or at the first step of a track
35 // created inside it (e.g. a delta ray). Reset ELoss.
36 if (gMC->IsTrackEntering() || gMC->IsNewTrack()) {
37 // Geant4 VMC also flags the first step of a new track as entering.
38 fEntered = !gMC->IsNewTrack();
39 fELoss = 0.;
40 fTime = gMC->TrackTime() * 1.0e09;
41 fLength = gMC->TrackLength();
42 gMC->TrackPosition(fPos);
43 gMC->TrackMomentum(fMom);
44 }
45
46 // Sum energy loss for all steps in the active volume
47 fELoss += gMC->Edep();
48
49 // Create vetoPoint at exit of active volume
50 if (gMC->IsTrackExiting() || gMC->IsTrackStop() ||
51 gMC->IsTrackDisappeared()) {
52 if (fELoss == 0.) {
53 return kFALSE;
54 }
55
56 fTrackID = gMC->GetStack()->GetCurrentTrackNumber();
57 fEventID = gMC->CurrentEvent();
58 Int_t tileId;
59 gMC->CurrentVolID(tileId);
60
61 TParticle* p = gMC->GetStack()->GetCurrentTrack();
62 Int_t pdgCode = p->GetPdgCode();
63 TLorentzVector Pos;
64 gMC->TrackPosition(Pos);
65 TLorentzVector Mom;
66 gMC->TrackMomentum(Mom);
67 Double_t xmean = (fPos.X() + Pos.X()) / 2.;
68 Double_t ymean = (fPos.Y() + Pos.Y()) / 2.;
69 Double_t zmean = (fPos.Z() + Pos.Z()) / 2.;
70
71 AddHit(fEventID, fTrackID, tileId, TVector3(xmean, ymean, zmean),
72 TVector3(fMom.Px(), fMom.Py(), fMom.Pz()), fTime, fLength, fELoss,
73 pdgCode, TVector3(Pos.X(), Pos.Y(), Pos.Z()),
74 TVector3(Mom.Px(), Mom.Py(), Mom.Pz()));
75 fELoss = 0.;
76
77 // Count a point for tracks that entered the region. A track created in
78 // the plastic (delta ray, Compton electron) still gives a point, for its
79 // energy deposit, but does not keep its track in MCTrack: with
80 // MCTracksWithHitsOnly (--MuonBack) every soft electron of every crossing
81 // muon would be kept. Its point gets track ID -2 unless the track is kept
82 // for another reason.
83 if (fEntered) {
84 ShipStack* stack = dynamic_cast<ShipStack*>(gMC->GetStack());
85 stack->AddPoint(kUpstreamTagger);
86 }
87 }
88
89 return kTRUE;
90}
UpstreamTaggerPoint * AddHit(Args &&... args)
Definition Detector.h:38
Bool_t fEntered
allocated longitudinal space

◆ SetBoxCenter()

void UpstreamTagger::SetBoxCenter ( Double_t x,
Double_t y )
inline

Definition at line 55 of file UpstreamTagger.h.

55 {
56 fCenterX = x;
57 fCenterY = y;
58 }

◆ SetBoxDimensions()

void UpstreamTagger::SetBoxDimensions ( Double_t x,
Double_t y,
Double_t z )
inline

Definition at line 50 of file UpstreamTagger.h.

50 {
51 fSizeX = x;
52 fSizeY = y;
53 fEnvelopeZ = z;
54 }

◆ SetZposition()

void UpstreamTagger::SetZposition ( Double_t z)
inline

Sets detector position and sizes

Definition at line 49 of file UpstreamTagger.h.

49{ det_zPos = z; }

Member Data Documentation

◆ det_zPos

Double_t UpstreamTagger::det_zPos

Detector parameters.

Definition at line 77 of file UpstreamTagger.h.

◆ fCenterX

Double_t UpstreamTagger::fCenterX = 0.
private

detector height

Definition at line 94 of file UpstreamTagger.h.

◆ fCenterY

Double_t UpstreamTagger::fCenterY = 0.
private

detector centre x

Definition at line 95 of file UpstreamTagger.h.

◆ fEntered

Bool_t UpstreamTagger::fEntered
private
Initial value:
=
kFALSE

allocated longitudinal space

Definition at line 97 of file UpstreamTagger.h.

◆ fEnvelopeZ

Double_t UpstreamTagger::fEnvelopeZ = 0.
private

detector centre y

Definition at line 96 of file UpstreamTagger.h.

◆ fRegions

std::vector<Region> UpstreamTagger::fRegions
private

Definition at line 91 of file UpstreamTagger.h.

◆ fSizeX

Double_t UpstreamTagger::fSizeX = 0.
private

coarse regions loaded from detector map

Definition at line 92 of file UpstreamTagger.h.

◆ fSizeY

Double_t UpstreamTagger::fSizeY = 0.
private

detector width

Definition at line 93 of file UpstreamTagger.h.


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