ATLAS Offline Software
Loading...
Searching...
No Matches
FPGATrackSimFunctions.cxx File Reference
Include dependency graph for FPGATrackSimFunctions.cxx:

Go to the source code of this file.

Functions

std::vector< std::vector< int > > getComboIndices (std::vector< size_t > const &sizes)
 Given a list of sizes (of arrays), generates a list of all combinations of indices to index one element from each array.
double rms95 (TH1 const *h)
 This function is used to calculate RMS95 value for 1D histograms.
std::vector< float > computeIdealCoords (const FPGATrackSimHit &hit, const double hough_x, const double hough_y, const double target_r, const bool doDeltaGPhis, const TrackCorrType trackCorrType)
double fieldCorrection (unsigned region, double qoverpt, double r)

Function Documentation

◆ computeIdealCoords()

std::vector< float > computeIdealCoords ( const FPGATrackSimHit & hit,
const double hough_x,
const double hough_y,
const double target_r,
const bool doDeltaGPhis,
const TrackCorrType trackCorrType )

Definition at line 116 of file FPGATrackSimFunctions.cxx.

116 {
117
118 std::vector<float> idealized_coordinates;
119
120 float hitGPhi = (float) hit.getGPhi();
121 float hitZ = (float) hit.getZ();
122
123 // rho = 0.33 m * (pT / GeV) / (B/T)
124 // B = 2 T so
125 // rho = 0.33 m * (pT / GeV) / (2)
126 double houghRho = 0.0003 * hough_y; //A*q/pT
127
128 hitGPhi += (hit.getR() - target_r) * houghRho; //first order
129
130 if (trackCorrType == TrackCorrType::Second) {
131 hitGPhi += (pow(hit.getR() * houghRho, 3.0) / 6.0); //higher order
132 }
133
134 if (hit.getR() > 1e-8) {
135 hitZ -= hit.getGCotTheta() * (hit.getR() - target_r); //first order
136 if (trackCorrType == TrackCorrType::Second)
137 hitZ -= (hit.getGCotTheta() * std::pow(hit.getR(), 3.0) * houghRho * houghRho) / 6.0; //higher order
138 }
139
140 idealized_coordinates.push_back(hitZ);
141
142 if (doDeltaGPhis) {
143 double expectedGPhi = hough_x;
144
145 expectedGPhi -= target_r * houghRho; //first order
146
147 if (trackCorrType == TrackCorrType::Second) {
148 expectedGPhi -= (std::pow(target_r * houghRho, 3.0) / 6.0); //higher order
149 }
150
151 idealized_coordinates.push_back(hitGPhi - expectedGPhi);
152 }
153 else {
154 idealized_coordinates.push_back(hitGPhi);
155 }
156
157
158 return idealized_coordinates;
159
160}
constexpr int pow(int base, int exp) noexcept
float getGPhi() const
float getZ() const
float getGCotTheta() const
float getR() const

◆ fieldCorrection()

double fieldCorrection ( unsigned region,
double qoverpt,
double r )

Definition at line 163 of file FPGATrackSimFunctions.cxx.

164{
165 double corr = 0;
166 if (region == 34) {
167 corr = 0.0248 + -0.0005727f*r + 0.000000781*r*r;
168 }
169 else if (region == 98) {
170 corr = 0.0465 + -0.0008291f*r + 0.000000951*r*r;
171 }
172 else if (region == 162) {
173 corr = -0.0106 + -0.0003101f*r + 0.000000253*r*r;
174 }
175 else if (region == 226) {
176 corr = -0.0283 + -0.0000953f*r + -0.000001034*r*r;
177 }
178 else if (region == 290) {
179 corr = -0.0308 + 0.0001405f*r + -0.000002490*r*r;
180 }
181 else if (region == 354) {
182 corr = -0.0458 + 0.0010403f*r + -0.000005134*r*r;
183 }
184 else if (region == 418) {
185 corr = -0.2827 + 0.0037327f*r + -0.000011028*r*r;
186 }
187 else if (region == 482) {
188 corr = -0.5366 + 0.0071298f*r + -0.000019784*r*r;
189 }
190 else if (region == 546) {
191 corr = -1.2843 + 0.0158170f*r + -0.000039258*r*r;
192 }
193 else if (region == 610) {
194 corr = -1.5723 + 0.0218720f*r + -0.000058057*r*r;
195 }
196 else if (region == 674) {
197 corr = -1.6054 + 0.0255374f*r + -0.000075211*r*r;
198 }
199 else if (region == 738) {
200 corr = -1.1620 + 0.0218955f*r + -0.000082656*r*r;
201 }
202 else if (region == 802) {
203 corr = -1.0069 + 0.0232949f*r + -0.000108384*r*r;
204 }
205 else if (region == 866) {
206 corr = -0.6938 + 0.0183421f*r + -0.000105477*r*r;
207 }
208 else if (region == 930) {
209 corr = -0.5990 + 0.0176694f*r + -0.000122848*r*r;
210 }
211 else if (region == 994) {
212 corr = -0.6198 + 0.0185393f*r + -0.000151144*r*r;
213 }
214 else if (region == 1058) {
215 corr = -0.6539 + 0.0218236f*r + -0.000196043*r*r;
216 }
217 else if (region == 1122) {
218 corr = -0.8929 + 0.0316982f*r + -0.000308742*r*r;
219 }
220 else if (region == 1186) {
221 corr = -0.7069 + 0.0283101f*r + -0.000328576*r*r;
222 }
223 else if (region == 1250) {
224 corr = -1.2240 + 0.0472546f*r + -0.000538216*r*r;
225 }
226 return -corr*qoverpt;
227}
int r
Definition globals.cxx:22

◆ getComboIndices()

std::vector< std::vector< int > > getComboIndices ( std::vector< size_t > const & sizes)

Given a list of sizes (of arrays), generates a list of all combinations of indices to index one element from each array.

Given a vector of sizes (of arrays), generates a vector of all combinations of indices to index one element from each array.

For example, given [2 3], generates [(0 0) (1 0) (0 1) (1 1) (0 2) (1 2)].

This basically amounts to a positional number system of where each digit has its own base. The number of digits is sizes.size(), and the base of digit i is sizes[i]. Then all combinations can be uniquely represented just by counting from [0, nCombs).

For a decimal number like 1357, you get the thousands digit with n / 1000 = n / (10 * 10 * 10). So here, you get the 0th digit with n / (base_1 * base_2 * base_3);

Definition at line 21 of file FPGATrackSimFunctions.cxx.

22{
23 size_t nCombs = 1;
24 std::vector<size_t> nCombs_prior(sizes.size());
25 std::vector<int> temp(sizes.size(), 0);
26
27 for (size_t i = 0; i < sizes.size(); i++)
28 {
29 if (sizes[i] > 0)
30 {
31 nCombs_prior[i] = nCombs;
32 nCombs *= sizes[i];
33 }
34 else temp[i] = -1;
35 }
36
37 std::vector<std::vector<int>> combos(nCombs, temp);
38
39 for (size_t icomb = 0; icomb < nCombs; icomb++)
40 {
41 size_t index = icomb;
42 for (size_t isize = sizes.size() - 1; isize < sizes.size(); isize--)
43 {
44 if (sizes[isize] == 0) continue;
45 combos[icomb][isize] = static_cast<int>(index / nCombs_prior[isize]);
46 index = index % nCombs_prior[isize];
47 }
48 }
49
50 return combos;
51}
Definition index.py:1

◆ rms95()

double rms95 ( TH1 const * h)

This function is used to calculate RMS95 value for 1D histograms.

It was ported from https://gitlab.cern.ch:8443/fpastore/l1tracksim/-/blob/master/PatRec/macros/FraMacros/Functions.cxx#L253 See more details there.

Definition at line 60 of file FPGATrackSimFunctions.cxx.

61{
62 double const frac = 0.95;
63 double entries = h->Integral(0, h->GetNbinsX() + 1);
64
65 // Not enough entries for this fraction, i.e. we want 0.95 then need 5% to be 1 events, so need at least 20 events.
66 if ((1.0 - frac) * entries < 1 || entries == 0) return h->GetRMS();
67
68 TH1* h_tmp = dynamic_cast<TH1*>(h->Clone());
69 if (not h_tmp){
70 throw "dynamic_cast failure in FPGATrackSimFunctions rms95(TH1*)";
71 }
72 h_tmp->GetXaxis()->SetRange(1, h_tmp->GetNbinsX());
73
74 int meanbin = h->GetXaxis()->FindBin(h_tmp->GetMean());
75 int lowerbin = meanbin;
76 int upperbin = meanbin;
77
78 double sum = h->GetBinContent(meanbin);
79 double lowerfrac = 0;
80 double upperfrac = 0;
81
82 int i = 1;
83 while (true) {
84 int this_lowerbin = meanbin - i;
85 int this_upperbin = meanbin + i;
86 if (this_lowerbin < 1 || this_upperbin > h->GetNbinsX()) break;
87
88 sum += h_tmp->GetBinContent(this_lowerbin) + h_tmp->GetBinContent(this_upperbin);
89 if (sum >= entries * frac) break;
90
91 lowerfrac = sum / entries;
92 lowerbin = this_lowerbin;
93 upperbin = this_upperbin;
94
95 i++;
96 }
97 upperfrac = sum / entries;
98
99 if (upperfrac == lowerfrac) return h->GetRMS();
100
101 double rms_lower = 0;
102 double rms_upper = 0;
103
104 h_tmp->GetXaxis()->SetRange(lowerbin, upperbin);
105 rms_lower = h_tmp->GetRMS();
106
107 h_tmp->GetXaxis()->SetRange(lowerbin - 1, upperbin + 1);
108 rms_upper = h_tmp->GetRMS();
109
110 double rms = rms_lower + (frac - lowerfrac) * (rms_upper - rms_lower) / (upperfrac - lowerfrac);
111
112 return rms * 1.1479538518;
113}
Header file for AthHistogramAlgorithm.
double entries
Definition listroot.cxx:49