1 package org.lcsim.recon.cat;
2
3 import java.util.*;
4
5 import org.lcsim.event.*;
6 import org.lcsim.util.Driver;
7
8 import org.lcsim.recon.cat.util.NoSuchParameterException;
9
10
11
12
13
14
15
16 public class AssociatedHitRemover extends Driver {
17
18
19
20 public AssociatedHitRemover() {}
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36 public void set(String name, Object value) throws NoSuchParameterException {
37 if (name.equalsIgnoreCase("Track_List")) {
38 _trackListName = (String)value;
39 } else if (name.equalsIgnoreCase("Input_Tracker_Hit_List")) {
40 _inputTrackerHitListName = (String)value;
41 } else if (name.equalsIgnoreCase("Output_Tracker_Hit_List")) {
42 _outputTrackerHitListName = (String)value;
43 } else {
44 throw new NoSuchParameterException(name, this.getClass());
45 }
46 }
47
48
49
50
51
52
53
54 public void process(EventHeader event) {
55
56 _event = event;
57
58
59
60 _inputTrackerHitList = _event.get(TrackerHit.class, _inputTrackerHitListName);
61 _trackList = _event.get(Track.class, _trackListName);
62
63
64
65 ArrayList<TrackerHit> associatedTrackerHitList = new ArrayList<TrackerHit>();
66 for (Track track : _trackList) {
67 associatedTrackerHitList.addAll(track.getTrackerHits());
68 }
69
70
71
72 ArrayList _outputTrackerHitList = new ArrayList<TrackerHit>();
73 for (TrackerHit hit : _inputTrackerHitList) {
74 for (TrackerHit assHit : associatedTrackerHitList) {
75 hit = match(hit, assHit);
76 if (hit == null) break;
77 }
78 if (hit != null) _outputTrackerHitList.add(hit);
79 }
80 _outputTrackerHitList.trimToSize();
81
82
83
84 _event.put(_outputTrackerHitListName, _outputTrackerHitList, TrackerHit.class, 0);
85
86 return;
87
88 }
89
90
91
92
93
94
95
96
97 protected TrackerHit match(TrackerHit hit, TrackerHit refHit) {
98 return (hit == refHit) ? null : hit ;
99 }
100
101
102
103
104
105
106 protected EventHeader _event;
107
108 protected String _inputTrackerHitListName;
109 protected String _trackListName;
110 protected String _outputTrackerHitListName;
111
112 protected List<TrackerHit> _inputTrackerHitList;
113 protected List<Track> _trackList;
114 protected ArrayList<TrackerHit> _outputTrackerHitList;
115
116 }