00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "TwistPatch.h"
00014 #include "TMath.h"
00015 #include "StMessMgr.h"
00016
00017
00018 ClassImp(TwistPatch)
00019
00020 TwistPatch::TwistPatch() {
00021 magf = -1;
00022
00023 vtxpars = 0;
00024 etapars = 0;
00025 ptpars = 0;
00026 phipars = 0;
00027
00028 CorrectP05ia();
00029
00030 }
00031
00032 TwistPatch::~TwistPatch() {}
00033
00035
00036 void TwistPatch::SetMagF(double mag) {
00037
00038 if (TMath::Abs(TMath::Abs(mag/4.98) - 1) > 0.1) {
00039 gMessMgr->Error() << "TwistPatch: Invalid magnetic field: " << mag
00040 << "\n Need +/- 4.98 (+/- 10%)" << endm;
00041 return;
00042 }
00043
00044 magf = (int) (0.5 + TMath::Sign(0.5,mag));
00045 SetVtxPars();
00046 SetEtaPars();
00047 }
00048
00049 void TwistPatch::SetVtxPars() {
00050 Double_t* arr = vtxparsFull.GetArray();
00051 int offset = magf*3*2;
00052 vtxpars = &(arr[offset]);
00053 }
00054
00055 void TwistPatch::SetEtaPars() {
00056 Double_t* arr = etaparsFull.GetArray();
00057 int offset = magf*2;
00058 etapars = &(arr[offset]);
00059 }
00060
00061 void TwistPatch::SetPtPars(int ew, int ch) {
00062 Double_t* arr = ptparsFull.GetArray();
00063 int offset = ((magf*2 + ew)*2 + ch)*4*2;
00064 ptpars = &(arr[offset]);
00065 }
00066
00067 void TwistPatch::SetPhiPars(int ew, int ch) {
00068 Double_t* arr = phiparsFull.GetArray();
00069 int offset = ((magf*2 + ew)*2 + ch)*5*2;
00070 phipars = &(arr[offset]);
00071 }
00072
00074
00075 void TwistPatch::PrimaryVertex(StThreeVectorF& vtx, double mag) {
00076 double vx = vtx.x(); double vy = vtx.y(); double vz = vtx.z();
00077 PrimaryVertex(vx,vy,vz,mag);
00078 vtx.setX(vx); vtx.setY(vy); vtx.setZ(vz);
00079 }
00080
00081 void TwistPatch::PrimaryVertex(double& vx, double& vy, double& vz, double mag) {
00082 if (mag != -999.) SetMagF(mag);
00083 if (magf == -1) {
00084 gMessMgr->Error() << "TwistPatch: unassigned magnetic field." << endm;
00085 return;
00086 }
00087 if (TMath::Abs(vz)>40.) {
00088 gMessMgr->Warning() << "TwistPatch: corrections invalid outsize |vz|<40cm." << endm;
00089 vx = -999.; vy = -999.; vz = -999.;
00090 return;
00091 }
00092 vx += vtxpars[0] + vtxpars[1]*vz;
00093 vy += vtxpars[2] + vtxpars[3]*vz;
00094 vz += vtxpars[4] + vtxpars[5]*vz;
00095 }
00096
00097 void TwistPatch::PrimaryTrack(double& pt, double& phi, double& eta,
00098 int ch, double vz, double mag) {
00099 if (mag != -999.) SetMagF(mag);
00100 if (magf == -1) {
00101 gMessMgr->Error() << "TwistPatch: unassigned magnetic field." << endm;
00102 return;
00103 }
00104 if (TMath::Abs(vz)>40.) {
00105 gMessMgr->Warning() << "TwistPatch: corrections invalid outsize |vz|<40cm."
00106 << endm;
00107 pt = -999.; phi = 0.; eta = -999.;
00108 return;
00109 }
00110
00111
00112 if (pt < 0.5) return;
00113
00114 int ewi = -1;
00115 double seta = TMath::SinH(eta);
00116 if (seta < TMath::Min(-vz/60.0,-vz/200.0)) {
00117 ewi = 0;
00118 } else if (seta > TMath::Max(-vz/60.0,-vz/200.0)) {
00119 ewi = 1;
00120 } else {
00121
00122 pt = -999.; phi = 0.; eta = -999.;
00123 return;
00124 }
00125 int chi = ( (ch>0) ? 1 : 0 );
00126 SetPtPars(ewi,chi);
00127 SetPhiPars(ewi,chi);
00128
00129 double Amp, Phase;
00130
00131 Amp = etapars[0];
00132 Phase = etapars[1];
00133 eta += Amp*sin(phi-Phase);
00134
00135 Amp = ptpars[0] + ptpars[1]*eta + ptpars[2]*vz + ptpars[3]*eta*vz;
00136 Phase = ptpars[4] + ptpars[5]*eta + ptpars[6]*vz + ptpars[7]*eta*vz;
00137 pt += pt*pt*Amp*sin(phi-Phase);
00138
00139 Amp = phipars[0] + phipars[1]*eta + phipars[2]*vz +
00140 phipars[3]*eta*vz + phipars[4]*eta*eta;
00141 Phase = phipars[5] + phipars[6]*eta + phipars[7]*vz +
00142 phipars[8]*eta*vz + phipars[9]*eta*eta;
00143 phi += Amp*sin(phi-Phase);
00144
00145 }
00146
00148
00149 void TwistPatch::CorrectP05ia() {
00150 double vtxparsP05ia[12] = {
00151
00152
00153 2.30466e-02,
00154 -1.32527e-03,
00155
00156 -9.30086e-02,
00157 7.34537e-04,
00158
00159 -1.35367e-02,
00160 -1.58680e-05,
00161
00162
00163
00164 2.37662e-02,
00165 -3.26507e-04,
00166
00167 -9.14897e-02,
00168 4.78500e-04,
00169
00170 -1.30379e-02,
00171 6.15786e-06
00172 };
00173 vtxparsFull.Set(12,vtxparsP05ia);
00174
00175 double etaparsP05ia[4] = {
00176
00177 -5.00077e-04,
00178 1.31853e+00,
00179
00180
00181 3.89157e-04,
00182 -1.82777e+00
00183 };
00184 etaparsFull.Set(4,etaparsP05ia);
00185
00186 double ptparsP05ia[64] ={
00187
00188
00189 2.32846e-03,
00190 -3.40209e-04,
00191 6.60694e-05,
00192 9.85024e-06,
00193 -4.95131e-01,
00194 4.82614e-02,
00195 -2.38376e-03,
00196 -1.56343e-03,
00197
00198 2.25788e-03,
00199 3.33810e-04,
00200 5.91728e-05,
00201 -2.54143e-06,
00202 2.61730e+00,
00203 -1.06788e-01,
00204 -4.76870e-03,
00205 -4.34837e-04,
00206
00207 2.32846e-03,
00208 -3.40209e-04,
00209 6.60694e-05,
00210 9.85024e-06,
00211 -4.95131e-01,
00212 4.82614e-02,
00213 -2.38376e-03,
00214 -1.56343e-03,
00215
00216 2.54657e-03,
00217 -4.67158e-04,
00218 -6.49651e-05,
00219 6.93050e-06,
00220 -6.42205e-01,
00221 7.98875e-02,
00222 2.84334e-04,
00223 8.89173e-04,
00224
00225
00226
00227 8.88408e-04,
00228 1.05058e-03,
00229 2.30728e-05,
00230 2.93934e-06,
00231 1.41523e+00,
00232 -1.58434e-01,
00233 4.30552e-03,
00234 1.22534e-02,
00235
00236 8.01270e-04,
00237 -9.31071e-04,
00238 2.02355e-05,
00239 -4.55626e-07,
00240 -1.64989e+00,
00241 -3.21806e-01,
00242 1.81404e-04,
00243 2.80395e-03,
00244
00245 8.88408e-04,
00246 1.05058e-03,
00247 2.30728e-05,
00248 2.93934e-06,
00249 1.41523e+00,
00250 -1.58434e-01,
00251 4.30552e-03,
00252 1.22534e-02,
00253
00254 1.03332e-03,
00255 7.57373e-04,
00256 -2.41674e-05,
00257 1.02034e-06,
00258 1.57296e+00,
00259 2.25255e-01,
00260 1.34373e-05,
00261 1.96348e-03
00262
00263 };
00264 ptparsFull.Set(64,ptparsP05ia);
00265
00266 double phiparsP05ia[80] ={
00267
00268
00269 4.93131e-04,
00270 -4.23908e-05,
00271 1.31741e-05,
00272 -7.03829e-08,
00273 1.51012e-04,
00274 2.89801e+00,
00275 -1.45601e-01,
00276 -2.42827e-03,
00277 4.78493e-03,
00278 9.33780e-03,
00279
00280 4.52643e-04,
00281 -2.45860e-05,
00282 1.20074e-05,
00283 -1.90426e-06,
00284 1.28262e-04,
00285 2.47569e+00,
00286 -1.19158e-01,
00287 -2.04744e-05,
00288 8.56369e-03,
00289 1.85302e-01,
00290
00291 4.93131e-04,
00292 -4.23908e-05,
00293 1.31741e-05,
00294 -7.03829e-08,
00295 1.51012e-04,
00296 2.89801e+00,
00297 -1.45601e-01,
00298 -2.42827e-03,
00299 4.78493e-03,
00300 9.33780e-03,
00301
00302 5.08061e-04,
00303 9.58800e-06,
00304 -1.27918e-05,
00305 -4.98383e-07,
00306 1.32884e-04,
00307 -7.77448e-01,
00308 2.44479e-01,
00309 3.67018e-04,
00310 5.51353e-03,
00311 5.67082e-02,
00312
00313
00314
00315 1.74816e-04,
00316 1.33818e-04,
00317 4.61758e-06,
00318 3.63453e-06,
00319 3.29694e-04,
00320 1.20753e+00,
00321 -2.84916e+00,
00322 -1.17895e-02,
00323 5.26084e-03,
00324 -1.32828e+00,
00325
00326 1.59700e-04,
00327 -1.00637e-04,
00328 4.01605e-06,
00329 1.43594e-06,
00330 1.92839e-04,
00331 1.78569e+00,
00332 -2.14438e+00,
00333 -9.44847e-03,
00334 7.87320e-04,
00335 -1.15795e+00,
00336
00337 1.74816e-04,
00338 1.33818e-04,
00339 4.61758e-06,
00340 3.63453e-06,
00341 3.29694e-04,
00342 1.20753e+00,
00343 -2.84916e+00,
00344 -1.17895e-02,
00345 5.26084e-03,
00346 -1.32828e+00,
00347
00348 1.93766e-04,
00349 5.79827e-05,
00350 -4.49880e-06,
00351 1.40342e-06,
00352 2.00904e-04,
00353 -1.40318e+00,
00354 1.86508e+00,
00355 7.21917e-03,
00356 2.70015e-03,
00357 -8.63279e-01
00358
00359 };
00360 phiparsFull.Set(80,phiparsP05ia);
00361
00362 }
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374