CbmRoot
Loading...
Searching...
No Matches
CbmTrdHitMC.cxx
Go to the documentation of this file.
1/* Copyright (C) 2018-2022 Horia Hulubei National Institute of Physics and Nuclear Engineering, Bucharest
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Alexandru Bercuci [committer] */
4
5#include "CbmTrdHitMC.h"
6
7#include "CbmTrdDigi.h"
8
9#include <TDatabasePDG.h>
10#include <TParticlePDG.h>
11#include <TVector3.h>
12
13#include <sstream>
14
15// Error parametrization
16int CbmTrdHitMC::fSx[5][2] = {{190, 2321}, {147, 1920}, {50, 1461}, {22, 2094}, {21, 4297}};
17//_____________________________________________________________________
19
20//_____________________________________________________________________
22
23//_____________________________________________________________________
25
26//_____________________________________________________________________
28
29//_____________________________________________________________________
30size_t CbmTrdHitMC::AddPoint(const CbmTrdPoint* p, double t, int id)
31{
32 fTrdPoints.push_back(std::make_tuple(CbmTrdPoint(*p), t, id));
33 return fTrdPoints.size();
34}
35
36//_____________________________________________________________________
37size_t CbmTrdHitMC::AddSignal(const CbmTrdDigi* digi, uint64_t t0)
38{
39 if (GetClassType() == 1) { // TRD2D type
40 int dt;
41 double t, r = digi->GetCharge(t, dt);
42 fTrdSignals.push_back(std::make_pair(t, digi->GetTimeDAQ() - t0));
43 fTrdSignals.push_back(std::make_pair(r, digi->GetTimeDAQ() + dt - t0));
44 }
45 else // TRD1D type
46 fTrdSignals.push_back(std::make_pair(digi->GetCharge(), digi->GetTime() - t0));
47
48 return fTrdSignals.size();
49}
50
51//_____________________________________________________________________
53{
54 if (!GetNSignals()) return 0;
55 if (fTrdSignals.front().first < 1.e-3) fTrdSignals.erase(fTrdSignals.begin());
56 if (fTrdSignals.back().first < 1.e-3) fTrdSignals.pop_back();
57
58 return fTrdSignals.size();
59}
60
61//_____________________________________________________________________
62const CbmTrdPoint* CbmTrdHitMC::GetPoint(uint idx) const
63{
64 if (idx >= fTrdPoints.size()) return nullptr;
65 return &std::get<0>(fTrdPoints[idx]);
66}
67
68//_____________________________________________________________________
69double CbmTrdHitMC::GetSignal(uint idx) const
70{
71 if (idx >= fTrdSignals.size()) return 0;
72 return fTrdSignals[idx].first;
73}
74
75//_____________________________________________________________________
77{
78 if (fCluster.HasStart()) {
79 if (fCluster.HasStop())
81 else
83 }
84 else {
85 if (fCluster.HasStop())
87 else
89 }
90}
91
92//_____________________________________________________________________
93double CbmTrdHitMC::GetDx() const
94{
95 const CbmTrdPoint* p(nullptr);
96 if (!(p = GetPoint())) return -999;
97 double dz(GetZ() - p->GetZ()), x(p->GetX() + dz * p->GetPx() / p->GetPz());
98 return GetX() - x;
99}
100
101//_____________________________________________________________________
102double CbmTrdHitMC::GetSx() const
103{
104 const CbmTrdPoint* p(nullptr);
105 if (!(p = GetPoint())) return 1;
106 double phi(p->GetPx() / p->GetPz());
107 int isz = GetNSignals() - 2;
108
109 if (isz < 0) isz = 0;
110 if (isz >= 5) isz = 4;
111
112 return 1.e-4 * (fSx[isz][0] + phi * phi * fSx[isz][1]); // error in cm
113}
114
115//_____________________________________________________________________
116double CbmTrdHitMC::GetDy() const
117{
118 const CbmTrdPoint* p(nullptr);
119 if (!(p = GetPoint())) return -999;
120 double dz(GetZ() - p->GetZ()), y(p->GetY() + dz * p->GetPy() / p->GetPz());
121 return GetY() - y;
122}
123
124//_____________________________________________________________________
125double CbmTrdHitMC::GetSy() const { return GetDy(); }
126
127//_____________________________________________________________________
128double CbmTrdHitMC::GetDt() const
129{
130 constexpr double speedOfLight = 29.979246; // cm/ns
131 const CbmTrdPoint* p(nullptr);
132 if (!(p = GetPoint())) return -999;
133
134 int pdg = std::get<2>(fTrdPoints[0]);
135 double t0(std::get<1>(fTrdPoints[0])), dz(GetZ() - p->GetZ()), t(t0 + p->GetTime()), mass(0);
136
137 TParticlePDG* pmc = (TParticlePDG*) TDatabasePDG::Instance()->GetParticle(pdg);
138 if (pdg < 9999999 && pmc) mass = pmc->Mass();
139
140 TVector3 mom3;
141 p->Momentum(mom3);
142 t += dz / (p->GetPz() * speedOfLight) * sqrt(mass * mass + mom3.Mag2());
143 return GetTime() - t;
144}
145
146//_____________________________________________________________________
147std::string CbmTrdHitMC::ToString() const
148{
149 std::stringstream ss;
150 for (auto mcp : fTrdPoints) {
151 ss << "Event time(ns)=" << std::get<1>(mcp) << " partId=" << std::get<2>(mcp) << "\n";
152 ss << std::get<0>(mcp).ToString();
153 }
154
155 ss << "CbmTrdDigi: [" << fTrdSignals.size() << "] Signal / Relative Time\n ";
156 for (auto sgn : fTrdSignals) {
157 ss << sgn.first << "/" << sgn.second << " ";
158 }
159 ss << "\n";
160
161 ss << fCluster.ToString();
162
163 ss << CbmTrdHit::ToString();
164
165 if (fErrMsg != "") ss << "Error : " << fErrMsg << "\n";
166 return ss.str();
167}
168
ClassImp(CbmConverterManager)
friend fvec sqrt(const fvec &a)
friend fscal sgn(fscal x)
double GetTime() const
Definition CbmHit.h:76
double GetZ() const
Definition CbmHit.h:71
double GetY() const
Definition CbmPixelHit.h:74
double GetX() const
Definition CbmPixelHit.h:73
Data class with information on a STS local track.
Data Container for TRD clusters.
bool HasStart() const
virtual std::string ToString() const
Extended functionality.
bool HasStop() const
uint64_t GetTimeDAQ() const
Getter for global DAQ time [clk]. Differs for each ASIC. In FASP case DAQ time is already stored in f...
Definition CbmTrdDigi.h:158
double GetTime() const
Getter for physical time [ns]. Accounts for clock representation of each ASIC. In SPADIC case physica...
Definition CbmTrdDigi.h:153
double GetCharge() const
Common purpose charge getter.
TRD hit to MC point correlation class.
Definition CbmTrdHitMC.h:28
CbmTrdCluster fCluster
std::vector< std::pair< double, int > > fTrdSignals
size_t AddPoint(const CbmTrdPoint *p, double t, int id)
Add MC points to the hit. The first time this function is called is for the best matched MC point.
virtual std::string ToString() const
Verbosity functionality.
double GetSignal(uint idx=0) const
return signal at position
std::string fErrMsg
std::vector< std::tuple< CbmTrdPoint, double, int > > fTrdPoints
double GetSy() const
Calculate error for the azimuth direction.
const CbmTrdPoint * GetPoint(uint idx=0) const
Register a MC point.
eCbmTrdHitMCshape GetClShape() const
return cluster shape according to the eCbmTrdHitMCshape definitions
void AddCluster(const CbmTrdCluster *c)
Copy cluster details.
double GetSx() const
Calculate error in the bending plane.
double GetDt() const
Calculate residuals for time.
size_t PurgeSignals()
Applies to TRD2D and remove 0 charges from the boundaries of the cluster.
size_t AddSignal(const CbmTrdDigi *d, uint64_t t0)
Add signal values in the increasing order of pad index.
double GetDy() const
Calculate residuals for the azimuth direction.
virtual ~CbmTrdHitMC()
Destructor.
size_t GetNSignals() const
return cluster size
Definition CbmTrdHitMC.h:81
double GetDx() const
Calculate residuals in the bending plane.
static int fSx[5][2]
Definition CbmTrdHitMC.h:16
CbmTrdHitMC()
Default constructor.
data class for a reconstructed Energy-4D measurement in the TRD
Definition CbmTrdHit.h:40
bool GetClassType() const
Definition CbmTrdHit.h:80
virtual std::string ToString() const
Inherited from CbmBaseHit.
Definition CbmTrdHit.cxx:42