SND@LHC Software
Loading...
Searching...
No Matches
DriftTubeHit.cxx
Go to the documentation of this file.
1#include "DriftTubeHit.h"
2#include "DriftTube.h"
3#include "TROOT.h"
4#include "FairRunSim.h"
5#include "TGeoNavigator.h"
6#include "TGeoManager.h"
7#include "TGeoBBox.h"
9#include <TRandom.h>
10#include <iomanip>
11
12// ----- Default constructor -------------------------------------------
14 : TObject(),
15 fDetectorID(-1)
16{
17}
18// ----- Standard constructor ------------------------------------------
20 : TObject(),
21 fDetectorID(detID)
22{
23 flag = true;
24}
25DriftTubeHit::DriftTubeHit(Int_t detID, const Double_t& m_timestamp) : TObject(), fDetectorID(detID), timestamp(m_timestamp)
26{
27 flag = true;
28}
29
30// ----- constructor from point class ------------------------------------------
31DriftTubeHit::DriftTubeHit(int detID, std::vector<DriftTubePoint *> V, std::vector<Float_t> W)
32{
33 DriftTube *DriftTubeDet = dynamic_cast<DriftTube *>(gROOT->GetListOfGlobals()->FindObject("DriftTube"));
34 Float_t timeResol = DriftTubeDet->GetConfParF("DriftTube/timeResol"); // example
35
36 for (auto p = std::begin(V); p != std::end(V); ++p) {
37
38 Double_t signal = (*p)->GetEnergyLoss();
39 // Find the distance from MCPoint to the center of cell (the anode)
40 TVector3 vLeft, vRight;
41 TVector3 impact((*p)->GetX(), (*p)->GetY(), (*p)->GetZ());
42 DriftTubeDet->GetPosition(detID, vLeft, vRight);
43 Double_t distance = (vLeft - impact).Perp(); // transverse component
44
45 // for the timing - what to do?
46 Double_t ptime = (*p)->GetTime();
47 }
48 // what needs to be set: distance? time?
49
50 LOG(DEBUG) << "signal created";
51}
52
53// ----- Destructor ----------------------------------------------------
55// -------------------------------------------------------------------------
56
57// ----- Public method Print -------------------------------------------
59{
60 std::cout << "-I- DriftTubeHit: DriftTube hit " << " in station " << GetPlane();
61 if (isVertical()) {
62 std::cout << " vertical plane ";
63 } else {
64 std::cout << " horizontal plane ";
65 }
66 std::cout << "layer nr " << GetLayer() << " cell nr " << GetCell() << std::endl;
67}
68// -------------------------------------------------------------------------
69
71 TVector3 position {};
72 std::string node = Form("/Detector_0/volDriftTubePlane_%d/volLayer_%d/volCell_%d/volAnode_2", GetPlane(), GetLayer(), GetDetectorID());
73 auto navigator = gGeoManager->GetCurrentNavigator();
74
75 DriftTube *DriftTubeDet = dynamic_cast<DriftTube *>(gROOT->GetListOfGlobals()->FindObject("DriftTube"));
76 const auto WCELL = static_cast<double>(DriftTubeDet->GetConfParF("DriftTube/cellWidth"));
77
78 if (gGeoManager->cd(node.c_str())) {
79 TGeoShape *shape = gGeoManager->GetCurrentNode()->GetVolume()->GetShape();
80 if (shape->InheritsFrom("TGeoBBox")) {
81 TGeoBBox *box = dynamic_cast<TGeoBBox *>(shape);
82 const Double_t *origin = box->GetOrigin();
83
84 navigator->cd(node.c_str());
85 Double_t localPosition[3] {origin[0] + std::min(static_cast<double>((timestamp - drifttube::tped) * drifttube::vdrift), WCELL * 0.5) * laterality, origin[1], origin[2]};
86 Double_t globalPosition[3] {};
87 navigator->LocalToMaster(localPosition, globalPosition);
88
89 position.SetXYZ(globalPosition[0], globalPosition[1], globalPosition[2]);
90 }
91 }
92
93 return position;
94}
95
Int_t GetPlane()
Int_t GetLayer()
Int_t GetCell()
int GetDetectorID()
TVector3 GetPosition()
bool isVertical()
Float_t flag
flag
Double_t timestamp
virtual ~DriftTubeHit()
ClassImp(ecalContFact) ecalContFact
constexpr double vdrift
constexpr double tped