View Javadoc

1   /*
2    * BaseTrackerHitMC.java
3    *
4    * Created on March 24, 2006, 9:46 AM
5    *
6    * $Id: BaseTrackerHitMC.java,v 1.3 2006/03/30 18:33:13 ngraf Exp $
7    */
8   
9   package org.lcsim.event.base;
10  
11  import java.util.ArrayList;
12  import java.util.List;
13  import org.lcsim.event.MCParticle;
14  import org.lcsim.event.SimTrackerHit;
15  
16  /**
17   * A BaseTrackerHit which includes information about the Monte Carlo particles contributing to it.
18   * @author Norman Graf
19   */
20  public class BaseTrackerHitMC extends BaseTrackerHit
21  {
22      // TODO should this be a Set so we have no duplicates?
23      protected List<MCParticle> _mcparticles = new ArrayList<MCParticle>();
24      protected List<SimTrackerHit> _simHits = new ArrayList<SimTrackerHit>();
25  
26      /**
27       * fully qualified constructor
28       * @param pos the position of this hit (x,y,z) in mm
29       * @param cov the covariance matrix for the position measurement, packed as 6 elements.
30       * @param t the time for this measurement in ns
31       * @param e the energy deposit associated with this measurement, in GeV
32       * @param type the type of this measurement. not yet defined.
33       * @param mcparticle The monte carlo particle contributing to this measurement.
34       */
35      public BaseTrackerHitMC(double[] pos, double[] cov, double t, double e, int type, MCParticle mcparticle)
36      {
37          super(pos, cov, t, e, type);
38          _mcparticles.add(mcparticle);
39      }
40      
41      /**
42       * fully qualified constructor
43       * @param pos the position of this hit (x,y,z) in mm
44       * @param cov the covariance matrix for the position measurement, packed as 6 elements.
45       * @param t the time for this measurement in ns
46       * @param e the energy deposit associated with this measurement, in GeV
47       * @param type the type of this measurement. not yet defined.
48       * @param simHits The list of SimTrackerHit(s) contributing to this measurement.
49       */
50      public BaseTrackerHitMC(double[] pos, double[] cov, double t, double e, int type, List<SimTrackerHit> simHits)
51      {
52          super(pos, cov, t, e, type);
53          for(SimTrackerHit hit : simHits)
54          {
55              MCParticle mcp = hit.getMCParticle();
56              if(!_mcparticles.contains(mcp)) _mcparticles.add(mcp);
57              if(!_simHits.contains(hit)) _simHits.add(hit);
58          }
59      }
60      
61      /**
62       * Add an MCParticle which contributed to this hit.
63       * @param mcp The MCParticle to associate with this hit.
64       */
65      public void addMCParticle(MCParticle mcp)
66      {
67          if(!_mcparticles.contains(mcp)) _mcparticles.add(mcp);
68      }
69      /**
70       * The list of monte carlo particles contributing to this measurement.
71       * @return The list of monte carlo particles contributing to this measurement.
72       */
73      public List<MCParticle> mcParticles()
74      {
75          return _mcparticles;
76      }
77      
78      /**
79       * The MC tracker hits contributing to this hit.
80       * @return the list of SimTrackerHit which contribute to this hit.
81       */
82      public List<SimTrackerHit> getSimHits()
83      {
84          return _simHits;
85      }
86      
87      public String toString()
88      {
89          StringBuffer sb = new StringBuffer(super.toString());
90          sb.append(" with "+_mcparticles.size()+" MCParticle"+(_mcparticles.size()==1?"":"s")+"\n");
91          for(MCParticle mcp : _mcparticles)
92          {
93              sb.append(mcp+"\n");
94          }
95          return sb.toString();
96      }
97      
98  }