95 #ifndef StiHitContainer_HH
96 #define StiHitContainer_HH
105 #include "Sti/Base/Named.h"
106 #include "Sti/Base/Described.h"
107 #include "Sti/Base/Filter.h"
108 #include "Sti/Base/Factory.h"
109 #include "Sti/StiMapUtilities.h"
110 #include "Sti/StiHit.h"
111 #include "Sti/StiDetector.h"
112 #include "Sti/StiKalmanTrackNode.h"
119 bool fEffectiveEndValid;
120 vector<StiHit*>::iterator theEffectiveEnd;
123 vector<StiHit*>::iterator TheEffectiveEnd() {
124 return fEffectiveEndValid ? theEffectiveEnd
130 vector<StiHit*> theHitVec;
132 static int fIdCounter;
134 void setEnd(vector<StiHit*>::iterator &endHit) {
135 theEffectiveEnd = endHit;
136 fEffectiveEndValid =
true;
138 void invalidateEnd(){ fEffectiveEndValid =
false; }
139 vector<StiHit*> &hits() {
return theHitVec; }
140 const vector<StiHit*> &hits()
const {
return theHitVec; }
141 size_t size()
const {
return theHitVec.size(); }
142 void push_back(
StiHit *
hit) { theHitVec.push_back(hit); }
143 vector<StiHit*>::iterator begin() {
return theHitVec.begin() ; }
146 typedef map<HitMapKey, VectorAndEnd, MapKeyLessThan> HitMapToVectorAndEndType;
149 typedef HitMapToVectorAndEndType::value_type HitMapToVectorAndEndTypeValType;
157 virtual void add(
StiHit*);
158 virtual unsigned int size()
const;
159 virtual void reset();
160 virtual void unset(){;}
161 virtual void clear();
163 virtual void sortHits();
164 void setMaxTimes(
int nTimes);
165 vector<StiHit*> & getHits();
166 vector<StiHit*> & getHits(Filter<StiHit> & filter);
167 vector<StiHit*> & getHits(
StiHit& ref,
double dY,
double dZ,
bool fetchAll=
false);
168 vector<StiHit*> & getHits(
double position,
double refAngle,
double y,
double z,
169 double dY,
double dZ,
bool fetchAll=
false);
171 vector<StiHit*> & getHits(
double refangle,
double position);
173 vector<StiHit*>::iterator hitsBegin(
const StiDetector*);
174 vector<StiHit*>::iterator hitsEnd(
const StiDetector*);
175 const HitMapToVectorAndEndType& hits()
const;
176 HitMapToVectorAndEndType& hits();
177 StiHit * getNearestHit(
StiHit& ref,
double dY,
double dZ,
bool fetchAll=
false);
178 StiHit * getNearestHit(
double position,
double refAngle,
double y,
double z,
179 double dY,
double dZ,
bool fetchAll=
false);
184 bool hasKey(
double refangle,
double position);
188 HitMapToVectorAndEndType::key_type _key;
196 vector<StiHit*>::iterator _start;
198 vector<StiHit*>::iterator _stop;
200 vector<StiHit*> _selectedHits;
202 HitMapToVectorAndEndType _map;
211 inline const HitMapToVectorAndEndType& StiHitContainer::hits()
const
216 inline HitMapToVectorAndEndType& StiHitContainer::hits()
225 double dY,
double dZ,
bool fetchAll)
227 _utilityHit.set(position,refAngle,y,z);
228 return getHits(_utilityHit,dY,dZ,fetchAll);
234 _utilityHit.set(node.getRefPosition(),node.getLayerAngle(),node.getY(),node.getZ());
235 return getHits(_utilityHit,node.getWindowY(),node.getWindowZ(), fetchAll);
251 _key.refangle = refangle;
252 _key.position = position;
253 assert(_map.find(_key) != _map.end());
254 return _map[_key].theHitVec;
256 inline bool StiHitContainer::hasKey(
double refangle,
double position)
258 HitMapToVectorAndEndType::key_type key;
259 key.refangle = refangle;
260 key.position = position;
261 return _map.find(key) != _map.end();
263 inline bool StiHitContainer::hasDetector(
const StiDetector* layer)
265 double refangle = layer->getPlacement()->getLayerAngle();
266 double position = layer->getPlacement()->getLayerRadius();
267 return hasKey(refangle,position);
272 _key.refangle = layer->getPlacement()->getLayerAngle();
273 _key.position = layer->getPlacement()->getLayerRadius();
274 assert(_map.find(_key) != _map.end());
275 return _map[_key].theHitVec;
279 inline StiHit * StiHitContainer::getNearestHit(
double position,
double refAngle,
double y,
double z,
280 double dY,
double dZ,
bool fetchAll)
282 _utilityHit.set(position,refAngle,y,z);
283 return getNearestHit(_utilityHit,dY,dZ,fetchAll);
294 StiHit *
hit = getHitFactory()->getInstance();
299 ostream& operator<<(ostream&, const vector<StiHit*>&);
vector< StiHit * > & getHits()
Get hits selected by the given filter. If no filter is given (i.e. filter==0)
We define this globally for convenience of users.
StiHit * getHit()
Get a hit instance from the factory.
Factory< StiHit > * getHitFactory()
Get the hit factory.
virtual unsigned int size() const