FairShip
Loading...
Searching...
No Matches
UpstreamTagger.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// RPC Timing Detector
6// 17/12/2019
7// celso.franco@cern.ch
8
9#include "UpstreamTagger.h"
10
11#include <ROOT/TSeq.hxx>
12#include <iostream>
13#include <sstream>
14
15#include "FairGeoBuilder.h"
16#include "FairGeoInterface.h"
17#include "FairGeoLoader.h"
18#include "FairGeoMedia.h"
19#include "FairGeoNode.h"
20#include "FairGeoVolume.h"
21#include "FairRootManager.h"
22#include "FairRun.h"
23#include "FairRuntimeDb.h"
24#include "FairVolume.h"
25#include "ShipDetectorList.h"
26#include "ShipGeoUtil.h"
27#include "ShipStack.h"
28#include "TClonesArray.h"
29#include "TGeoBBox.h"
30#include "TGeoCompositeShape.h"
31#include "TGeoManager.h"
32#include "TGeoMaterial.h"
33#include "TGeoMedium.h"
34#include "TGeoTube.h"
35#include "TMath.h"
36#include "TParticle.h"
37#include "TVector3.h"
38#include "TVirtualMC.h"
39#include "UpstreamTaggerHit.h"
40#include "UpstreamTaggerPoint.h"
41using ROOT::TSeq;
42using ShipUnit::cm;
43using ShipUnit::m;
44using std::cout;
45using std::endl;
46
48 : Detector("UpstreamTagger", kTRUE, kUpstreamTagger),
49 det_zPos(0),
50 UpstreamTagger_fulldet(0),
51 scoringPlaneUBText(0) {}
52
53UpstreamTagger::UpstreamTagger(const char* name, Bool_t active)
54 : Detector(name, active, kUpstreamTagger),
55 det_zPos(0),
56 UpstreamTagger_fulldet(0),
57 scoringPlaneUBText(0) {}
58
59Bool_t UpstreamTagger::ProcessHits(FairVolume* vol) {
61 // Set parameters at entrance of volume. Reset ELoss.
62 if (gMC->IsTrackEntering()) {
63 fELoss = 0.;
64 fTime = gMC->TrackTime() * 1.0e09;
65 fLength = gMC->TrackLength();
66 gMC->TrackPosition(fPos);
67 gMC->TrackMomentum(fMom);
68 }
69
70 // Sum energy loss for all steps in the active volume
71 fELoss += gMC->Edep();
72
73 // Create vetoPoint at exit of active volume
74 if (gMC->IsTrackExiting() || gMC->IsTrackStop() ||
75 gMC->IsTrackDisappeared()) {
76 if (fELoss == 0.) {
77 return kFALSE;
78 }
79
80 fTrackID = gMC->GetStack()->GetCurrentTrackNumber();
81 fEventID = gMC->CurrentEvent();
82 Int_t uniqueId;
83 gMC->CurrentVolID(uniqueId);
84 if (uniqueId > 1000000) // Solid scintillator case
85 {
86 Int_t vcpy;
87 gMC->CurrentVolOffID(1, vcpy);
88 if (vcpy == 5) uniqueId += 4; // Copy of half
89 }
90
91 TParticle* p = gMC->GetStack()->GetCurrentTrack();
92 Int_t pdgCode = p->GetPdgCode();
93 TLorentzVector Pos;
94 gMC->TrackPosition(Pos);
95 TLorentzVector Mom;
96 gMC->TrackMomentum(Mom);
97 Double_t xmean = (fPos.X() + Pos.X()) / 2.;
98 Double_t ymean = (fPos.Y() + Pos.Y()) / 2.;
99 Double_t zmean = (fPos.Z() + Pos.Z()) / 2.;
100
101 AddHit(fEventID, fTrackID, uniqueId, TVector3(xmean, ymean, zmean),
102 TVector3(fMom.Px(), fMom.Py(), fMom.Pz()), fTime, fLength, fELoss,
103 pdgCode, TVector3(Pos.X(), Pos.Y(), Pos.Z()),
104 TVector3(Mom.Px(), Mom.Py(), Mom.Pz()));
105
106 // Increment number of veto det points in TParticle
107 ShipStack* stack = dynamic_cast<ShipStack*>(gMC->GetStack());
108 stack->AddPoint(kUpstreamTagger);
109 }
110
111 return kTRUE;
112}
113
115 TGeoVolume* top = gGeoManager->GetTopVolume();
116
118
120
122
123 ShipGeo::InitMedium("vacuum");
124 TGeoMedium* Vacuum_box = gGeoManager->GetMedium("vacuum");
126
127 // Adding UBT Extension
128 if (!Vacuum_box) {
129 Fatal("ConstructGeometry", "Medium 'vacuum' not found.");
130 }
131
133 gGeoManager->MakeBox("Upstream_Tagger", Vacuum_box, xbox_fulldet / 2.0,
134 ybox_fulldet / 2.0, zbox_fulldet / 2.0);
135 UpstreamTagger_fulldet->SetLineColor(kGreen);
136
137 top->AddNode(UpstreamTagger_fulldet, 1,
138 new TGeoTranslation(0.0, 0.0, det_zPos));
139 AddSensitiveVolume(UpstreamTagger_fulldet);
140 cout << " Z Position (Upstream Tagger1) " << det_zPos << endl;
142
143 return;
144}
@ kUpstreamTagger
TLorentzVector fPos
volume id
Definition: Detector.h:87
Double_t fTime
momentum at entrance
Definition: Detector.h:89
UpstreamTaggerPoint * AddHit(Args &&... args)
Definition: Detector.h:38
TLorentzVector fMom
position at entrance
Definition: Detector.h:88
Bool_t ProcessHits(FairVolume *v=0) override
Double_t ybox_fulldet
X dimension (default: 4.4 m)
void ConstructGeometry() override
Double_t xbox_fulldet
z-position of detector (set via SetZposition)
Double_t det_zPos
TGeoVolume * UpstreamTagger_fulldet
Z dimension/thickness (default: 16 cm)
Double_t zbox_fulldet
Y dimension (default: 6.4 m)
Int_t InitMedium(const char *name)
Definition: ShipGeoUtil.h:20