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