3 #include "TGeoManager.h"
6 #include "StIstSimMaker/StIstFastSimMaker.h"
7 #include "StEvent/StEvent.h"
9 #include "StMcEvent/StMcEvent.hh"
10 #include "StMcEvent/StMcHit.hh"
11 #include "StMcEvent/StMcIstHit.hh"
12 #include "StIstUtil/StIstConsts.h"
13 #include "StEvent/StIstHit.h"
14 #include "StEvent/StIstHitCollection.h"
15 #include "StIstDbMaker/StIstDb.h"
16 #include "StMcEvent/StMcIstHit.hh"
17 #include "StMcEvent/StMcIstHitCollection.hh"
18 #include "StThreeVectorF.hh"
19 #include "tables/St_HitError_Table.h"
24 mRandom(useRandomSeed ? time(0) : 65539), mSmear(kTRUE)
29 Int_t StIstFastSimMaker::Init()
31 LOG_INFO <<
"StIstFastSimMaker::Init()" << endm;
38 Int_t StIstFastSimMaker::InitRun(
int runNo)
40 LOG_INFO <<
"StIstFastSimMaker::InitRun" << endm;
42 if (mBuildIdealGeom && !gGeoManager) {
44 GetDataBase(
"VmcGeometry");
47 LOG_ERROR <<
"Init() - "
48 "Cannot initialize StIstFastSimMaker due to missing global object of TGeoManager class. "
49 "Make sure STAR geometry is properly loaded with BFC AgML option" << endm;
55 TDataSet *calibDataSet = GetDataBase(
"Calibrations/tracker");
56 St_HitError *istTableSet = (St_HitError *) calibDataSet->
Find(
"ist1HitError");
57 HitError_st *istHitError = istTableSet->GetTable();
58 mResXIst1 = sqrt(istHitError->coeff[0]);
59 mResZIst1 = sqrt(istHitError->coeff[3]);
67 LOG_ERROR <<
"InitRun : no mIstDb" << endm;
72 mIstRot = mIstDb->getRotations();
75 LOG_FATAL <<
"InitRun(): mIstRot is not initialized" << endm;
79 if (mBuildIdealGeom) {
80 LOG_DEBUG <<
" Using ideal geometry" << endm;
83 LOG_DEBUG <<
" Using geometry tables from the DB." << endm;
97 using namespace StIstConsts;
102 if (! rcEvent) {LOG_WARN <<
"Make() - StEvent not found" << endl;
return kStWarn;}
106 if (! mcEvent) {LOG_WARN <<
"Make() - StMcEvent not found" << endl;
return kStWarn;}
111 if (!istHitCollection) {
113 rcEvent->setIstHitCollection(istHitCollection);
114 LOG_WARN <<
"Make() - Added new StIstHitCollection to StEvent" << endm;
123 LOG_FATAL <<
"No Ist MC hits found." << endm;
129 Int_t nIsthits = istMcHitCol->numberOfHits();
131 if (istMcHitCol->layer(0)) {
132 for (UInt_t kk = 0; kk < istMcHitCol->layer(0)->hits().size(); kk++) {
133 StMcHit *mcH = istMcHitCol->layer(0)->hits()[kk];
138 TGeoHMatrix *combI = NULL;
141 if (mBuildIdealGeom) {
142 TString path(
"HALL_1/CAVE_1/TpcRefSys_1/IDSM_1/IBMO_1");
143 path += Form(
"/IBAM_%ld/IBLM_%ld/IBSS_1", mcI->ladder(), mcI->wafer());
144 gGeoManager->RestoreMasterVolume();
145 gGeoManager->CdTop();
146 gGeoManager->cd(path);
147 combI = (TGeoHMatrix *)gGeoManager->GetCurrentMatrix();
150 combI = (TGeoHMatrix *)mIstRot->FindObject(Form(
"R%04i", matIst));
154 Double_t globalIstHitPos[3] = {mcI->position().x(), mcI->position().y(), mcI->position().z()};
155 Double_t localIstHitPos[3] = {mcI->position().x(), mcI->position().y(), mcI->position().z()};
157 LOG_DEBUG <<
"ladder/wafer = " << mcI->ladder() <<
" / " << mcI->wafer() <<
"\n"
158 <<
"x/y/z before smearing" << localIstHitPos[0] <<
"/" << localIstHitPos[1] <<
"/" << localIstHitPos[2] << endm;
161 localIstHitPos[0] = distortHit(localIstHitPos[0], mResXIst1, kIstSensorActiveSizeRPhi / 2.0);
162 localIstHitPos[2] = distortHit(localIstHitPos[2], mResZIst1, kIstSensorActiveSizeZ / 2.0);
166 Float_t rPhiPos = kIstSensorActiveSizeRPhi / 2.0 - localIstHitPos[0];
167 Float_t zPos = localIstHitPos[2] + kIstSensorActiveSizeZ / 2.0;
168 Short_t meanColumn = (Short_t)floor( zPos / kIstPadPitchColumn ) + 1;
169 Short_t meanRow = (Short_t)floor( rPhiPos / kIstPadPitchRow ) + 1;
170 rPhiPos = (meanRow - 1) * kIstPadPitchRow + 0.5 * kIstPadPitchRow;
171 zPos = (meanColumn - 1) * kIstPadPitchColumn + 0.5 * kIstPadPitchColumn;
172 localIstHitPos[0] = kIstSensorActiveSizeRPhi / 2.0 - rPhiPos;
173 localIstHitPos[2] = zPos - kIstSensorActiveSizeZ / 2.0;
176 LOG_DEBUG <<
"x/y/z after smearing" << localIstHitPos[0] <<
"/" << localIstHitPos[1] <<
"/" << localIstHitPos[2] << endm;
179 combI->LocalToMaster(localIstHitPos, globalIstHitPos);
184 tempHit->setDetectorId(kIstId);
185 tempHit->setId(mcI->key());
186 mcI->parentTrack() ? tempHit->setIdTruth(mcI->parentTrack()->key(), 100) : tempHit->setIdTruth(-999);
187 tempHit->setLocalPosition(localIstHitPos[0], localIstHitPos[1], localIstHitPos[2]);
188 istHitCollection->addHit(tempHit);
192 LOG_DEBUG <<
"StIstFastSimMaker::Make() -I- Loaded " << nIsthits <<
" ist hits. \n";
204 Double_t StIstFastSimMaker::distortHit(
const Double_t x,
const Double_t res,
const Double_t detLength)
207 if (fabs(x) > detLength) {
208 LOG_WARN <<
"distortHit() - Generated hit is outside detector sensor plane" << endm;
215 smeared_x = mRandom.Gaus(x, res);
217 while ( fabs(smeared_x) > detLength);
const int kIstNumSensorsPerLadder
6 sensor per one IST Ladder
virtual TObject * GetObject() const
The depricated method (left here for the sake of the backward compatibility)
Event data structure to hold all information from a Monte Carlo simulation. This class is the interfa...
virtual TDataSet * Find(const char *path) const