View Javadoc

1   /*
2    * ConstrainHelix.java
3    *
4    * Created on April 2, 2008, 5:00 PM
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   * @author Richard Partridge
19   * @version 1.0
20   */
21  public class ConstrainHelix {
22      private double _bfield = 0.;
23      
24      /**
25       * Creates a new instance of ConstrainHelix
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          //  Inflate chi^2 if |curvature| is too large
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          //  Inflate chi^2 if |DCA| is too large
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          //  Inflate chi^2 if |z0| is too large
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          //  Add the chi^2 penalty from the cross hits
59          for (HelicalTrackHit hit : hits) {
60              nhchisq += hit.chisq();
61          }
62          
63          //  Set the non-holenomic chi squared term in the helix
64          helix.setnhchisq(nhchisq);
65          
66          return;
67      }
68  
69      public void setBField(double bfield) {
70          _bfield = bfield;
71          return;
72      }
73  }