27 #include "TDirectory.h"
28 #include "LaserEvent.h"
30 #include "StProbPidTraits.h"
31 #include "StDedxPidTraits.h"
34 #include "StPrimaryVertex.h"
36 #include "StPrimaryTrack.h"
37 #include "StGlobalTrack.h"
38 #include "StTrackNode.h"
39 #include "StTpcDb/StTpcDb.h"
40 #include "StDbUtilities/StTpcCoordinateTransform.hh"
41 #include "StEventTypes.h"
42 #include "TGeoMatrix.h"
43 #include "StDetectorDbMaker/St_tpcPadConfigC.h"
50 TClonesArray *LaserEvent::fgVertices = 0;
51 TClonesArray *LaserEvent::fgTracks = 0;
52 TClonesArray *LaserEvent::fgHits = 0;
53 TClonesArray *LaserEvent::fgFit = 0;
55 LaserB::LaserB(
const LaserRaft &laser) : Sector(laser.Sector), Raft(laser.Raft), Bundle(laser.Bundle), Mirror(laser.Mirror),
56 XyzL(laser.XyzL), XyzU(laser.XyzU), XyzB(laser.XyzB),
57 dirL(laser.dirL), dirU(laser.dirU),dirB(laser.dirB),
58 Theta(laser.Theta), Phi(laser.Phi){
61 LaserEvent::LaserEvent()
67 if (!fgVertices) fgVertices =
new TClonesArray(
"Vertex", 1000);
68 fVertices = fgVertices;
70 if (!fgTracks) fgTracks =
new TClonesArray(
"Track", 1000);
74 if (!fgHits) fgHits =
new TClonesArray(
"Hit", 1000);
78 if (!fgFit) fgFit =
new TClonesArray(
"FitDV", 1000);
79 fgFit->ExpandCreate(12);
84 LaserEvent::~LaserEvent()
91 if (! vertex)
return 0;
92 TClonesArray &vertices = *fVertices;
94 const TGeoHMatrix &Tpc2Global = gStTpcDb->Tpc2GlobalMatrix();
95 Tpc2Global.MasterToLocal(vx->Xyz.xyz(),vx->XyzL.xyz());
100 if (! track)
return 0;
101 TClonesArray &tracks = *fTracks;
102 Track *t =
new(tracks[fNtrack++])
Track(sector, track, laser, z);
108 TClonesArray &hits = *fHits;
109 Hit *t =
new(hits[fNhit++])
Hit(hit,trackKey);
113 void LaserEvent::AddTrackFit(
Track *t) {
115 Int_t sector = t->Laser.Sector;
116 Int_t bundle = t->Laser.Bundle;
117 Int_t mirror = t->Laser.Mirror;
118 Int_t s2 = (sector-1)/2;
119 if (s2 >= 0 && s2 < 12) {
120 TClonesArray &fits = *fFit;
122 fit->Sector = sector;
124 Double32_t x = t->Laser.XyzL.z();
125 Double32_t y = t->XyzPL.z() - x;
129 fit->Bundle[N] = bundle;
130 fit->Mirror[N] = mirror;
136 void LaserEvent::Clear(Option_t *option) {
137 fTracks->Clear(option);
138 fHits->Clear(option);
139 fVertices->Clear(option);
140 fgFit->Clear(option);
143 void LaserEvent::Reset() {
145 SafeDelete(fgTracks);
147 SafeDelete(fgVertices);
152 void LaserEvent::SetHeader(Int_t i, Int_t run, Int_t date, Int_t time)
157 fEvtHdr.Set(i, run, date, time);
160 void LaserEvent::SetHeader(Int_t i, Int_t run, Int_t date, Int_t time,
161 Float_t tzero, Float_t drivel, Float_t clock)
163 SetHeader(i, run, date, time);
164 fEvtHdr.SetE(tzero, drivel, clock);
167 void LaserEvent::SetHeader(Int_t i, Int_t run, Int_t date, Int_t time,
168 Float_t tzero, Float_t drivel, Float_t clock, Float_t trigger)
170 SetHeader(i, run, date, time);
171 fEvtHdr.SetE(tzero, drivel, clock, trigger);
174 Track::Track(Int_t sector,
StTrack *track,
LaserB *theLaser, Double_t z) :
175 Flag(0),mType(kUndefinedVtxId), mSector(sector),
176 fpTInv(-999), thePath(0), dPhi(-999), dTheta(-999), zLastHit(z) {
183 fpTInv = fgeoOut.charge()/g3.perp();
184 fTheta = fgeoOut.momentum().theta();
185 fPhi = fgeoOut.momentum().phi();
187 thePath = helixO.
pathLength(Laser.XyzG.x(),Laser.XyzG.y());
188 if (theLaser) Laser = *theLaser;
194 mType = vertex->type();
195 Vertex = vertex->position();
199 mKey = gTrack->key();
200 mFlag = gTrack->flag();
201 mNumberOfPossiblePointsTpc = gTrack->numberOfPossiblePoints(kTpcId);
202 mImpactParameter = gTrack->impactParameter();
203 mLength = gTrack->length();
206 mNumberOfFitPointsTpc = fitTraits.numberOfFitPoints(kTpcId);
207 mPrimaryVertexUsedInFit = fitTraits.primaryVertexUsedInFit();
209 StSPtrVecTrackPidTraits &traits = gTrack->pidTraits();
210 unsigned int size = traits.size();
212 for (
unsigned int i = 0; i < size; i++) {
213 if (! traits[i])
continue;
214 if ( traits[i]->IsZombie())
continue;
216 if (pid && pid->detector() == kTpcId && pid->method() == kTruncatedMeanId) {
217 fNdEdx = pid->numberOfPoints();
226 void Track::SetPredictions(TGeoHMatrix *Raft2Tpc, TGeoHMatrix *Bundle2Tpc, TGeoHMatrix *Mirror2Tpc) {
228 if ( Laser.Sector < 1 || Laser.Sector > 24)
return;
230 const TGeoHMatrix &Tpc2Global = gStTpcDb->Tpc2GlobalMatrix();
232 thePath = helixO.
pathLength(Laser.XyzG.x(),Laser.XyzG.y());
233 XyzP = helixO.at(thePath);
234 Tpc2Global.MasterToLocal(XyzP.xyz(),XyzPL.xyz());
237 Tpc2Global.MasterToLocalVect(dirP.xyz(),dirPL.xyz());
240 Raft2Tpc->MasterToLocal(XyzPL.xyz(),XyzPU.xyz());
241 Raft2Tpc->MasterToLocalVect(dirPL.xyz(),dirPU.xyz());
242 dU = XyzPU - Laser.XyzU;
245 Bundle2Tpc->MasterToLocal(XyzPL.xyz(),XyzPB.xyz());
246 Bundle2Tpc->MasterToLocalVect(dirPL.xyz(),dirPB.xyz());
249 Mirror2Tpc->MasterToLocal(XyzPL.xyz(),XyzPM.xyz());
250 Mirror2Tpc->MasterToLocalVect(dirPL.xyz(),dirPM.xyz());
255 Vertex::Vertex(
StPrimaryVertex *vertex) : mType(kUndefinedVtxId), WestEast(0),
256 Xyz(), numberOfDaughter(0){
258 mType = vertex->type();
259 Xyz = vertex->position();
260 numberOfDaughter = vertex->numberOfDaughters();
261 if (numberOfDaughter > 24) {
262 for (UInt_t i = 0; i < numberOfDaughter; i++) {
263 StTrack *track = vertex->daughter(i);
264 if (! track )
continue;
265 StPtrVecHit hvec = track->detectorInfo()->hits();
266 for (
unsigned int j=0; j<hvec.size(); j++) {
267 if (hvec[j]->detector() != kTpcId)
continue;
269 Int_t sector = tpcHit->sector();
270 Int_t WE = sector <= 12 ? 1 : 2;
271 if (! WestEast) WestEast = WE;
273 if (WE != WestEast) {
284 Int_t Track::Matched() {
289 if (Flag != 2)
return iok;
291 if (Laser.Sector < 1 || Laser.Sector > 24 ||
292 Laser.Mirror < 1 || Laser.Mirror > 7)
return iok;
295 if (TMath::Abs(dU.x()) > 0.05) status |= 1 << 3;
296 if (TMath::Abs(dU.y()) > 0.05) status |= 1 << 4;
297 if (thePath < 5 || thePath > 25) status |= 1 << 5;
298 if (mNumberOfFitPointsTpc < 25) status |= 1 << 6;
299 dTheta = Laser.ThetaG-fgeoOut.dipAngle()-TMath::Pi()/2;
301 if (TMath::Abs(dTheta) > 0.030) status |= 1 << 7;;
303 dPhi = Laser.PhiG - fgeoOut.psi();
304 if (dPhi >= TMath::Pi()) dPhi -= 2*TMath::Pi();
305 if (dPhi <= -TMath::Pi()) dPhi += 2*TMath::Pi();
308 if ( TMath::Abs(dPhi) > 0.020) status |= 1 << 9;
310 static const Double_t pTInv0 = 4.78815e-03;
311 static const Double_t DpTInv0 = 9.75313e-03;
312 if (TMath::Abs(fpTInv - pTInv0) > 3.0*DpTInv0) status |= 1 << 10;
313 return iok + 10*status;
316 Hit::Hit(
StTpcHit *tpcHit, Int_t trKey) : sector(0),row(0),charge(0),flag(0),usedInFit(0), trackKey(trKey) {
320 sector = tpcHit->sector();
321 row = tpcHit->padrow();;
322 charge = tpcHit->charge();
323 flag = tpcHit->flag();
324 usedInFit = tpcHit->usedInFit();
325 xyz = tpcHit->position();
329 transform(glob,local,tpcHit->sector(),tpcHit->padrow());
330 xyzL =
StThreeVectorF(local.position().x(),local.position().y(),local.position().z());
332 transform(glob,localTpc,tpcHit->sector(),tpcHit->padrow());
333 xyzTpcL =
StThreeVectorF(localTpc.position().x(),localTpc.position().y(),localTpc.position().z());
335 gStTpcDb->SupS2Tpc(tpcHit->sector()).MasterToLocal(localTpc.position().xyz(),xyzs);
337 pad = tpcHit->pad() - St_tpcPadConfigC::instance()->padsPerRow(sector,row)/2 - 1;
338 tbk = tpcHit->timeBucket();
pair< double, double > pathLength(double r) const
path length at given r (cylindrical r)