1
2
3
4
5
6
7
8 package org.lcsim.recon.tracking.seedtracker;
9
10 import java.util.List;
11
12 import org.lcsim.constants.Constants;
13 import org.lcsim.fit.helicaltrack.HelicalTrackFit;
14 import org.lcsim.fit.helicaltrack.HelicalTrackHit;
15
16
17
18
19
20
21 public class ConstrainHelix {
22 private double _bfield = 0.;
23
24
25
26
27 public ConstrainHelix() {
28 }
29
30 public void setConstraintChisq(SeedStrategy strategy, HelicalTrackFit helix, List<HelicalTrackHit> hits) {
31
32 if (_bfield == 0.) throw new RuntimeException("B Field must be set before calling setConstraintChisq method");
33
34 double nhchisq = 0.;
35
36
37 double curvmax = Constants.fieldConversion * _bfield / strategy.getMinPT();
38 double curv = Math.abs(helix.curvature());
39 double dcurv = helix.covariance().diagonal(HelicalTrackFit.curvatureIndex);
40 if (curv > curvmax) nhchisq += Math.pow(curv - curvmax, 2) / Math.abs(dcurv);
41
42
43 double dcamax = strategy.getMaxDCA();
44 double dca = Math.abs(helix.dca());
45 double ddca = helix.covariance().diagonal(HelicalTrackFit.dcaIndex);
46 if (dca > dcamax) {
47 nhchisq += Math.pow(dca - dcamax, 2) / Math.abs(ddca);
48 }
49
50
51 double z0max = strategy.getMaxZ0();
52 double z0 = Math.abs(helix.z0());
53 double dz0 = helix.covariance().diagonal(HelicalTrackFit.z0Index);
54 if (z0 > z0max) {
55 nhchisq += Math.pow(z0 - z0max, 2) / Math.abs(dz0);
56 }
57
58
59 for (HelicalTrackHit hit : hits) {
60 nhchisq += hit.chisq();
61 }
62
63
64 helix.setnhchisq(nhchisq);
65
66 return;
67 }
68
69 public void setBField(double bfield) {
70 _bfield = bfield;
71 return;
72 }
73 }