19 #include "StFttPointMaker.h"
22 #include "StEvent/StFttRawHit.h"
23 #include "StEvent/StFttCluster.h"
24 #include "StEvent/StFttPoint.h"
25 #include "StEvent/StEvent.h"
26 #include "StEvent/StFttCollection.h"
28 #include "StFttDbMaker/StFttDb.h"
32 StFttPointMaker::StFttPointMaker(
const char* name )
36 mUseTestData( false ),
39 LOG_DEBUG <<
"StFttPointMaker::ctor" << endm;
43 StFttPointMaker::~StFttPointMaker()
48 StFttPointMaker::Init()
55 StFttPointMaker::InitRun( Int_t runnumber )
62 StFttPointMaker::FinishRun( Int_t runnumber )
79 mEvent = (
StEvent*)GetInputDS(
"StEvent");
81 LOG_DEBUG<<
"Found StEvent"<<endm;
85 mFttCollection=mEvent->fttCollection();
90 mFttDb =
static_cast<StFttDb*
>(GetDataSet(
"fttDb"));
100 LOG_INFO <<
"StFttPointMaker made " << mFttCollection->numberOfPoints() <<
" points this event" << endm;
105 void StFttPointMaker::InjectTestData(){
106 mFttCollection->rawHits().clear();
111 void StFttPointMaker::MakeLocalPoints(){
116 std::vector< StFttCluster *> clusters[StFttDb::nRob][StFttDb::nRowsPerQuad][StFttDb::nStripOrientations];
118 for (
StFttCluster* clu : mFttCollection->clusters() ) {
119 UChar_t rob = mFttDb->rob( clu );
120 if ( clu->nStrips() < 2 )
continue;
121 clusters[ rob ][ clu->row() ][ clu->orientation() ].push_back( clu );
125 for (
size_t iRob = 1; iRob < StFttDb::nRob; iRob ++ ){
126 for (
size_t iRowH = 0; iRowH < 3; iRowH++ ){
127 size_t nH = clusters[ iRob ][ iRowH ][ kFttHorizontal ].size();
128 for (
size_t iRowV = 0; iRowV < 3; iRowV++ ){
129 size_t nV = clusters[ iRob ][ iRowV ][ kFttVertical ].size();
130 for (
size_t iH = 0; iH < nH; iH++ ){
131 auto cluH = clusters[ iRob ][ iRowH ][ kFttHorizontal ][ iH ];
132 for (
size_t iV = 0; iV < nV; iV++ ){
133 auto cluV = clusters[ iRob ][ iRowV ][ kFttVertical ][ iV ];
143 void StFttPointMaker::MakeGlobalPoints() {
144 for (
StFttPoint * p : mFttCollection->points() ){
152 float dx = 0, dy = 0, dz = 0;
154 float sx = 0, sy = 0, sz = 0;
155 mFttDb->getGloablOffset( p->plane(), p->quadrant(), dx, sx, dy, sy, dz, sz );
156 global.set( (x + dx) * sx, (y + dy) * sy, (z + dz) * sz );
170 p->setPlane( cluV->plane() );
171 p->setQuadrant( cluV->quadrant() );
174 p->addCluster( cluH, kFttHorizontal );
175 p->addCluster( cluV, kFttVertical );
176 mFttCollection->addPoint(p);
178 }
else if ( mode == 1 ){
179 float hx1, hx2, hy1, hy2;
180 clusterBounds( cluH, hx1, hy1, hx2, hy2 );
181 float vx1, vx2, vy1, vy2;
182 clusterBounds( cluV, vx1, vy1, vx2, vy2 );
185 if ( y < vy1 || y > vy2 || x < hx1 || x > hx2 ){
190 p->setPlane( cluV->plane() );
191 p->setQuadrant( cluV->quadrant() );
194 p->addCluster( cluH, kFttHorizontal );
195 p->addCluster( cluV, kFttVertical );
196 mFttCollection->addPoint(p);
203 void StFttPointMaker::clusterBounds(
StFttCluster* clu,
float &x1,
float &y1,
float &x2,
float &y2 ){
205 const float rowWidth = 176;
206 if ( clu->orientation() == kFttHorizontal ){
208 x1 = clu->row() * rowWidth;
209 x2 = (clu->row() + 1) * rowWidth;
212 if ( clu->orientation() == kFttVertical ){
214 y1 = clu->row() * rowWidth;
215 y2 = (clu->row() + 1) * rowWidth;