StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StiSsdHitLoader.cxx
1 // $Id: StiSsdHitLoader.cxx,v 1.16 2015/03/09 23:40:22 smirnovd Exp $
2 //
3 // $Log: StiSsdHitLoader.cxx,v $
4 // Revision 1.16 2015/03/09 23:40:22 smirnovd
5 // Removed commented code
6 //
7 // Revision 1.15 2015/03/09 21:44:26 perev
8 // Remove redundant printouts
9 //
10 // Revision 1.14 2015/01/24 04:43:41 smirnovd
11 // StiSsdHitLoader: Just to be safe got rid of local variable 'ladder' shadowing the loop's counter having the same name
12 //
13 // Revision 1.13 2009/03/18 19:55:39 fisyak
14 // remove StiDetectorFinder class
15 //
16 // Revision 1.12 2005/10/26 21:59:12 fisyak
17 // get rid off dependencies from StMcEvent
18 //
19 // Revision 1.11 2005/06/21 15:31:47 lmartin
20 // CVS tags added
21 //
27 #include "Stiostream.h"
28 #include <cmath>
29 #include <stdio.h>
30 
31 #include "StEventTypes.h"
32 #include "StEvent.h"
33 #include "Sti/Base/Factory.h"
34 #include "StiSsd/StiSsdHitLoader.h"
35 #include "Sti/StiHit.h"
36 #include "Sti/StiTrack.h"
37 #include "Sti/StiHitContainer.h"
38 #include "Sti/StiDetector.h"
39 #include "Sti/StiDetectorBuilder.h"
40 #include "Sti/StiDetector.h"
41 
42 StiSsdHitLoader::StiSsdHitLoader()
43  : StiHitLoader<StEvent,StiDetectorBuilder>("SsdHitLoader")
44 {}
45 
46 StiSsdHitLoader::StiSsdHitLoader(StiHitContainer* hitContainer,
47  Factory<StiHit>*hitFactory,
48  StiDetectorBuilder*detector)
49  : StiHitLoader<StEvent,StiDetectorBuilder>("SsdHitLoader",hitContainer,hitFactory,detector)
50 {}
51 
52 StiSsdHitLoader::~StiSsdHitLoader()
53 {}
54 
55 void StiSsdHitLoader::loadHits(StEvent* source,
56  Filter<StiTrack> * trackFilter,
57  Filter<StiHit> * hitFilter)
58 {
59  if (!source)
60  throw runtime_error("StiSsdHitLoader::loadHits() - FATAL - source==0 ");
61  StSsdHitCollection* ssdhits = source->ssdHitCollection();
62  if (!ssdhits)
63  {
64  return;
65  }
66  int compt = 0;
67  int layer = 0;
68  StSsdHit* hit;
69  StiHit* stiHit;
70  StiDetector* detector;
71  if (!_hitContainer)
72  throw runtime_error("StiSsdHitLoader::loadHits() - FATAL - _hitContainer==0 ");
73 
74 
75  for (unsigned int ladder = 0; ladder< ssdhits->numberOfLadders(); ++ladder)
76  {
77  StSsdLadderHitCollection* ladderhits = ssdhits->ladder(ladder);
78  if (!ladderhits) break;
79 
80  for (unsigned int wafer = 0; wafer< ladderhits->numberOfWafers(); ++wafer)
81  {
82  StSsdWaferHitCollection* waferhits = ladderhits->wafer(wafer);
83 
84  if (!waferhits) break;
85  const StSPtrVecSsdHit& hits = waferhits->hits();
86 
87  for (const_StSsdHitIterator it=hits.begin(); it!=hits.end(); ++it)
88  {
89  if (!*it) throw runtime_error("StiSsdHitLoader::loadHits() - WARNING - *it==0");
90  hit = static_cast<StSsdHit*>(*it);
91 
92  if (!hit) throw runtime_error("StiSsdHitLoader::loadHits() - WARNING - hit==0");
93 
94  detector = _detector->getDetector(layer, hit->ladder() - 1);
95 
96  if (hit && detector)
97  {
98  compt++;
99  stiHit = _hitFactory->getInstance();
100  stiHit->setGlobal(detector,hit,
101  hit->position().x(),
102  hit->position().y(),
103  hit->position().z(),
104  hit->charge() );
105  _hitContainer->add( stiHit );
106  }
107  }
108  }
109  }
110 
111 }
112 
113 
virtual void add(StiHit *)
void setGlobal(const StiDetector *detector, const StMeasuredPoint *stHit, Float_t x, Float_t y, Float_t z, Float_t energy)
Definition: StiHit.cxx:133
Definition: StiHit.h:51
virtual Abstract * getInstance()=0
Get a pointer to instance of objects served by this factory.