SND@LHC Software
Loading...
Searching...
No Matches
TargetTracker.cxx
Go to the documentation of this file.
1//
2// TargetTracker.cxx
3//
4//
5// Created by Annarita Buonaura on 21/10/15.
6//
7//
8
9#include "TargetTracker.h"
10
11#include "TTPoint.h"
12
13#include "TGeoManager.h"
14#include "FairRun.h" // for FairRun
15#include "FairRuntimeDb.h" // for FairRuntimeDb
16#include <iosfwd> // for ostream
17#include "TList.h" // for TListIter, TList (ptr only)
18#include "TObjArray.h" // for TObjArray
19#include "TString.h" // for TString
20
21#include "TClonesArray.h"
22#include "TVirtualMC.h"
23
24#include "TGeoBBox.h"
25#include "TGeoTrd1.h"
26#include "TGeoCompositeShape.h"
27#include "TGeoTube.h"
28#include "TGeoMaterial.h"
29#include "TGeoMedium.h"
30#include "TGeoTrd1.h"
31#include "TGeoArb8.h"
32
33#include "TParticle.h"
34#include "TParticlePDG.h"
35#include "TParticleClassPDG.h"
36#include "TVirtualMCStack.h"
37
38#include "FairVolume.h"
39#include "FairGeoVolume.h"
40#include "FairGeoNode.h"
41#include "FairRootManager.h"
42#include "FairGeoLoader.h"
43#include "FairGeoInterface.h"
44#include "FairGeoTransform.h"
45#include "FairGeoMedia.h"
46#include "FairGeoMedium.h"
47#include "FairGeoBuilder.h"
48#include "FairRun.h"
49#include "FairRuntimeDb.h"
50
51#include "ShipDetectorList.h"
52#include "ShipUnit.h"
53#include "ShipStack.h"
54
55#include "TGeoUniformMagField.h"
56#include <stddef.h> // for NULL
57#include <iostream> // for operator<<, basic_ostream,etc
58#include <string.h>
59
60using std::cout;
61using std::endl;
62
63using namespace ShipUnit;
64
66: FairDetector("TargetTracker", "",kTRUE),
67 fTrackID(-1),
68fVolumeID(-1),
69fPos(),
70fMom(),
71fTime(-1.),
72fLength(-1.),
73fELoss(-1),
74fTTPointCollection(new TClonesArray("TTPoint"))
75{
76}
77
78TargetTracker::TargetTracker(const char* name, Double_t TTX, Double_t TTY, Double_t TTZ, Bool_t Active,const char* Title)
79: FairDetector(name, true, ktauTT),
80 fTrackID(-1),
81fVolumeID(-1),
82fPos(),
83fMom(),
84fTime(-1.),
85fLength(-1.),
86fELoss(-1),
87fTTPointCollection(new TClonesArray("TTPoint"))
88{
89 TTrackerX = TTX;
90 TTrackerY = TTY;
91 TTrackerZ = TTZ;
92}
93
101
103{
104 FairDetector::Initialize();
105}
106
107// ----- Private method InitMedium
108Int_t TargetTracker::InitMedium(const char* name)
109{
110 static FairGeoLoader *geoLoad=FairGeoLoader::Instance();
111 static FairGeoInterface *geoFace=geoLoad->getGeoInterface();
112 static FairGeoMedia *media=geoFace->getMedia();
113 static FairGeoBuilder *geoBuild=geoLoad->getGeoBuilder();
114
115 FairGeoMedium *ShipMedium=media->getMedium(name);
116
117 if (!ShipMedium)
118 {
119 Fatal("InitMedium","Material %s not defined in media file.", name);
120 return -1111;
121 }
122 TGeoMedium* medium=gGeoManager->GetMedium(name);
123 if (medium!=NULL)
124 return ShipMedium->getMediumIndex();
125 return geoBuild->createMedium(ShipMedium);
126}
127
128void TargetTracker::SetSciFiParam(Double_t scifimat_width_, Double_t scifimat_hor_, Double_t scifimat_vert_,
129 Double_t scifimat_z_, Double_t support_z_, Double_t honeycomb_z_)
130{
131 scifimat_width = scifimat_width_;
132 scifimat_hor = scifimat_hor_;
133 scifimat_vert = scifimat_vert_;
134 scifimat_z = scifimat_z_;
135 support_z = support_z_;
136 honeycomb_z = honeycomb_z_;
137}
138
139void TargetTracker::SetNumberSciFi(Int_t n_hor_planes_, Int_t n_vert_planes_)
140{
141 n_hor_planes = n_hor_planes_;
142 n_vert_planes = n_vert_planes_;
143}
144
145void TargetTracker::SetTargetTrackerParam(Double_t TTX, Double_t TTY, Double_t TTZ)
146{
147 TTrackerX = TTX;
148 TTrackerY = TTY;
149 TTrackerZ = TTZ;
150}
151
153{
154 CellWidth = CellW;
155}
156
158{
159 ZDimension = Zdim;
160}
161
163{
164 fNTT =n;
165}
166
167void TargetTracker::SetDesign(Int_t Design)
168{
169 fDesign = Design;
170}
171
173{
174 InitMedium("TTmedium");
175 TGeoMedium *TTmedium = gGeoManager->GetMedium("TTmedium");
176
177 InitMedium("vacuum");
178 TGeoMedium *vacuum = gGeoManager->GetMedium("vacuum");
179
180 InitMedium("CarbonComposite");
181 TGeoMedium *CarbonComposite = gGeoManager->GetMedium("CarbonComposite");
182
183 InitMedium("SciFiMat");
184 TGeoMedium *SciFiMat = gGeoManager->GetMedium("SciFiMat");
185
186 InitMedium("Airex");
187 TGeoMedium *Airex = gGeoManager->GetMedium("Airex");
188
189 //Target Tracker
190 TGeoVolume *volTarget = gGeoManager->GetVolume("volTarget");
191
192 TGeoBBox* TT_box = new TGeoBBox("TT_box", TTrackerX / 2, TTrackerY / 2, TTrackerZ / 2);
193 TGeoVolume* TT_volume = new TGeoVolume("TT", TT_box, vacuum);
194 TT_volume->SetLineColor(kBlue - 1);
195 //TT_volume->SetTransparency(1);
196 TT_volume->SetVisibility(1);
197 TT_volume->SetVisDaughters(1);
198
199 //Support Carbon Composite
200 TGeoBBox* TT_support_box = new TGeoBBox("TT_support_box", TTrackerX / 2, TTrackerY / 2, support_z / 2);
201 TGeoVolume* TT_support_volume = new TGeoVolume("TT_support", TT_support_box, CarbonComposite);
202 TT_support_volume->SetLineColor(kGray - 2);
203 TT_support_volume->SetVisibility(1);
204
205 //Honeycomb Airex (or Nomex)
206 TGeoBBox* TT_honeycomb_box = new TGeoBBox("TT_honeycomb_box", TTrackerX / 2, TTrackerY / 2, honeycomb_z / 2);
207 TGeoVolume* TT_honeycomb_volume = new TGeoVolume("TT_honeycomb", TT_honeycomb_box, Airex);
208 TT_honeycomb_volume->SetLineColor(kYellow);
209 TT_honeycomb_volume->SetVisibility(1);
210
211 //SciFi planes
212 TGeoBBox* TT_scifi_plane_hor_box = new TGeoBBox("TT_scifi_plane_hor_box", TTrackerX / 2, TTrackerY / 2, scifimat_z / 2);
213 TGeoVolume* TT_scifi_plane_hor_volume = new TGeoVolume("TT_scifi_plane_hor", TT_scifi_plane_hor_box, SciFiMat);
214 TT_scifi_plane_hor_volume->SetVisibility(1);
215
216 TGeoBBox* TT_scifi_plane_vert_box = new TGeoBBox("TT_scifi_plane_vert_box", TTrackerX / 2, TTrackerY / 2, scifimat_z / 2);
217 TGeoVolume* TT_scifi_plane_vert_volume = new TGeoVolume("TT_scifi_plane_vert", TT_scifi_plane_vert_box, SciFiMat);
218 TT_scifi_plane_vert_volume->SetVisibility(1);
219
220 //SciFi mats for X and Y
221 TGeoBBox* TT_scifimat_hor_box = new TGeoBBox("TT_scifimat_hor_box", scifimat_hor / 2, scifimat_width / 2, scifimat_z / 2);
222 TGeoVolume* TT_scifimat_hor_volume = new TGeoVolume("TT_scifimat_hor", TT_scifimat_hor_box, SciFiMat);
223 TT_scifimat_hor_volume->SetLineColor(kCyan-9);
224
225 TGeoBBox* TT_scifimat_vert_box = new TGeoBBox("TT_scifimat_vert_box", scifimat_width / 2, scifimat_vert / 2, scifimat_z / 2);
226 TGeoVolume* TT_scifimat_vert_volume = new TGeoVolume("TT_scifimat_vert", TT_scifimat_vert_box, SciFiMat);
227 TT_scifimat_vert_volume->SetLineColor(kGreen-7);
228
229 //Add SciFi mat as sensitive unit
230 AddSensitiveVolume(TT_scifimat_hor_volume);
231 AddSensitiveVolume(TT_scifimat_vert_volume);
232
233 //Creating physical volumes and multiply
234 for (int i = 0; i < n_hor_planes; i++){
235 TT_scifi_plane_hor_volume->AddNode(TT_scifimat_hor_volume, i+1, new TGeoTranslation(0, (-(n_hor_planes-1)/2.0 + i)*scifimat_width, 0));
236 }
237 for (int i = 0; i < n_vert_planes; i++){
238 TT_scifi_plane_vert_volume->AddNode(TT_scifimat_vert_volume, 100+i+1, new TGeoTranslation((-(n_vert_planes-1)/2.0 + i)*scifimat_width, 0, 0));
239 }
240
241 TT_volume->AddNode(TT_support_volume, 0, new TGeoTranslation(0, 0, -TTrackerZ/2 + support_z/2));
242 TT_volume->AddNode(TT_scifi_plane_hor_volume, 0, new TGeoTranslation(0, 0, -TTrackerZ/2 + support_z + scifimat_z/2));
243 TT_volume->AddNode(TT_scifi_plane_vert_volume, 0, new TGeoTranslation(0, 0, -TTrackerZ/2 + support_z + scifimat_z + scifimat_z/2));
244 TT_volume->AddNode(TT_honeycomb_volume, 0, new TGeoTranslation(0, 0, -TTrackerZ/2 + support_z + 2*scifimat_z + honeycomb_z/2));
245 TT_volume->AddNode(TT_support_volume, 1, new TGeoTranslation(0, 0, -TTrackerZ/2 + support_z + 2*scifimat_z + honeycomb_z + support_z/2));
246
247 Double_t first_tt_position = -ZDimension / 2 + TTrackerZ / 2;
248
249 //fNTT - number of TT walls
250 for (int l = 0; l < fNTT; ++l){
251 volTarget->AddNode(TT_volume, 1000*(l+1), new TGeoTranslation(0, 0, first_tt_position + l * (TTrackerZ + CellWidth)));
252 }
253
254}
255
256
257Bool_t TargetTracker::ProcessHits(FairVolume* vol)
258{
260 //Set parameters at entrance of volume. Reset ELoss.
261 if ( gMC->IsTrackEntering() ) {
262 fELoss = 0.;
263 fTime = gMC->TrackTime() * 1.0e09;
264 fLength = gMC->TrackLength();
265 gMC->TrackPosition(fPos);
266 gMC->TrackMomentum(fMom);
267 }
268 // Sum energy loss for all steps in the active volume
269 fELoss += gMC->Edep();
270
271 // Create muonPoint at exit of active volume
272 if (gMC->IsTrackExiting() ||
273 gMC->IsTrackStop() ||
274 gMC->IsTrackDisappeared() ){
275 if (fELoss == 0. ) { return kFALSE; }
276 TParticle* p=gMC->GetStack()->GetCurrentTrack();
277 Int_t pdgCode = p->GetPdgCode();
278 fTrackID = gMC->GetStack()->GetCurrentTrackNumber();
279
280 gMC->CurrentVolID(fVolumeID);
281 Int_t detID = fVolumeID;
282 Int_t TTstationID;
283 gMC->CurrentVolOffID(2, TTstationID);
284 fVolumeID = TTstationID + detID;
285
286 TLorentzVector Pos;
287 gMC->TrackPosition(Pos);
288 Double_t xmean = (fPos.X()+Pos.X())/2. ;
289 Double_t ymean = (fPos.Y()+Pos.Y())/2. ;
290 Double_t zmean = (fPos.Z()+Pos.Z())/2. ;
291
292 AddHit(fTrackID, fVolumeID, TVector3(xmean, ymean, zmean),
293 TVector3(fMom.Px(), fMom.Py(), fMom.Pz()),
294 fTime, fLength, fELoss, pdgCode);
295
296 // Increment number of muon det points in TParticle
297 ShipStack* stack = (ShipStack*) gMC->GetStack();
298 stack->AddPoint(ktauTT);
299 }
300
301 return kTRUE;
302}
303
304
305void TargetTracker::DecodeTTID(Int_t detID, Int_t &NTT, int &nplane, Bool_t &ishor)
306{
307 NTT = detID/1000;
308 int idir = (detID - NTT*1000)/100;
309
310 if (idir == 1) ishor = kFALSE;
311 else if (idir == 0) ishor = kTRUE;
312
313 nplane = (detID - NTT*1000 - idir*100);
314}
315
316
318{
319 fTTPointCollection->Clear();
320}
321
322
324{
325
332 FairRootManager::Instance()->Register("TTPoint", "TargetTracker",
333 fTTPointCollection, kTRUE);
334}
335
336TClonesArray* TargetTracker::GetCollection(Int_t iColl) const
337{
338 if (iColl == 0) { return fTTPointCollection; }
339 else { return NULL; }
340}
341
343{
344 fTTPointCollection->Clear();
345}
346
347
348TTPoint* TargetTracker::AddHit(Int_t trackID,Int_t detID,
349 TVector3 pos, TVector3 mom,
350 Double_t time, Double_t length,
351 Double_t eLoss, Int_t pdgCode)
352{
353 TClonesArray& clref = *fTTPointCollection;
354 Int_t size = clref.GetEntriesFast();
355 //cout << "brick hit called"<< pos.z()<<endl;
356 return new(clref[size]) TTPoint(trackID,detID, pos, mom,
357 time, length, eLoss, pdgCode);
358}
359
361
@ ktauTT
void SetNumberTT(Int_t n)
TClonesArray * fTTPointCollection
energy loss
TLorentzVector fMom
position at entrance
virtual Bool_t ProcessHits(FairVolume *v=0)
Double_t ZDimension
Double_t support_z
void DecodeTTID(Int_t detID, Int_t &NTT, int &nplane, Bool_t &ishor)
Double_t TTrackerX
Double_t scifimat_z
Double_t scifimat_width
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_)
virtual ~TargetTracker()
Double_t TTrackerY
Int_t InitMedium(const char *name)
TTPoint * AddHit(Int_t trackID, Int_t detID, TVector3 pos, TVector3 mom, Double_t time, Double_t length, Double_t eLoss, Int_t pdgCode)
virtual TClonesArray * GetCollection(Int_t iColl) const
Int_t fVolumeID
track index
Double_t scifimat_vert
virtual void EndOfEvent()
Double32_t fLength
time
void SetDesign(Int_t Design)
virtual void Initialize()
Double32_t fTime
momentum at entrance
Double_t CellWidth
Double_t TTrackerZ
Double_t honeycomb_z
void SetBrickParam(Double_t CellW)
TLorentzVector fPos
volume id
virtual void Register()
virtual void Reset()
Double_t scifimat_hor
void SetTargetTrackerParam(Double_t TTX, Double_t TTY, Double_t TTZ)
Double32_t fELoss
length
ClassImp(ecalContFact) ecalContFact