-
Notifications
You must be signed in to change notification settings - Fork 0
/
tstal.C
154 lines (139 loc) · 5.19 KB
/
tstal.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#if !defined(__CINT__) || defined(__MAKECINT__)
#include <TGeoMatrix.h>
#include <TMath.h>
#include "AliGeomManager.h"
#include "AliAlignObjParams.h"
#endif
void DPosTraDParLoc(const double *tra, double* deriv);
void GetDeltaMatrixLoc(TGeoHMatrix& deltaM, const Double_t *delta);
void GetModifiedMatrixG2L(TGeoHMatrix& matMod, const Double_t *delta);
void GetModifiedMatrixT2L(TGeoHMatrix& matMod, const Double_t *delta);
double fXTracking,alpTra,dtdp[6*3];
TGeoHMatrix fMatT2L,fMatG2T,fMatG2L;
void tstal(double xg,double yg,double zg, int vid)
{
if (!AliGeomManager::GetGeometry()) AliGeomManager::LoadGeometry("data/geometry.root");
//
fMatT2L = *AliGeomManager::GetTracking2LocalMatrix(vid);
fMatG2L = *AliGeomManager::GetMatrix(vid);
AliGeomManager::GetTrackingMatrix(vid,fMatG2T);
//
double glo[3] = {xg,yg,zg};
//
double tmp[3],tra[3],loc[3]={0,0,0};
double* trans = fMatG2T.GetTranslation();
fXTracking = TMath::Sqrt(trans[0]*trans[0]+trans[1]*trans[1]);
loc[0] = 100; loc[1] = 0;
fMatG2T.LocalToMaster(loc,tmp);
alpTra = TMath::ATan2(tmp[1],tmp[0]);
printf("Xtracking:%e alpTracking: %e\n",fXTracking, alpTra);
//
printf("Global: %+e %+e %+e\n",glo[0],glo[1],glo[2]);
fMatG2L.MasterToLocal(glo,loc);
printf("Local : %+e %+e %+e\n",loc[0],loc[1],loc[2]);
//
fMatT2L.MasterToLocal(loc,tra);
printf("TrackF: %+e %+e %+e\n",tra[0]+fXTracking,tra[1],tra[2]);
//
fMatG2T.MasterToLocal(glo,tmp);
printf("TrackFF: %+e %+e %+e\n",tmp[0]+fXTracking,tmp[1],tmp[2]);
//
// derivative of tracking coordinates vs local parameters
DPosTraDParLoc(tra, dtdp);
for (int i=0;i<6;i++) {
double *curd = dtdp + i*3;
printf("dXYZtr/dP_%d:\t%+e\t%+e\t%+e\n",i,curd[0],curd[1],curd[2]);
}
}
void DPosTraDParLoc(const double *tra, double* deriv)
{
// Jacobian of position in sensor tracking frame (tra) vs sensor local parameters.
// Result is stored in array deriv as linearized matrix 6x3
const int kMaxParGeom = 6;
const double kDelta[kMaxParGeom]={0.1,0.1,0.1,0.5,0.5,0.5};
double delta[kMaxParGeom],loc[3],pos0[3],pos1[3],pos2[3],pos3[3];
TGeoHMatrix matMod;
//
fMatT2L.MasterToLocal(tra,loc);
for (int ip=kMaxParGeom;ip--;) delta[ip] = 0;
for (int ip=kMaxParGeom;ip--;) {
//
double var = kDelta[ip];
delta[ip] -= var;
GetModifiedMatrixT2L(matMod, delta);
matMod.LocalToMaster(loc,pos0); // varied position in tracking frame
//
delta[ip] += 0.5*var;
GetModifiedMatrixT2L(matMod, delta);
matMod.LocalToMaster(loc,pos1); // varied position in tracking frame
//
delta[ip] += var;
GetModifiedMatrixT2L(matMod, delta);
matMod.LocalToMaster(loc,pos2); // varied position in tracking frame
//
delta[ip] += 0.5*var;
GetModifiedMatrixT2L(matMod, delta);
matMod.LocalToMaster(loc,pos3); // varied position in tracking frame
//
delta[ip] = 0;
double *curd = deriv + ip*3;
for (int i=3;i--;) curd[i] = (8.*(pos2[i]-pos1[i]) - (pos3[i]-pos0[i]))/6./var;
}
//
}
//__________________________________________________________________
void GetDeltaMatrixLoc(TGeoHMatrix& deltaM, const Double_t *delta)
{
// prepare delta matrix for the sensitive volume from
// local delta vector (TGeoMatrix convension): dx,dy,dz,phi,theta,psi
const double *tr=&delta[0],*rt=&delta[3]; // translation(cm) and rotation(degree)
AliAlignObjParams tempAlignObj;
tempAlignObj.SetRotation(rt[0],rt[1],rt[2]);
tempAlignObj.SetTranslation(tr[0],tr[1],tr[2]);
tempAlignObj.GetMatrix(deltaM);
//
}
//__________________________________________________________________
void GetDeltaMatrixTra(TGeoHMatrix& deltaM, const Double_t *delta)
{
// prepare delta matrix for the sensitive volume from delta vector
// of tracking frame: shift by dx,dy,dz THEN rotation by phi,theta,psi
// Note that this is opposite to TGeo convention (1st rotation then translation)
//
// RS: do we need to shift by fXTracking ?
const double *tr=&delta[0],*rt=&delta[3]; // translation(cm) and rotation(degree)
TGeoHMatrix trM,rtM;
deltaM.Clear();
deltaM.SetTranlation(tr);
// deltaM.SetDx(delta[0]+fXTracking);
// deltaM.SetDy(delta[1]);
// deltaM.SetDy(delta[2]);
rtM.SetRotation(rt);
deltaM.MultiplyLeft(rtM);
//
}
//__________________________________________________________________
void DeltaTra2DeltaLoc(const TGeoHMatrix& deltaTra, TGeoHMatrix& deltaLoc)
{
// convert delta matrix for tracking frame (obtained by GetDeltaMatrixTra)
// to delta matrix in local frame (like the one from GetDeltaMatrixLoc)
deltaLoc = deltaTra;
deltaLoc.MultiplyLoc(fMatT2L);
//
}
//__________________________________________________________________
void GetModifiedMatrixG2L(TGeoHMatrix& matMod, const Double_t *delta)
{
// prepare for the sensitive module global2local matrix from its current matrix
// by applying local delta
GetDeltaMatrixLoc(matMod, delta);
matMod.MultiplyLeft(&fMatG2L);
}
//__________________________________________________________________
void GetModifiedMatrixT2L(TGeoHMatrix& matMod, const Double_t *delta)
{
// prepare the sensitive module tracking2local matrix from its current T2L matrix
// by applying local delta
GetDeltaMatrixLoc(matMod, delta);
matMod.MultiplyLeft(&fMatT2L);
}