BOSS 6.6.4.p01
BESIII Offline Software System
Loading...
Searching...
No Matches
TMLine Class Reference

A class to represent a track in tracking. More...

#include <TMLine.h>

+ Inheritance diagram for TMLine:

Public Member Functions

 TMLine ()
 Constructor.
 
 TMLine (const AList< TMLink > &)
 Constructor.
 
virtual ~TMLine ()
 Destructor.
 
virtual unsigned objectType (void) const
 returns type.
 
void dump (const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
 dumps debug information.
 
double a (void) const
 returns coefficient a.
 
double b (void) const
 returns coefficient b.
 
double chi2 (void) const
 returns chi2.
 
double reducedChi2 (void) const
 returns reduced-chi2.
 
double distance (const TMLink &) const
 returns distance to a position of TMLink itself. (not to a wire)
 
double distance (const HepPoint3D &) const
 
int fit2 ()
 fits itself. Error was happened if return value is not zero.
 
int fit2s ()
 fits itself using single hits in a wire-layer. Error was happened if return value is not zero.
 
int fit2p ()
 fits itself using isolated hits. Error was happened if return value is not zero.
 
int fit2sp ()
 fits itself using single hits in a wire-layer. Error was happened if return value is not zero.
 
void removeChits ()
 remove extremly bad points.
 
void refine (AList< TMLink > &list, float maxSigma)
 remove bad points by chi2. Bad points are returned in a 'list'. fit() should be called before calling this function.
 
void removeSLY (AList< TMLink > &list)
 
void appendSLY (AList< TMLink > &list)
 
void appendByszdistance (AList< TMLink > &list, unsigned isl, float maxSigma)
 
void property (double a, double b, double det)
 sets circle properties.
 
- Public Member Functions inherited from TTrackBase
 TTrackBase ()
 Constructor.
 
 TTrackBase (const AList< TMLink > &links)
 Constructor.
 
virtual ~TTrackBase ()
 Destructor.
 
virtual unsigned objectType (void) const
 returns object type.
 
virtual unsigned type (void) const
 returns type. Definition is depending on an object class.
 
virtual void dump (const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
 dumps debug information.
 
const AList< TMLink > & links (unsigned mask=0) const
 returns a list of masked TMLinks assigned to this track. 'mask' will be applied if mask is not 0.
 
unsigned nLinks (unsigned mask=0) const
 returns # of masked TMLinks assigned to this track object.
 
const AList< TMLink > & cores (unsigned mask=0) const
 returns a list of masked TMLinks for fit. 'mask' will be applied if mask is not 0.
 
unsigned nCores (unsigned mask=0) const
 returns # of masked TMLinks for fit. 'mask' will be applied if mask is not 0.
 
void update (void) const
 update cache.
 
void append (TMLink &)
 appends a TMLink.
 
void append (const AList< TMLink > &)
 appends TMLinks.
 
void appendByApproach (AList< TMLink > &list, double maxSigma)
 appends TMLinks by approach. 'list' is an input. Unappended TMLinks will be removed from 'list' when returned.
 
void appendByDistance (AList< TMLink > &list, double maxDistance)
 appends TMLinks by distance. 'list' is an input. Unappended TMLinks will be removed from 'list' when returned.
 
void remove (TMLink &a)
 removes a TMLink.
 
void remove (const AList< TMLink > &)
 removes TMLinks.
 
virtual void refine (AList< TMLink > &list, double maxSigma)
 removes bad points by pull. The bad points are removed from the track, and are returned in 'list'.
 
virtual void refine (double maxSigma)
 removes bad points by pull. The bad points are masked not to be used in fit.
 
virtual int DropWorst ()
 
virtual void removeLinks (void)
 
virtual double distance (const TMLink &) const
 returns distance to a position of TMLink in TMLink space.
 
virtual int approach (TMLink &) const
 calculates the closest approach to a wire in real space. Results are stored in TMLink. Return value is negative if error happened.
 
unsigned testByApproach (const TMLink &list, double sigma) const
 returns # of good hits to be appended.
 
unsigned testByApproach (const AList< TMLink > &list, double sigma) const
 
virtual int fit (void)
 fits itself by a default fitter. Error was happened if return value is not zero.
 
const TMFitter *const fitter (void) const
 returns a pointer to a default fitter.
 
const TMFitter *const fitter (const TMFitter *)
 sets a default fitter.
 
void falseFit ()
 false Fit
 
TMLinkoperator[] (unsigned i) const
 
const TTrackHEP *const hep (void) const
 returns TTrackHEP.
 
unsigned nHeps (void) const
 returns # of contributed TTrackHEP tracks.
 
const TTrackMC *const mc (void) const
 returns a pointer to TTrackMC.
 
bool fitted (void) const
 returns true if fitted.
 
bool fittedWithCathode (void) const
 returns true if fitted with cathode hits(TEMPORARY).
 

Additional Inherited Members

- Protected Attributes inherited from TTrackBase
AList< TMLink_links
 
bool _fitted
 
bool _fittedWithCathode
 
TTrackMC_mc
 

Detailed Description

A class to represent a track in tracking.

Definition at line 40 of file TMLine.h.

Constructor & Destructor Documentation

◆ TMLine() [1/2]

TMLine::TMLine ( )

Constructor.

Definition at line 23 of file TMLine.cxx.

24: TTrackBase(),
25 _a(0.),
26 _b(0.),
27 _det(0.),
28 _fittedUpdated(false),
29 _chi2(0.),
30 _reducedChi2(0.) {
31
32 //...Set a defualt fitter...
33 fitter(& TMLine::_fitter);
34}
const TMFitter *const fitter(void) const
returns a pointer to a default fitter.
Definition: TTrackBase.h:255
TTrackBase()
Constructor.
Definition: TTrackBase.cxx:40

◆ TMLine() [2/2]

TMLine::TMLine ( const AList< TMLink > &  a)

Constructor.

Definition at line 36 of file TMLine.cxx.

37: TTrackBase(a),
38 _a(0.),
39 _b(0.),
40 _det(0.),
41 _fittedUpdated(false),
42 _chi2(0.),
43 _reducedChi2(0.) {
44
45 //...Set a defualt fitter...
46 fitter(& TMLine::_fitter);
47}
double a(void) const
returns coefficient a.
Definition: TMLine.h:147

◆ ~TMLine()

TMLine::~TMLine ( )
virtual

Destructor.

Definition at line 49 of file TMLine.cxx.

49 {
50}

Member Function Documentation

◆ a()

double TMLine::a ( void  ) const
inline

returns coefficient a.

Definition at line 147 of file TMLine.h.

147 {
148#ifdef TRKRECO_DEBUG
149 if (! _fitted) std::cout << "TMLine::a !!! fit not performed" << std::endl;
150#endif
151 return _a;
152}
bool _fitted
Definition: TTrackBase.h:162

Referenced by TBuilder::build(), TBuilder::buildStereo(), TBuilderCurl::buildStereo(), and property().

◆ appendByszdistance()

void TMLine::appendByszdistance ( AList< TMLink > &  list,
unsigned  isl,
float  maxSigma 
)

Definition at line 568 of file TMLine.cxx.

568 {
569
570 //... intialize
571 unsigned nb = _links.length();
572
573 //....Select good hit
574 unsigned n = list.length();
575 for (unsigned i = 0; i < n; i++) {
576 TMLink & l = * list[i];
577 if(l.hit()->wire()->superLayerId() == isl){
578 double dist = distance(l);
579 if (dist < maxSigma) {
580 _links.append(l);
581 }
582 }
583 }
584
585 unsigned na = _links.length();
586 if(nb != na){
587 AList<TMLink> bad;
588 //... remove duplicated hits
589 for(unsigned i = 0; i<na ;i++){
590 TMLink & l = * _links[i];
591 if(i < na - 1) {
592 TMLink & lnext = * _links[i+1];
593 if(l.hit()->wire()->layerId() == lnext.hit()->wire()->layerId() ){
594 if(l.hit()->wire()->localId() == lnext.hit()->wire()->localId()){
595 bad.append(l);
596 }
597 }
598 }
599 }
600 if(bad.length() > 0) _links.remove(bad);
601 _fitted = false;
602 _fittedUpdated = false;
603 }
604}
const Int_t n
const TMDCWire *const wire(void) const
returns a pointer to a TMDCWire.
Definition: TMDCWireHit.h:218
unsigned localId(void) const
returns local id in a wire layer.
Definition: TMDCWire.h:213
unsigned layerId(void) const
returns layer id.
Definition: TMDCWire.h:219
unsigned superLayerId(void) const
returns super layer id.
Definition: TMDCWire.h:225
double distance(const TMLink &) const
returns distance to a position of TMLink itself. (not to a wire)
Definition: TMLine.h:165
AList< TMLink > _links
Definition: TTrackBase.h:161

◆ appendSLY()

void TMLine::appendSLY ( AList< TMLink > &  list)

Definition at line 561 of file TMLine.cxx.

561 {
562 _links.append(list);
563 _fitted = false;
564 _fittedUpdated = false;
565}

◆ b()

double TMLine::b ( void  ) const
inline

returns coefficient b.

Definition at line 156 of file TMLine.h.

156 {
157#ifdef TRKRECO_DEBUG
158 if (! _fitted) std::cout << "TMLine::b !!! fit not performed" << std::endl;
159#endif
160 return _b;
161}

Referenced by TBuilder::build(), TBuilder::buildStereo(), TBuilderCurl::buildStereo(), and property().

◆ chi2()

double TMLine::chi2 ( void  ) const

returns chi2.

Definition at line 113 of file TMLine.cxx.

113 {
114#ifdef TRKRECO_DEBUG
115 if (! _fitted)
116 std::cout << "TMLine::chi2 !!! fit not performed" << std::endl;
117#endif
118
119 if (_fittedUpdated) return _chi2;
120 _chi2 = 0.;
121 unsigned n = _links.length();
122 for (unsigned i = 0; i < n; i++) {
123 TMLink & l = * _links[i];
124
125 double x = l.position().x();
126 double y = l.position().y();
127 double c = y - _a * x - _b;
128 _chi2 += c * c;
129 }
130 _fittedUpdated = true;
131 return _chi2;
132}
Double_t x[10]

Referenced by reducedChi2().

◆ distance() [1/2]

double TMLine::distance ( const HepPoint3D p) const
inline

Definition at line 176 of file TMLine.h.

176 {
177#ifdef TRKRECO_DEBUG
178 if (! _fitted) std::cout << "TMLine::distance !!! fit not performed" << std::endl;
179#endif
180 double dy = fabs(_a * p.x() + _b - p.y());
181 double invCos = sqrt(1. + _a * _a);
182 return dy / invCos;
183}

◆ distance() [2/2]

double TMLine::distance ( const TMLink l) const
inlinevirtual

returns distance to a position of TMLink itself. (not to a wire)

Reimplemented from TTrackBase.

Definition at line 165 of file TMLine.h.

165 {
166#ifdef TRKRECO_DEBUG
167 if (! _fitted) std::cout << "TMLine::distance !!! fit not performed" << std::endl;
168#endif
169 double dy = fabs(_a * l.position().x() + _b - l.position().y());
170 double invCos = sqrt(1. + _a * _a);
171 return dy / invCos;
172}

Referenced by appendByszdistance(), TBuilder::buildStereo(), refine(), TBuilder::removeFarSegment(), TBuilder::searchLine(), and TBuilder::selectStereoSegment().

◆ dump()

void TMLine::dump ( const std::string &  message = std::string(""),
const std::string &  prefix = std::string("") 
) const
virtual

dumps debug information.

Reimplemented from TTrackBase.

Definition at line 53 of file TMLine.cxx.

53 {
54 bool def = false;
55 if (msg == "") def = true;
56
57 if (def || msg.find("line") != std::string::npos || msg.find("detail") != std::string::npos) {
58 std::cout << pre;
59 std::cout << "#links=" << _links.length();
60 std::cout << ",a=" << _a;
61 std::cout << ",b=" << _b;
62 std::cout << ",det=" << _det;
63 std::cout << std::endl;
64 }
65 if (! def) TTrackBase::dump(msg, pre);
66}
virtual void dump(const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
dumps debug information.
Definition: TTrackBase.cxx:58

◆ fit2()

int TMLine::fit2 ( )

fits itself. Error was happened if return value is not zero.

fits itself using isolated hits. Error was happened if return value is not zero.

Definition at line 174 of file TMLine.cxx.

174 {
175 std::cout<<" "<<__FILE__<<" "<<__LINE__<<" ERROR : nsl"<<std::endl;
176 // if (_fitted) return 0;
177
178 unsigned n = _links.length();
179 int mask[100] = {0};
180 int nsl[11] = {64,80,96,128,144,160,192,208,240,256,288};
181 int npos = 0, nneg = 0;
182 for (unsigned i = 0; i < n -1 ; i++) {
183 TMLink & l = * _links[i];
184 for (unsigned j = i+1; j < n ; j++) {
185 TMLink & s = * _links[j];
186 if(l.hit()->wire()->layerId() == s.hit()->wire()->layerId()){
187 //... Check 3 consective hits
188 if(i > 0 && (mask[i-1] == 1 && mask[j] == 1) ){
189 TMLink & t = * _links[i-1];
190 if(l.hit()->wire()->layerId() == t.hit()->wire()->layerId()){
191 mask[i] = 1;
192 }
193 }
194 int ilast = nsl[l.hit()->wire()->superLayerId()]-1;
195 int ilocal = l.hit()->wire()->localId();
196 int jlocal = s.hit()->wire()->localId();
197 if(ilocal > 0 && ilocal < ilast){
198 if(abs(jlocal-ilocal) > 1 ) {
199 mask[i] = 1;
200 mask[j] = 1;
201 }
202 }else if(ilocal == 0){
203 if(jlocal > 1 && jlocal < ilast){
204 mask[i] = 1;
205 mask[j] = 1;
206 }
207 }else if(ilocal == ilast){
208 if(jlocal > 0 && jlocal < ilast-1){
209 mask[i] = 1;
210 mask[j] = 1;
211 }
212 }
213 }
214 }
215 //...
216 if(mask[i] == 0){
217 if(l.position().y() >= 0) npos += 1;
218 if(l.position().y() < 0) nneg += 1;
219 }
220 }
221
222 //....
223 double sumX = 0., sumY = 0., sumX2 = 0., sumXY = 0., sumY2 = 0.;
224 int nused = 0;
225 int lyid[2];
226 for (unsigned i = 0; i < n; i++) {
227
228 if(mask[i] == 1) continue;
229
230 TMLink & l = * _links[i];
231
232 double x = l.position().x();
233 double y = l.position().y();
234 if(abs(npos-nneg) > 3){
235 if(npos > nneg && y < 0 ) continue;
236 if(npos < nneg && y > 0 ) continue;
237 }
238 sumX += x;
239 sumY += y;
240 sumX2 += x * x;
241 sumXY += x * y;
242 sumY2 += y * y;
243 if(nused < 2){
244 lyid[nused] = l.hit()->wire()->layerId();
245 }
246 nused += 1;
247 }
248
249 if(nused < 2 || (nused == 2 && lyid[0]==lyid[1])) {
250 return -2;
251 }
252 double sum = double(nused);
253 _det = sum * sumX2 - sumX * sumX;
254 if(_det == 0.) {
255 return -1;
256 }
257 _a = (sumXY * sum - sumX * sumY) / _det;
258 _b = (sumX2 * sumY - sumX * sumXY) / _det;
259
260 _fitted = true;
261 return 0;
262}
double abs(const EvtComplex &c)
Definition: EvtComplex.hh:212
XmlRpcServer s
Definition: HelloServer.cpp:11
int t()
Definition: t.c:1

◆ fit2p()

int TMLine::fit2p ( )

fits itself using isolated hits. Error was happened if return value is not zero.

Definition at line 403 of file TMLine.cxx.

403 {
404 // if (_fitted) return 0;
405
406 std::cout<<" "<<__FILE__<<" "<<__LINE__<<" ERROR : nsl"<<std::endl;
407 unsigned n = _links.length();
408 int mask[100] = {0};
409 int nsl[11] = {64,80,96,128,144,160,192,208,240,256,288};
410 double phi_ave = 0.;
411 int nphi = 0;
412 double Crad = 180./3.141592;
413 for (unsigned i = 0; i < n -1 ; i++) {
414 TMLink & l = * _links[i];
415 for (unsigned j = i+1; j < n ; j++) {
416 TMLink & s = * _links[j];
417 if(l.hit()->wire()->layerId() == s.hit()->wire()->layerId()){
418 //... Check 3 consective hits
419 if(i > 0 && (mask[i-1] == 1 && mask[j] == 1) ){
420 TMLink & t = * _links[i-1];
421 if(l.hit()->wire()->layerId() == t.hit()->wire()->layerId()){
422 mask[i] = 1;
423 }
424 }
425 int ilast = nsl[l.hit()->wire()->superLayerId()]-1;
426 int ilocal = l.hit()->wire()->localId();
427 int jlocal = s.hit()->wire()->localId();
428 if(ilocal > 0 && ilocal < ilast){
429 if(abs(jlocal-ilocal) > 1 ) {
430 mask[i] = 1;
431 mask[j] = 1;
432 }
433 }else if(ilocal == 0){
434 if(jlocal > 1 && jlocal < ilast){
435 mask[i] = 1;
436 mask[j] = 1;
437 }
438 }else if(ilocal == ilast){
439 if(jlocal > 0 && jlocal < ilast-1){
440 mask[i] = 1;
441 mask[j] = 1;
442 }
443 }
444 }
445 }
446 //...
447 //...
448 if(mask[i] != 1){
449 double phi = Crad*atan2(l.position().y(), l.position().x());
450 phi_ave += phi;
451 nphi += 1;
452 }
453 }
454
455 //...
456 if(mask[n-1] != 1){
457 TMLink & l = * _links[n-1];
458 double phi = Crad*atan2(l.position().y(), l.position().x());
459 phi_ave += phi;
460 nphi += 1;
461 }
462 double phi_max = 0.;
463 double phi_min = 0.;
464 if(nphi> 0){
465 phi_max = phi_ave/n + 40;
466 phi_min = phi_ave/n - 40;
467 }
468
469 //....
470 double sumX = 0., sumY = 0., sumX2 = 0., sumXY = 0., sumY2 = 0.;
471 int nused = 0;
472 int lyid[2];
473 for (unsigned i = 0; i < n; i++) {
474
475 if(mask[i] == 1) continue;
476
477 TMLink & l = * _links[i];
478
479 double x = l.position().x();
480 double y = l.position().y();
481 double phi = Crad*atan2(l.position().y(), l.position().x());
482 if(phi > phi_max && phi<phi_min ) continue;
483
484 sumX += x;
485 sumY += y;
486 sumX2 += x * x;
487 sumXY += x * y;
488 sumY2 += y * y;
489 if(nused < 2){
490 lyid[nused] = l.hit()->wire()->layerId();
491 }
492 nused += 1;
493 }
494
495 if(nused < 2 || (nused == 2 && lyid[0]==lyid[1])) {
496 return -2;
497 }
498 double sum = double(nused);
499 _det = sum * sumX2 - sumX * sumX;
500 if(_det == 0.) {
501 return -1;
502 }
503 _a = (sumXY * sum - sumX * sumY) / _det;
504 _b = (sumX2 * sumY - sumX * sumXY) / _det;
505
506 _fitted = true;
507 return 0;
508}

◆ fit2s()

int TMLine::fit2s ( )

fits itself using single hits in a wire-layer. Error was happened if return value is not zero.

Definition at line 265 of file TMLine.cxx.

265 {
266 // if (_fitted) return 0;
267
268 unsigned n = _links.length();
269 int mask[100] = {0};
270 int npos = 0, nneg = 0;
271 for (unsigned i = 0; i < n -1 ; i++) {
272 TMLink & l = * _links[i];
273 for (unsigned j = i+1; j < n ; j++) {
274 TMLink & s = * _links[j];
275 if(l.hit()->wire()->layerId() == s.hit()->wire()->layerId()){
276 mask[i] = 1;
277 mask[j] = 1;
278 }
279 }
280 //...
281 if(mask[i] == 0){
282 if(l.position().y() >= 0) npos += 1;
283 if(l.position().y() < 0) nneg += 1;
284 }
285 }
286
287 //....
288 double sumX = 0., sumY = 0., sumX2 = 0., sumXY = 0., sumY2 = 0.;
289 int nused = 0;
290 int lyid[2];
291 for (unsigned i = 0; i < n; i++) {
292
293 if(mask[i] == 1) continue;
294
295 TMLink & l = * _links[i];
296
297 double x = l.position().x();
298 double y = l.position().y();
299 if(npos > nneg && y < 0 ) continue;
300 if(npos < nneg && y > 0 ) continue;
301
302 sumX += x;
303 sumY += y;
304 sumX2 += x * x;
305 sumXY += x * y;
306 sumY2 += y * y;
307 nused += 1;
308 }
309
310 if(nused < 4) {
311 return -2;
312 }
313 double sum = double(nused);
314 _det = sum * sumX2 - sumX * sumX;
315 if(_det == 0.) {
316 return -1;
317 }
318 _a = (sumXY * sum - sumX * sumY) / _det;
319 _b = (sumX2 * sumY - sumX * sumXY) / _det;
320
321 _fitted = true;
322 return 0;
323}

◆ fit2sp()

int TMLine::fit2sp ( )

fits itself using single hits in a wire-layer. Error was happened if return value is not zero.

Definition at line 325 of file TMLine.cxx.

325 {
326 // if (_fitted) return 0;
327
328 unsigned n = _links.length();
329 int mask[100] = {0};
330 double phi_ave = 0.;
331 int nphi = 0;
332 double Crad = 180./3.141592;
333 for (unsigned i = 0; i < n -1 ; i++) {
334 TMLink & l = * _links[i];
335 for (unsigned j = i+1; j < n ; j++) {
336 TMLink & s = * _links[j];
337 if(l.hit()->wire()->layerId() == s.hit()->wire()->layerId()){
338 mask[i] = 1;
339 mask[j] = 1;
340 }
341 }
342 //...
343 if(mask[i] != 1){
344 double phi = Crad*atan2(l.position().y(), l.position().x());
345 phi_ave += phi;
346 nphi += 1;
347 }
348 }
349
350 //...
351 if(mask[n-1] != 1){
352 TMLink & l = * _links[n-1];
353 double phi = Crad*atan2(l.position().y(), l.position().x());
354 phi_ave += phi;
355 nphi += 1;
356 }
357 double phi_max = 0.;
358 double phi_min = 0.;
359 if(nphi> 0){
360 phi_max = phi_ave/n + 40;
361 phi_min = phi_ave/n - 40;
362 }
363
364 //....
365 double sumX = 0., sumY = 0., sumX2 = 0., sumXY = 0., sumY2 = 0.;
366 int nused = 0;
367 int lyid[2];
368 for (unsigned i = 0; i < n; i++) {
369
370 if(mask[i] == 1) continue;
371
372 TMLink & l = * _links[i];
373
374 double x = l.position().x();
375 double y = l.position().y();
376 double phi = Crad*atan2(l.position().y(), l.position().x());
377 if(phi > phi_max && phi<phi_min ) continue;
378
379 sumX += x;
380 sumY += y;
381 sumX2 += x * x;
382 sumXY += x * y;
383 sumY2 += y * y;
384 nused += 1;
385 }
386
387 if(nused < 4) {
388 return -2;
389 }
390 double sum = double(nused);
391 _det = sum * sumX2 - sumX * sumX;
392 if(_det == 0.) {
393 return -1;
394 }
395 _a = (sumXY * sum - sumX * sumY) / _det;
396 _b = (sumX2 * sumY - sumX * sumXY) / _det;
397
398 _fitted = true;
399 return 0;
400}

◆ objectType()

unsigned TMLine::objectType ( void  ) const
inlinevirtual

returns type.

Reimplemented from TTrackBase.

Definition at line 195 of file TMLine.h.

195 {
196 return Line;
197}
#define Line
Definition: TTrackBase.h:29

◆ property()

void TMLine::property ( double  a,
double  b,
double  det 
)
inline

sets circle properties.

Definition at line 187 of file TMLine.h.

187 {
188 _a = a;
189 _b = b;
190 _det = det;
191}
double b(void) const
returns coefficient b.
Definition: TMLine.h:156

◆ reducedChi2()

double TMLine::reducedChi2 ( void  ) const

returns reduced-chi2.

Definition at line 607 of file TMLine.cxx.

607 {
608#ifdef TRKRECO_DEBUG
609 if (! _fitted)
610 std::cout << "TMLine::reducedChi2 !!! fit not performed" << std::endl;
611#endif
612
613 if (_fittedUpdated) return _reducedChi2;
614 double chi2 = 0.;
615 double scale = 20.;
616 unsigned n = _links.length();
617 for (unsigned i = 0; i < n; i++) {
618 TMLink & l = * _links[i];
619
620 double x = l.position().x();
621 double y = l.position().y();
622 double c = y - _a * x - _b;
623 double err = 1.;
624 if (l.hit()) err = scale * l.hit()->dDrift();
625 chi2 += c * c / err / err;
626 }
627
628 _reducedChi2 = chi2/(n-2);
629 _fittedUpdated = true;
630 return _reducedChi2;
631}
float dDrift(unsigned) const
returns drift distance error.
Definition: TMDCWireHit.h:243
double chi2(void) const
returns chi2.
Definition: TMLine.cxx:113

◆ refine()

void TMLine::refine ( AList< TMLink > &  list,
float  maxSigma 
)

remove bad points by chi2. Bad points are returned in a 'list'. fit() should be called before calling this function.

Definition at line 135 of file TMLine.cxx.

135 {
136 AList<TMLink> bad;
137 unsigned n = _links.length();
138 for (unsigned i = 0; i < n; i++) {
139 TMLink & l = * _links[i];
140 double dist = distance(l);
141 if (dist > maxSigma) bad.append(l);
142 }
143
144#ifdef TRKRECO_DEBUG_DETAIL
145 std::cout << " TMLine::refine ... rejected hits:max distance=" << maxSigma;
146 std::cout << std::endl;
147 bad.sort(SortByWireId);
148 for (unsigned i = 0; i < bad.length(); i++) {
149 TMLink & l = * _links[i];
150 std::cout << " ";
151 std::cout << l.wire()->layerId() << "-";
152 std::cout << l.wire()->localId();
153 std::cout << "(";
154 if (l.hit()->mc()) {
155 if (l.hit()->mc()->hep()) std::cout << l.hit()->mc()->hep()->id();
156 else std::cout << "0";
157 }
158 std::cout << "),";
159 std::cout << l.position() << "," << distance(l);
160 if (distance(l) > maxSigma) std::cout << " X";
161 std::cout << std::endl;
162 }
163#endif
164
165 if (bad.length()) {
166 _links.remove(bad);
167 list.append(bad);
168 _fitted = false;
169 _fittedUpdated = false;
170 }
171}
const TTrackHEP *const hep(void) const
returns a pointer to a GEN_HEPEVT.
const TMDCWireHitMC *const mc(void) const
returns a pointer to TMDCWireHitMC.
Definition: TMDCWireHit.h:298
unsigned id(void) const
returns an id started from 0.
Definition: TTrackHEP.h:122

◆ removeChits()

void TMLine::removeChits ( )

remove extremly bad points.

Definition at line 511 of file TMLine.cxx.

511 {
512
513 unsigned n = _links.length();
514 int nlyr[50] = {0};
515 int nneg = 0, npos = 0;
516 for (unsigned i = 0; i < n -1 ; i++) {
517 TMLink & l = * _links[i];
518 nlyr[l.hit()->wire()->layerId()] += 1;
519 if(l.position().y() < 0.){
520 nneg += 1;
521 }else {
522 npos += 1;
523 }
524 }
525
526 //...
527 AList<TMLink> bad;
528 for (unsigned i = 0; i < n; i++) {
529
530 TMLink & l = * _links[i];
531
532 //...if # of hits in a wire layer, don't use...
533 if (nlyr[l.hit()->wire()->layerId()] > 3) {
534 bad.append(l);
535 continue;
536 }
537 //...remove extremely bad poinits
538 if(abs(nneg - npos) > 3) {
539 if(npos > nneg && l.position().y() < 0 ) bad.append(l);
540 if(npos < nneg && l.position().y() > 0 ) bad.append(l);
541 }
542 }
543 //...
544 if (bad.length() > 0 && bad.length() < n) {
545 _links.remove(bad);
546 }
547
548 //... For the next fit
549 _fitted = false;
550 _fittedUpdated = false;
551}

◆ removeSLY()

void TMLine::removeSLY ( AList< TMLink > &  list)

Definition at line 554 of file TMLine.cxx.

554 {
555 _links.remove(list);
556 _fitted = false;
557 _fittedUpdated = false;
558}

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