4 #include "StEventTypes.h"
6 #include "Sti/Base/Factory.h"
7 #include "StiSvt/StiSvtHitLoader.h"
8 #include "Sti/StiHit.h"
9 #include "Sti/StiTrack.h"
10 #include "Sti/StiHitContainer.h"
11 #include "Sti/StiDetectorBuilder.h"
12 #include "Sti/StiDetector.h"
13 #include "Sti/StiHitTest.h"
15 StiSvtHitLoader::StiSvtHitLoader()
25 StiSvtHitLoader::~StiSvtHitLoader()
28 void StiSvtHitLoader::loadHits(
StEvent* source,
30 Filter<StiHit> * hitFilter)
32 cout <<
"StiSvtHitLoader::loadHits() - Started"<<endl;
33 if (!source)
throw runtime_error(
"StiSvtHitLoader::loadHits() -F- source==0 ");
37 cout <<
"StiSvtHitLoader::loadHits(StEvent* source) -W- NO SVT hits"<<endl;
43 if (!_hitContainer)
throw runtime_error(
"StiSvtHitLoader::loadHits() -F- _hitContainer==0 ");
45 for (
unsigned int barrel=0; barrel<svthits->numberOfBarrels(); ++barrel)
48 if (!barrelhits)
continue;
49 for (
unsigned int ladder=0; ladder<barrelhits->numberOfLadders(); ++ladder)
52 if (!ladderhits)
continue;
53 for (
unsigned int wafer=0; wafer<ladderhits->numberOfWafers(); ++wafer)
56 if (!waferhits)
continue;
57 const StSPtrVecSvtHit& hits = waferhits->hits();
59 for (const_StSvtHitIterator it=hits.begin(); it!=hits.end(); ++it)
61 if (!*it)
throw runtime_error(
"StiSvtHitLoader::loadHits() -W- *it==0!");
63 if (!hit)
throw runtime_error(
"StiSvtHitLoader::loadHits() -W- hit==0!");
64 int svtLayer = hit->layer();
65 int svtLadder = hit->ladder();
66 int stilayer = getLayer(svtLayer);
67 int stiladder = getLadder(svtLayer,svtLadder);
68 detector = _detector->getDetector(stilayer,stiladder);
69 if (!detector)
throw runtime_error(
"StiSvtHitLoader::loadHits() -W- detector==0!");
70 if (hit->flag()>=4)
continue;
71 if (hit->flag()< 0)
continue;
73 stiHit->
setGlobal(detector,hit,hit->position().x(),hit->position().y(),hit->position().z(),hit->charge() );
74 hitTest.add(stiHit->
x(),stiHit->y(),stiHit->z());
75 _hitContainer->
add( stiHit );
78 if (hitTest.getN()< 10)
continue;
79 double w=hitTest.width();
80 double dx = detector->getPlacement()->getNormalRadius()-hitTest.center()[0];;
81 double ay = hitTest.yAngle()*180/3.1415;
82 double az = hitTest.zAngle()*180/3.1415;
84 if (w< 0.1 && fabs(dx)<1 && fabs(ay)<1 && fabs(az)<1)
continue;
85 printf(
"**** SVT geom problem: barrel=%d ladder%d wafer%d\n",barrel,ladder,wafer);
86 printf(
"**** SVT dX=%g aY=%g aZ=%g\n\n",dx,ay,az);
90 cout <<
"StiSvtHitLoader::loadHits() -I- SVT Hits added:"<<hitCounter<<endl;
91 cout <<
"StiSvtHitLoader::loadHits() -I- Hit Container size:"<<_hitContainer->
size()<<endl;
92 cout <<
"StiSvtHitLoader::loadHits() -I- Done"<<endl;
96 int StiSvtHitLoader::getLayer(
int svtLayer)
const
101 case 1: layer = 0;
break;
102 case 2: layer = 1;
break;
103 case 3: layer = 2;
break;
104 case 4: layer = 3;
break;
105 case 5: layer = 4;
break;
106 case 6: layer = 5;
break;
107 default:
throw runtime_error(
"StiSvtHitLoader:getLayer() -E- invalid argument");
112 int StiSvtHitLoader::getLadder(
int svtLayer,
int svtLadder)
const
121 case 2: layer = 0; ladder = 0;
break;
122 case 4: layer = 0; ladder = 1;
break;
123 case 6: layer = 0; ladder = 2;
break;
124 case 8: layer = 0; ladder = 3;
break;
125 default:
throw runtime_error(
"StiSvtHitLoader:loadHits() -E- 1");
131 case 1: layer = 1; ladder = 0;
break;
132 case 3: layer = 1; ladder = 1;
break;
133 case 5: layer = 1; ladder = 2;
break;
134 case 7: layer = 1; ladder = 3;
break;
135 default:
throw runtime_error(
"StiSvtHitLoader:loadHits() -E- 2");
141 case 2: layer = 2; ladder = 0;
break;
142 case 4: layer = 2; ladder = 1;
break;
143 case 6: layer = 2; ladder = 2;
break;
144 case 8: layer = 2; ladder = 3;
break;
145 case 10: layer = 2; ladder = 4;
break;
146 case 12: layer = 2; ladder = 5;
break;
147 default:
throw runtime_error(
"StiSvtHitLoader:loadHits() -E- 3");
153 case 1: layer = 3; ladder = 0;
break;
154 case 3: layer = 3; ladder = 1;
break;
155 case 5: layer = 3; ladder = 2;
break;
156 case 7: layer = 3; ladder = 3;
break;
157 case 9: layer = 3; ladder = 4;
break;
158 case 11: layer = 3; ladder = 5;
break;
159 default:
throw runtime_error(
"StiSvtHitLoader:loadHits() -E- 4");
165 case 2: layer = 4; ladder = 0;
break;
166 case 4: layer = 4; ladder = 1;
break;
167 case 6: layer = 4; ladder = 2;
break;
168 case 8: layer = 4; ladder = 3;
break;
169 case 10: layer = 4; ladder = 4;
break;
170 case 12: layer = 4; ladder = 5;
break;
171 case 14: layer = 4; ladder = 6;
break;
172 case 16: layer = 4; ladder = 7;
break;
173 default:
throw runtime_error(
"StiSvtHitLoader:loadHits() -E- 5");
179 case 1: layer = 5; ladder = 0;
break;
180 case 3: layer = 5; ladder = 1;
break;
181 case 5: layer = 5; ladder = 2;
break;
182 case 7: layer = 5; ladder = 3;
break;
183 case 9: layer = 5; ladder = 4;
break;
184 case 11: layer = 5; ladder = 5;
break;
185 case 13: layer = 5; ladder = 6;
break;
186 case 15: layer = 5; ladder = 7;
break;
187 default:
throw runtime_error(
"StiSvtHitLoader:loadHits() -E- 6");
virtual void add(StiHit *)
void setGlobal(const StiDetector *detector, const StMeasuredPoint *stHit, Float_t x, Float_t y, Float_t z, Float_t energy)
const Float_t & x() const
Return the local x, y, z values.
virtual Abstract * getInstance()=0
Get a pointer to instance of objects served by this factory.
virtual unsigned int size() const