1 #include "StMuEmcPosition.h"
3 #include "SystemOfUnits.h"
4 #include "PhysicalConstants.h"
5 #include "StPhysicalHelixD.hh"
7 #include "StMcEvent.hh"
8 #include "StMcEventTypes.hh"
9 #include "StMcEventMaker/StMcEventMaker.h"
11 #include "StEventTypes.h"
12 #include "StEmcUtil/geometry/StEmcGeom.h"
13 #include "StEEmcUtil/EEmcGeom/EEmcGeomSimple.h"
16 #include "StMuDSTMaker/COMMON/StMuTrack.h"
23 mGeom[0] = StEmcGeom::getEmcGeom(
"bemc");
24 mGeom[1] = StEmcGeom::getEmcGeom(
"bprs");
25 mGeom[2] = StEmcGeom::getEmcGeom(
"bsmde");
26 mGeom[3] = StEmcGeom::getEmcGeom(
"bsmdp");
29 StMuEmcPosition::~StMuEmcPosition()
34 const StMuTrack*
track,
double magField,
double radius,
int option)
38 *momentumAtFinal=Zero;
49 double charge = track->
charge();
53 s1 = pathLength.first;
54 s2 = pathLength.second;
59 if (finite(s1) == 0 && finite(s2) == 0) {
return kFALSE;}
64 if (s1 >= 0 && s2 >= 0) {s = s1; goProj = kTRUE; }
65 if (s1 >= 0 && s2 < 0) { s = s1; goProj = kTRUE; }
66 if (s1 < 0 && s2 >= 0) { s = s2; goProj = kTRUE; }
72 if (s1 <= 0 && s2 <= 0) { s = s2; goProj = kTRUE; }
73 if (s1 <= 0 && s2 > 0) { s = s1; goProj = kTRUE; }
74 if (s1 > 0 && s2 <= 0) { s = s2; goProj = kTRUE; }
79 *atFinal = helix.at( s );
80 *momentumAtFinal = helix.momentumAt( s, magField*tesla );
81 if (charge == 0) *momentumAtFinal = momentum;
87 StMcTrack* mcTrack,
double magField,
double radius,
int option)
91 *momentumAtFinal=Zero;
95 double charge = mcTrack->particleDefinition()->charge();
101 s1 = pathLength.first;
102 s2 = pathLength.second;
107 if (finite(s1) == 0 && finite(s2) == 0) {
return kFALSE;}
112 if (s1 >= 0 && s2 >= 0) { s = s1; goProj = kTRUE; }
113 if (s1 >= 0 && s2 < 0) { s = s1; goProj = kTRUE; }
114 if (s1 < 0 && s2 >= 0) { s = s2; goProj = kTRUE; }
120 if (s1 <= 0 && s2 <= 0) { s = s2; goProj = kTRUE; }
121 if (s1 <= 0 && s2 > 0) { s = s1; goProj = kTRUE; }
122 if (s1 > 0 && s2 <= 0) { s = s2; goProj = kTRUE; }
127 *atFinal = helix.at( s );
128 *momentumAtFinal = helix.momentumAt( s, magField*tesla );
129 if (charge == 0) *momentumAtFinal = momentum;
136 return trackOnBEmc(position, momentum, track, magField, emcRadius);
151 float xO = origin.x();
152 float yO = origin.y();
153 float distToOrigin = ::sqrt( ::pow(xO, 2) + ::pow(yO, 2) );
154 if ( distToOrigin < emcRadius )
156 bool projTrackOk =
projTrack( position, momentum, track, magField, emcRadius );
159 int m = 0, e = 0, s = 0;
160 float phi = position->phi();
161 float eta = position->pseudoRapidity();
162 if ( mGeom[0]->getBin(phi, eta, m, e, s) == 0 && s != -1 )
return kTRUE;
170 StMcTrack* mcTrack,
double magField,
double emcRadius )
172 return trackOnBEmc(position, momentum, mcTrack, magField, emcRadius );
176 StMcTrack* mcTrack,
double magField,
double emcRadius )
178 float startVertexX = mcTrack->startVertex()->position().x();
179 float startVertexY = mcTrack->startVertex()->position().y();
180 float startVtxToOrigin = ::sqrt( ::pow( startVertexX, 2 ) + ::pow( startVertexY, 2 ) );
182 if ( !mcTrack->stopVertex() && startVtxToOrigin < emcRadius )
184 bool projTrackOk =
projTrack( position, momentum, mcTrack, magField, emcRadius );
187 int m = 0, e = 0, s = 0;
188 float phi = position->phi();
189 float eta = position->pseudoRapidity();
190 if ( mGeom[0]->getBin(phi, eta, m, e, s) == 0 && s != -1 )
return kTRUE;
195 float stopVtxToOrigin = -1;
196 if ( mcTrack->stopVertex() )
198 float stopVertexX = mcTrack->stopVertex()->position().x();
199 float stopVertexY = mcTrack->stopVertex()->position().y();
200 stopVtxToOrigin = ::sqrt( ::pow( stopVertexX,2 ) + ::pow(stopVertexY,2) );
203 if (stopVtxToOrigin >= emcRadius)
205 bool projTrackOk =
projTrack( position, momentum, mcTrack, magField, emcRadius );
208 int m = 0, e = 0, s = 0;
209 float phi = position->phi();
210 float eta = position->pseudoRapidity();
211 if ( mGeom[0]->getBin(phi, eta, m, e, s) == 0 && s != -1 )
return kTRUE;
221 if (track->
eta() < 0)
return false;
223 if (fabs(outerHelix.
origin().z()) > fabs(z))
return false;
227 if (!finite(s))
return false;
228 if (s == StHelix::NoSolution)
return false;
229 if (s < 0)
return false;
230 *position = outerHelix.at(s);
231 int sector, subsector, etabin;
233 *momentum = outerHelix.momentumAt(s, magField*tesla);
239 *towerEta = 0; *towerPhi = 0;
240 float tempTowerEta = 0, tempTowerPhi = 0;
241 int m = 0, e = 0, s = 0, towerId = -1;
243 mGeom[0]->
getBin(phi, eta, m, e, s);
246 mGeom[0]->getId(m, e, s, towerId);
247 mGeom[0]->getEtaPhi(towerId, tempTowerEta, tempTowerPhi);
248 *towerEta = tempTowerEta;
249 *towerPhi = tempTowerPhi;
256 mGeom[0]->
getBin( Phi, Eta, m, e, s );
267 if(id<1 || id>4800)
return 0;
269 mGeom[0]->
getBin(
id,m,e,s);
275 if(m<1 || m>120)
return 0;
276 if(e<1 || e>20)
return 0;
277 if(s<1 || s>2)
return 0;
278 return getNextId(1,m,e,s,nTowersdEta,nTowersdPhi);
283 if(det<1 || det>4)
return 0;
284 if(m<1 || m>120)
return 0;
285 if(s<1 || s>mGeom[det-1]->NSub())
return 0;
286 if(e<1 || e>mGeom[det-1]->NEta())
return 0;
292 int NE=mGeom[det-1]->NEta();
293 int NS=mGeom[det-1]->NSub();
295 if(abs(ef)>NE)
return 0;
313 }
while(sf<=0 || sf>NS);
322 mGeom[det-1]->getId(mf, ef, sf, rid);
323 mGeom[det-1]->getEtaPhi(rid, eta, phi);
324 mGeom[det-1]->
getBin(phi,-eta,mf,etmp,stmp);
328 if(mf<1 || mf>120)
return 0;
329 if(ef<1 || ef>NE)
return 0;
330 if(sf<1 || sf>NS)
return 0;
331 mGeom[det-1]->getId(mf, ef, sf, rid);
337 int nTowersdEta,
int nTowersdPhi )
341 float towerEta = 0, towerToTrackdEta = 0;
342 float towerPhi = 0, towerToTrackdPhi = 0;
343 float mdistTowerToTrack = 0;
345 towerId =
getNextTowerId( trackEta, trackPhi, nTowersdEta, nTowersdPhi );
349 mGeom[0]->getEtaPhi(towerId, towerEta, towerPhi);
350 towerToTrackdEta = towerEta-trackEta;
351 towerToTrackdPhi = towerPhi-trackPhi;
353 mdistTowerToTrack = ::sqrt( ::pow(towerToTrackdEta, 2) + ::pow(towerToTrackdPhi, 2) );
355 return mdistTowerToTrack;
364 if(TowerId<1 || TowerId>4800)
return Zero;
366 float xTower,yTower,zTower;
368 mGeom[0]->getXYZ(TowerId, xTower, yTower, zTower);
372 return PositionFromVertex;
378 if(TowerId<1 || TowerId>4800)
return Zero;
380 float xTower,yTower,zTower;
382 mGeom[0]->getXYZ(TowerId, xTower, yTower, zTower);
386 return PositionFromVertex;
404 return p.pseudoRapidity();
410 return p.pseudoRapidity();
float getPhiFromVertex(const StThreeVectorF &, int)
Return phi of the tower considering the collision vertex.
float getDistTowerToTrack(double, double, int, int)
Return distance from track to center of one tower.
static EEmcGeomSimple & Instance()
returns a reference to a static instance of EEmcGeomSimple
Monte Carlo Track class All information on a simulated track is stored in this class: kinematics...
float getEtaFromVertex(const StThreeVectorF &, int)
Return eta of the tower considering the collision vertex.
bool trackOnBEmc(StThreeVectorD *, StThreeVectorD *, const StMuTrack *, double, double=225.405)
StjTrack projection utility.
pair< double, double > pathLength(double r) const
path length at given r (cylindrical r)
Short_t charge() const
Returns charge.
StThreeVectorF getPosFromVertex(const StThreeVectorF &, int)
Return Position from collision vertex.
int getTowerEtaPhi(double, double, float *, float *)
Return tower eta/phi.
Double_t eta() const
Returns pseudo rapidity at point of dca to primary vertex.
float getThetaFromVertex(const StThreeVectorF &, int)
Return theta of the tower considering the collision vertex.
const StThreeVector< double > & origin() const
-sign(q*B);
const StThreeVectorF & momentum() const
Returns 3-momentum at dca to primary vertex.
bool trackOnEEmc(StThreeVectorD *position, StThreeVectorD *momentum, const StMuTrack *track, double magField=0.5, double z=kEEmcZSMD) const
Project track into EEMC at SMD depth (magnetic field must be in Tesla)
Int_t getBin(const Float_t phi, const Float_t eta, Int_t &m, Int_t &e, Int_t &s) const
StPhysicalHelixD outerHelix() const
Returns outer helix (last measured point)
int getNextId(int, int, int, int, int, int)
Return neighbor id (works for all detectors 1=bemc, 2=bprs, 3=bsmde, 4=bsmdp)
bool projTrack(StThreeVectorD *, StThreeVectorD *, const StMuTrack *, double, double=225.405, int=1)
StjTrack projection utility.
bool trackOnEmc(StThreeVectorD *, StThreeVectorD *, const StMuTrack *, double, double=225.405)
StjTrack projection utility.
int getNextTowerId(float, float, int, int)
Return neighbor tower id's.