ATLAS Offline Software
Public Types | Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
MuonCalib::StraightPatRec Class Reference

#include <StraightPatRec.h>

Inheritance diagram for MuonCalib::StraightPatRec:
Collaboration diagram for MuonCalib::StraightPatRec:

Public Types

typedef std::vector< unsigned int > HitSelection
 

Public Member Functions

 StraightPatRec ()
 Default constructor: road width for pattern recognition = 0.5 mm. More...
 
 StraightPatRec (const double &r_road_width)
 Constructor: user-defined road width for pattern recognition. More...
 
double roadWidth () const
 get the final track in the local co-ordinate frame, i.e. More...
 
void setRoadWidth (const double &r_road_width)
 set the road width for the pattern recognition = r_road_width More...
 
void setTimeOut (const double &time_out)
 set the time-out for the track finding to time_out (in seconds) More...
 
void setFixSelection (bool fix_sel)
 
bool fit (MuonCalibSegment &r_segment) const
 reconstruction of the track using all hits in the segment "r_segment", returns true in case of success; the algorithm overwrites the track radii, the track position, track direction, and chi^2 per degrees of freedom; warning: the errors of the track radii are only approximate reconstruction of the track using only those hits in r_segment for which the r_selection[. More...
 
bool fit (MuonCalibSegment &r_segment, HitSelection r_selection) const
 fit subset of the hits. More...
 
bool fit (MuonCalibSegment &r_segment, HitSelection r_selection, MTStraightLine &line_track) const
 the CurvedPatRec class relies on the first place on information cached in the MSStraightLine More...
 
void printLevel (int)
 
bool fitCallByReference (MuonCalibSegment &r_segment, HitSelection &r_selection, MTStraightLine &line_track) const
 
bool fitCallByReference (MuonCalibSegment &r_segment, HitSelection &r_selection) const
 
void SetRefineSegmentFlag (const bool flag)
 number of hits selected for track More...
 
bool RefineSegmentFlag () const
 get refine segment flag More...
 
void switchOnRefit ()
 switch on/off chi^2 refit after hit selection More...
 
void switchOffRefit ()
 
bool refit () const
 return refit flag More...
 

Protected Attributes

bool m_refine_segment
 flags More...
 
bool m_refit
 

Private Member Functions

void init ()
 
void init (const double &r_road_width)
 
MTStraightLine tangent (const Amg::Vector3D &r_w1, const double &r_r1, const double &r_sigma12, const Amg::Vector3D &r_w2, const double &r_r2, const double &r_sigma22, const int &r_case) const
 
MTStraightLine fitCandidate (MuonCalibSegment &r_segment, const std::vector< unsigned int > &r_selection, const MTStraightLine &cand_line) const
 

Private Attributes

bool m_fix_selection
 
double m_r_max
 
double m_road_width
 
double m_time_out
 

Detailed Description

Definition at line 24 of file StraightPatRec.h.

Member Typedef Documentation

◆ HitSelection

typedef std::vector<unsigned int> MuonCalib::IMdtSegmentFitter::HitSelection
inherited

Definition at line 32 of file IMdtSegmentFitter.h.

Constructor & Destructor Documentation

◆ StraightPatRec() [1/2]

MuonCalib::StraightPatRec::StraightPatRec ( )
inline

Default constructor: road width for pattern recognition = 0.5 mm.

Definition at line 27 of file StraightPatRec.h.

◆ StraightPatRec() [2/2]

MuonCalib::StraightPatRec::StraightPatRec ( const double &  r_road_width)
inline

Constructor: user-defined road width for pattern recognition.

Definition at line 30 of file StraightPatRec.h.

Member Function Documentation

◆ fit() [1/3]

bool StraightPatRec::fit ( MuonCalibSegment r_segment) const
virtual

reconstruction of the track using all hits in the segment "r_segment", returns true in case of success; the algorithm overwrites the track radii, the track position, track direction, and chi^2 per degrees of freedom; warning: the errors of the track radii are only approximate reconstruction of the track using only those hits in r_segment for which the r_selection[.

] is 0, return true in case of success; the algorithm overwrites the track position, direction, and the chi^2 in r_segment; it updates the distances of all hits from the track, i.e. also of those hits which were rejected from the track reconstruction; warning : the errors of the track CLHEP::radii are only approximate

Implements MuonCalib::IMdtSegmentFitter.

Definition at line 289 of file StraightPatRec.cxx.

289  {
290  // select all hits //
291  HitSelection selection(r_segment.mdtHitsOnTrack(), 0);
292 
293  // call the other fit function //
294  return fit(r_segment, selection);
295 }

◆ fit() [2/3]

bool StraightPatRec::fit ( MuonCalibSegment seg,
HitSelection  selection 
) const
virtual

fit subset of the hits.

If the HitSelection vector contains a 0 for a given hit the hit is used else the hit is not included in the fit. The size of the HitSelection vector should be equal to the number of hits on track else no fit is performed.

Implements MuonCalib::IMdtSegmentFitter.

Definition at line 296 of file StraightPatRec.cxx.

296 { return fitCallByReference(r_segment, r_selection); }

◆ fit() [3/3]

bool StraightPatRec::fit ( MuonCalibSegment r_segment,
HitSelection  r_selection,
MTStraightLine line_track 
) const

the CurvedPatRec class relies on the first place on information cached in the MSStraightLine

Definition at line 297 of file StraightPatRec.cxx.

297  {
298  return fitCallByReference(r_segment, r_selection, line_track);
299 }

◆ fitCallByReference() [1/2]

bool StraightPatRec::fitCallByReference ( MuonCalibSegment r_segment,
HitSelection r_selection 
) const

Definition at line 300 of file StraightPatRec.cxx.

300  {
301  MTStraightLine fitted_track{};
302  return fitCallByReference(r_segment, r_selection, fitted_track);
303 }

◆ fitCallByReference() [2/2]

bool StraightPatRec::fitCallByReference ( MuonCalibSegment r_segment,
HitSelection r_selection,
MTStraightLine line_track 
) const

Definition at line 304 of file StraightPatRec.cxx.

304  {
306  // VARIABLES //
308 
309  time_t start, end; // start and end time (needed for time-out)
310  time(&start);
311  double diff; // difference of start and end time (needed for time-out)
312  Combination combination;
313 
314  std::vector<unsigned int> hit_index; // hit indices for given selection
315  unsigned int try_nb_hits; // try this given number of hits for the
316  // segment reconstruction
317 
318  MuonCalibSegment::MdtHitVec selected_hits;
319  std::vector<unsigned int> selected_hits_index;
320 
321  Amg::Vector3D w_min, w_max; // wire with the minimum local z coordinate,
322  // wire with the maximum local z coordinate
323  double r_min, r_max{}; // corresponding drift CLHEP::radii
324  double sigma2_min, sigma2_max; // corresponding spatial resolution
325 
326  unsigned int counter1; // auxiliary counter
327 
328  unsigned int nb_candidates(0); // number of straight-track candidates
329 
330  MTStraightLine tangents[4]; // the four tangents to the drift circles of a
331  // hit pair
332  MTStraightLine aux_track; // auxiliary track
333  Amg::Vector3D null(0.0, 0.0, 0.0);
334  Amg::Vector3D xhat(1.0, 0.0, 0.0);
335 
336  MTStraightLine initial_track(r_segment.position(), r_segment.direction(), null, null);
337  // initial track stored in the segment
338  Amg::Vector3D aux_pos, aux_dir; // auxiliary position and direction vectors
339 
341  // RESET //
343 
344  if (r_segment.mdtHitsOnTrack() != r_selection.size()) {
345  MsgStream log(Athena::getMessageSvc(), "StraightPatRec");
346  log << MSG::WARNING
347  << "fitCallByReference() - Vector with selected hits unequal to the number of hits on the segment! The user selection will "
348  "be "
349  "ignored!"
350  << endmsg;
351  r_selection.clear();
352  r_selection.assign(r_segment.hitsOnTrack(), 0);
353  }
354 
355  // Filling selected_hits vector
356  for (unsigned int k = 0; k < r_segment.mdtHitsOnTrack(); k++) {
357  if (!r_selection[k]) {
358  selected_hits.push_back(r_segment.mdtHOT()[k]);
359  selected_hits_index.push_back(k);
360  }
361  }
362 
364  // RETURN, IF THERE ARE LESS THAN 3 HITS, I.E. THE TRACK IS NOT UNIQUELY //
365  // DEFINED BY THE HITS. //
367 
368  if (selected_hits.size() < 3) { return false; }
369 
371  // FIX POTENTIAL SECOND-COORDINATE PROBLEM OF THE INITIAL TRACK SEGMENT //
373 
374  if (r_segment.direction().z() == 0.0) {
375  Amg::Vector3D dir(r_segment.direction().x(), r_segment.direction().y(), 1.0);
376  initial_track = MTStraightLine(r_segment.position(), dir, null, null);
377  }
378 
380  // TRACK RECONSTRUCTION //
382  // try to find a segment with as many hits as selected initially //
383 
384  HitSelection final_selection(r_selection);
385 
386  try_nb_hits = selected_hits.size();
387  //=============================================================================
388  while (nb_candidates == 0) {
389  //-----------------------------------------------------------------------------
390  // Return in case of large amount of fake hits
391  if (try_nb_hits < 5 && (selected_hits.size() - try_nb_hits) > 2) return false;
392  // reset //
393  double best_chi2ndf = -1.0;
394  MTStraightLine best_aux_line(initial_track);
395 
396  // loop over all combinations //
397  combination.setNewParameters(selected_hits.size(), try_nb_hits);
398 
399  //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
400  for (unsigned int cb = 0; cb < combination.numberOfCombinations(); cb++) {
401  //.............................................................................
402 
403  // time-out //
404  time(&end);
405  diff = difftime(end, start);
406  if (diff > m_time_out) { return false; }
407 
408  // get the present hit combination //
409  if (cb == 0) {
410  combination.currentCombination(hit_index);
411  } else {
412  combination.nextCombination(hit_index);
413  }
414 
415  // Current selection of hits
416  HitSelection tmp_selection(r_selection);
417  tmp_selection.assign(tmp_selection.size(), 1);
418  for (unsigned int k = 0; k < try_nb_hits; k++) { tmp_selection[selected_hits_index[hit_index[k] - 1]] = 0; }
419 
420  // investigate the current combination //
421  // find the wires with minimum and maximum local z //
422  w_min = selected_hits[hit_index[0] - 1]->localPosition();
423  w_max = selected_hits[hit_index[0] - 1]->localPosition();
424  r_min = selected_hits[hit_index[0] - 1]->driftRadius();
425  r_max = selected_hits[hit_index[0] - 1]->driftRadius();
426  sigma2_min = selected_hits[hit_index[0] - 1]->sigma2DriftRadius();
427  sigma2_max = selected_hits[hit_index[0] - 1]->sigma2DriftRadius();
428  for (unsigned int k = 1; k < try_nb_hits; k++) {
429  if (selected_hits[hit_index[k] - 1]->localPosition().z() < w_min.z()) {
430  w_min = selected_hits[hit_index[k] - 1]->localPosition();
431  r_min = selected_hits[hit_index[k] - 1]->driftRadius();
432  sigma2_min = selected_hits[hit_index[k] - 1]->sigma2DriftRadius();
433  }
434  if (selected_hits[hit_index[k] - 1]->localPosition().z() > w_max.z()) {
435  w_max = selected_hits[hit_index[k] - 1]->localPosition();
436  r_max = selected_hits[hit_index[k] - 1]->driftRadius();
437  sigma2_max = selected_hits[hit_index[k] - 1]->sigma2DriftRadius();
438  }
439  }
440 
441  // set the spatial resolution to 0.1 CLHEP::mm if it is 0 //
442  if (sigma2_min == 0) { sigma2_min = 0.1; }
443  if (sigma2_max == 0) { sigma2_max = 0.1; }
444 
445  // get the four segment candidates tangential to the outermost hits //
446  for (unsigned int r_case = 1; r_case < 5; r_case++) {
447  tangents[r_case - 1] = tangent(w_min, r_min, sigma2_min, w_max, r_max, sigma2_max, r_case);
448  }
449 
450  // determine additional track points within the road width around //
451  // the four tangents and determine a segment //
452  for (unsigned int r_case = 1; r_case < 5; r_case++) {
453  counter1 = 0;
454  for (unsigned int n = 0; n < try_nb_hits; n++) {
455  MTStraightLine aux_line(selected_hits[hit_index[n] - 1]->localPosition(), xhat, null, null);
456  if (std::abs(std::abs(tangents[r_case - 1].signDistFrom(aux_line)) - selected_hits[hit_index[n] - 1]->driftRadius()) <=
457  m_road_width) {
458  counter1 = counter1 + 1;
459  }
460  }
461 
462  // Used to fix initial configuration of hits
463  if (m_fix_selection) counter1 = try_nb_hits;
464  // perform a straight line fit for the candidate //
465  if (counter1 == try_nb_hits) {
466  nb_candidates++;
467  aux_track = fitCandidate(r_segment, tmp_selection, tangents[r_case - 1]);
468 
469  if ((best_chi2ndf == -1) || (best_chi2ndf > r_segment.chi2())) {
470  best_chi2ndf = r_segment.chi2();
471  best_aux_line = aux_track;
472  final_selection.assign(final_selection.size(), 1);
473  for (unsigned int j = 0; j < try_nb_hits; j++) { final_selection[selected_hits_index[hit_index[j] - 1]] = 0; }
474  }
475  }
476  }
477  //.............................................................................
478  }
479  //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
480 
482  // MAKE THE FINAL STRAIGHT SEGMENT, IF POSSIBLE //
484 
485  MuonCalibSegment::MdtHitVec used_hits;
486  if (nb_candidates > 0) {
487  // store track hits, rewrite hit selection //
488  for (unsigned int k = 0; k < r_selection.size(); k++) {
489  r_selection[k] = final_selection[k];
490  if (!final_selection[k]) { used_hits.push_back(r_segment.mdtHOT()[k]); }
491  }
492 
493  // Final refit //
494  fitted_track = fitCandidate(r_segment, final_selection, best_aux_line);
495  fitted_track.setUsedHits(used_hits);
496 
497  if (m_refine_segment) { r_segment.refineMdtSelection(r_selection); }
498 
499  } else {
500  try_nb_hits = try_nb_hits - 1;
501  if (try_nb_hits < 3) { return false; }
502  }
503 
504  //-----------------------------------------------------------------------------
505  }
506  //=============================================================================
507 
508  return fitted_track.chi2() > 0;
509 }

◆ fitCandidate()

MTStraightLine StraightPatRec::fitCandidate ( MuonCalibSegment r_segment,
const std::vector< unsigned int > &  r_selection,
const MTStraightLine cand_line 
) const
private

Definition at line 154 of file StraightPatRec.cxx.

155  {
157  // VARIABLES //
159  Amg::Vector3D null(0.0, 0.0, 0.0);
160  Amg::Vector3D xhat(1.0, 0.0, 0.0);
161 
162  unsigned int num_selected_hits(0);
163  for (unsigned int k : r_selection) {
164  if (!k) { num_selected_hits++; }
165  }
166  if (num_selected_hits < 3) return cand_line;
167 
168  Amg::Vector3D init_dir(r_segment.direction());
169  Amg::Vector3D init_pos(r_segment.position());
171  // SET THE CORRECT SIGNED TRACK DISTANCES //
173 
174  r_segment.set(r_segment.chi2(), cand_line.positionVector(), cand_line.directionVector());
175 
176  for (unsigned int k = 0; k < r_segment.mdtHitsOnTrack(); k++) {
177  MTStraightLine aux_line(r_segment.mdtHOT()[k]->localPosition(), xhat, null, null);
178  r_segment.mdtHOT()[k]->setDistanceToTrack(cand_line.signDistFrom(aux_line), r_segment.mdtHOT()[k]->sigmaDriftRadius());
179  }
180 
182  // Analitical fit of linearized measurements (transformation to reference frame is used) //
184  unsigned int NLC = 2; // number of fit parameters
185 
186  // Normalization on z-direction
187  Amg::Vector3D dir_norm(r_segment.direction().x() / r_segment.direction().z(), r_segment.direction().y() / r_segment.direction().z(),
188  1.0);
189 
190  Amg::Vector3D refTransl(r_segment.position());
191  refTransl[0] = 0;
192  Amg::Vector3D refDir(dir_norm);
193  refDir[0] = 0;
194  refDir = refDir.unit();
195 
196  // Rotation Matrix for Toewr_to_track transformation
197 
198  double rotAngle = Amg::angle(Amg::Vector3D::UnitZ(), refDir) * (refDir.y()) / std::abs(refDir.y());
199  Amg::AngleAxis3D RotMatr(rotAngle, Amg::Vector3D::UnitX()); // Matrix for Track reference transformation
200  Amg::AngleAxis3D RotMatr_inv(-rotAngle, Amg::Vector3D::UnitX()); // inverse
201 
202  Amg::VectorX alpha = Amg::VectorX(NLC);
203  alpha.setZero();
204  Amg::VectorX betha = Amg::VectorX(NLC);
205  betha.setZero();
206  Amg::MatrixX Gamma = Amg::MatrixX(NLC, NLC);
207  Gamma.setZero();
208  // vector to store hit positions
209  std::vector<Amg::Vector3D> hit_position_track;
210 
211  for (unsigned int l = 0; l < r_segment.mdtHitsOnTrack(); l++) {
212  // Transformation to track reference frame
213  Amg::Vector3D WirPosLocal = r_segment.mdtHOT()[l]->localPosition();
214  Amg::Vector3D WirPosTrack = WirPosLocal - refTransl;
215  WirPosTrack = RotMatr * WirPosTrack;
216  double signedDrifRadius =
217  std::abs(r_segment.mdtHOT()[l]->driftRadius()) *
218  (r_segment.mdtHOT()[l]->signedDistanceToTrack() / std::abs(r_segment.mdtHOT()[l]->signedDistanceToTrack()));
219  Amg::Vector3D HitPosTrack = WirPosTrack;
220  HitPosTrack[0] = HitPosTrack.y() + signedDrifRadius;
221  HitPosTrack[1] = r_segment.mdtHOT()[l]->sigma2DriftRadius(); // trick to store hit resolution
222 
223  hit_position_track.push_back(HitPosTrack);
224 
225  Amg::VectorX delta = Amg::VectorX(NLC);
226  delta.setZero();
227  delta[0] = 1.0;
228  delta[1] = HitPosTrack.z();
229 
230  if (!r_selection[l]) {
231  double weight = 1.0 / (r_segment.mdtHOT()[l]->sigma2DriftRadius());
232  Gamma += weight * delta * delta.transpose();
233  betha += weight * HitPosTrack.y() * delta;
234  }
235  }
236 
237  // solution of linear system of equations
238  Gamma = Gamma.inverse();
239  alpha = Gamma * betha;
240 
241  double refit_chi2(0.0);
242  for (unsigned int j = 0; j < hit_position_track.size(); j++) {
243  double res = (alpha[0] + alpha[1] * hit_position_track[j].z() - hit_position_track[j].y());
244  if (!r_selection[j]) refit_chi2 += res * res / hit_position_track[j].x();
245  }
246 
247  // Backward transformation
248  Amg::Vector3D seg_dir(0.0, alpha[1], 1.0);
249  seg_dir = RotMatr_inv * seg_dir;
250  seg_dir[1] = seg_dir.y() / seg_dir.z();
251  seg_dir[0] = init_dir.x() / init_dir.z();
252  seg_dir[2] = 1.0;
253 
254  Amg::Vector3D seg_pos(0.0, alpha[0], 0.0);
255  seg_pos = RotMatr_inv * seg_pos;
256  seg_pos = seg_pos + refTransl;
257 
258  seg_pos[1] = seg_pos.y() + seg_dir.y() * (init_pos.z() - seg_pos.z());
259  seg_pos[0] = init_pos.x();
260  seg_pos[2] = init_pos.z();
261 
262  // Rewriting segment
263  r_segment.set(refit_chi2 / (num_selected_hits - 2), seg_pos, seg_dir);
264 
265  MTStraightLine aux_line(seg_pos, seg_dir, Amg::Vector3D(0.0, 0.0, 0.0), Amg::Vector3D(0.0, 0.0, 0.0));
266 
267  for (unsigned int k = 0; k < r_segment.mdtHitsOnTrack(); k++) {
268  MTStraightLine aux_t(r_segment.mdtHOT()[k]->localPosition(), xhat, null, null);
269  r_segment.mdtHOT()[k]->setDistanceToTrack(aux_line.signDistFrom(aux_t), r_segment.mdtHOT()[k]->sigmaDriftRadius());
270  }
271 
272  aux_line.setNumberOfTrackHits(num_selected_hits);
273  aux_line.setChi2(refit_chi2);
274  return aux_line;
275 }

◆ init() [1/2]

void StraightPatRec::init ( )
private

Definition at line 24 of file StraightPatRec.cxx.

24  {
25  init(0.5 * CLHEP::mm); // default road width = 0.5 CLHEP::mm
26  return;
27 }

◆ init() [2/2]

void StraightPatRec::init ( const double &  r_road_width)
private

Definition at line 29 of file StraightPatRec.cxx.

29  {
30  //:::::::::::::::
31  //:: VARIABLES ::
32  //:::::::::::::::
33 
34  Amg::Vector3D null_vec(0.0, 0.0, 0.0); // auxiliary 0 vector
35 
36  //::::::::::::::::::
37  //:: SET TIME-OUT ::
38  //::::::::::::::::::
39 
40  m_time_out = 10.0;
41 
42  //::::::::::::::::::::::::::::
43  //:: SET THE MAXIMUM RADIUS ::
44  //::::::::::::::::::::::::::::
45 
46  m_r_max = 15.0;
47 
48  //::::::::::::::::::::::::
49  //:: SET THE ROAD WIDTH ::
50  //::::::::::::::::::::::::
51 
52  m_road_width = r_road_width;
53 
54  //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
55  //:: INITIALIZE PRIVATE VARIABLES WHICH ARE ACCESSIBLE BY METHODS ::
56  //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
57 
58  // m_nb_track_hits = 0;
59  // m_chi2 = 0.0;
60  // m_track = MTStraightLine(null_vec, null_vec, null_vec, null_vec);
61 
62  m_fix_selection = false;
63 
64  return;
65 }

◆ printLevel()

void MuonCalib::StraightPatRec::printLevel ( int  )
inlinevirtual

Implements MuonCalib::IMdtSegmentFitter.

Definition at line 83 of file StraightPatRec.h.

83 {}

◆ RefineSegmentFlag()

bool MuonCalib::IMdtPatRecFitter::RefineSegmentFlag ( ) const
inlineinherited

get refine segment flag

Definition at line 38 of file IMdtPatRecFitter.h.

38 { return m_refine_segment; }

◆ refit()

bool MuonCalib::IMdtPatRecFitter::refit ( ) const
inlineinherited

return refit flag

Definition at line 44 of file IMdtPatRecFitter.h.

44 { return m_refit; }

◆ roadWidth()

double StraightPatRec::roadWidth ( ) const

get the final track in the local co-ordinate frame, i.e.

z ^ o o o o o o | ... o o o o o ... o--> y o o o o o o x

Definition at line 277 of file StraightPatRec.cxx.

277 { return m_road_width; }

◆ setFixSelection()

void StraightPatRec::setFixSelection ( bool  fix_sel)

Definition at line 288 of file StraightPatRec.cxx.

288 { m_fix_selection = fix_sel; }

◆ SetRefineSegmentFlag()

void MuonCalib::IMdtPatRecFitter::SetRefineSegmentFlag ( const bool  flag)
inlineinherited

number of hits selected for track

virtual unsigned int numberOfTrackHits() const = 0; get selected track hits virtual const std::vector<const MdtCalibHitBase *> &trackHits() const = 0; set refine segment flag

Parameters
flagif true the hit selection is changed in the segment

Definition at line 35 of file IMdtPatRecFitter.h.

◆ setRoadWidth()

void StraightPatRec::setRoadWidth ( const double &  r_road_width)
virtual

set the road width for the pattern recognition = r_road_width

Implements MuonCalib::IMdtPatRecFitter.

Definition at line 279 of file StraightPatRec.cxx.

279  {
280  m_road_width = std::abs(r_road_width);
281  return;
282 }

◆ setTimeOut()

void StraightPatRec::setTimeOut ( const double &  time_out)

set the time-out for the track finding to time_out (in seconds)

Definition at line 283 of file StraightPatRec.cxx.

283  {
284  m_time_out = time_out;
285  return;
286 }

◆ switchOffRefit()

void MuonCalib::IMdtPatRecFitter::switchOffRefit ( )
inlineinherited

Definition at line 42 of file IMdtPatRecFitter.h.

42 { m_refit = false; }

◆ switchOnRefit()

void MuonCalib::IMdtPatRecFitter::switchOnRefit ( )
inlineinherited

switch on/off chi^2 refit after hit selection

Definition at line 41 of file IMdtPatRecFitter.h.

41 { m_refit = true; }

◆ tangent()

MTStraightLine StraightPatRec::tangent ( const Amg::Vector3D r_w1,
const double &  r_r1,
const double &  r_sigma12,
const Amg::Vector3D r_w2,
const double &  r_r2,
const double &  r_sigma22,
const int &  r_case 
) const
private

Definition at line 67 of file StraightPatRec.cxx.

68  {
69  //:::::::::::::::
70  //:: VARIABLES ::
71  //:::::::::::::::
72 
73  double sinalpha; // auxiliary sinus of an angle
74  double cosalpha; // auxiliary sinus of an angle
75  Amg::Vector3D e2prime, e3prime; // auxiliary direction vectors
76  MTStraightLine tang; // tangent to drift circles of a hit pair
77  Amg::Vector3D p1(0.0, 0.0, 0.0), p2(0.0, 0.0, 0.0); // hit points defining a tangent
78  Amg::Vector3D null_vec(0.0, 0.0, 0.0); // auxiliary 0 vector
79  double mx1 = 0, bx1 = 0, mx2 = 0, bx2 = 0; // auxiliary track parameters
80 
81  //::::::::::::::::::::::::::::::::::::::::::::
82  //:: CHECK WHETHER THE SELECTED CASE EXISTS ::
83  //::::::::::::::::::::::::::::::::::::::::::::
84 
85  if (r_case < 1 || r_case > 4) {
86  throw std::runtime_error(
87  Form("File: %s, Line: %d\nStraightPatRec::tangent - Illegal case %i, must be 1,2,3, or 4.!", __FILE__, __LINE__, r_case));
88  }
89 
90  //:::::::::::::::::::::::::::::::::::::
91  //:: CALCULATE THE REQUESTED TANGENT ::
92  //:::::::::::::::::::::::::::::::::::::
93 
94  // local coordinate axis vectors //
95  e3prime = (r_w2 - r_w1).unit();
96  e2prime = Amg::Vector3D(0.0, e3prime.z(), -e3prime.y());
97 
98  // case 1 and 2 //
99  if (r_case == 1 || r_case == 2) {
100  sinalpha = std::abs(r_r2 - r_r1) / (r_w2 - r_w1).mag();
101  cosalpha = std::sqrt(1.0 - sinalpha * sinalpha);
102 
103  // case 1 //
104  if (r_case == 1) {
105  p1 = r_w1 + ((1 && r_r2 >= r_r1) - (1 && r_r2 < r_r1)) * r_r1 * (cosalpha * e2prime - sinalpha * e3prime);
106  p2 = r_w2 + ((1 && r_r2 >= r_r1) - (1 && r_r2 < r_r1)) * r_r2 * (cosalpha * e2prime - sinalpha * e3prime);
107  }
108 
109  // case 2 //
110  if (r_case == 2) {
111  p1 = r_w1 - ((1 && r_r2 >= r_r1) - (1 && r_r2 < r_r1)) * r_r1 * (cosalpha * e2prime + sinalpha * e3prime);
112  p2 = r_w2 - ((1 && r_r2 >= r_r1) - (1 && r_r2 < r_r1)) * r_r2 * (cosalpha * e2prime + sinalpha * e3prime);
113  }
114  }
115 
116  // case 3 and 4 //
117  if (r_case == 3 || r_case == 4) {
118  sinalpha = (r_r1 + r_r2) / (r_w2 - r_w1).mag();
119  cosalpha = std::sqrt(1.0 - sinalpha * sinalpha);
120 
121  // case 3 //
122  if (r_case == 3) {
123  p1 = r_w1 + r_r1 * (cosalpha * e2prime + sinalpha * e3prime);
124  p2 = r_w2 - r_r2 * (cosalpha * e2prime + sinalpha * e3prime);
125  }
126 
127  // case 4 //
128  if (r_case == 4) {
129  p1 = r_w1 - r_r1 * (cosalpha * e2prime - sinalpha * e3prime);
130  p2 = r_w2 + r_r2 * (cosalpha * e2prime - sinalpha * e3prime);
131  }
132  }
133 
134  // calculation of the tangent and estimation of its errors //
135  if ((p2 - p1).z() != 0.0) {
136  tang = MTStraightLine(p1, p2 - p1, null_vec, null_vec);
137  } else {
138  Amg::Vector3D direction(p2 - p1);
139  direction[2] = (1.0e-99);
140  tang = MTStraightLine(p1, direction, null_vec, null_vec);
141  }
142  mx1 = tang.a_x1();
143  bx2 = tang.b_x1();
144  mx2 = tang.a_x2();
145  bx2 = tang.b_x2();
146  tang = MTStraightLine(mx1, bx1, mx2, bx2, 1.0, 1.0, std::sqrt(r_sigma12 + r_sigma22) / std::abs(p2.z() - p1.z()),
147  std::sqrt(r_sigma12 + p1.z() * p1.z() * (r_sigma12 + r_sigma22) / std::pow(p2.z() - p1.z(), 2)));
148  // errors in mx1 and bx1 are arbitrary since they are
149  // not used at a later stage.
150 
151  return tang;
152 }

Member Data Documentation

◆ m_fix_selection

bool MuonCalib::StraightPatRec::m_fix_selection
private

Definition at line 97 of file StraightPatRec.h.

◆ m_r_max

double MuonCalib::StraightPatRec::m_r_max
private

Definition at line 100 of file StraightPatRec.h.

◆ m_refine_segment

bool MuonCalib::IMdtPatRecFitter::m_refine_segment
protectedinherited

flags

Definition at line 50 of file IMdtPatRecFitter.h.

◆ m_refit

bool MuonCalib::IMdtPatRecFitter::m_refit
protectedinherited

Definition at line 51 of file IMdtPatRecFitter.h.

◆ m_road_width

double MuonCalib::StraightPatRec::m_road_width
private

Definition at line 101 of file StraightPatRec.h.

◆ m_time_out

double MuonCalib::StraightPatRec::m_time_out
private

Definition at line 102 of file StraightPatRec.h.


The documentation for this class was generated from the following files:
MuonCalib::StraightPatRec::m_r_max
double m_r_max
Definition: StraightPatRec.h:100
MuonCalib::MuonCalibSegment::hitsOnTrack
unsigned int hitsOnTrack() const
retrieve the sum of all XxxCalibHits assigned to the MuonCalibSegment
Definition: MuonCalibSegment.cxx:136
MuonCalib::MTStraightLine::a_x1
double a_x1() const
get the slope of the straight line in the x1-x3 plane
Definition: MTStraightLine.cxx:46
Amg::VectorX
Eigen::Matrix< double, Eigen::Dynamic, 1 > VectorX
Dynamic Vector - dynamic allocation.
Definition: EventPrimitives.h:32
Amg::MatrixX
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Definition: EventPrimitives.h:29
Amg::angle
double angle(const Amg::Vector3D &v1, const Amg::Vector3D &v2)
calculates the opening angle between two vectors
Definition: GeoPrimitivesHelpers.h:41
mergePhysValFiles.start
start
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:14
conifer::pow
constexpr int pow(int x)
Definition: conifer.h:20
MuonCalib::MuonCalibSegment::MdtHitVec
std::vector< MdtHitPtr > MdtHitVec
Definition: MuonCalibSegment.h:45
MuonCalib::StraightPatRec::m_road_width
double m_road_width
Definition: StraightPatRec.h:101
MuonCalib::MTStraightLine::a_x2
double a_x2() const
get the slope of the straight line in the x2-x3 plane
Definition: MTStraightLine.cxx:65
MuonCalib::MTStraightLine::directionVector
Amg::Vector3D directionVector() const
get the direction vector of the straight line
Definition: MTStraightLine.cxx:43
MuonCalib::Combination
Definition: MuonSpectrometer/MuonCalib/MuonCalibUtils/MuonCalibMath/MuonCalibMath/Combination.h:33
mc.diff
diff
Definition: mc.SFGenPy8_MuMu_DD.py:14
MuonCalib::MuonCalibSegment::position
const Amg::Vector3D & position() const
retrieve local position of segment (on station level)
Definition: MuonCalibSegment.cxx:186
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
VP1PartSpect::Gamma
@ Gamma
Definition: VP1PartSpectFlags.h:22
MuonCalib::MTStraightLine::b_x1
double b_x1() const
get the intercept of the straight line in the x1-x3 plane
Definition: MTStraightLine.cxx:53
MuonCalib::IMdtPatRecFitter::m_refit
bool m_refit
Definition: IMdtPatRecFitter.h:51
MuonCalib::StraightPatRec::m_fix_selection
bool m_fix_selection
Definition: StraightPatRec.h:97
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
MuonCalib::StraightPatRec::fitCallByReference
bool fitCallByReference(MuonCalibSegment &r_segment, HitSelection &r_selection, MTStraightLine &line_track) const
Definition: StraightPatRec.cxx:304
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
MuonCalib::MuonCalibSegment::direction
const Amg::Vector3D & direction() const
retrieve local direction of segment (on station level) retrieve the transformation from local chamber...
Definition: MuonCalibSegment.cxx:187
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:200
z
#define z
MuonCalib::StraightPatRec::init
void init()
Definition: StraightPatRec.cxx:24
beamspotman.n
n
Definition: beamspotman.py:731
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
Trk::driftRadius
@ driftRadius
trt, straws
Definition: ParamDefs.h:59
master.flag
bool flag
Definition: master.py:29
res
std::pair< std::vector< unsigned int >, bool > res
Definition: JetGroupProductTest.cxx:14
MuonCalib::MuonCalibSegment::refineMdtSelection
void refineMdtSelection(const std::vector< unsigned int > &new_selection)
move trck hits to close hits
Definition: MuonCalibSegment.cxx:94
MuonCalib::MTStraightLine::b_x2
double b_x2() const
get the intercept of the straight line in the x2-x3 plane
Definition: MTStraightLine.cxx:74
selection
std::string selection
Definition: fbtTestBasics.cxx:73
MuonCalib::StraightPatRec::m_time_out
double m_time_out
Definition: StraightPatRec.h:102
beamspotman.dir
string dir
Definition: beamspotman.py:623
fitman.mx2
mx2
Definition: fitman.py:536
MuonCalib::MuonCalibSegment::mdtHitsOnTrack
unsigned int mdtHitsOnTrack() const
retrieve the number of MdtCalibHitBase s assigned to this segment
Definition: MuonCalibSegment.cxx:147
MuonCalib::StraightPatRec::fit
bool fit(MuonCalibSegment &r_segment) const
reconstruction of the track using all hits in the segment "r_segment", returns true in case of succes...
Definition: StraightPatRec.cxx:289
MuonCalib::MTStraightLine::signDistFrom
double signDistFrom(const MTStraightLine &h) const
get the signed distance of two lines (if both are parallel, dist>0)
Definition: MTStraightLine.cxx:89
MuonCalib::StraightPatRec::fitCandidate
MTStraightLine fitCandidate(MuonCalibSegment &r_segment, const std::vector< unsigned int > &r_selection, const MTStraightLine &cand_line) const
Definition: StraightPatRec.cxx:154
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
python.SystemOfUnits.mm
int mm
Definition: SystemOfUnits.py:83
MuonCalib::IMdtPatRecFitter::m_refine_segment
bool m_refine_segment
flags
Definition: IMdtPatRecFitter.h:50
MuonCalib::MuonCalibSegment::set
void set(double chi2, const Amg::Vector3D &pos, const Amg::Vector3D &dir)
Definition: MuonCalibSegment.cxx:129
MuonCalib::StraightPatRec::tangent
MTStraightLine tangent(const Amg::Vector3D &r_w1, const double &r_r1, const double &r_sigma12, const Amg::Vector3D &r_w2, const double &r_r2, const double &r_sigma22, const int &r_case) const
Definition: StraightPatRec.cxx:67
CaloSwCorrections.time
def time(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:242
unit
const PlainObject unit() const
This is a plugin that makes Eigen look like CLHEP & defines some convenience methods.
Definition: AmgMatrixBasePlugin.h:20
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
MuonCalib::MTStraightLine
Definition: MTStraightLine.h:16
MuonCalib::MTStraightLine::positionVector
Amg::Vector3D positionVector() const
get the position vector of the straight line
Definition: MTStraightLine.cxx:42
Amg::AngleAxis3D
Eigen::AngleAxisd AngleAxis3D
Definition: GeoPrimitives.h:45
MuonCalib::MuonCalibSegment::chi2
double chi2() const
retrieve chi2
Definition: MuonCalibSegment.cxx:183
MuonCalib::MuonCalibSegment::mdtHOT
const MdtHitVec & mdtHOT() const
retrieve the full set of MdtCalibHitBase s assigned to this segment
Definition: MuonCalibSegment.cxx:148
mag
Scalar mag() const
mag method
Definition: AmgMatrixBasePlugin.h:25
fitman.k
k
Definition: fitman.py:528
MuonCalib::IMdtSegmentFitter::HitSelection
std::vector< unsigned int > HitSelection
Definition: IMdtSegmentFitter.h:32