2 #include "StFttFastSimMaker.h"
4 #include "StEvent/StEvent.h"
5 #include "St_base/StMessMgr.h"
7 #include "StEvent/StRnDHit.h"
8 #include "StEvent/StRnDHitCollection.h"
9 #include "StThreeVectorF.hh"
17 #include "tables/St_g2t_fts_hit_Table.h"
18 #include "tables/St_g2t_track_Table.h"
21 #include "StarGenerator/UTIL/StarRandom.h"
24 const bool verbose =
false;
27 StFttFastSimMaker::StFttFastSimMaker(
const Char_t *name)
44 int StFttFastSimMaker::Init() {
47 return StMaker::Init();
51 LOG_DEBUG <<
"StFttFastSimMaker::Make" << endm;
58 LOG_DEBUG <<
"Creating StEvent" << endm;
61 if (0 == event->rndHitCollection()) {
63 LOG_DEBUG <<
"Creating StRnDHitCollection for FTS" << endm;
66 FillThinGapChambers(event);
80 void StFttFastSimMaker::GlobalToLocal(
float x,
float y,
int disk,
int &quad,
float &localX,
float &localY) {
87 QuadBottomLeft(disk, 0, qb, ql);
88 qr = ql + STGC_QUAD_WIDTH;
89 qt = qb + STGC_QUAD_HEIGHT;
90 if (x >= ql && x < qr && y >= qb && y < qt) {
96 QuadBottomLeft(disk, 1, qb, ql);
97 qr = ql + STGC_QUAD_WIDTH;
98 qt = qb + STGC_QUAD_HEIGHT;
99 if (x >= ql && x < qr && y >= qb && y < qt) {
104 QuadBottomLeft(disk, 2, qb, ql);
105 qr = ql + STGC_QUAD_WIDTH;
106 qt = qb + STGC_QUAD_HEIGHT;
107 if (x >= ql && x < qr && y >= qb && y < qt) {
112 QuadBottomLeft(disk, 3, qb, ql);
113 qr = ql + STGC_QUAD_WIDTH;
114 qt = qb + STGC_QUAD_HEIGHT;
115 if (x >= ql && x < qr && y >= qb && y < qt) {
124 float StFttFastSimMaker::DiskOffset(
int disk) {
125 assert(disk >= 9 && disk <= 12);
137 float StFttFastSimMaker::DiskRotation(
int disk) {
138 assert(disk >= 9 && disk <= 12);
141 return this->sTGC_disk9_theta;
143 return this->sTGC_disk10_theta;
145 return this->sTGC_disk11_theta;
147 return this->sTGC_disk12_theta;
151 void StFttFastSimMaker::QuadBottomLeft(
int disk,
int quad,
float &bottom,
float &left) {
152 float hbp = DiskOffset(disk);
153 if ( FttGlobal::verbose ) {LOG_INFO <<
"disk: " << disk <<
", offset = " << hbp << endm;}
156 float q0l = hbp - STGC_QUAD_WIDTH;
163 float q2b = -hbp - STGC_QUAD_HEIGHT;
165 float q3l = -hbp - STGC_QUAD_WIDTH;
166 float q3b = hbp - STGC_QUAD_HEIGHT;
190 void StFttFastSimMaker::LocalToGlobal(
float localX,
float localY,
int disk,
int quad,
float &globalX,
float &globalY) {
194 QuadBottomLeft(disk, quad, qb, ql);
196 globalX = localX + ql;
197 globalY = localY + qb;
208 if (hitA->layer() != hitB->layer())
210 int disk = hitA->layer();
212 if (hitA->wafer() != hitB->wafer())
214 int quad = hitA->wafer();
216 float x1 = hitA->double2();
217 float y1 = hitA->double3();
218 float x2 = hitB->double2();
219 float y2 = hitB->double3();
221 float b = -1, l = -1;
222 QuadBottomLeft(disk, quad, b, l);
229 int chunkx1 = lx1 / STGC_WIRE_LENGTH;
230 int chunky1 = ly1 / STGC_WIRE_LENGTH;
232 int chunkx2 = lx2 / STGC_WIRE_LENGTH;
233 int chunky2 = ly2 / STGC_WIRE_LENGTH;
235 if (chunkx1 != chunkx2)
237 if (chunky1 != chunky2)
242 void StFttFastSimMaker::FillThinGapChambers(
StEvent *event) {
244 St_g2t_fts_hit *hitTable =
static_cast<St_g2t_fts_hit *
>(GetDataSet(
"g2t_stg_hit"));
246 LOG_INFO <<
"g2t_stg_hit table is empty" << endm;
252 std::vector<StRnDHit *> hits;
255 const int nhits = hitTable->GetNRows();
256 const g2t_fts_hit_st *
hit = hitTable->GetTable();
260 float dx = STGC_SIGMA_X;
261 float dy = STGC_SIGMA_Y;
262 float dz = STGC_SIGMA_Z;
266 sTGCNGhostPoints = 0;
268 for (
int i = 0; i < nhits; i++) {
269 hit = (g2t_fts_hit_st *)hitTable->At(i);
273 float xhit = hit->x[0];
274 float yhit = hit->x[1];
275 float zhit = hit->x[2];
276 int volume_id = hit->volume_id;
278 int disk = ((volume_id - 1) / 100) + 9 ;
279 LOG_DEBUG <<
"sTGC hit: volume_id = " << volume_id <<
" disk = " << disk << endm;
282 if (disk < 9 || volume_id % 2 == 0)
285 float theta = DiskRotation(disk);
287 float x_blurred = xhit + rand.
gauss( STGC_SIGMA_X);
288 float y_blurred = yhit + rand.
gauss( STGC_SIGMA_Y);
290 float x_rot = -999, y_rot = -999;
291 this->rot(-theta, x_blurred, y_blurred, x_rot, y_rot);
294 float localX = -999, localY = -999;
295 GlobalToLocal(x_rot, y_rot, disk, quad, localX, localY);
298 if (quad < 0 || quad > 3)
304 ahit->setPosition({x_blurred, y_blurred, zhit});
305 ahit->setPositionError({dx, dy, 0.1});
307 ahit->setDouble0(xhit);
308 ahit->setDouble1(yhit);
309 ahit->setDouble2(x_rot);
310 ahit->setDouble3(y_rot);
312 ahit->setLayer(disk);
314 ahit->setWafer(quad);
316 ahit->setIdTruth(hit->track_p, 0);
317 ahit->setDetectorId(kFtsId);
322 0.f, 0, 0.f, dz * dz};
324 ahit->setErrorMatrix(Ematrix);
325 hits.push_back(ahit);
327 if (!STGC_MAKE_GHOST_HITS) {
329 if (FttGlobal::verbose){
332 ftscollection->addHit(ahit);
337 if (STGC_MAKE_GHOST_HITS) {
338 for (
auto &hit0 : hits) {
339 float hit0_x = hit0->double2();
340 float hit0_y = hit0->double3();
341 int disk0 = hit0->layer();
342 int quad0 = hit0->wafer();
343 float theta = DiskRotation(disk0);
345 for (
auto &hit1 : hits) {
346 float hit1_x = hit1->double2();
347 float hit1_y = hit1->double3();
348 int disk1 = hit1->layer();
349 int quad1 = hit1->wafer();
357 if (
false == Overlaps(hit0, hit1))
365 if (hit1_x == hit0_x && hit1_y == hit0_y) {
368 idTruth = hit0->idTruth();
374 float rx = -999, ry = -999;
375 this->rot(theta, x, y, rx, ry);
383 ahit->setPosition({rx, ry, hit0->position().z()});
384 ahit->setPositionError({dx, dy, 0.1});
386 ahit->setDouble0(hit0_x);
387 ahit->setDouble1(hit0_y);
388 ahit->setDouble2(hit1_x);
389 ahit->setDouble3(hit1_y);
391 ahit->setLayer(disk0);
393 ahit->setWafer(quad0);
395 ahit->setIdTruth(idTruth, qaTruth);
396 ahit->setDetectorId(kFtsId);
401 0.f, 0, 0.f, dz * dz};
402 ahit->setErrorMatrix(Ematrix);
403 ftscollection->addHit(ahit);
411 for (
size_t i = 0; i < hits.size(); i++ ){
417 if (FttGlobal::verbose) {
418 LOG_INFO <<
"nHits (all FTS) = " << nhits << endm;
420 if (FttGlobal::verbose) {
421 LOG_INFO <<
"nSTGC = " << nSTGCHits << endm;
423 if (FttGlobal::verbose) {
424 LOG_INFO <<
"nReal = " << sTGCNRealPoints << endm;
426 if (FttGlobal::verbose) {
427 LOG_INFO <<
"nGhost = " << sTGCNGhostPoints << endm;
Double_t gauss(const Double_t sigma) const
Return a random number distributed according to a gaussian with specified sigma.
static StarRandom & Instance()
Obtain the single instance of the random number generator.
virtual void AddData(TDataSet *data, const char *dir=".data")
User methods.
A class for providing random number generation.