View Javadoc

1   package org.lcsim.recon.tracking.trfbase;
2   
3   import java.util.List;
4   import java.util.ArrayList;
5   import java.util.Iterator;
6   
7   /** The class McCluster provides a simple implementation of the list
8    * of MC track ID's for a cluster.  The list is provided in the
9    * constructor and is held directly.
10   *
11   * This class is abstract due to pure virtual methods in its base.
12   *
13   *@author Norman A. Graf
14   *@version 1.0
15   *
16   */
17  
18  
19  public abstract class McCluster extends Cluster
20  {
21      
22      // data
23      
24      // List of associated Monte Carlo track ID's.
25      private int[] _mcids;
26      
27      // methods
28      
29      //
30      
31      /**
32       *Default constructor.
33       *
34       */
35      public McCluster()
36      {
37          _mcids = new int[0];
38      }
39      
40      //
41      
42      /**
43       *Constructor from a single mc id
44       *
45       * @param   mcid  MC track ID to associate with this Cluster
46       */
47      public McCluster( int mcid )
48      {
49          _mcids = new int[1];
50          _mcids[0] = mcid;
51      }
52      
53      //
54      
55      /**
56       *Constructor from an array of mc ids
57       *
58       * @param   mcids  array of MC tracks ID's  to associate with this Cluster
59       */
60      public McCluster( int[] mcids)
61      {
62          _mcids = new int[mcids.length];
63          System.arraycopy(mcids,0, _mcids, 0, mcids.length);
64      }
65      
66      //
67      
68      /**
69       *Constructor from a List of mc ids
70       *
71       * @param   mcids List of MC tracks ID's  to associate with this Cluster
72       */
73      public McCluster( List mcids)
74      {
75          _mcids = new int[mcids.size()];
76          int i = 0;
77          for(Iterator it = mcids.iterator(); it.hasNext(); )
78          {
79              _mcids[i++] = ((Integer) it.next()).intValue();
80          }
81      }
82      
83      //
84      
85      /**
86       *Copy constructor.
87       *
88       * @param   mcclus McCluster to replicate
89       */
90      public McCluster( McCluster mcclus)
91      {
92          _mcids = mcclus._mcids;
93      }
94      
95      //
96      
97      /**
98       *Return the ID's of MC tracks contributing to this cluster.
99       *
100      * @return   List of MC track ID's for this cluster
101      */
102     public List mcIds()
103     {
104         List list = new ArrayList();
105         for(int i = 0; i<_mcids.length; ++i)
106         {
107             list.add(new Integer(_mcids[i]));
108         }
109         return list;
110     }
111     
112     
113     /**
114      *Return the ID's of MC tracks contributing to this cluster.
115      *
116      * @return  array of MC track ID's for this cluster
117      */
118     public int[] mcIdArray()
119     {
120         int[] tmp = new int[_mcids.length];
121         System.arraycopy(_mcids, 0, tmp, 0, _mcids.length);
122         return tmp;
123         
124     }
125     
126 }
127