38 #include "StTpcFastSimMaker.h"
40 #include "StEventTypes.h"
41 #include "tables/St_HitError_Table.h"
42 #include "StTpcHitCollection.h"
46 #include "StTpcDb/StTpcDb.h"
47 #include "tables/St_g2t_vertex_Table.h"
48 #include "tables/St_g2t_track_Table.h"
49 #include "tables/St_g2t_tpc_hit_Table.h"
50 #include "StDbUtilities/StTpcCoordinateTransform.hh"
51 #include "StDbUtilities/StMagUtilities.h"
52 #include "StTpcDb/StTpcDb.h"
54 #include "TDataSetIter.h"
55 #include "StDetectorDbMaker/StiTpcInnerHitErrorCalculator.h"
56 #include "StDetectorDbMaker/StiTpcOuterHitErrorCalculator.h"
57 #include "StDetectorDbMaker/St_tpcPadConfigC.h"
61 static Int_t iBreak = 0;
62 mExB = StMagUtilities::Instance();
63 if (! gRandom) gRandom =
new TRandom();
66 if (! rEvent) { LOG_WARN <<
"No StEvent on input, bye bye" << endm;
return kStWarn; }
70 rEvent->setTpcHitCollection(rCol);
72 St_g2t_tpc_hit *
g2t_tpc_hit = (St_g2t_tpc_hit *) GetDataSet(
"geant/g2t_tpc_hit");
74 LOG_WARN <<
"No g2t_tpc_hit on input, bye bye" << endm;
return kStWarn;
76 Int_t Nhits = g2t_tpc_hit->GetNRows();
78 St_g2t_track *g2t_track = (St_g2t_track *) GetDataSet(
"geant/g2t_track");
79 g2t_track_st *tpc_track = 0;
80 if (g2t_track) tpc_track = g2t_track->GetTable();
81 St_g2t_vertex *g2t_ver = (St_g2t_vertex *) GetDataSet(
"geant/g2t_vertex");
82 g2t_vertex_st *gver = 0;
83 if (g2t_ver) gver = g2t_ver->GetTable();
84 g2t_tpc_hit_st *tpc_hit = g2t_tpc_hit->GetTable();
86 for (Int_t i = 0; i < Nhits; i++) {
87 if (tpc_hit[i].volume_id > 100000)
continue;
88 Int_t Id = tpc_hit[i].track_p;
91 id3 = tpc_track[Id-1].start_vertex_p;
92 Int_t sector = (tpc_hit[i].volume_id%10000)/100;
93 Int_t row = tpc_hit[i].volume_id%100;
96 transform(dirG, dirL, sector, row);
99 transform(coorG,coorLT,sector,row);
102 Float_t pos[3] = {(Float_t) coorLTD.position().x(),(Float_t) coorLTD.position().y(),(Float_t) coorLTD.position().z()};
107 coorLTD.setPosition(newPos);
110 transform(coorLTD,coorLS);
111 Double_t xyzL[3] = {coorLS.position().x(),coorLS.position().y(),coorLS.position().z()};
112 if (TMath::Abs(xyzL[1]-transform.yFromRow(sector,row)) > 0.1000) {
114 LOG_DEBUG <<
"Id: " << tpc_hit[i].volume_id
115 <<
"\txyzL :" << xyzL[0] <<
"\t" << xyzL[1] <<
"\t" << xyzL[2]
116 <<
"\tdR :" << xyzL[1]-transform.yFromRow(sector,row) << endm;
120 Double_t Z = xyzL[2];
121 Double_t eta = TMath::PiOver2() - TMath::Abs(dirL.position().phi());
122 Double_t tanl = dirL.position().z()/dirL.position().perp();
123 Double_t sigmaY2, sigmaZ2;
124 if (row <= St_tpcPadConfigC::instance()->innerPadRows(sector))
125 StiTpcInnerHitErrorCalculator::instance()->
calculateError(Z,eta,tanl,sigmaY2, sigmaZ2);
127 StiTpcOuterHitErrorCalculator::instance()->
calculateError(Z,eta,tanl,sigmaY2, sigmaZ2);
128 Double_t sigmaY = TMath::Sqrt(sigmaY2);
129 Double_t sigmaZ = TMath::Sqrt(sigmaZ2);
131 xyzL[0] += gRandom->Gaus(0, sigmaY);
132 xyzL[2] += gRandom->Gaus(0, sigmaZ);
134 coorLS.setPosition(newPosition);
136 transform(coorLS,Pad,kFALSE,kTRUE);
138 if (gver) tof = gver[id3-1].ge_tof;
139 tof += tpc_hit[i].tof;
140 Float_t timebkt = Pad.timeBucket() + 1.e6*gStTpcDb->Electronics()->samplingFrequency()*tof;
141 if (timebkt < 0 || timebkt > 512)
continue;
143 Short_t pad = newPad.pad();
144 Short_t tmb = newPad.timeBucket();
146 transform(newPad,global,kFALSE);
150 StTpcHit *tpcHit =
new StTpcHit(global.position(),e, hw,TMath::Abs(tpc_hit[i].de)
152 , tpc_hit[i].track_p, 100
154 , pad, pad+1,tmb,tmb+1
155 , newPad.pad(), newPad.timeBucket()
157 if (Debug() > 1) tpcHit->Print();
158 rCol->addHit(tpcHit);
virtual void calculateError(Double_t _z, Double_t _eta, Double_t _tanl, Double_t &ecross, Double_t &edip, Double_t fudgeFactor=1) const
coeff[6] = 0:intrinsicY 1: driftY 2: crossY 3:intrinsicZ 4: driftZ 5: crossZ
virtual void DoDistortion(const Float_t x[], Float_t Xprime[], Int_t Sector=-1)
Main Entry Point for requests to DO the E and B field distortions (for simulations) ...