ATLAS Offline Software
Loading...
Searching...
No Matches
MuonHough::MuonLayerHough Struct Reference

#include <MuonLayerHough.h>

Collaboration diagram for MuonHough::MuonLayerHough:

Classes

struct  Maximum
 struct representing the maximum in the hough space More...

Public Types

using DetRegIdx = Muon::MuonStationIndex::DetectorRegionIndex
using ChIdx = Muon::MuonStationIndex::ChIndex

Public Member Functions

 MuonLayerHough (const RegionDescriptor &descriptor)
 constructor
 ~MuonLayerHough ()=default
 destructor
void reset ()
 reset the transform
void setDebug (bool d)
 enable debug output
int bin (const Hit &hit) const
 calculate the position bin the hit will endup in
int bin (float x, float y) const
 calculate the bin corresponing to the given x,y position
float yval (int posBin) const
 access to y coordinate of a given bin
void pars (int posBin, int, float &x, float &y) const
 calculate x,y for the given position bin
float layerConfirmation (const Hit &hit, float range=1000.) const
 calculate the highest value of the hough transform within the specified range for the given hit
float layerConfirmation (float x, float y, float range=1000.) const
 calculate the highest value of the hough transform within the specified range for the given hit position
std::pair< float, float > layerConfirmation (unsigned int thetaBin, float x, float y, float range=1000.) const
 calculate the highest value of the hough transform within the specified range for the given hit position
bool findMaximum (Maximum &maximum, const MuonLayerHoughSelector &selector) const
 find the highest maximum that is above maxval
void associateHitsToMaximum (Maximum &maximum, const HitVec &hits) const
 associates the list of input hits to the provided maximum
std::pair< int, int > range (const float x, const float y1, const float y2, const int bintheta) const
 calculates the first and last bin the hit should be filled in for a given theta bin
std::pair< float, float > maximum (float x, float y, int &posbin, int &thetabin) const
 returns a pair with the position and angle corresponing to the input x,y values
void fill (const Hit &hit)
 fill the hough space with a single position
void fill (float x, float y, float weight)
 fill the hough space with a single position
void fillLayer (const HitVec &hits, bool substract=false)
 fill the hough space with a vector of hits using the layer mode
void fillLayer2 (const HitVec &hits, bool subtract=false)
std::vector< TH1 * > rootHistos (const std::string &prefix, const float *rmin=0, const float *rmax=0) const
 returns a vector with all the histograms of the hough as TH1*

Public Attributes

float m_binsize {0}
float m_invbinsize {0}
 binsize
int m_nbins {-1}
 inverse binsize
unsigned int max {0}
int maxhist {-1}
int maxbin {-1}
bool m_debug {false}
std::vector< std::unique_ptr< unsigned int[]> > m_histos
RegionDescriptor m_descriptor

Detailed Description

Definition at line 59 of file MuonLayerHough.h.

Member Typedef Documentation

◆ ChIdx

◆ DetRegIdx

Constructor & Destructor Documentation

◆ MuonLayerHough()

MuonHough::MuonLayerHough::MuonLayerHough ( const RegionDescriptor & descriptor)

constructor

Definition at line 35 of file MuonLayerHough.cxx.

35 :
36 m_descriptor(descriptor) {
37 // calculate the number of bins
38 m_nbins = (m_descriptor.yMaxRange - m_descriptor.yMinRange) / m_descriptor.yBinSize; // the same for all the cycles
39 m_binsize = (m_descriptor.yMaxRange - m_descriptor.yMinRange) / m_nbins;
40 m_invbinsize = 1. / m_binsize; // binsize in the floating plane
41
42 // setup the histograms; determines the number of theta slices
43 m_histos.reserve(m_descriptor.nthetaSamples); // it contains all the theta layers
44 for (unsigned int i = 0; i < m_descriptor.nthetaSamples; ++i) m_histos.emplace_back(new unsigned int[m_nbins]);
45 reset();
46 }
void reset()
reset the transform
RegionDescriptor m_descriptor
std::vector< std::unique_ptr< unsigned int[]> > m_histos
int m_nbins
inverse binsize

◆ ~MuonLayerHough()

MuonHough::MuonLayerHough::~MuonLayerHough ( )
default

destructor

Member Function Documentation

◆ associateHitsToMaximum()

void MuonHough::MuonLayerHough::associateHitsToMaximum ( MuonLayerHough::Maximum & maximum,
const HitVec & hits ) const

associates the list of input hits to the provided maximum

Definition at line 368 of file MuonLayerHough.cxx.

368 {
369 if (maximum.bintheta == -1 || maximum.binposmax == -1 || maximum.binposmin == -1) return;
370 // loop over hits and find those that are compatible with the maximum
371 HitVec::const_iterator it = hits.begin();
372 HitVec::const_iterator it_end = hits.end();
373 for (; it != it_end; ++it) {
374 // calculate the bins associated with the hit and check whether any of they are part of the maximum
375 std::pair<int, int> minMax = range((*it)->x, (*it)->ymin, (*it)->ymax, maximum.bintheta);
376 if (m_debug) {
377 std::cout << " associating hit: x " << (*it)->x << " ymin " << (*it)->ymin << " ymax " << (*it)->ymax << " layer "
378 << (*it)->layer << " range " << minMax.first << " " << minMax.second << " max range " << maximum.binposmin
379 << " " << maximum.binposmax << " prd " << (*it)->prd << " tgc " << (*it)->tgc;
380 if ((*it)->debugInfo()) std::cout << " trigC " << (*it)->debugInfo()->trigConfirm;
381 std::cout << std::endl;
382 }
383 if (minMax.first > maximum.binposmax) continue; // minimum bin large than the maximum, drop
384 if (minMax.second < maximum.binposmin) continue; // maximum bin smaller than the minimum, drop
385 // keep everything else
386 maximum.hits.push_back(*it);
387 if ((*it)->debugInfo() && (*it)->debugInfo()->trigConfirm > 0) ++maximum.triggerConfirmed;
388 }
389 }
float minMax(float x, const std::vector< float > &params)
std::pair< float, float > maximum(float x, float y, int &posbin, int &thetabin) const
returns a pair with the position and angle corresponing to the input x,y values
std::pair< int, int > range(const float x, const float y1, const float y2, const int bintheta) const
calculates the first and last bin the hit should be filled in for a given theta bin

◆ bin() [1/2]

int MuonHough::MuonLayerHough::bin ( const Hit & hit) const
inline

calculate the position bin the hit will endup in

Definition at line 190 of file MuonLayerHough.h.

190{ return bin(hit.x, hit.ymin); }
int bin(const Hit &hit) const
calculate the position bin the hit will endup in

◆ bin() [2/2]

int MuonHough::MuonLayerHough::bin ( float x,
float y ) const
inline

calculate the bin corresponing to the given x,y position

Definition at line 192 of file MuonLayerHough.h.

192 {
193 float yref = y * (m_descriptor.referencePosition - x) / x + y;
194 int in = (yref - m_descriptor.yMinRange) / m_binsize;
195 if (in < 0 || in >= m_nbins) in = -1;
196 return in;
197 }
#define y
#define x

◆ fill() [1/2]

void MuonHough::MuonLayerHough::fill ( const Hit & hit)
inline

fill the hough space with a single position

Definition at line 208 of file MuonLayerHough.h.

208{ fill(hit.x, hit.ymin, hit.w); }
void fill(const Hit &hit)
fill the hough space with a single position

◆ fill() [2/2]

void MuonHough::MuonLayerHough::fill ( float x,
float y,
float weight )

fill the hough space with a single position

Definition at line 55 of file MuonLayerHough.cxx.

55 {
56 int cycles = m_histos.size();
57 for (int ci = 0; ci < cycles; ++ci) {
58 float dtheta = m_descriptor.thetaStep;
59 float dthetaOffset = 2 * m_descriptor.thetaStep * (ci - (cycles - 1) / 2.);
60 float theta = std::atan2(x, y);
61 float zref = (m_descriptor.referencePosition - x) * cot(theta - dthetaOffset) + y;
62 float z0 = (m_descriptor.referencePosition - x) * cot(theta - dthetaOffset + dtheta) + y;
63 float z1 = (m_descriptor.referencePosition - x) * cot(theta - dthetaOffset - dtheta) + y;
64
65 float zmin = z0 < z1 ? z0 : z1;
66 float zmax = z0 < z1 ? z1 : z0;
67 int bincenter = (zref - m_descriptor.yMinRange) * m_invbinsize;
68
69 int binmin = (zmin - m_descriptor.yMinRange) * m_invbinsize;
70 int binmax = (zmax - m_descriptor.yMinRange) * m_invbinsize;
71 if (binmin - bincenter < -3) binmin = bincenter - 3;
72 if (binmin == bincenter) binmin -= 1;
73 if (binmax == bincenter) binmax += 1;
74 if (binmin >= m_nbins) continue;
75 if (binmax - bincenter > 3) binmax = bincenter + 3;
76 if (binmax < 0) continue;
77
78 if (binmin < 0) binmin = 0;
79 if (binmax >= m_nbins) binmax = m_nbins - 1;
80 if (m_debug)
81 std::cout << " filling " << x << " y " << binmin << " " << binmax << " w " << weight << " center " << bincenter << " range "
82 << (zmin - m_descriptor.yMinRange) * m_invbinsize << " " << (zmax - m_descriptor.yMinRange) * m_invbinsize
83 << std::endl;
84 for (int n = binmin; n <= binmax; ++n) {
85 unsigned int& val = m_histos[ci][n];
86 int w = 1000 * weight;
87 if (w < 0 && (int)val < -w)
88 val = 0;
89 else
90 val += weight;
91 if (val > max) {
92 max = val;
93 maxhist = ci;
94 maxbin = n;
95 }
96 }
97 }
98 }
Scalar theta() const
theta method

◆ fillLayer()

void MuonHough::MuonLayerHough::fillLayer ( const HitVec & hits,
bool substract = false )

fill the hough space with a vector of hits using the layer mode

Definition at line 100 of file MuonLayerHough.cxx.

100 {
101 if (hits.empty()) return;
102
103 // outer loop over cycles
104 int cycles = m_histos.size();
105 for (int ci = 0; ci < cycles; ++ci) {
106 // float dtheta = m_descriptor.thetaStep;
107 // float dthetaOffset = 2*m_descriptor.thetaStep*(ci-(cycles-1)/2.);
108
109 int prevlayer = -1;
110 int prevbinmin = 10000;
111 int prevbinmax = -1;
112 // inner loop over hits
113 HitVec::const_iterator it = hits.begin();
114 HitVec::const_iterator it_end = hits.end();
115 for (; it != it_end; ++it) {
116 float x = (*it)->x;
117 float y1 = (*it)->ymin;
118 float y2 = (*it)->ymax;
119 std::pair<int, int> minMax = range((*it)->x, (*it)->ymin, (*it)->ymax, ci);
120 int binmin = std::max(minMax.first,0);
121 int binmax = std::min(minMax.second, m_nbins - 1);
122 if (binmin >= m_nbins || binmax < 0) continue;
123
124 if (m_debug) {
125 std::cout << " filling hit " << x << " refpos " << m_descriptor.referencePosition << " ymin " << y1 << " ymax " << y2
126 << " layer " << (*it)->layer << " binmin " << binmin << " max " << binmax;
127 if ((*it)->debugInfo()) {
128 const HitDebugInfo* db1 = (*it)->debugInfo();
129 std::cout << " sec " << db1->sector << " r " <<Muon::MuonStationIndex::regionName(db1->region) << " type "
130 << db1->type << " lay " << Muon::MuonStationIndex::layerName(db1->layer)
131 << " slay " << db1->sublayer << std::endl;
132 } else
133 std::cout << std::endl;
134 }
135 // first hit within range
136 if (prevbinmax == -1) {
137 if (m_debug) std::cout << " first range " << binmin << " " << binmax << std::endl;
138 prevbinmin = binmin;
139 prevbinmax = binmax;
140 prevlayer = (*it)->layer;
141 continue;
142 }
143
144 if (binmin < prevbinmin && prevlayer == (*it)->layer) {
145 std::cout << "Error hits are out of order: min " << binmin << " max " << binmax << " lay " << (*it)->layer << std::endl;
146 }
147 // if the max value of the previous hit is smaller than the current minvalue fill the histogram of the previous hit
148 // do the same when reached last hit
149 if (prevbinmax < binmin || prevlayer != (*it)->layer) {
150 if (m_debug)
151 std::cout << " filling range " << prevbinmin << " " << prevbinmax << " new min " << binmin << " " << binmax
152 << " weight " << (*it)->w << std::endl;
153 for (int n = prevbinmin; n <= prevbinmax; ++n) {
154 unsigned int& val = m_histos[ci][n];
155 int w = 1000 * (*it)->w;
156 if (subtract) w *= -1;
157 if (w < 0 && (int)val < -w)
158 val = 0;
159 else
160 val += w;
161 if (val > max) {
162 max = val;
163 maxhist = ci;
164 maxbin = n;
165 }
166 }
167 prevbinmin = binmin;
168 prevbinmax = binmax;
169 prevlayer = (*it)->layer;
170
171 } else {
172 // update the maximum value of the window
173 if (m_debug)
174 std::cout << " updating range " << prevbinmin << " " << prevbinmax << " hit " << binmin << " " << binmax
175 << " new " << prevbinmin << " " << binmax << std::endl;
176 prevbinmax = binmax;
177 }
178 }
179 if (prevbinmax != -1) {
180 if (m_debug)
181 std::cout << " filling last range " << prevbinmin << " " << prevbinmax << " weight " << hits.back()->w << std::endl;
182 for (int n = prevbinmin; n <= prevbinmax; ++n) {
183 unsigned int& val = m_histos[ci][n];
184 int w = 1000 * hits.back()->w;
185 if (subtract) w *= -1;
186 if (w < 0 && (int)val < -w)
187 val = 0;
188 else
189 val += w;
190 if (val > max) {
191 max = val;
192 maxhist = ci;
193 maxbin = n;
194 }
195 }
196 }
197 }
198 }
const std::string & layerName(LayerIndex index)
convert LayerIndex into a string
const std::string & regionName(DetectorRegionIndex index)
convert DetectorRegionIndex into a string

◆ fillLayer2()

void MuonHough::MuonLayerHough::fillLayer2 ( const HitVec & hits,
bool subtract = false )

Definition at line 200 of file MuonLayerHough.cxx.

200 {
201 if (hits.empty()) return;
202
203 std::vector<int> layerCounts(m_nbins, 0);
204 int sign = subtract ? -1000 : 1000;
205 // outer loop over cycles
206 int cycles = m_histos.size();
207 for (int ci = 0; ci < cycles; ++ci) {
208 // keep track of the previous layer
209 int prevlayer = hits.front()->layer;
210
211 // inner loop over hits
212 HitVec::const_iterator it = hits.begin();
213 HitVec::const_iterator it_end = hits.end();
214 for (; it != it_end; ++it) {
215 // if we get to the next layer process the current one and fill the Hough space
216 if (prevlayer != (*it)->layer) {
217 for (int i = 0; i < m_nbins; ++i) {
218 if (subtract && -layerCounts[i] >= static_cast<int>(m_histos[ci][i]))
219 m_histos[ci][i] = 0;
220 else
221 m_histos[ci][i] += layerCounts[i];
222 layerCounts[i] = 0; // reset bin
223 }
224 prevlayer = (*it)->layer;
225 }
226
227 // get bin range
228 std::pair<int, int> minMax = range((*it)->x, (*it)->ymin, (*it)->ymax, ci);
229 int binmin = minMax.first;
230 int binmax = minMax.second;
231
232 // check wether we are within the Hough space
233 if (binmin >= m_nbins) continue;
234 if (binmax < 0) continue;
235
236 // adjust boundaries if needed
237 if (binmin < 0) binmin = 0;
238 if (binmax >= m_nbins) binmax = m_nbins - 1;
239
240 // output hit for debug purposes
241 if (m_debug) {
242 std::cout << " cycle(theta layers) " << ci << " filling hit " << (*it)->x << " refpos "
243 << m_descriptor.referencePosition << " ymin " << (*it)->ymin << " ymax " << (*it)->ymax << " layer "
244 << (*it)->layer << " weight " << (*it)->w << " binmin " << binmin << " max " << binmax;
245 std::cout << " zmin " << binmin * m_binsize + m_descriptor.yMinRange << " zmax "
246 << binmax * m_binsize + m_descriptor.yMinRange;
247 if ((*it)->debugInfo()) {
248 const HitDebugInfo* db1 = (*it)->debugInfo();
249 std::cout << " sec " << db1->sector << " r " << Muon::MuonStationIndex::regionName(db1->region)
250 << " type " << db1->type << " lay " << Muon::MuonStationIndex::layerName(db1->layer)
251 << " bc " << db1->uniqueID << std::endl;
252 } else
253 std::cout << std::endl;
254 }
255 int weight = sign * (*it)->w; // set the hit weight
256 // set bits to true
257 for (; binmin <= binmax; ++binmin) layerCounts[binmin] = weight;
258 } // end of loopin gover hits
259 // if the last set of hits was not filled, fill them now; just for the last layer
260 for (int i = 0; i < m_nbins; ++i) {
261 if (subtract && -layerCounts[i] >= static_cast<int>(m_histos[ci][i]))
262 m_histos[ci][i] = 0;
263 else
264 m_histos[ci][i] += layerCounts[i];
265 // if( m_debug && layerCounts[i] != 0 ) std::cout << " filling layer " << prevlayer << " bin " << i << " val " <<
266 // layerCounts[i] << " tot " << m_histos[ci][i] << std::endl;
267 layerCounts[i] = 0; // reset bin
268 }
269 }
270 }
int sign(int a)

◆ findMaximum()

bool MuonHough::MuonLayerHough::findMaximum ( Maximum & maximum,
const MuonLayerHoughSelector & selector ) const

find the highest maximum that is above maxval

Definition at line 290 of file MuonLayerHough.cxx.

290 {
291 const float preMaxCut = selector.getMinCutValue(); // in this case it is likely to be 1.9
292 maximum.max = 0;
293 maximum.pos = 0;
294 maximum.theta = 0;
295 maximum.refpos = 0;
296 maximum.refregion = DetRegIdx::DetectorRegionUnknown;
297 maximum.refchIndex = ChIdx::ChUnknown;
298 maximum.binpos = -1;
299 maximum.binposmin = -1;
300 maximum.binposmax = -1;
301 maximum.binsize = -1;
302 maximum.bintheta = -1;
303 maximum.triggerConfirmed = 0;
304 maximum.hits.clear();
305 maximum.hough = this;
306
307 if (preMaxCut < 0) return false; // this is where there is no cut
308
309 float tmax = 0;
310 int posb = -1;
311 int thetab = -1;
312 int imaxval = preMaxCut * 1000;
313 const int cycles = m_histos.size();
314 // loop over histograms and find maximum
315 for (int ci = 0; ci < cycles; ++ci) {
316 const float scale =
317 1. - 0.01 * std::abs(ci - cycles / 2.0); // small deweighting of non pointing bins; weighting more on the central part
318 for (int n = 0; n < m_nbins; ++n) {
319 const int val = m_histos[ci][n];
320 if (val < imaxval) continue;
321
322 if (scale * val > tmax) {
323 tmax = scale * val;
324 posb = n;
325 thetab = ci;
326 }
327 }
328 }
329 if (posb == -1) return false; // didn't find a max
330
331 const float candidatePos = m_descriptor.yMinRange + m_binsize * posb;
332 if (tmax < selector.getCutValue(candidatePos)) return false;
333
334 maximum.max = tmax * 0.001;
335 maximum.pos = candidatePos;
336 maximum.theta =
337 -m_descriptor.thetaStep * (thetab - (m_histos.size() - 1) * 0.5) + std::atan2(m_descriptor.referencePosition, maximum.pos);
338 maximum.refpos = m_descriptor.referencePosition;
339 maximum.refregion = m_descriptor.region;
340 maximum.refchIndex = m_descriptor.chIndex;
341 maximum.binpos = posb;
342 maximum.binposmin = posb;
343 maximum.binposmax = posb;
344 maximum.binsize = m_binsize;
345 maximum.bintheta = thetab;
346
347 // determin width of maximum; now to be 70% of the original height
348 unsigned int imax = m_histos[thetab][posb];
349 unsigned int sidemax = 0.7 * imax;
350 // loop down, catch case the maximum is in the first bin
351 for (int n = posb != 0 ? posb - 1 : posb; n >= 0; --n) {
352 if (m_histos[thetab][n] > sidemax) {
353 maximum.binposmin = n;
354 } else {
355 break;
356 }
357 }
358 for (int n = posb + 1; n < m_nbins; ++n) {
359 if (m_histos[thetab][n] > sidemax) {
360 maximum.binposmax = n;
361 } else {
362 break;
363 }
364 }
365 return true;
366 }
int imax(int i, int j)

◆ layerConfirmation() [1/3]

float MuonHough::MuonLayerHough::layerConfirmation ( const Hit & hit,
float range = 1000. ) const
inline

calculate the highest value of the hough transform within the specified range for the given hit

Definition at line 206 of file MuonLayerHough.h.

206{ return layerConfirmation(hit.x, hit.ymin, range); }
float layerConfirmation(const Hit &hit, float range=1000.) const
calculate the highest value of the hough transform within the specified range for the given hit

◆ layerConfirmation() [2/3]

float MuonHough::MuonLayerHough::layerConfirmation ( float x,
float y,
float range = 1000. ) const

calculate the highest value of the hough transform within the specified range for the given hit position

Definition at line 427 of file MuonLayerHough.cxx.

427 {
428 unsigned int max = 0;
429 if (x == 0) return 0;
430
431 float yloc = m_descriptor.referencePosition * y / x;
432 int bincenter = (yloc - m_descriptor.yMinRange) / m_binsize;
433 int scanRange = range / m_binsize;
434 int binmin = bincenter - scanRange;
435 int binmax = bincenter + scanRange;
436 if (binmin >= m_nbins) return 0;
437 if (binmax < 0) return 0;
438
439 int maxbin = -1;
440 if (binmin < 0) binmin = 0;
441 if (binmax >= m_nbins) binmax = m_nbins - 1;
442 int cyclesmin = 0;
443 int cycles = m_histos.size();
444 if (cycles > 3) {
445 int c0 = cycles / 2;
446 cyclesmin = c0 - 1;
447 cycles = c0 + 1;
448 }
449 for (int n = binmin; n < binmax; ++n) {
450 for (int ci = cyclesmin; ci < cycles; ++ci) {
451 if (max < m_histos[ci][n]) {
452 max = m_histos[ci][n];
453 maxbin = n;
454 }
455 }
456 }
457 if (range == 900) std::cout << " layerConfirmation " << max << " bin " << maxbin << " entry " << bincenter << std::endl;
458 return 0.001 * max;
459 }

◆ layerConfirmation() [3/3]

std::pair< float, float > MuonHough::MuonLayerHough::layerConfirmation ( unsigned int thetaBin,
float x,
float y,
float range = 1000. ) const

calculate the highest value of the hough transform within the specified range for the given hit position

Definition at line 461 of file MuonLayerHough.cxx.

461 {
462 unsigned int max = 0;
463 if (x == 0) return std::make_pair(0., 0.);
464 if (thetaBin >= m_histos.size()) return std::make_pair(0., 0.);
465 float yloc = m_descriptor.referencePosition * y / x;
466 int bincenter = (yloc - m_descriptor.yMinRange) / m_binsize;
467 int scanRange = range / m_binsize;
468 int binmin = bincenter - scanRange;
469 int binmax = bincenter + scanRange;
470 if (binmin >= m_nbins) return std::make_pair(0., 0.);
471 if (binmax < 0) return std::make_pair(0., 0.);
472
473 int maxbin = -1;
474 if (binmin < 0) binmin = 0;
475 if (binmax >= m_nbins) binmax = m_nbins - 1;
476 for (int n = binmin; n < binmax; ++n) {
477 if (max < m_histos[thetaBin][n]) {
478 max = m_histos[thetaBin][n];
479 maxbin = n;
480 }
481 }
482 std::cout << " layerConfirmation " << max << " bin " << maxbin << " entry " << bincenter << " val " << yval(max) << std::endl;
483 return std::make_pair(0.001 * max, yval(maxbin));
484 }
float yval(int posBin) const
access to y coordinate of a given bin

◆ maximum()

std::pair< float, float > MuonHough::MuonLayerHough::maximum ( float x,
float y,
int & posbin,
int & thetabin ) const

returns a pair with the position and angle corresponing to the input x,y values

Definition at line 391 of file MuonLayerHough.cxx.

391 {
392 unsigned int max = 0;
393 thetabin = -1;
394 posbin = -1;
395
396 int cycles = m_histos.size();
397 for (int ci = 0; ci < cycles; ++ci) {
398 int relbin = ci - (cycles - 1) / 2;
399 float dtheta = m_descriptor.thetaStep;
400 float dthetaOffset = 2 * m_descriptor.thetaStep * (relbin); // if bintheta = cycles, this is the same as dtheta * (cycles + 1 )
401 float theta = std::atan2(x, y);
402 float z0 = (m_descriptor.referencePosition - x) * cot(theta - dthetaOffset + dtheta) +
403 y; // move the angle by a step, recalculate the new y value
404 float z1 = (m_descriptor.referencePosition - x) * cot(theta - dthetaOffset - dtheta) + y;
405
406 float zmin = z0 < z1 ? z0 : z1;
407 float zmax = z0 < z1 ? z1 : z0;
408 int binmin = (zmin - m_descriptor.yMinRange) / m_binsize - 1;
409 int binmax = (zmax - m_descriptor.yMinRange) / m_binsize + 1;
410 if (binmin >= m_nbins) continue;
411 if (binmax < 0) continue;
412
413 if (binmin < 0) binmin = 0;
414 if (binmax >= m_nbins) binmax = m_nbins - 1;
415 for (int n = binmin; n < binmax; ++n) {
416 if (max < m_histos[ci][n]) {
417 max = m_histos[ci][n];
418 posbin = n;
419 thetabin = ci;
420 }
421 }
422 }
423 float dthetaOffset = 2 * m_descriptor.thetaStep * (thetabin - (cycles - 1) / 2.);
424 return std::make_pair(0.001 * max, -dthetaOffset);
425 }

◆ pars()

void MuonHough::MuonLayerHough::pars ( int posBin,
int ,
float & x,
float & y ) const
inline

calculate x,y for the given position bin

Definition at line 199 of file MuonLayerHough.h.

199 {
200 x = m_descriptor.referencePosition;
201 y = yval(posBin);
202 }

◆ range()

std::pair< int, int > MuonHough::MuonLayerHough::range ( const float x,
const float y1,
const float y2,
const int bintheta ) const

calculates the first and last bin the hit should be filled in for a given theta bin

The z values shall be some where inside the cavern. Given that the out wheel is at 22m, this is a very rough estimate to crimp the z value and to hopefully avoid spooky FPEs

Definition at line 486 of file MuonLayerHough.cxx.

486 {
487 int cycles = m_histos.size();
488 float dx = m_descriptor.referencePosition - x;
489 float dtheta = m_descriptor.thetaStep;
490 if (dtheta <= 0)
491 throw std::runtime_error(
492 Form("File: %s, Line: %d\nMuonLayerHough::range() - dtheta is not positive (%.4f)", __FILE__, __LINE__, dtheta));
493 float dthetaOffset = 2 * dtheta * (bintheta - (cycles - 1) / 2.);
494
495 float theta1 = std::atan2(x, y1) - dthetaOffset;
496 float z01 = dx * cot(theta1 + dtheta) + y1;
497 float z11 = dx * cot(theta1 - dtheta) + y1;
498 float zmin1 = std::min(z01, z11);
499 float zmax1 = std::max(z01, z11);
500
501 float theta2 = std::atan2(x, y2) - dthetaOffset;
502 float z02 = dx * cot(theta2 + dtheta) + y2;
503 float z12 = dx * cot(theta2 - dtheta) + y2;
504 float zmin2 = std::min(z02, z12);
505 float zmax2 = std::max(z02, z12);
506
507 const float zmin = std::min(zmin1, zmin2);
508 const float zmax = std::max(zmax1, zmax2);
509
512 constexpr float cavern_size = 100.*Gaudi::Units::meter;
513 const float flt_lower_bin = std::max(-cavern_size, (zmin - m_descriptor.yMinRange) * m_invbinsize);
514 const float flt_upper_bin = std::min(cavern_size, (zmax - m_descriptor.yMinRange) * m_invbinsize);
515 const int lower_bin = std::floor(flt_lower_bin);
516 const int upper_bin = std::floor(flt_upper_bin);
517
518 return std::make_pair(lower_bin, upper_bin); // convert the output to bins
519 }

◆ reset()

void MuonHough::MuonLayerHough::reset ( )

reset the transform

Definition at line 48 of file MuonLayerHough.cxx.

48 {
49 for (unsigned int i = 0; i < m_histos.size(); ++i) memset(m_histos[i].get(), 0, sizeof(unsigned int) * m_nbins);
50 max = 0;
51 maxhist = -1;
52 maxbin = -1;
53 }
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition hcg.cxx:130

◆ rootHistos()

std::vector< TH1 * > MuonHough::MuonLayerHough::rootHistos ( const std::string & prefix,
const float * rmin = 0,
const float * rmax = 0 ) const

returns a vector with all the histograms of the hough as TH1*

Definition at line 272 of file MuonLayerHough.cxx.

272 {
273 std::vector<TH1*> hists;
274 hists.reserve(m_histos.size());
275
276 float rmin = rmi ? *rmi : m_descriptor.yMinRange;
277 float rmax = rma ? *rma : m_descriptor.yMaxRange;
278
279 int cycles = m_histos.size();
280 for (int ci = 0; ci < cycles; ++ci) {
281 TString hname = prefix + "_hist";
282 hname += ci;
283 TH1F* h = new TH1F(hname, hname, m_nbins, rmin, rmax); // register the new histograms here
284 for (int n = 0; n < m_nbins; ++n) h->SetBinContent(n + 1, m_histos[ci][n] * 0.001);
285 hists.push_back(h);
286 }
287 return hists;
288 }
TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)

◆ setDebug()

void MuonHough::MuonLayerHough::setDebug ( bool d)
inline

enable debug output

Definition at line 124 of file MuonLayerHough.h.

◆ yval()

float MuonHough::MuonLayerHough::yval ( int posBin) const
inline

access to y coordinate of a given bin

Definition at line 204 of file MuonLayerHough.h.

204{ return m_descriptor.yMinRange + posBin * m_binsize; }

Member Data Documentation

◆ m_binsize

float MuonHough::MuonLayerHough::m_binsize {0}

Definition at line 176 of file MuonLayerHough.h.

176{0};

◆ m_debug

bool MuonHough::MuonLayerHough::m_debug {false}

Definition at line 185 of file MuonLayerHough.h.

185{false};

◆ m_descriptor

RegionDescriptor MuonHough::MuonLayerHough::m_descriptor

Definition at line 187 of file MuonLayerHough.h.

◆ m_histos

std::vector<std::unique_ptr<unsigned int[]> > MuonHough::MuonLayerHough::m_histos

Definition at line 186 of file MuonLayerHough.h.

◆ m_invbinsize

float MuonHough::MuonLayerHough::m_invbinsize {0}

binsize

Definition at line 177 of file MuonLayerHough.h.

177{0};

◆ m_nbins

int MuonHough::MuonLayerHough::m_nbins {-1}

inverse binsize

Definition at line 180 of file MuonLayerHough.h.

180{-1};

◆ max

unsigned int MuonHough::MuonLayerHough::max {0}

Definition at line 182 of file MuonLayerHough.h.

182{0};

◆ maxbin

int MuonHough::MuonLayerHough::maxbin {-1}

Definition at line 184 of file MuonLayerHough.h.

184{-1};

◆ maxhist

int MuonHough::MuonLayerHough::maxhist {-1}

Definition at line 183 of file MuonLayerHough.h.

183{-1};

The documentation for this struct was generated from the following files: