9 #include "DcaService.h"
10 #include "StXiMuDst.hh"
12 #include "TDataMember.h"
13 #include "TRealData.h"
14 #include "phys_constants.h"
15 #include "math_constants.h"
17 #include "StMessMgr.h"
20 Long_t GGetOffset(TClass* cl, TDataMember* that);
28 Long_t
DcaService::offsetDcaXiToPrimVertex = 0;
29 Long_t
DcaService::offsetDcaBachelorToPrimVertex = 0;
30 Long_t
DcaService::offsetDcaPosToPrimVertex = 0;
31 Long_t
DcaService::offsetDcaNegToPrimVertex = 0;
34 offsetDcaXiToPrimVertex = 0;
35 offsetDcaBachelorToPrimVertex = 0;
36 offsetDcaPosToPrimVertex = 0;
37 offsetDcaNegToPrimVertex = 0;
41 PrimVertex.setX(ev->primaryVertexX());
42 PrimVertex.setY(ev->primaryVertexY());
46 double DcaService::dcaToPrimVertex(
int charge, Float_t x, Float_t y, Float_t z,
47 Float_t px, Float_t py, Float_t pz) {
49 double pt = TMath::Sqrt(px*px + py*py);
50 double bcharge = ((double) charge)*B;
51 double curvature = TMath::Abs(bcharge)*C_D_CURVATURE/pt;
52 double dip = TMath::ATan(pz/pt);
53 int h = ((bcharge > 0) ? -1 : 1);
54 double phase = TMath::ATan2(py,px) - (h*C_PI_2);
58 Track.setParameters(curvature, dip, phase, Origin, h);
59 return Track.distance(PrimVertex);
62 double DcaService::dcaXiToPrimVertex(
StXiMuDst* xi) {
63 return dcaToPrimVertex(xi->
charge(),
65 xi->momXiX(), xi->momXiY(), xi->
momXiZ());
68 double DcaService::dcaBachelorToPrimVertex(
StXiMuDst* xi) {
69 return dcaToPrimVertex(xi->
charge(),
71 xi->momBachelorX(), xi->momBachelorY(), xi->
momBachelorZ());
74 double DcaService::dcaPosToPrimVertex(
StV0MuDst* v0) {
75 return dcaToPrimVertex(1,
77 v0->momPosX(), v0->momPosY(), v0->
momPosZ());
80 double DcaService::dcaNegToPrimVertex(
StV0MuDst* v0) {
81 return dcaToPrimVertex(-1,
83 v0->momNegX(), v0->momNegY(), v0->
momNegZ());
86 double DcaService::signIt() {
91 p1.y()-
Track.ycenter(),0);
93 PrimVertex.y()-
Track.ycenter(),0);
94 if (p3.mag2() > p2.mag2())
return -1.0;
98 void DcaService::replaceDca(TObject* obj, Float_t dca, Long_t& offset, TClass* cl,
99 const char* memname) {
101 offset = GGetOffset(cl,cl->GetDataMember(memname));
102 if (!offset) LOG_WARN << Form(
"OFFSET NOT FOUND: %s in %s\n",
103 memname,cl->GetName()) << endm;
105 Float_t* cf = (Float_t*) obj;
106 Float_t* dcaptr = (Float_t*) (((Long_t) cf) + offset);
110 void DcaService::replaceDcaXiToPrimVertex(
StXiMuDst* xi,Float_t dca) {
111 replaceDca(xi,dca,offsetDcaXiToPrimVertex,xi->Class(),
112 "mDcaXiToPrimVertex");
115 void DcaService::replaceDcaBachelorToPrimVertex(
StXiMuDst* xi,Float_t dca) {
116 replaceDca(xi,dca,offsetDcaBachelorToPrimVertex,xi->Class(),
117 "mDcaBachelorToPrimVertex");
120 void DcaService::replaceDcaPosToPrimVertex(
StV0MuDst* v0,Float_t dca) {
121 replaceDca(v0,dca,offsetDcaPosToPrimVertex,v0->Class(),
122 "mDcaPosToPrimVertex");
125 void DcaService::replaceDcaNegToPrimVertex(
StV0MuDst* v0,Float_t dca) {
126 replaceDca(v0,dca,offsetDcaNegToPrimVertex,v0->Class(),
127 "mDcaNegToPrimVertex");
132 for( Int_t j=0; j<mk->GetNXi(); j++ ) {
133 fixDcaXiToPrimVertex(mk->GetXi(j));
139 for( Int_t j=0; j<mk->GetNXi(); j++ ) {
140 fixSignedDcaXiToPrimVertex(mk->GetXi(j));
146 for( Int_t j=0; j<mk->GetNXi(); j++ ) {
147 fixSignedDcaBachelorToPrimVertex(mk->GetXi(j));
153 for( Int_t j=0; j<mk->GetNV0(); j++ ) {
154 fixSignedDcaPosToPrimVertex(mk->GetV0(j));
160 for( Int_t j=0; j<mk->GetNV0(); j++ ) {
161 fixSignedDcaNegToPrimVertex(mk->GetV0(j));
167 for( Int_t j=0; j<mk->GetNXi(); j++ ) {
169 fixSignedDcaXiToPrimVertex(xi);
170 fixSignedDcaBachelorToPrimVertex(xi);
171 fixSignedDcaPosToPrimVertex(xi);
172 fixSignedDcaNegToPrimVertex(xi);
178 for( Int_t j=0; j<mk->GetNV0(); j++ ) {
180 fixSignedDcaPosToPrimVertex(v0);
181 fixSignedDcaNegToPrimVertex(v0);
190 Long_t GGetOffset(TClass* cl, TDataMember* that) {
196 sprintf(dmbracket,
"%s[",that->GetName());
198 TIter next(cl->GetListOfRealData());
200 while ((rdm = (TRealData*)next())) {
201 char *rdmc = (
char*)rdm->GetName();
204 if (that->IsaPointer() && rdmc[0] ==
'*') rdmc++;
206 if (rdm->GetDataMember() != that)
continue;
207 if (strcmp(rdmc,that->GetName()) == 0) {
208 return rdm->GetThisOffset();
210 if (strcmp(rdm->GetName(),that->GetName()) == 0) {
211 if (rdm->IsObject()) {
212 return rdm->GetThisOffset();
215 if (strstr(rdm->GetName(),dmbracket)) {
216 return rdm->GetThisOffset();
Float_t momPosZ() const
Momentum components of pos. daughter.
static void fixSignedDcasV0s(StStrangeMuDstMaker *mk)
All DCAs for V0s.
Float_t momXiZ()
Momentum components of Xi/Omega at decay vertex.
Int_t charge() const
Particle charge.
Float_t primaryVertexZ() const
Primary vtx position coordinates.
Float_t momBachelorZ() const
Momentum components of bachelor.
Float_t decayVertexV0Z() const
Coordinates of decay vertex.
Float_t momNegZ() const
Momentum components of neg. daughter.
Float_t decayVertexXiZ() const
Coordinates of decay vertex.
static void fixSignedDcasXis(StStrangeMuDstMaker *mk)
All DCAs for Xis.