1
2
3
4
5
6
7
8
9 package org.lcsim.cal.calib;
10
11 import java.util.ArrayList;
12 import java.util.HashMap;
13 import java.util.List;
14 import java.util.Map;
15 import org.lcsim.conditions.ConditionsManager;
16 import org.lcsim.conditions.ConditionsManager.ConditionsSetNotFoundException;
17 import org.lcsim.conditions.ConditionsSet;
18 import org.lcsim.event.CalorimeterHit;
19 import org.lcsim.event.EventHeader;
20 import org.lcsim.event.base.BaseCalorimeterHit;
21 import org.lcsim.util.Driver;
22
23
24
25
26
27 public class ProcessHitsDriver extends Driver
28 {
29 private ConditionsSet _cond;
30 private boolean _initialized;
31
32 private String[] _hitCollectionNames;
33 private List<String> _emCalNames = new ArrayList<String>();
34 private List<String> _hadCalNames = new ArrayList<String>();
35
36 private double _timeCut;
37
38 private int _hadCalorimeterMaxLayer;
39
40 private double _ECalMipCut;
41 private double _HCalMipCut;
42 private double[] _rawMipCut;
43
44 private CollectionManager _collectionmanager = CollectionManager.defaultInstance();
45
46
47 public ProcessHitsDriver()
48 {
49 }
50
51 protected void process(EventHeader event)
52 {
53 super.process(event);
54
55 if(!_initialized)
56 {
57 ConditionsManager mgr = ConditionsManager.defaultInstance();
58 try
59 {
60 _cond = mgr.getConditions("CalorimeterCalibration");
61 }
62 catch(ConditionsSetNotFoundException e)
63 {
64 System.out.println("ConditionSet CalorimeterCalibration not found for detector "+mgr.getDetector());
65 System.out.println("Please check that this properties file exists for this detector ");
66 }
67
68
69
70 String names = _cond.getString("BaseHitCollectionNames");
71
72 _hitCollectionNames = names.split(",\\s");
73
74 names = _cond.getString("HadCalorimeterCollections");
75 String[] hadCalCollectionNames = names.split(",\\s");
76 for(int i=0; i<hadCalCollectionNames.length; ++i)
77 {
78 _hadCalNames.add(hadCalCollectionNames[i]);
79 }
80
81
82
83 _hadCalorimeterMaxLayer = _cond.getInt("HadCalorimeterMaxLayer");
84
85 names = _cond.getString("EMCalorimeterCollections");
86 String[] emCalCollectionNames = names.split(",\\s");
87 for(int i=0; i<emCalCollectionNames.length; ++i)
88 {
89 _emCalNames.add(emCalCollectionNames[i]);
90 }
91
92
93 _timeCut = _cond.getDouble("timeCut");
94
95
96 _ECalMipCut = _cond.getDouble("ECalMip_Cut");
97 _HCalMipCut = _cond.getDouble("HCalMip_Cut");
98
99
100
101
102
103 _rawMipCut = new double[_hitCollectionNames.length];
104 for(int i=0; i<_rawMipCut.length; ++i)
105 {
106 if(_emCalNames.contains(_hitCollectionNames[i]))
107 {
108 _rawMipCut[i] = _ECalMipCut;
109 }
110 else if (_hadCalNames.contains(_hitCollectionNames[i]))
111 {
112 _rawMipCut[i] = _HCalMipCut;
113 }
114 }
115 _initialized = true;
116 }
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131 List<CalorimeterHit> hitsToCluster = new ArrayList<CalorimeterHit>();
132 int i = 0;
133
134 for(String name : _hitCollectionNames)
135 {
136 boolean isHadCal = _hadCalNames.contains(name);
137 List<CalorimeterHit> hits = event.get(CalorimeterHit.class, name);
138
139
140 for(CalorimeterHit hit: hits)
141 {
142 BaseCalorimeterHit h = (BaseCalorimeterHit) hit;
143
144
145 if(h.getRawEnergy() < _rawMipCut[i]) continue;
146
147
148 if(h.getTime() > _timeCut) continue;
149
150
151 if(isHadCal && h.getLayerNumber() > _hadCalorimeterMaxLayer) continue;
152
153
154
155
156
157
158 hitsToCluster.add(hit);
159 }
160 ++i;
161 }
162
163
164 String outputCollectionName = _cond.getString("ProcessedHitsCollectionName");
165
166 _collectionmanager.addList(outputCollectionName, hitsToCluster);
167 }
168
169
170
171
172
173 }