SND@LHC Software
Loading...
Searching...
No Matches
TimeDetHit.cxx
Go to the documentation of this file.
1#include "TimeDetHit.h"
2#include "TimeDet.h"
3#include "TVector3.h"
4#include "TMath.h"
5#include "TRandom1.h"
6#include "TRandom3.h"
7#include "TGeoManager.h"
8#include "TGeoBBox.h"
9#include "TGeoNode.h"
10
11#include <iostream>
12#include <cmath>
13
14using std::cout;
15using std::endl;
16
17Double_t speedOfLight = TMath::C() *100./1000000000.0 ; // from m/sec to cm/ns
18
19
20// ----- Default constructor --------------
22 : ShipHit()
23{
24 flag = true;
25}
26
27
28// ----- constructor from TimeDetPoint from TimeDetHit-------------------------------
30 : ShipHit()
31{
32 fDetectorID = p->GetDetectorID();
33 Float_t lpos, lneg;
34 Dist(p->GetX(), lpos, lneg);
35 Double_t sigma = Resol(lneg); // in ns
36 t_1 = gRandom->Gaus( 0, sigma ) + lneg/v_drift + t0 + p->GetTime();
37 sigma = Resol(lpos); // in ns
38 t_2 = gRandom->Gaus( 0, sigma ) + lpos/v_drift + t0 + p->GetTime();
39 flag = true;
40}
41
42
43// ----- Destructor -------------------------
45
46// ---- return time information for a given track extrapolation
47std::vector<double> TimeDetHit::GetTime(Double_t x){
48 // calculate distance to left and right end
49 Float_t lpos, lneg;
50 Dist(x, lpos, lneg);
51 Double_t r = Resol(lneg);
52 Double_t w1 = 1./(r*r);
53 r = Resol(lpos);
54 Double_t w2 = 1./(r*r);
55 Double_t dt = 1./TMath::Sqrt(w1+w2);
56 Double_t t = ( (t_1-lneg/v_drift)*w1+(t_2-lpos/v_drift)*w2 )/(w1+w2);
57 std::vector<double> m;
58 m.push_back(t);
59 m.push_back(dt);
60 return m;
61}
62// ---- return mean time information
63std::vector<double> TimeDetHit::GetTime(){
64 TGeoBBox* shape = (TGeoBBox*)gGeoManager->GetVolume("TimeDet")->GetShape();
65 Double_t t0 = (t_1+t_2)/2.-shape->GetDX()/v_drift;
66 Float_t lpos, lneg;
67 lneg = (t_1-t0)*v_drift;
68 lpos = (t_2-t0)*v_drift;
69 Float_t r1 = Resol(lneg);
70 Float_t r2 = Resol(lpos);
71 Double_t dt = TMath::Sqrt(r1*r1+r2*r2);
72 std::vector<double> m;
73 m.push_back(t0);
74 m.push_back(dt);
75 return m;
76}
77// ----- resolution function-------------------
78Double_t TimeDetHit::Resol(Double_t x)
79{
80 return par[0]*TMath::Exp( (x-par[2])/par[1] )+par[3];
81}
82
83std::vector<double> TimeDetHit::GetMeasurements(){
84 std::vector<double> m;
85 m.push_back( t_1);
86 m.push_back( t_2);
87 return m;
88}
89
90// distance to edges
91void TimeDetHit::Dist(Float_t x, Float_t& lpos, Float_t& lneg){
92 TGeoNode* node = GetNode();
93 auto shape = dynamic_cast<TGeoBBox*>(node->GetVolume()->GetShape());
94 TVector3 pos = GetXYZ();
95 lpos = TMath::Abs( pos.X() + shape->GetDX() - x );
96 lneg = TMath::Abs( pos.X() - shape->GetDX() - x );
97}
98// ----------------------------------------------
100{
101 TGeoNavigator* nav = gGeoManager->GetCurrentNavigator();
102 TGeoNode* node = GetNode();
103 auto shape = dynamic_cast<TGeoBBox*>(node->GetVolume()->GetShape());
104 Double_t origin[3] = {shape->GetOrigin()[0],shape->GetOrigin()[1],shape->GetOrigin()[2]};
105 Double_t master[3] = {0,0,0};
106 nav->LocalToMaster(origin,master);
107 TVector3 pos = TVector3(master[0],master[1],master[2]);
108 return pos;
109}
110
111
113{ TVector3 pos = GetXYZ();
114 return pos.X();
115}
116
117
119{ TVector3 pos = GetXYZ();
120 return pos.Y();
121}
122
123
125{ TVector3 pos = GetXYZ();
126 return pos.Z();
127}
128
129
131{
132 TGeoNavigator* nav = gGeoManager->GetCurrentNavigator();
133 TString path = "/Timing Detector_1/TimeDet_";path+=fDetectorID;
134 Bool_t rc = nav->cd(path);
135 return nav->GetCurrentNode();
136}
137
138
139// ----- Public method Print -----------------------
141{
142 cout << "-I- TimeDetHit: TimeDet hit " << " in detector " << fDetectorID << endl;
143 cout << " TDC left " << t_1 << " ns TDC right " << t_2 << " ns" << endl;
144}
145
146
147// -----------------------------------------------------
149
Double_t m
Double_t speedOfLight
Int_t fDetectorID
Detector unique identifier.
Definition ShipHit.h:58
Double_t Resol(Double_t x)
virtual ~TimeDetHit()
TVector3 GetXYZ()
std::vector< double > GetTime()
Double_t v_drift
Definition TimeDetHit.h:51
Float_t t_1
Definition TimeDetHit.h:55
Double_t GetX()
Double_t GetY()
TGeoNode * GetNode()
std::vector< double > GetMeasurements()
Double_t par[4]
Definition TimeDetHit.h:52
virtual void Print() const
Double_t GetZ()
void Dist(Float_t x, Float_t &lpos, Float_t &lneg)
Float_t flag
flag
Definition TimeDetHit.h:54
Float_t t_2
TDC on both sides.
Definition TimeDetHit.h:55
ClassImp(ecalContFact) ecalContFact