StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StiDetectorContainer.h
1 //StiDetectorContainer.h
2 //M.L. Miller (Yale Software)
3 //02/02/01
4 
46 #ifndef StiDetectorContainer_HH
47 #define StiDetectorContainer_HH
48 
49 #include <vector>
50 using std::vector;
51 #include <map>
52 using std::map;
53 
54 #include "Sti/Base/Named.h"
55 #include "Sti/Base/Described.h"
56 #include "Sti/Base/Factory.h"
57 #include "Sti/StiDetector.h"
58 #include "Sti/StiDetectorBuilder.h"
59 #include "Sti/StiMasterDetectorBuilder.h"
60 #include "Sti/StiCompositeLeafIterator.h"
61 #include "Sti/StiMapUtilities.h"
62 #include "Sti/StiCompositeTreeNode.h"
63 
64 using namespace std;
65 using std::vector;
66 using std::map;
67 template <class FILTERED> class Filter;
68 
69 class StiDetectorContainer : public Named, public Described
70 {
71  public:
72  StiDetectorContainer(const string & name, const string & description,StiMasterDetectorBuilder *);
73  virtual ~StiDetectorContainer();
74  void initialize();
76  virtual void build(StiDetectorBuilder * builder);
78  const StiDetectorNode* root() const;
80  void add(StiDetector* det);
82  void reset();
83  void unset(){;}
84  void clear(){;}
86  StiDetector* operator*() const;
87  StiDetector* getCurrentDetector() const;
89  bool moveIn(double phiCut=-1.0, double zCut=-1.0, double rMin=-1.0);
91  void setToDetector(const StiDetector* layer);
92  vector<StiDetector*> & getDetectors();
93  vector<StiDetector*> & getDetectors(Filter<StiDetector> & filter);
94  StiMasterDetectorBuilder * getDetectorBuilder();
95  vector<StiDetector*>::const_iterator begin() const;
96  vector<StiDetector*>::const_iterator end() const;
97  vector<StiDetector*>::iterator begin();
98  vector<StiDetector*>::iterator end();
99 
100  vector<StiDetectorNode*>::const_iterator beginRadial(const StiDetector * detector)
101  {
102  setToDetector(detector);
103  return mradial_it;//(*mregion)->begin();
104  }
105 
106  vector<StiDetectorNode*>::const_iterator endRadial()
107  {
108  return (*mregion)->end();
109  }
110 
111  vector<StiDetectorNode*>::reverse_iterator rbeginRadial(const StiDetector * detector)
112  {
113  setToDetector(detector);
114  vector<StiDetectorNode*>::reverse_iterator it;
115  for (it =(*mregion)->rbegin();
116  it != (*mregion)->rend();
117  ++it)
118  {
119  //if they point to the same node, we are done...
120  if (*it==*mradial_it) break;
121  }
122  return it;
123  }
124 
125  StiDetectorNodeVector::const_reverse_iterator rendRadial()
126  {
127  return (*mregion)->rend();
128  }
129 
130  StiDetectorNodeVector::const_iterator beginPhi(StiDetectorNodeVector::const_iterator &radialIterator)
131  {
132  //cout << " beginPhi: size:"<< (*radialIterator)->getChildCount()<<endl;
133  return (*radialIterator)->begin();
134  }
135  StiDetectorNodeVector::const_iterator endPhi(StiDetectorNodeVector::const_iterator &radialIterator)
136  {
137  return (*radialIterator)->end();
138  }
139  StiDetectorNodeVector::const_iterator beginPhi(StiDetectorNodeVector::const_reverse_iterator &radialIterator)
140  {
141  //cout << " beginPhi: size:"<< (*radialIterator)->getChildCount()<<endl;
142  return (*radialIterator)->begin();
143  }
144  StiDetectorNodeVector::const_iterator endPhi(StiDetectorNodeVector::const_reverse_iterator &radialIterator)
145  {
146  return (*radialIterator)->end();
147  }
148 
149 private:
151  void setToLeaf(StiDetectorNode* node);
152  bool setPhi(const StiOrderKey& oldOrder);
153  // Utility function for moveIn(), moveOut() functions
154  bool setPhiIterator(double oldOrder, unsigned int oldNDaughters,
155  StiDetectorNodeVector::difference_type oldDistance);
156 
157 private:
159  StiDetectorNode* mroot;
165  StiDetectorNodeVector::const_iterator mregion; //Test (MLM)
166  //StiDetectorNode* mregion;
168  StiDetectorNodeVector::const_iterator mradial_it;
170  StiDetectorNodeVector::const_iterator mphi_it;
173  vector<StiDetector *> _sortedDetectors;
174  vector<StiDetector *> _selectedDetectors;
175  StiMasterDetectorBuilder * _masterDetectorBuilder;
176 };
177 
178 
180 {
181  public:
182  bool operator()(const StiDetector* lhs, const StiDetector* rhs);
183 };
184 
186 {
187  return mroot;
188 }
189 
190 inline StiMasterDetectorBuilder * StiDetectorContainer::getDetectorBuilder()
191 {
192  return _masterDetectorBuilder;
193 }
194 
195 #endif
const StiDetectorNode * root() const
Get the root detector node of this tree.
Definition: Named.h:16