00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00018 #include "Stiostream.h"
00019 #include <cmath>
00020 #include <stdio.h>
00021
00022 #include "StEventTypes.h"
00023 #include "StEvent.h"
00024 #include "Sti/Base/Factory.h"
00025 #include "StiSsd/StiSsdHitLoader.h"
00026 #include "Sti/StiHit.h"
00027 #include "Sti/StiTrack.h"
00028 #include "Sti/StiHitContainer.h"
00029 #include "Sti/StiDetector.h"
00030 #include "Sti/StiDetectorBuilder.h"
00031 #include "Sti/StiDetector.h"
00032
00033 StiSsdHitLoader::StiSsdHitLoader()
00034 : StiHitLoader<StEvent,StiDetectorBuilder>("SsdHitLoader")
00035 {}
00036
00037 StiSsdHitLoader::StiSsdHitLoader(StiHitContainer* hitContainer,
00038 Factory<StiHit>*hitFactory,
00039 StiDetectorBuilder*detector)
00040 : StiHitLoader<StEvent,StiDetectorBuilder>("SsdHitLoader",hitContainer,hitFactory,detector)
00041 {}
00042
00043 StiSsdHitLoader::~StiSsdHitLoader()
00044 {}
00045
00046 void StiSsdHitLoader::loadHits(StEvent* source,
00047 Filter<StiTrack> * trackFilter,
00048 Filter<StiHit> * hitFilter)
00049 {
00050 cout <<"StiSsdHitLoader::loadHits() - Started"<<endl;
00051 if (!source)
00052 throw runtime_error("StiSsdHitLoader::loadHits() - FATAL - source==0 ");
00053 StSsdHitCollection* ssdhits = source->ssdHitCollection();
00054 if (!ssdhits)
00055 {
00056 cout << "StiSsdHitLoader::loadHits(StEvent* source) - WARNING - NO SSD hits"<<endl;
00057 return;
00058 }
00059 int compt = 0;
00060 int layer = 0;
00061 StSsdHit* hit;
00062 StiHit* stiHit;
00063 StiDetector* detector;
00064 if (!_hitContainer)
00065 throw runtime_error("StiSsdHitLoader::loadHits() - FATAL - _hitContainer==0 ");
00066
00067
00068 for (unsigned int ladder = 0; ladder< ssdhits->numberOfLadders(); ++ladder)
00069 {
00070 StSsdLadderHitCollection* ladderhits = ssdhits->ladder(ladder);
00071 if (!ladderhits) break;
00072
00073 for (unsigned int wafer = 0; wafer< ladderhits->numberOfWafers(); ++wafer)
00074 {
00075 StSsdWaferHitCollection* waferhits = ladderhits->wafer(wafer);
00076
00077 if (!waferhits) break;
00078 const StSPtrVecSsdHit& hits = waferhits->hits();
00079
00080 for (const_StSsdHitIterator it=hits.begin(); it!=hits.end(); ++it)
00081 {
00082 if (!*it) throw runtime_error("StiSsdHitLoader::loadHits() - WARNING - *it==0");
00083 hit = static_cast<StSsdHit*>(*it);
00084
00085 if (!hit) throw runtime_error("StiSsdHitLoader::loadHits() - WARNING - hit==0");
00086
00087 int ssdLadder = hit->ladder();
00088 int ladder = ssdLadder -1 ;
00089 detector = _detector->getDetector(layer,ladder);
00090 if (hit && detector)
00091 {
00092 compt++;
00093 stiHit = _hitFactory->getInstance();
00094 stiHit->setGlobal(detector,hit,
00095 hit->position().x(),
00096 hit->position().y(),
00097 hit->position().z(),
00098 hit->charge() );
00099 _hitContainer->add( stiHit );
00100 }
00101 }
00102 }
00103 }
00104
00105 cout <<"StiSsdHitLoader::loadHits() - I - Done <====> Number of SSD Hits = " <<compt<<endl;
00106 }
00107
00108