1 #include "StTpcHitMoverMaker.h"
2 #include "StTpcDb/StTpcDb.h"
4 #include "StDbUtilities/StMagUtilities.h"
5 #include "StDbUtilities/StTpcCoordinateTransform.hh"
6 #include "StEventTypes.h"
7 #ifdef __CORRECT_CHARGE__
8 #include "StDetectorDbMaker/St_tss_tssparC.h"
10 #include "StDetectorDbMaker/St_tpcSlewingC.h"
11 #include "StDetectorDbMaker/St_tpcPadConfigC.h"
12 #include "StDetectorDbMaker/St_tpcEffectiveGeomC.h"
13 #include "StDetectorDbMaker/St_tpcTimeBucketCorC.h"
14 #include "StDetectorDbMaker/St_spaceChargeCorC.h"
15 #include "StDetectorDbMaker/St_tpcChargeEventC.h"
16 #include "StDetectorDbMaker/St_tpcBXT0CorrEPDC.h"
17 #include "StEventUtilities/StEbyET0.h"
22 #define PrPP(A,B) if (_debug %10 > 1) {LOG_INFO << "StTpcHitMover::" << (#A) << "\t" << (#B) << " = \t" << (B) << endm;}
27 Int_t StTpcHitMover::_debug = 0;
29 StTpcHitMover::StTpcHitMover(
const Char_t *name) :
StMaker(name) {
30 gMessMgr->Info(
"StTpcHitMover::StTpcHitMover: constructor called");
33 StTpcHitMover::~StTpcHitMover() {
37 Int_t StTpcHitMover::Init() {
38 return StMaker::Init();
41 Int_t StTpcHitMover::InitRun(Int_t runnumber) {
46 void StTpcHitMover::FlushDB() {
47 SafeDelete(mTpcTransForm);
51 if (StMagUtilities::Instance() && StMagUtilities::Instance()->GetSpaceChargeMode() &&
52 St_spaceChargeCorR2C::instance()->IsMarked()) {
53 gMessMgr->Error() <<
"StTpcHitMover::Make questionable hit corrections" << endm;
57 Bool_t EmbeddingShortCut = IAttr(
"EmbeddingShortCut");
60 LOG_WARN <<
"StTpcHitMover::Make there is no StEvent " << endm;
66 double mTimeBinWidth = 1./StTpcDb::instance()->Electronics()->samplingFrequency();
68 double ebyeT0 = (IAttr(
"EbyET0") ? StEbyET0::Instance()->getT0(pEvent) / mTimeBinWidth : 0);
74 int doEPDT0Correction = StTpcBXT0CorrEPDC::instance()->nrows();
76 if (doEPDT0Correction) {
79 StSPtrVecEpdHit &epdHits = epdCol->epdHits();
80 int nEpdHits = epdHits.size();
82 for(
int i = 0; i < nEpdHits; i++) {
85 if (epdHit->
tile() > 9)
continue;
86 if (epdHit->
id() < 0) ew = -1;
88 if (epdHit->
adc() < 100)
continue;
90 if (TAC > maxTAC) maxTAC = TAC;
96 gMessMgr->Info() <<
"StTpcHitMover::Make use StEvent " << endm;
98 gMessMgr->Error() <<
"StTpcHitMover::Make TpcDb has not been instantiated " << endm;
101 if (pEvent && StMagUtilities::Instance() && StMagUtilities::Instance()->UsingDistortion(kAbortGap)) {
103 if (trg) St_tpcChargeEventC::instance()->findChargeTimes(trg->bunchCounter());
108 #ifdef __CORRECT_CHARGE__
110 Double_t gains[2] = {
111 tsspar->gain_in() / tsspar->wire_coupling_in() *tsspar->ave_ion_pot() *tsspar->scale(),
112 tsspar->gain_out()/ tsspar->wire_coupling_out()*tsspar->ave_ion_pot() *tsspar->scale()
115 if (TpcHitCollection) {
116 UInt_t numberOfSectors = TpcHitCollection->numberOfSectors();
117 for (UInt_t i = 0; i< numberOfSectors; i++) {
119 if (sectorCollection) {
120 Int_t sector = i + 1;
122 double driftVelocity = StTpcDb::instance()->DriftVelocity(sector);
124 Int_t numberOfPadrows = sectorCollection->numberOfPadrows();
125 for (
int j = 0; j< numberOfPadrows; j++) {
128 if (row > St_tpcPadConfigC::instance()->innerPadRows(sector)) io = 1;
129 Double_t padlength = (io == 0) ?
130 St_tpcPadConfigC::instance()->innerSectorPadLength(sector) :
131 St_tpcPadConfigC::instance()->outerSectorPadLength(sector);
134 StSPtrVecTpcHit &hits = rowCollection->hits();
135 UInt_t NoHits = hits.size();
137 for (UInt_t k = 0; k < NoHits; k++) {
139 #ifdef __CORRECT_CHARGE__
140 Double_t q = tpcHit->charge();
143 q = gains[io] * ((Double_t) tpcHit->adc());
146 if (EmbeddingShortCut && tpcHit->idTruth() && tpcHit->idTruth() < 10000 &&
147 tpcHit->qaTruth() > 95) {
150 if (! tpcHit->pad() && ! tpcHit->timeBucket()) {
151 StTpcLocalCoordinate coorL(tpcHit->position().x(),tpcHit->position().y(),tpcHit->position().z(),i+1,j+1);
152 moveTpcHit(coorL,coorG);
153 StThreeVectorF xyzF(coorG.position().x(),coorG.position().y(),coorG.position().z());
154 tpcHit->setPosition(xyzF);
156 Float_t pad = tpcHit->pad();
157 Float_t time = tpcHit->timeBucket();
158 if (! StTpcDb::IsOldScheme()) {
159 if (St_tpcTimeBucketCorC::instance()->getNumRows()) {
161 if (row <= St_tpcPadConfigC::instance()->innerPadRows(sector)) io = 1;
162 Double_t noTmbks = tpcHit->maxTmbk() - tpcHit->minTmbk() + 1;
163 time += St_tpcTimeBucketCorC::instance()->CalcCorrection(io, noTmbks);
167 if (doEPDT0Correction) time += StTpcBXT0CorrEPDC::instance()->getCorrection(maxTAC, driftVelocity, mTimeBinWidth);
173 transform(padcoord,coorS,kFALSE);
175 Double_t y = coorS.position().y();
176 for (Int_t l = 0; l < 3; l++) {
177 if (l == 1) coorS.position().setY(y + padlength/2);
178 else if (l == 2) coorS.position().setY(y - padlength/2);
179 transform(coorS,coorL);
180 moveTpcHit(coorL,coorG);
181 StThreeVectorF xyzF(coorG.position().x(),coorG.position().y(),coorG.position().z());
182 if (l == 1) tpcHit->setPositionU(xyzF);
183 else if (l == 2) tpcHit->setPositionL(xyzF);
184 else tpcHit->setPosition (xyzF);
194 if (StMagUtilities::Instance()) {
195 pEvent->runInfo()->setSpaceCharge(StMagUtilities::Instance()->CurrentSpaceChargeR2());
196 pEvent->runInfo()->setSpaceChargeCorrectionMode(StMagUtilities::Instance()->GetSpaceChargeMode());
203 Float_t pos[3] = {(Float_t) coorLTD.position().x(), (Float_t) coorLTD.position().y(), (Float_t) coorLTD.position().z()};
204 if ( StMagUtilities::Instance() ) {
206 StMagUtilities::Instance()->UndoDistortion(pos,posMoved,coorL.fromSector());
208 coorLTD.setPosition(newPos);
216 moveTpcHit(coorL,coorLTD);
217 transform(coorLTD,coorG); PrPP(moveTpcHit,coorLTD); PrPP(moveTpcHit,coorG);
StTpcHitMoverMaker - implements corrections on TPC hits.
int adc() const
ADC value [0,4095].
Stores information for tiles in STAR Event Plane Detector.
int tile() const
tile on the supersector [1,31]
int tac() const
TAC value [0,4095].