FairShip
Loading...
Searching...
No Matches
TargetTracker.cxx
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//
6// TargetTracker.cxx
7//
8//
9// Created by Annarita Buonaura on 21/10/15.
10//
11//
12
13#include "TargetTracker.h"
14
15#include <cstring>
16#include <iosfwd> // for ostream
17#include <iostream> // for operator<<, basic_ostream,etc
18
19#include "FairGeoBuilder.h"
20#include "FairGeoInterface.h"
21#include "FairGeoLoader.h"
22#include "FairGeoMedia.h"
23#include "FairGeoMedium.h"
24#include "FairGeoNode.h"
25#include "FairGeoTransform.h"
26#include "FairGeoVolume.h"
27#include "FairRun.h" // for FairRun
28#include "FairRun.h"
29#include "FairRuntimeDb.h" // for FairRuntimeDb
30#include "FairRuntimeDb.h"
31#include "FairVolume.h"
32#include "ShipDetectorList.h"
33#include "ShipGeoUtil.h"
34#include "ShipStack.h"
35#include "ShipUnit.h"
36#include "TGeoArb8.h"
37#include "TGeoBBox.h"
38#include "TGeoCompositeShape.h"
39#include "TGeoManager.h"
40#include "TGeoMaterial.h"
41#include "TGeoMedium.h"
42#include "TGeoTrd1.h"
43#include "TGeoTube.h"
44#include "TGeoUniformMagField.h"
45#include "TList.h" // for TListIter, TList (ptr only)
46#include "TObjArray.h" // for TObjArray
47#include "TParticle.h"
48#include "TParticleClassPDG.h"
49#include "TParticlePDG.h"
50#include "TString.h" // for TString
51#include "TTPoint.h"
52#include "TVirtualMC.h"
53#include "TVirtualMCStack.h"
54
55using std::cout;
56using std::endl;
57
58TargetTracker::TargetTracker() : Detector("TargetTracker", kTRUE, ktauTT) {}
59
60TargetTracker::TargetTracker(const char* name, Double_t TTX, Double_t TTY,
61 Double_t TTZ, Bool_t Active, const char* /*Title*/)
62 : Detector(name, Active, ktauTT) {
63 TTrackerX = TTX;
64 TTrackerY = TTY;
65 TTrackerZ = TTZ;
66}
67
68void TargetTracker::SetSciFiParam(Double_t scifimat_width_,
69 Double_t scifimat_hor_,
70 Double_t scifimat_vert_, Double_t scifimat_z_,
71 Double_t support_z_, Double_t honeycomb_z_) {
72 scifimat_width = scifimat_width_;
73 scifimat_hor = scifimat_hor_;
74 scifimat_vert = scifimat_vert_;
75 scifimat_z = scifimat_z_;
76 support_z = support_z_;
77 honeycomb_z = honeycomb_z_;
78}
79
80void TargetTracker::SetNumberSciFi(Int_t n_hor_planes_, Int_t n_vert_planes_) {
81 n_hor_planes = n_hor_planes_;
82 n_vert_planes = n_vert_planes_;
83}
84
85void TargetTracker::SetTargetTrackerParam(Double_t TTX, Double_t TTY,
86 Double_t TTZ) {
87 TTrackerX = TTX;
88 TTrackerY = TTY;
89 TTrackerZ = TTZ;
90}
91
92void TargetTracker::SetBrickParam(Double_t CellW) { CellWidth = CellW; }
93
94void TargetTracker::SetTotZDimension(Double_t Zdim) { ZDimension = Zdim; }
95
96void TargetTracker::SetNumberTT(Int_t n) { fNTT = n; }
97
98void TargetTracker::SetDesign(Int_t Design) { fDesign = Design; }
99
101 ShipGeo::InitMedium("vacuum");
102 TGeoMedium* vacuum = gGeoManager->GetMedium("vacuum");
103
104 ShipGeo::InitMedium("CarbonComposite");
105 TGeoMedium* CarbonComposite = gGeoManager->GetMedium("CarbonComposite");
106
107 ShipGeo::InitMedium("SciFiMat");
108 TGeoMedium* SciFiMat = gGeoManager->GetMedium("SciFiMat");
109
110 ShipGeo::InitMedium("Airex");
111 TGeoMedium* Airex = gGeoManager->GetMedium("Airex");
112
113 // Target Tracker
114 TGeoVolume* volTarget = gGeoManager->GetVolume("volTarget");
115
116 TGeoBBox* TT_box =
117 new TGeoBBox("TT_box", TTrackerX / 2, TTrackerY / 2, TTrackerZ / 2);
118 TGeoVolume* TT_volume = new TGeoVolume("TT", TT_box, vacuum);
119 TT_volume->SetLineColor(kBlue - 1);
120 // TT_volume->SetTransparency(1);
121 TT_volume->SetVisibility(1);
122 TT_volume->SetVisDaughters(1);
123
124 // Support Carbon Composite
125 TGeoBBox* TT_support_box = new TGeoBBox("TT_support_box", TTrackerX / 2,
126 TTrackerY / 2, support_z / 2);
127 TGeoVolume* TT_support_volume =
128 new TGeoVolume("TT_support", TT_support_box, CarbonComposite);
129 TT_support_volume->SetLineColor(kGray - 2);
130 TT_support_volume->SetVisibility(1);
131
132 // Honeycomb Airex (or Nomex)
133 TGeoBBox* TT_honeycomb_box = new TGeoBBox("TT_honeycomb_box", TTrackerX / 2,
134 TTrackerY / 2, honeycomb_z / 2);
135 TGeoVolume* TT_honeycomb_volume =
136 new TGeoVolume("TT_honeycomb", TT_honeycomb_box, Airex);
137 TT_honeycomb_volume->SetLineColor(kYellow);
138 TT_honeycomb_volume->SetVisibility(1);
139
140 // SciFi planes
141 TGeoBBox* TT_scifi_plane_hor_box = new TGeoBBox(
142 "TT_scifi_plane_hor_box", TTrackerX / 2, TTrackerY / 2, scifimat_z / 2);
143 TGeoVolume* TT_scifi_plane_hor_volume =
144 new TGeoVolume("TT_scifi_plane_hor", TT_scifi_plane_hor_box, SciFiMat);
145 TT_scifi_plane_hor_volume->SetVisibility(1);
146
147 TGeoBBox* TT_scifi_plane_vert_box = new TGeoBBox(
148 "TT_scifi_plane_vert_box", TTrackerX / 2, TTrackerY / 2, scifimat_z / 2);
149 TGeoVolume* TT_scifi_plane_vert_volume =
150 new TGeoVolume("TT_scifi_plane_vert", TT_scifi_plane_vert_box, SciFiMat);
151 TT_scifi_plane_vert_volume->SetVisibility(1);
152
153 // SciFi mats for X and Y
154 TGeoBBox* TT_scifimat_hor_box =
155 new TGeoBBox("TT_scifimat_hor_box", scifimat_hor / 2, scifimat_width / 2,
156 scifimat_z / 2);
157 TGeoVolume* TT_scifimat_hor_volume =
158 new TGeoVolume("TT_scifimat_hor", TT_scifimat_hor_box, SciFiMat);
159 TT_scifimat_hor_volume->SetLineColor(kCyan - 9);
160
161 TGeoBBox* TT_scifimat_vert_box =
162 new TGeoBBox("TT_scifimat_vert_box", scifimat_width / 2,
163 scifimat_vert / 2, scifimat_z / 2);
164 TGeoVolume* TT_scifimat_vert_volume =
165 new TGeoVolume("TT_scifimat_vert", TT_scifimat_vert_box, SciFiMat);
166 TT_scifimat_vert_volume->SetLineColor(kGreen - 7);
167
168 // Add SciFi mat as sensitive unit
169 AddSensitiveVolume(TT_scifimat_hor_volume);
170 AddSensitiveVolume(TT_scifimat_vert_volume);
171
172 // Creating physical volumes and multiply
173 for (int i = 0; i < n_hor_planes; i++) {
174 TT_scifi_plane_hor_volume->AddNode(
175 TT_scifimat_hor_volume, i + 1,
176 new TGeoTranslation(0, (-(n_hor_planes - 1) / 2.0 + i) * scifimat_width,
177 0));
178 }
179 for (int i = 0; i < n_vert_planes; i++) {
180 TT_scifi_plane_vert_volume->AddNode(
181 TT_scifimat_vert_volume, 100 + i + 1,
182 new TGeoTranslation((-(n_vert_planes - 1) / 2.0 + i) * scifimat_width,
183 0, 0));
184 }
185
186 TT_volume->AddNode(TT_support_volume, 0,
187 new TGeoTranslation(0, 0, -TTrackerZ / 2 + support_z / 2));
188 TT_volume->AddNode(
189 TT_scifi_plane_hor_volume, 0,
190 new TGeoTranslation(0, 0, -TTrackerZ / 2 + support_z + scifimat_z / 2));
191 TT_volume->AddNode(
192 TT_scifi_plane_vert_volume, 0,
193 new TGeoTranslation(
194 0, 0, -TTrackerZ / 2 + support_z + scifimat_z + scifimat_z / 2));
195 TT_volume->AddNode(
196 TT_honeycomb_volume, 0,
197 new TGeoTranslation(
198 0, 0, -TTrackerZ / 2 + support_z + 2 * scifimat_z + honeycomb_z / 2));
199 TT_volume->AddNode(
200 TT_support_volume, 1,
201 new TGeoTranslation(0, 0,
202 -TTrackerZ / 2 + support_z + 2 * scifimat_z +
203 honeycomb_z + support_z / 2));
204
205 Double_t first_tt_position = -ZDimension / 2 + TTrackerZ / 2;
206
207 // fNTT - number of TT walls
208 for (int l = 0; l < fNTT; ++l) {
209 volTarget->AddNode(
210 TT_volume, 1000 * (l + 1),
211 new TGeoTranslation(0, 0,
212 first_tt_position + l * (TTrackerZ + CellWidth)));
213 }
214}
215
216Bool_t TargetTracker::ProcessHits(FairVolume* vol) {
218 // Set parameters at entrance of volume. Reset ELoss.
219 if (gMC->IsTrackEntering()) {
220 fELoss = 0.;
221 fTime = gMC->TrackTime() * 1.0e09;
222 fLength = gMC->TrackLength();
223 gMC->TrackPosition(fPos);
224 gMC->TrackMomentum(fMom);
225 }
226 // Sum energy loss for all steps in the active volume
227 fELoss += gMC->Edep();
228
229 // Create TTPoint at exit of active volume
230 if (gMC->IsTrackExiting() || gMC->IsTrackStop() ||
231 gMC->IsTrackDisappeared()) {
232 if (fELoss == 0.) {
233 return kFALSE;
234 }
235 TParticle* p = gMC->GetStack()->GetCurrentTrack();
236 Int_t pdgCode = p->GetPdgCode();
237 fTrackID = gMC->GetStack()->GetCurrentTrackNumber();
238
239 gMC->CurrentVolID(fVolumeID);
240 Int_t detID = fVolumeID;
241 Int_t TTstationID;
242 gMC->CurrentVolOffID(2, TTstationID);
243 fVolumeID = TTstationID + detID;
244
245 TLorentzVector Pos;
246 gMC->TrackPosition(Pos);
247 Double_t xmean = (fPos.X() + Pos.X()) / 2.;
248 Double_t ymean = (fPos.Y() + Pos.Y()) / 2.;
249 Double_t zmean = (fPos.Z() + Pos.Z()) / 2.;
250
251 AddHit(fTrackID, fVolumeID, TVector3(xmean, ymean, zmean),
252 TVector3(fMom.Px(), fMom.Py(), fMom.Pz()), fTime, fLength, fELoss,
253 pdgCode);
254
255 // Increment number of muon det points in TParticle
256 ShipStack* stack = dynamic_cast<ShipStack*>(gMC->GetStack());
257 stack->AddPoint(ktauTT);
258 }
259
260 return kTRUE;
261}
262
263void TargetTracker::DecodeTTID(Int_t detID, Int_t& NTT, int& nplane,
264 Bool_t& ishor) {
265 NTT = detID / 1000;
266 int idir = (detID - NTT * 1000) / 100;
267
268 if (idir == 1)
269 ishor = kFALSE;
270 else if (idir == 0)
271 ishor = kTRUE;
272
273 nplane = (detID - NTT * 1000 - idir * 100);
274}
@ ktauTT
Int_t fTrackID
event index
Definition: Detector.h:85
Int_t fVolumeID
track index
Definition: Detector.h:86
TLorentzVector fPos
volume id
Definition: Detector.h:87
Double_t fTime
momentum at entrance
Definition: Detector.h:89
Double_t fELoss
length
Definition: Detector.h:91
TTPoint * AddHit(Args &&... args)
Definition: Detector.h:38
TLorentzVector fMom
position at entrance
Definition: Detector.h:88
Double_t fLength
time
Definition: Detector.h:90
void SetNumberTT(Int_t n)
Bool_t ProcessHits(FairVolume *v=0) override
Double_t ZDimension
Definition: TargetTracker.h:65
Double_t support_z
Definition: TargetTracker.h:59
void DecodeTTID(Int_t detID, Int_t &NTT, int &nplane, Bool_t &ishor)
Double_t TTrackerX
Definition: TargetTracker.h:51
Int_t n_hor_planes
Definition: TargetTracker.h:61
Double_t scifimat_z
Definition: TargetTracker.h:58
Double_t scifimat_width
Definition: TargetTracker.h:55
void SetTotZDimension(Double_t Zdim)
void SetNumberSciFi(Int_t n_hor_planes_, Int_t n_vert_planes_)
void SetSciFiParam(Double_t scifimat_width_, Double_t scifimat_hor_, Double_t scifimat_vert_, Double_t scifimat_z_, Double_t support_z_, Double_t honeycomb_z_)
Double_t TTrackerY
Definition: TargetTracker.h:52
Double_t scifimat_vert
Definition: TargetTracker.h:57
void ConstructGeometry() override
void SetDesign(Int_t Design)
Double_t CellWidth
Definition: TargetTracker.h:64
Double_t TTrackerZ
Definition: TargetTracker.h:53
Double_t honeycomb_z
Definition: TargetTracker.h:60
void SetBrickParam(Double_t CellW)
Int_t n_vert_planes
Definition: TargetTracker.h:62
Double_t scifimat_hor
Definition: TargetTracker.h:56
void SetTargetTrackerParam(Double_t TTX, Double_t TTY, Double_t TTZ)
Int_t InitMedium(const char *name)
Definition: ShipGeoUtil.h:20