8 #include "St_sfs_Maker.h"
10 #include "StEventTypes.h"
11 #include "tables/St_HitError_Table.h"
12 #include "StSvtHitCollection.h"
16 #include "StSvtDbMaker/StSvtDbMaker.h"
17 #include "tables/St_g2t_svt_hit_Table.h"
18 #include "TGeoMatrix.h"
21 Int_t St_sfs_Maker::InitRun(Int_t RunNo)
24 St_HitError *tableSet = (St_HitError *) GetDataBase(
"Calibrations/tracker/svtHitError");
25 HitError_st* hitError = tableSet->GetTable();
26 mResXSvt = TMath::Sqrt(hitError->coeff[0]);
27 mResZSvt = TMath::Sqrt(hitError->coeff[3]);
28 LOG_DEBUG <<
"Smearing SVT hits by " << mResXSvt <<
" " << mResZSvt <<
" cm in the SVT " << endm;
34 if (! gRandom) gRandom =
new TRandom();
37 if (! rEvent) { LOG_WARN <<
"No StEvent on input, bye bye" << endm;
return kStWarn; }
41 rEvent->setSvtHitCollection(rCol);
44 St_g2t_svt_hit *g2t_svt_hit = (St_g2t_svt_hit *) geant(
"g2t_svt_hit");
46 LOG_WARN <<
"No g2t_svt_hit on input, bye bye" << endm;
return kStWarn;
49 g2t_svt_hit_st *g2t = g2t_svt_hit->GetTable();
50 Int_t Nhits = g2t_svt_hit->GetNRows();
52 THashList *rotMHash = gStSvtDbMaker->GetRotations();
53 if (! rotMHash) {LOG_WARN <<
" No list of Rotation from StSvtDbMaker " << endm;
return kStWarn;}
55 for (Int_t i = 0; i < Nhits; i++) {
56 TGeoHMatrix *comb = (TGeoHMatrix *) rotMHash->FindObject(Form(
"R%04i",g2t[i].volume_id%10000));
57 if (! comb) { LOG_WARN <<
"No rotation matrix for wafer =" << g2t[i].volume_id << endm;
continue;}
58 Double_t xyzG[3] = {g2t[i].x[0],g2t[i].x[1],g2t[i].x[2]};
60 comb->MasterToLocal(xyzG,xyzL);
61 if (Debug() && TMath::Abs(xyzL[2]) > 0.0100) {
62 cout <<
"Id: " << g2t[i].volume_id
63 <<
"\txyzL :" << xyzL[0] <<
"\t" << xyzL[1] <<
"\t" << xyzL[2] << endl;
66 xyzL[0] += gRandom->Gaus(0, mResXSvt);
67 xyzL[1] += gRandom->Gaus(0, mResZSvt);
68 comb->LocalToMaster(xyzL,xyzG);
70 Int_t ladderID = g2t[i].volume_id%100;
71 Int_t waferID = (g2t[i].volume_id/100)%10;
72 Int_t layerID = (g2t[i].volume_id%10000)/1000;
73 Int_t barrelID = (layerID-1)/2 + 1;
75 if (xyzL[0] >= 0) hybridID = 2;
76 static const Int_t NumberOfHybrids = 2;
77 static const Int_t NumberOfWafers[3] = {4, 6, 7};
78 static const Int_t NumberOfLadders[3] = {8,12,16};
79 Int_t index = ((ladderID-1)*NumberOfWafers[barrelID-1] + (waferID-1))*NumberOfHybrids + (hybridID-1);
81 case 3: index += NumberOfLadders[barrelID-3]*NumberOfWafers[barrelID-3]*NumberOfHybrids;
82 case 2: index += NumberOfLadders[barrelID-2]*NumberOfWafers[barrelID-2]*NumberOfHybrids;
85 LOG_ERROR <<
"There is NO barrel number " << barrelID <<
" !!!" << endm;
92 hw += (1L<<4)*(index);
94 svtHit->setHardwarePosition(hw);
95 svtHit->setLocalPosition(xyzL[0],xyzL[1]);
96 svtHit->setCharge(g2t[i].de);
97 svtHit->setIdTruth(g2t[i].track_p,100);
99 svtHit->setFitFlag(0);
101 svtHit->setPosition(pos);
102 rCol->addHit(svtHit);