StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StiMasterHitLoader.h
1 #ifndef StiMasterHitLoader_H
2 #define StiMasterHitLoader_H
3 
4 #include <cassert>
5 #include <stdexcept>
6 #include <vector>
7 #include "StiHitLoader.h"
8 #include "Sti/StiTrackContainer.h"
9 #include "StEvent.h"
10 #include "StEventTypes.h"
11 
30 template<class Source1, class Detector>
31 class StiMasterHitLoader : public StiHitLoader<Source1, Detector>,
32 public vector< StiHitLoader<Source1, Detector> *>
33 {
34 public:
35 
37  StiMasterHitLoader(const string& name,
38  StiHitContainer* hitContainer,
39  Factory<StiHit>*hitFactory,
40  Detector*transform);
41  virtual ~StiMasterHitLoader();
42  void addLoader(StiHitLoader<Source1, Detector>*loader);
43  void loadEvent(Source1 *source1,
44  Filter<StiTrack> * trackFilter,
45  Filter<StiHit> * hitFilter);
46  void setHitContainer(StiHitContainer* hitContainer);
47  void setHitFactory(Factory<StiHit>*hitFactory);
48  virtual void setDetector(Detector*detector);
49 protected:
51  typedef vector< HitLoaderKey > HitLoaderVector;
52  typedef typename HitLoaderVector::iterator HitLoaderIter;
53  typedef typename HitLoaderVector::const_iterator HitLoaderConstIter;
54  //HitLoaderVector _hitLoaders;
55 };
56 
57 template<class Source1, class Detector>
59 : StiHitLoader<Source1, Detector>("MasterHitLoader",0,0,0)
60 {}
61 
62 template<class Source1,class Detector>
64  StiHitContainer* hitContainer,
65  Factory<StiHit>*hitFactory,
66  Detector*transform)
67 : StiHitLoader<Source1, Detector>(name,hitContainer,hitFactory,transform)
68 {}
69 
70 template<class Source1,class Detector>
72 {}
73 
74 template<class Source1,class Detector>
76 {
77  this->push_back(loader);
78 }
79 
80 template<class Source1, class Detector>
82  Filter<StiTrack> * trackFilter,
83  Filter<StiHit> * hitFilter)
84 {
85  assert(this->_hitContainer);
86  this->_hitContainer->clear();
87  HitLoaderConstIter iter;
88  for (iter=this->begin();iter!=this->end();iter++) {
89  unsigned nHitsBeforeLoad = this->_hitContainer->size();
90  (*iter)->loadHits(source1,trackFilter, hitFilter);
91  LOG_INFO << "StiMasterHitLoader::loadEvent() - "
92  << (*iter)->getName() << " loaded "
93  << this->_hitContainer->size() - nHitsBeforeLoad
94  << " hits" << endm;
95  }
96  this->_hitContainer->sortHits();
97  this->_hitContainer->reset();//declare all hits as unused...
98 }
99 
100 template<class Source1, class Detector>
102 {
103  this->_hitContainer = hitContainer;
104  HitLoaderIter iter;
105  for (iter=this->begin();iter!=this->end();iter++)
106  (*iter)->setHitContainer(hitContainer);
107 }
108 
109 
110 template<class Source1, class Detector>
112 {
113  HitLoaderIter iter;
114  for (iter=this->begin();iter!=this->end();iter++)
115  (*iter)->setHitFactory(hitFactory);
116 }
117 
118 template<class Source1,class Detector>
120 {
121  cout << "StiMasterHitLoader<Source1,Detector>::setDetector(Detector*) - This call is Forbiden in StiMasterHitLoader" << endl;
122  assert(0);
123 }
124 
125 
126 #endif
127 
128