FairShip
Loading...
Searching...
No Matches
SiliconTarget.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#include "SiliconTarget.h"
6
7#include "ShipDetectorList.h"
8#include "ShipGeoUtil.h"
9#include "ShipStack.h"
10#include "ShipUnit.h"
11
12// ROOT / TGeo headers
13#include "TGeoBBox.h"
14#include "TGeoCompositeShape.h"
15#include "TGeoManager.h"
16#include "TGeoMaterial.h"
17#include "TGeoMedium.h"
18#include "TGeoVolume.h"
19#include "TParticle.h"
20#include "TVector3.h"
21
22// FairROOT headers
23#include "FairVolume.h"
24#include "TVirtualMC.h"
25
26using ShipUnit::mm;
27using ShipUnit::um;
28
30 : Detector("SiliconTarget", kTRUE, kSiliconTarget) {}
31
32SiliconTarget::SiliconTarget(const char* name, Bool_t Active,
33 const char* /*Title*/)
34 : Detector(name, Active, kSiliconTarget) {}
35
37 Double_t targetWidth, Double_t targetHeight, Double_t sensorWidth,
38 Double_t sensorLength, Int_t nLayers, Double_t zPosition,
39 Double_t targetThickness, Double_t targetSpacing, Double_t moduleOffset) {
40 fTargetWidth = targetWidth;
41 fTargetHeight = targetHeight;
42 fSensorWidth = sensorWidth;
43 fSensorLength = sensorLength;
44 fLayers = nLayers;
45 fZPosition = zPosition;
46 fTargetThickness = targetThickness;
47 fTargetSpacing = targetSpacing;
48 fModuleOffset = moduleOffset;
49}
50
51TGeoVolume* SiliconTarget::CreateSiliconPlanes(const char* name, Double_t width,
52 Double_t length,
53 Double_t spacing,
54 TGeoMedium* silicon,
55 Int_t layerId) {
56 Double_t strip_pitch = 75.5 * um;
57 Int_t nRows = 2;
58 Int_t nCols = 4;
59 Int_t nPlanes = 2;
60
61 TGeoBBox* SensorShape =
62 new TGeoBBox("SensorShape", width / 2, length / 2, 0.3 * mm / 2);
63 TGeoVolume* SensorVolume =
64 new TGeoVolume("SensorVolume", SensorShape, silicon);
65 SensorVolume->SetLineColor(kRed);
66 SensorVolume->SetTransparency(40);
67
68 auto* Strips =
69 SensorVolume->Divide("SLICEX", 1, 1298, -width / 2, strip_pitch);
70 AddSensitiveVolume(Strips);
71
72 TGeoVolumeAssembly* trackingStation =
73 new TGeoVolumeAssembly("TrackingStation");
74 // Each tracking station consists of X and Y planes
75 for (Int_t plane = 0; plane < nPlanes; plane++) {
76 TGeoVolumeAssembly* trackerPlane = new TGeoVolumeAssembly("TrackerPlane");
77 // Each plane consists of 8 modules
78 for (Int_t column = 0; column < nCols; column++) {
79 for (Int_t row = 0; row < nRows; row++) {
80 Int_t sensor_id =
81 (layerId << 5) + (plane << 4) + (column << 2) + (row << 1);
82 // Add 1mm gap between sensors for realistic placement
83 trackerPlane->AddNode(
84 SensorVolume, sensor_id,
85 new TGeoTranslation(
86 (-1.5 * width - 2. * mm) + (column * width + column * 1 * mm),
87 (length / 2. + 0.5 * mm) - row * (length + 1. * mm), 0));
88 }
89 }
90 if (plane == 0) {
91 trackingStation->AddNode(trackerPlane, plane);
92 } else if (plane == 1) {
93 // Rotate the second plane by 90 degrees and translate such that the
94 // planes are evenly spaced.
95 trackingStation->AddNode(
96 trackerPlane, plane,
97 new TGeoCombiTrans(TGeoTranslation(0, 0, spacing),
98 TGeoRotation("y_rot", 0, 0, 90)));
99 }
100 }
101
102 return trackingStation;
103}
105 ShipGeo::InitMedium("tungstensifon");
106 TGeoMedium* tungsten = gGeoManager->GetMedium("tungstensifon");
107 ShipGeo::InitMedium("air");
108 TGeoMedium* air = gGeoManager->GetMedium("air");
109 ShipGeo::InitMedium("silicon");
110 TGeoMedium* Silicon = gGeoManager->GetMedium("silicon");
111
112 Double_t totalLength = fLayers * fTargetSpacing;
113
114 // --- Create an envelope volume for the detector (green, semi-transparent)
115 // ---
116 auto envBox = new TGeoBBox("SiliconTarget_env", fTargetWidth / 2.,
117 fTargetHeight / 2., totalLength / 2.);
118 auto envVol = new TGeoVolume("SiliconTarget", envBox, air);
119 envVol->SetLineColor(kGreen);
120 envVol->SetTransparency(50);
121
122 auto target = new TGeoBBox("Target", fTargetWidth / 2., fTargetHeight / 2.,
123 fTargetThickness / 2.);
124 auto targetVol = new TGeoVolume("TargetVol", target, tungsten);
125 targetVol->SetLineColor(kGray);
126 targetVol->SetTransparency(40);
127
128 for (Int_t i = 0; i < fLayers; i++) {
129 // Compute the center position (z) for the current W layer
130 Double_t zPos = -totalLength / 2 + i * fTargetSpacing;
131
132 // Place the tungsten layer
133 envVol->AddNode(targetVol, i,
134 new TGeoTranslation(0, 0, zPos + fTargetThickness / 2.));
135
136 TGeoVolume* siliconPlanes = CreateSiliconPlanes(
137 "TrackerPlane", fSensorWidth, fSensorLength,
138 fTargetSpacing - fTargetThickness - 2. * fModuleOffset, Silicon, i);
139 envVol->AddNode(
140 siliconPlanes, i,
141 new TGeoTranslation(0, 0, zPos + fTargetThickness + fModuleOffset));
142 }
143
144 // Finally, add the envelope to the top volume with the global z offset
145 // fZCenter
146 gGeoManager->GetTopVolume()->AddNode(envVol, 1,
147 new TGeoTranslation(0, 0, fZPosition));
148}
149
150Bool_t SiliconTarget::ProcessHits(FairVolume* vol) {
152 // Set parameters at entrance of volume. Reset ELoss.
153 if (gMC->IsTrackEntering()) {
154 fELoss = 0.;
155 fTime = gMC->TrackTime() * 1.0e09;
156 fLength = gMC->TrackLength();
157 gMC->TrackPosition(fPos);
158 gMC->TrackMomentum(fMom);
159 }
160
161 // Sum energy loss for all steps in the active volume
162 fELoss += gMC->Edep();
163
164 // Create SiliconTargetPoint at exit of active volume
165 if (gMC->IsTrackExiting() || gMC->IsTrackStop() ||
166 gMC->IsTrackDisappeared()) {
167 if (fELoss == 0.) {
168 return kFALSE;
169 }
170
171 TParticle* p = gMC->GetStack()->GetCurrentTrack();
172 fTrackID = gMC->GetStack()->GetCurrentTrackNumber();
173 Int_t pdgCode = p->GetPdgCode();
174 TLorentzVector Pos;
175 gMC->TrackPosition(Pos);
176 TLorentzVector Mom;
177 gMC->TrackMomentum(Mom);
178
179 Double_t xmean = (fPos.X() + Pos.X()) / 2.;
180 Double_t ymean = (fPos.Y() + Pos.Y()) / 2.;
181 Double_t zmean = (fPos.Z() + Pos.Z()) / 2.;
182
183 Int_t strip_id = 0;
184 Int_t sensor_id = 0;
185 gMC->CurrentVolID(strip_id);
186 gMC->CurrentVolOffID(1, sensor_id);
187 fVolumeID = (sensor_id << 12) + strip_id;
188
189 AddHit(fTrackID, fVolumeID, TVector3(xmean, ymean, zmean),
190 TVector3(fMom.Px(), fMom.Py(), fMom.Pz()), fTime, fLength, fELoss,
191 pdgCode);
192
193 ShipStack* stack = dynamic_cast<ShipStack*>(gMC->GetStack());
194 stack->AddPoint(kSiliconTarget);
195 }
196 return kTRUE;
197}
@ kSiliconTarget
constexpr double um
Definition ShipUnit.h:26
SiliconTargetPoint * AddHit(Args &&... args)
Definition Detector.h:38
Double_t fModuleOffset
Bool_t ProcessHits(FairVolume *vol=nullptr) override
Double_t fSensorLength
Double_t fTargetWidth
Double_t fTargetHeight
void SetSiliconTargetParameters(Double_t targetWidth, Double_t targetHeight, Double_t sensorWidth, Double_t sensorLength, Int_t nLayers, Double_t zPosition, Double_t targetThickness, Double_t targetSpacing, Double_t moduleOffset)
Double_t fSensorWidth
Double_t fZPosition
Double_t fTargetSpacing
Double_t fTargetThickness
TGeoVolume * CreateSiliconPlanes(const char *name, Double_t sensorWidth, Double_t sensorLength, Double_t planeSpacing, TGeoMedium *material, Int_t layerId)
void ConstructGeometry() override
constexpr double mm
Definition ShipUnit.h:25
Int_t InitMedium(const char *name)
Definition ShipGeoUtil.h:22
constexpr double um
Definition ShipUnit.h:26
constexpr double mm
Definition ShipUnit.h:25