]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONAlignment.cxx
Updated serial number for station 345
[u/mrichter/AliRoot.git] / MUON / AliMUONAlignment.cxx
CommitLineData
010eb601 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/* $Id$ */
17
18//-----------------------------------------------------------------------------
c25af45b 19/// \class AliMUONAlignment
20/// Alignment class for the ALICE DiMuon spectrometer
010eb601 21///
22/// MUON specific alignment class which interface to AliMillepede.
23/// For each track ProcessTrack calculates the local and global derivatives
96ebe67e 24/// at each cluster and fill the corresponding local equations. Provide methods
25/// for fixing or constraining detection elements for best results.
010eb601 26///
27/// \author Bruce Becker, Javier Castillo
28//-----------------------------------------------------------------------------
29
30#include "AliMUONAlignment.h"
31#include "AliMUONTrack.h"
010eb601 32#include "AliMUONTrackParam.h"
96ebe67e 33#include "AliMUONVCluster.h"
010eb601 34#include "AliMUONGeometryTransformer.h"
35#include "AliMUONGeometryModuleTransformer.h"
36#include "AliMUONGeometryDetElement.h"
010eb601 37#include "AliMUONGeometryBuilder.h"
010eb601 38#include "AliMUONConstants.h"
010eb601 39#include "AliMillepede.h"
40
8c95578a 41#include "AliMpExMap.h"
630711ed 42#include "AliMpExMapIterator.h"
8c95578a 43
44#include "AliLog.h"
45
2060b217 46#include "TMath.h"
8c95578a 47#include "TSystem.h"
48
78649106 49/// \cond CLASSIMP
010eb601 50ClassImp(AliMUONAlignment)
78649106 51/// \endcond
52
010eb601 53 Int_t AliMUONAlignment::fgNDetElem = 4*2+4*2+18*2+26*2+26*2;
54 Int_t AliMUONAlignment::fgNDetElemCh[10] = {4,4,4,4,18,18,26,26,26,26};
55 Int_t AliMUONAlignment::fgSNDetElemCh[10] = {4,8,12,16,34,52,78,104,130,156};
56 Int_t AliMUONAlignment::fgNParCh = 3;
3b2890be 57 Int_t AliMUONAlignment::fgNTrkMod = 16;
010eb601 58 Int_t AliMUONAlignment::fgNCh = 10;
59 Int_t AliMUONAlignment::fgNSt = 5;
60
8395bff1 61AliMUONAlignment::AliMUONAlignment()
62 : TObject(),
63 fBFieldOn(kTRUE),
64 fStartFac(16.),
65 fResCutInitial(100.),
66 fResCut(100.),
67 fMillepede(0),
96ebe67e 68 fTrackParamAtCluster(0),
8395bff1 69 fTrack(0),
96ebe67e 70 fCluster(0),
8395bff1 71 fTrackParam(0),
72 fNGlobal(fgNDetElem*fgNParCh),
73 fNLocal(4),
74 fNStdDev(3),
75 fDetElemId(0),
76 fDetElemNumber(0),
77 fPhi(0.),
78 fCosPhi(1.),
79 fSinPhi(0.),
80 fTransform(0)
010eb601 81{
82 /// Default constructor, setting define alignment parameters
83 fSigma[0] = 1.0e-1;
84 fSigma[1] = 1.0e-2;
010eb601 85
86 fDoF[0] = kTRUE; fDoF[1] = kTRUE; fDoF[2] = kTRUE;
87 fAllowVar[0] = 0.05; fAllowVar[1] = 0.05; fAllowVar[2] = 0.001;
8395bff1 88
010eb601 89 AliInfo(Form("fAllowVar[0]: %f\t fAllowVar[1]: %f\t fPhi: %f\t fgNDetElem: %i\t fNGlobal: %i\t fNLocal: %i",fAllowVar[0],fAllowVar[1],fPhi,fgNDetElem,fNGlobal,fNLocal));
90
91 fMillepede = new AliMillepede();
92
93 Init(fNGlobal, fNLocal, fNStdDev);
94
95 ResetLocalEquation();
96 AliInfo("Parameters initialized to zero");
97
98}
99
100AliMUONAlignment::~AliMUONAlignment() {
101 /// Destructor
102}
103
104void AliMUONAlignment::Init(Int_t nGlobal, /* number of global paramers */
105 Int_t nLocal, /* number of local parameters */
106 Int_t nStdDev /* std dev cut */ )
107{
108 /// Initialization of AliMillepede. Fix parameters, define constraints ...
109 fMillepede->InitMille(nGlobal,nLocal,nStdDev,fResCut,fResCutInitial);
110
3b2890be 111 Bool_t bStOnOff[5] = {kTRUE,kTRUE,kTRUE,kTRUE,kTRUE};
112 Bool_t bSpecLROnOff[2] = {kTRUE,kTRUE};
010eb601 113
114 AllowVariations(bStOnOff);
115
116 // Fix parameters or add constraints here
117 for (Int_t iSt=0; iSt<5; iSt++)
118 if (!bStOnOff[iSt]) FixStation(iSt+1);
119
3b2890be 120 FixHalfSpectrometer(bStOnOff,bSpecLROnOff);
121
010eb601 122 ResetConstraints();
3b2890be 123
124 // Define global constrains to be applied
125 // X, Y, P, XvsZ, YvsZ, PvsZ, XvsY, YvsY, PvsY
126 Bool_t bVarXYT[9] = {kTRUE,kTRUE,kTRUE,kTRUE,kTRUE,kTRUE,kTRUE,kTRUE,kTRUE};
127 Bool_t bDetTLBR[4] = {kFALSE,kTRUE,kFALSE,kTRUE};
128 // AddConstraints(bStOnOff,bVarXYT,bDetTLBR,bSpecLROnOff);
129
130 // Other possible way to add constrains
010eb601 131 bVarXYT[0] = kFALSE; bVarXYT[1] = kFALSE; bVarXYT[2] = kTRUE;
132 bDetTLBR[0] = kFALSE; bDetTLBR[1] = kTRUE; bDetTLBR[2] = kFALSE; bDetTLBR[3] = kFALSE;
3b2890be 133// AddConstraints(bStOnOff,bVarXYT,bDetTLBR);
134
135 bVarXYT[0] = kTRUE; bVarXYT[1] = kTRUE; bVarXYT[2] = kFALSE;
136 // AddConstraints(bStOnOff,bVarXYT);
010eb601 137
138 // Set iterations
139 if (fStartFac>1) fMillepede->SetIterations(fStartFac);
140}
141
142void AliMUONAlignment::FixStation(Int_t iSt){
143 /// Fix all detection elements of station iSt
144 Int_t iDetElemFirst = (iSt>1) ? fgSNDetElemCh[2*(iSt-1)-1] : 0;
145 Int_t iDetElemLast = fgSNDetElemCh[2*(iSt)-1];
146 for (Int_t i = iDetElemFirst; i < iDetElemLast; i++){
147 FixParameter(i*fgNParCh+0, 0.0);
148 FixParameter(i*fgNParCh+1, 0.0);
149 FixParameter(i*fgNParCh+2, 0.0);
150 }
151}
152
3b2890be 153void AliMUONAlignment::FixHalfSpectrometer(Bool_t *lStOnOff, Bool_t *lSpecLROnOff){
154 /// Fix left or right detector
155 for (Int_t i = 0; i < fgNDetElem; i++){
156 Int_t iCh=0;
157 for (iCh=1; iCh<=fgNCh; iCh++){
158 if (i<fgSNDetElemCh[iCh-1]) break;
159 }
160 Int_t iSt = lStOnOff[(iCh-1)/2] ? (iCh+1)/2 : 0;
161 if (iSt){
162 Int_t lDetElemNumber = (iCh==1) ? i : i-fgSNDetElemCh[iCh-2];
163 if (iCh>=1 && iCh<=4){
164 if ((lDetElemNumber==1 || lDetElemNumber==2) && !lSpecLROnOff[0]){ // From track crossings
165 FixParameter(i*fgNParCh+0, 0.0);
166 FixParameter(i*fgNParCh+1, 0.0);
167 FixParameter(i*fgNParCh+2, 0.0);
168 }
169 if ((lDetElemNumber==0 || lDetElemNumber==3) && !lSpecLROnOff[1]){ // From track crossings
170 FixParameter(i*fgNParCh+0, 0.0);
171 FixParameter(i*fgNParCh+1, 0.0);
172 FixParameter(i*fgNParCh+2, 0.0);
173 }
174 }
175 if (iCh>=5 && iCh<=6){
176 if ((lDetElemNumber>=5&&lDetElemNumber<=13) && !lSpecLROnOff[0]){
177 FixParameter(i*fgNParCh+0, 0.0);
178 FixParameter(i*fgNParCh+1, 0.0);
179 FixParameter(i*fgNParCh+2, 0.0);
180 }
181 if (((lDetElemNumber>=0&&lDetElemNumber<=4) ||
182 (lDetElemNumber>=14&&lDetElemNumber<=17)) && !lSpecLROnOff[1]){
183 FixParameter(i*fgNParCh+0, 0.0);
184 FixParameter(i*fgNParCh+1, 0.0);
185 FixParameter(i*fgNParCh+2, 0.0);
186 }
187 }
188 if (iCh>=7 && iCh<=10){
189 if ((lDetElemNumber>=7&&lDetElemNumber<=19) && !lSpecLROnOff[0]){
190 FixParameter(i*fgNParCh+0, 0.0);
191 FixParameter(i*fgNParCh+1, 0.0);
192 FixParameter(i*fgNParCh+2, 0.0);
193 }
194 if (((lDetElemNumber>=0&&lDetElemNumber<=6) ||
195 (lDetElemNumber>=20&&lDetElemNumber<=25)) && !lSpecLROnOff[1]){
196 FixParameter(i*fgNParCh+0, 0.0);
197 FixParameter(i*fgNParCh+1, 0.0);
198 FixParameter(i*fgNParCh+2, 0.0);
199 }
200 }
201 }
202 }
203}
204
010eb601 205void AliMUONAlignment::SetNonLinear(Bool_t *lStOnOff,Bool_t *lVarXYT){
206 /// Set non linear parameter flag selected stations and degrees of freedom
207 for (Int_t i = 0; i < fgNDetElem; i++){
208 Int_t iCh=0;
209 for (iCh=1; iCh<=fgNCh; iCh++){
210 if (i<fgSNDetElemCh[iCh-1]) break;
211 }
212 Int_t iSt = lStOnOff[(iCh-1)/2] ? (iCh+1)/2 : 0;
213 if (iSt){
214 if (lVarXYT[0]) { // X constraint
215 SetNonLinear(i*fgNParCh+0);
216 }
217 if (lVarXYT[1]) { // Y constraint
218 SetNonLinear(i*fgNParCh+1);
219 }
220 if (lVarXYT[2]) { // T constraint
221 SetNonLinear(i*fgNParCh+2);
222 }
223 }
224 }
225}
226
227void AliMUONAlignment::AddConstraints(Bool_t *lStOnOff,Bool_t *lVarXYT){
228 /// Add constraint equations for selected stations and degrees of freedom
229 for (Int_t i = 0; i < fgNDetElem; i++){
230 Int_t iCh=0;
231 for (iCh=1; iCh<=fgNCh; iCh++){
232 if (i<fgSNDetElemCh[iCh-1]) break;
233 }
234 Int_t iSt = lStOnOff[(iCh-1)/2] ? (iCh+1)/2 : 0;
235 if (iSt){
236 if (lVarXYT[0]) { // X constraint
237 fConstraintX[i*fgNParCh+0]=1.0;
238 }
239 if (lVarXYT[1]) { // Y constraint
240 fConstraintY[i*fgNParCh+1]=1.0;
241 }
242 if (lVarXYT[2]) { // T constraint
243 fConstraintP[i*fgNParCh+2]=1.0;
244 }
245 }
246 }
247 if (lVarXYT[0]) { // X constraint
248 AddConstraint(fConstraintX,0.0);
249 }
250 if (lVarXYT[1]) { // Y constraint
251 AddConstraint(fConstraintY,0.0);
252 }
253 if (lVarXYT[2]) { // T constraint
254 AddConstraint(fConstraintP,0.0);
255 }
256}
257
3b2890be 258void AliMUONAlignment::AddConstraints(Bool_t *lStOnOff,Bool_t *lVarXYT, Bool_t *lDetTLBR, Bool_t *lSpecLROnOff){
259 /// Add constraint equations for selected stations, degrees of freedom and detector half
260 Double_t lDetElemLocX = 0.;
261 Double_t lDetElemLocY = 0.;
262 Double_t lDetElemLocZ = 0.;
263 Double_t lDetElemGloX = 0.;
264 Double_t lDetElemGloY = 0.;
265 Double_t lDetElemGloZ = 0.;
266 Double_t lMeanY = 0.;
267 Double_t lSigmaY = 0.;
268 Double_t lMeanZ = 0.;
269 Double_t lSigmaZ = 0.;
270 Int_t lNDetElem = 0;
010eb601 271 for (Int_t i = 0; i < fgNDetElem; i++){
272 Int_t iCh=0;
273 for (iCh=1; iCh<=fgNCh; iCh++){
274 if (i<fgSNDetElemCh[iCh-1]) break;
275 }
276 Int_t iSt = lStOnOff[(iCh-1)/2] ? (iCh+1)/2 : 0;
277 if (iSt){
3b2890be 278 Int_t lDetElemNumber = (iCh==1) ? i : i-fgSNDetElemCh[iCh-2];
279 Int_t lDetElemId = iCh*100+lDetElemNumber;
280 fTransform->Local2Global(lDetElemId,lDetElemLocX,lDetElemLocY,lDetElemLocZ,
281 lDetElemGloX,lDetElemGloY,lDetElemGloZ);
282 if (iCh>=1 && iCh<=4){
283 if ((lDetElemNumber==1 || lDetElemNumber==2) && lSpecLROnOff[0]){ // From track crossings
284 lMeanY += lDetElemGloY;
285 lSigmaY += lDetElemGloY*lDetElemGloY;
286 lMeanZ += lDetElemGloZ;
287 lSigmaZ += lDetElemGloZ*lDetElemGloZ;
288 lNDetElem++;
289 }
290 if ((lDetElemNumber==0 || lDetElemNumber==3) && lSpecLROnOff[1]){ // From track crossings
291 lMeanY += lDetElemGloY;
292 lSigmaY += lDetElemGloY*lDetElemGloY;
293 lMeanZ += lDetElemGloZ;
294 lSigmaZ += lDetElemGloZ*lDetElemGloZ;
295 lNDetElem++;
296 }
297 }
298 if (iCh>=5 && iCh<=6){
299 if ((lDetElemNumber>=5&&lDetElemNumber<=13) && lSpecLROnOff[0]){
300 lMeanY += lDetElemGloY;
301 lSigmaY += lDetElemGloY*lDetElemGloY;
302 lMeanZ += lDetElemGloZ;
303 lSigmaZ += lDetElemGloZ*lDetElemGloZ;
304 lNDetElem++;
305 }
306 if (((lDetElemNumber>=0&&lDetElemNumber<=4) ||
307 (lDetElemNumber>=14&&lDetElemNumber<=17)) && lSpecLROnOff[1]){
308 lMeanY += lDetElemGloY;
309 lSigmaY += lDetElemGloY*lDetElemGloY;
310 lMeanZ += lDetElemGloZ;
311 lSigmaZ += lDetElemGloZ*lDetElemGloZ;
312 lNDetElem++;
313 }
314 }
315 if (iCh>=7 && iCh<=10){
316 if ((lDetElemNumber>=7&&lDetElemNumber<=19) && lSpecLROnOff[0]){
317 lMeanY += lDetElemGloY;
318 lSigmaY += lDetElemGloY*lDetElemGloY;
319 lMeanZ += lDetElemGloZ;
320 lSigmaZ += lDetElemGloZ*lDetElemGloZ;
321 lNDetElem++;
322 }
323 if (((lDetElemNumber>=0&&lDetElemNumber<=6) ||
324 (lDetElemNumber>=20&&lDetElemNumber<=25)) && lSpecLROnOff[1]){
325 lMeanY += lDetElemGloY;
326 lSigmaY += lDetElemGloY*lDetElemGloY;
327 lMeanZ += lDetElemGloZ;
328 lSigmaZ += lDetElemGloZ*lDetElemGloZ;
329 lNDetElem++;
330 }
331 }
332 }
333 }
334 lMeanY /= lNDetElem;
335 lSigmaY /= lNDetElem;
336 lSigmaY = TMath::Sqrt(lSigmaY-lMeanY*lMeanY);
337 lMeanZ /= lNDetElem;
338 lSigmaZ /= lNDetElem;
339 lSigmaZ = TMath::Sqrt(lSigmaZ-lMeanZ*lMeanZ);
340 AliInfo(Form("Used %i DetElem, MeanZ= %f , SigmaZ= %f", lNDetElem,lMeanZ,lSigmaZ));
341
342 for (Int_t i = 0; i < fgNDetElem; i++){
343 Int_t iCh=0;
344 for (iCh=1; iCh<=fgNCh; iCh++){
345 if (i<fgSNDetElemCh[iCh-1]) break;
346 }
347 Int_t iSt = lStOnOff[(iCh-1)/2] ? (iCh+1)/2 : 0;
348 if (iSt){
349 Int_t lDetElemNumber = (iCh==1) ? i : i-fgSNDetElemCh[iCh-2];
350 Int_t lDetElemId = iCh*100+lDetElemNumber;
351 fTransform->Local2Global(lDetElemId,lDetElemLocX,lDetElemLocY,lDetElemLocZ,
352 lDetElemGloX,lDetElemGloY,lDetElemGloZ);
010eb601 353 if (lVarXYT[0]) { // X constraint
354 if (lDetTLBR[0]) ConstrainT(i,iCh,fConstraintXT,0); // Top half
355 if (lDetTLBR[1]) ConstrainL(i,iCh,fConstraintXL,0); // Left half
356 if (lDetTLBR[2]) ConstrainB(i,iCh,fConstraintXB,0); // Bottom half
357 if (lDetTLBR[3]) ConstrainR(i,iCh,fConstraintXR,0); // Right half
358 }
3b2890be 359 if (lVarXYT[1]) { // Y constraint
010eb601 360 if (lDetTLBR[0]) ConstrainT(i,iCh,fConstraintYT,1); // Top half
361 if (lDetTLBR[1]) ConstrainL(i,iCh,fConstraintYL,1); // Left half
362 if (lDetTLBR[2]) ConstrainB(i,iCh,fConstraintYB,1); // Bottom half
363 if (lDetTLBR[3]) ConstrainR(i,iCh,fConstraintYR,1); // Right half
364 }
3b2890be 365 if (lVarXYT[2]) { // P constraint
010eb601 366 if (lDetTLBR[0]) ConstrainT(i,iCh,fConstraintPT,2); // Top half
367 if (lDetTLBR[1]) ConstrainL(i,iCh,fConstraintPL,2); // Left half
368 if (lDetTLBR[2]) ConstrainB(i,iCh,fConstraintPB,2); // Bottom half
369 if (lDetTLBR[3]) ConstrainR(i,iCh,fConstraintPR,2); // Right half
370 }
3b2890be 371 if (lVarXYT[3]) { // X-Z shearing
372 if (lDetTLBR[0]) ConstrainT(i,iCh,fConstraintXZT,0,(lDetElemGloZ-lMeanZ)/lSigmaZ); // Top half
373 if (lDetTLBR[1]) ConstrainL(i,iCh,fConstraintXZL,0,(lDetElemGloZ-lMeanZ)/lSigmaZ); // Left half
374 if (lDetTLBR[2]) ConstrainB(i,iCh,fConstraintXZB,0,(lDetElemGloZ-lMeanZ)/lSigmaZ); // Bottom half
375 if (lDetTLBR[3]) ConstrainR(i,iCh,fConstraintXZR,0,(lDetElemGloZ-lMeanZ)/lSigmaZ); // Right half
376 }
377 if (lVarXYT[4]) { // Y-Z shearing
378 if (lDetTLBR[0]) ConstrainT(i,iCh,fConstraintYZT,1,(lDetElemGloZ-lMeanZ)/lSigmaZ); // Top half
379 if (lDetTLBR[1]) ConstrainL(i,iCh,fConstraintYZL,1,(lDetElemGloZ-lMeanZ)/lSigmaZ); // Left half
380 if (lDetTLBR[2]) ConstrainB(i,iCh,fConstraintYZB,1,(lDetElemGloZ-lMeanZ)/lSigmaZ); // Bottom half
381 if (lDetTLBR[3]) ConstrainR(i,iCh,fConstraintYZR,1,(lDetElemGloZ-lMeanZ)/lSigmaZ); // Right half
382 }
383 if (lVarXYT[5]) { // P-Z rotation
384 if (lDetTLBR[0]) ConstrainT(i,iCh,fConstraintPZT,2,(lDetElemGloZ-lMeanZ)/lSigmaZ); // Top half
385 if (lDetTLBR[1]) ConstrainL(i,iCh,fConstraintPZL,2,(lDetElemGloZ-lMeanZ)/lSigmaZ); // Left half
386 if (lDetTLBR[2]) ConstrainB(i,iCh,fConstraintPZB,2,(lDetElemGloZ-lMeanZ)/lSigmaZ); // Bottom half
387 if (lDetTLBR[3]) ConstrainR(i,iCh,fConstraintPZR,2,(lDetElemGloZ-lMeanZ)/lSigmaZ); // Right half
388 }
389 if (lVarXYT[6]) { // X-Y shearing
390 if (lDetTLBR[0]) ConstrainT(i,iCh,fConstraintXYT,0,(lDetElemGloY-lMeanY)/lSigmaY); // Top half
391 if (lDetTLBR[1]) ConstrainL(i,iCh,fConstraintXYL,0,(lDetElemGloY-lMeanY)/lSigmaY); // Left half
392 if (lDetTLBR[2]) ConstrainB(i,iCh,fConstraintXYB,0,(lDetElemGloY-lMeanY)/lSigmaY); // Bottom half
393 if (lDetTLBR[3]) ConstrainR(i,iCh,fConstraintXYR,0,(lDetElemGloY-lMeanY)/lSigmaY); // Right half
394 }
395 if (lVarXYT[7]) { // Y-Y scaling
396 if (lDetTLBR[0]) ConstrainT(i,iCh,fConstraintYYT,1,(lDetElemGloY-lMeanY)/lSigmaY); // Top half
397 if (lDetTLBR[1]) ConstrainL(i,iCh,fConstraintYYL,1,(lDetElemGloY-lMeanY)/lSigmaY); // Left half
398 if (lDetTLBR[2]) ConstrainB(i,iCh,fConstraintYYB,1,(lDetElemGloY-lMeanY)/lSigmaY); // Bottom half
399 if (lDetTLBR[3]) ConstrainR(i,iCh,fConstraintYYR,1,(lDetElemGloY-lMeanY)/lSigmaY); // Right half
400 }
401 if (lVarXYT[8]) { // P-Y rotation
402 if (lDetTLBR[0]) ConstrainT(i,iCh,fConstraintPYT,2,(lDetElemGloY-lMeanY)/lSigmaY); // Top half
403 if (lDetTLBR[1]) ConstrainL(i,iCh,fConstraintPYL,2,(lDetElemGloY-lMeanY)/lSigmaY); // Left half
404 if (lDetTLBR[2]) ConstrainB(i,iCh,fConstraintPYB,2,(lDetElemGloY-lMeanY)/lSigmaY); // Bottom half
405 if (lDetTLBR[3]) ConstrainR(i,iCh,fConstraintPYR,2,(lDetElemGloY-lMeanY)/lSigmaY); // Right half
406 }
010eb601 407 }
408 }
409 if (lVarXYT[0]) { // X constraint
410 if (lDetTLBR[0]) AddConstraint(fConstraintXT,0.0); // Top half
411 if (lDetTLBR[1]) AddConstraint(fConstraintXL,0.0); // Left half
412 if (lDetTLBR[2]) AddConstraint(fConstraintXB,0.0); // Bottom half
413 if (lDetTLBR[3]) AddConstraint(fConstraintXR,0.0); // Right half
414 }
415 if (lVarXYT[1]) { // Y constraint
416 if (lDetTLBR[0]) AddConstraint(fConstraintYT,0.0); // Top half
417 if (lDetTLBR[1]) AddConstraint(fConstraintYL,0.0); // Left half
418 if (lDetTLBR[2]) AddConstraint(fConstraintYB,0.0); // Bottom half
419 if (lDetTLBR[3]) AddConstraint(fConstraintYR,0.0); // Right half
420 }
421 if (lVarXYT[2]) { // T constraint
422 if (lDetTLBR[0]) AddConstraint(fConstraintPT,0.0); // Top half
423 if (lDetTLBR[1]) AddConstraint(fConstraintPL,0.0); // Left half
424 if (lDetTLBR[2]) AddConstraint(fConstraintPB,0.0); // Bottom half
425 if (lDetTLBR[3]) AddConstraint(fConstraintPR,0.0); // Right half
426 }
3b2890be 427 if (lVarXYT[3]) { // X-Z constraint
428 if (lDetTLBR[0]) AddConstraint(fConstraintXZT,0.0); // Top half
429 if (lDetTLBR[1]) AddConstraint(fConstraintXZL,0.0); // Left half
430 if (lDetTLBR[2]) AddConstraint(fConstraintXZB,0.0); // Bottom half
431 if (lDetTLBR[3]) AddConstraint(fConstraintXZR,0.0); // Right half
432 }
433 if (lVarXYT[4]) { // Y-Z constraint
434 if (lDetTLBR[0]) AddConstraint(fConstraintYZT,0.0); // Top half
435 if (lDetTLBR[1]) AddConstraint(fConstraintYZL,0.0); // Left half
436 if (lDetTLBR[2]) AddConstraint(fConstraintYZB,0.0); // Bottom half
437 if (lDetTLBR[3]) AddConstraint(fConstraintYZR,0.0); // Right half
438 }
439 if (lVarXYT[5]) { // P-Z constraint
440 if (lDetTLBR[0]) AddConstraint(fConstraintPZT,0.0); // Top half
441 if (lDetTLBR[1]) AddConstraint(fConstraintPZL,0.0); // Left half
442 if (lDetTLBR[2]) AddConstraint(fConstraintPZB,0.0); // Bottom half
443 if (lDetTLBR[3]) AddConstraint(fConstraintPZR,0.0); // Right half
444 }
445 if (lVarXYT[6]) { // X-Y constraint
446 if (lDetTLBR[0]) AddConstraint(fConstraintXYT,0.0); // Top half
447 if (lDetTLBR[1]) AddConstraint(fConstraintXYL,0.0); // Left half
448 if (lDetTLBR[2]) AddConstraint(fConstraintXYB,0.0); // Bottom half
449 if (lDetTLBR[3]) AddConstraint(fConstraintXYR,0.0); // Right half
450 }
451 if (lVarXYT[7]) { // Y-Y constraint
452 if (lDetTLBR[0]) AddConstraint(fConstraintYYT,0.0); // Top half
453 if (lDetTLBR[1]) AddConstraint(fConstraintYYL,0.0); // Left half
454 if (lDetTLBR[2]) AddConstraint(fConstraintYYB,0.0); // Bottom half
455 if (lDetTLBR[3]) AddConstraint(fConstraintYYR,0.0); // Right half
456 }
457 if (lVarXYT[8]) { // P-Y constraint
458 if (lDetTLBR[0]) AddConstraint(fConstraintPYT,0.0); // Top half
459 if (lDetTLBR[1]) AddConstraint(fConstraintPYL,0.0); // Left half
460 if (lDetTLBR[2]) AddConstraint(fConstraintPYB,0.0); // Bottom half
461 if (lDetTLBR[3]) AddConstraint(fConstraintPYR,0.0); // Right half
462 }
010eb601 463}
464
8ec2f43d 465void AliMUONAlignment::ConstrainT(Int_t lDetElem, Int_t lCh, Double_t *lConstraintT, Int_t iVar, Double_t /*lWeight*/){
010eb601 466 /// Set constrain equation for top half of spectrometer
467 Int_t lDetElemNumber = (lCh==1) ? lDetElem : lDetElem-fgSNDetElemCh[lCh-2];
468 if (lCh>=1 && lCh<=4){
469 if (lDetElemNumber==0 || lDetElemNumber==1){ // From track crossings
470 lConstraintT[lDetElem*fgNParCh+iVar]=1.0;
471 }
472 }
473 if (lCh>=5 && lCh<=6){
474 if (lDetElemNumber>=0&&lDetElemNumber<=9){
475 lConstraintT[lDetElem*fgNParCh+iVar]=1.0;
476 }
477 }
478 if (lCh>=7 && lCh<=10){
479 if (lDetElemNumber>=0&&lDetElemNumber<=13){
480 lConstraintT[lDetElem*fgNParCh+iVar]=1.0;
481 }
482 }
483}
484
3b2890be 485void AliMUONAlignment::ConstrainL(Int_t lDetElem, Int_t lCh, Double_t *lConstraintL, Int_t iVar, Double_t lWeight){
010eb601 486 /// Set constrain equation for left half of spectrometer
487 Int_t lDetElemNumber = (lCh==1) ? lDetElem : lDetElem-fgSNDetElemCh[lCh-2];
488 if (lCh>=1 && lCh<=4){
489 if (lDetElemNumber==1 || lDetElemNumber==2){ // From track crossings
3b2890be 490 lConstraintL[lDetElem*fgNParCh+iVar]=lWeight;
010eb601 491 }
492 }
493 if (lCh>=5 && lCh<=6){
494 if (lDetElemNumber>=5&&lDetElemNumber<=13){
3b2890be 495 lConstraintL[lDetElem*fgNParCh+iVar]=lWeight;
010eb601 496 }
497 }
498 if (lCh>=7 && lCh<=10){
499 if (lDetElemNumber>=7&&lDetElemNumber<=19){
3b2890be 500 lConstraintL[lDetElem*fgNParCh+iVar]=lWeight;
010eb601 501 }
502 }
503}
504
8ec2f43d 505void AliMUONAlignment::ConstrainB(Int_t lDetElem, Int_t lCh, Double_t *lConstraintB, Int_t iVar, Double_t /*lWeight*/){
010eb601 506 /// Set constrain equation for bottom half of spectrometer
507 Int_t lDetElemNumber = (lCh==1) ? lDetElem : lDetElem-fgSNDetElemCh[lCh-2];
508 if (lCh>=1 && lCh<=4){
3b2890be 509 if (lDetElemNumber==2 || lDetElemNumber==3){ // From track crossings
010eb601 510 lConstraintB[lDetElem*fgNParCh+iVar]=1.0;
511 }
512 }
513 if (lCh>=5 && lCh<=6){
514 if ((lDetElemNumber>=9&&lDetElemNumber<=17) ||
515 (lDetElemNumber==0)){
516 lConstraintB[lDetElem*fgNParCh+iVar]=1.0;
517 }
518 }
519 if (lCh>=7 && lCh<=10){
520 if ((lDetElemNumber>=13&&lDetElemNumber<=25) ||
521 (lDetElemNumber==0)){
522 lConstraintB[lDetElem*fgNParCh+iVar]=1.0;
523 }
524 }
525}
526
3b2890be 527void AliMUONAlignment::ConstrainR(Int_t lDetElem, Int_t lCh, Double_t *lConstraintR, Int_t iVar, Double_t lWeight){
010eb601 528 /// Set constrain equation for right half of spectrometer
529 Int_t lDetElemNumber = (lCh==1) ? lDetElem : lDetElem-fgSNDetElemCh[lCh-2];
530 if (lCh>=1 && lCh<=4){
3b2890be 531 if (lDetElemNumber==0 || lDetElemNumber==3){ // From track crossings
532 lConstraintR[lDetElem*fgNParCh+iVar]=lWeight;
010eb601 533 }
534 }
535 if (lCh>=5 && lCh<=6){
536 if ((lDetElemNumber>=0&&lDetElemNumber<=4) ||
537 (lDetElemNumber>=14&&lDetElemNumber<=17)){
3b2890be 538 lConstraintR[lDetElem*fgNParCh+iVar]=lWeight;
010eb601 539 }
540 }
541 if (lCh>=7 && lCh<=10){
542 if ((lDetElemNumber>=0&&lDetElemNumber<=6) ||
543 (lDetElemNumber>=20&&lDetElemNumber<=25)){
3b2890be 544 lConstraintR[lDetElem*fgNParCh+iVar]=lWeight;
010eb601 545 }
546 }
547}
548
549void AliMUONAlignment::ResetConstraints(){
550 /// Reset all constraint equations
551 for (Int_t i = 0; i < fgNDetElem; i++){
3b2890be 552 fConstraintX[i*fgNParCh+0]=0.0;
553 fConstraintX[i*fgNParCh+1]=0.0;
554 fConstraintX[i*fgNParCh+2]=0.0;
555 fConstraintY[i*fgNParCh+0]=0.0;
556 fConstraintY[i*fgNParCh+1]=0.0;
557 fConstraintY[i*fgNParCh+2]=0.0;
558 fConstraintP[i*fgNParCh+0]=0.0;
559 fConstraintP[i*fgNParCh+1]=0.0;
560 fConstraintP[i*fgNParCh+2]=0.0;
561 fConstraintXT[i*fgNParCh+0]=0.0;
562 fConstraintXT[i*fgNParCh+1]=0.0;
563 fConstraintXT[i*fgNParCh+2]=0.0;
564 fConstraintYT[i*fgNParCh+0]=0.0;
565 fConstraintYT[i*fgNParCh+1]=0.0;
566 fConstraintYT[i*fgNParCh+2]=0.0;
567 fConstraintPT[i*fgNParCh+0]=0.0;
568 fConstraintPT[i*fgNParCh+1]=0.0;
569 fConstraintPT[i*fgNParCh+2]=0.0;
570 fConstraintXZT[i*fgNParCh+0]=0.0;
571 fConstraintXZT[i*fgNParCh+1]=0.0;
572 fConstraintXZT[i*fgNParCh+2]=0.0;
573 fConstraintYZT[i*fgNParCh+0]=0.0;
574 fConstraintYZT[i*fgNParCh+1]=0.0;
575 fConstraintYZT[i*fgNParCh+2]=0.0;
576 fConstraintPZT[i*fgNParCh+0]=0.0;
577 fConstraintPZT[i*fgNParCh+1]=0.0;
578 fConstraintPZT[i*fgNParCh+2]=0.0;
579 fConstraintXYT[i*fgNParCh+0]=0.0;
580 fConstraintXYT[i*fgNParCh+1]=0.0;
581 fConstraintXYT[i*fgNParCh+2]=0.0;
582 fConstraintYYT[i*fgNParCh+0]=0.0;
583 fConstraintYYT[i*fgNParCh+1]=0.0;
584 fConstraintYYT[i*fgNParCh+2]=0.0;
585 fConstraintPYT[i*fgNParCh+0]=0.0;
586 fConstraintPYT[i*fgNParCh+1]=0.0;
587 fConstraintPYT[i*fgNParCh+2]=0.0;
588 fConstraintXL[i*fgNParCh+0]=0.0;
589 fConstraintXL[i*fgNParCh+1]=0.0;
590 fConstraintXL[i*fgNParCh+2]=0.0;
591 fConstraintYL[i*fgNParCh+0]=0.0;
592 fConstraintYL[i*fgNParCh+1]=0.0;
593 fConstraintYL[i*fgNParCh+2]=0.0;
594 fConstraintPL[i*fgNParCh+0]=0.0;
595 fConstraintPL[i*fgNParCh+1]=0.0;
596 fConstraintPL[i*fgNParCh+2]=0.0;
597 fConstraintXZL[i*fgNParCh+0]=0.0;
598 fConstraintXZL[i*fgNParCh+1]=0.0;
599 fConstraintXZL[i*fgNParCh+2]=0.0;
600 fConstraintYZL[i*fgNParCh+0]=0.0;
601 fConstraintYZL[i*fgNParCh+1]=0.0;
602 fConstraintYZL[i*fgNParCh+2]=0.0;
603 fConstraintPZL[i*fgNParCh+0]=0.0;
604 fConstraintPZL[i*fgNParCh+1]=0.0;
605 fConstraintPZL[i*fgNParCh+2]=0.0;
606 fConstraintXYL[i*fgNParCh+0]=0.0;
607 fConstraintXYL[i*fgNParCh+1]=0.0;
608 fConstraintXYL[i*fgNParCh+2]=0.0;
609 fConstraintYYL[i*fgNParCh+0]=0.0;
610 fConstraintYYL[i*fgNParCh+1]=0.0;
611 fConstraintYYL[i*fgNParCh+2]=0.0;
612 fConstraintPYL[i*fgNParCh+0]=0.0;
613 fConstraintPYL[i*fgNParCh+1]=0.0;
614 fConstraintPYL[i*fgNParCh+2]=0.0;
615 fConstraintXB[i*fgNParCh+0]=0.0;
616 fConstraintXB[i*fgNParCh+1]=0.0;
617 fConstraintXB[i*fgNParCh+2]=0.0;
618 fConstraintYB[i*fgNParCh+0]=0.0;
619 fConstraintYB[i*fgNParCh+1]=0.0;
620 fConstraintYB[i*fgNParCh+2]=0.0;
621 fConstraintPB[i*fgNParCh+0]=0.0;
622 fConstraintPB[i*fgNParCh+1]=0.0;
623 fConstraintPB[i*fgNParCh+2]=0.0;
624 fConstraintXZB[i*fgNParCh+0]=0.0;
625 fConstraintXZB[i*fgNParCh+1]=0.0;
626 fConstraintXZB[i*fgNParCh+2]=0.0;
627 fConstraintYZB[i*fgNParCh+0]=0.0;
628 fConstraintYZB[i*fgNParCh+1]=0.0;
629 fConstraintYZB[i*fgNParCh+2]=0.0;
630 fConstraintPZB[i*fgNParCh+0]=0.0;
631 fConstraintPZB[i*fgNParCh+1]=0.0;
632 fConstraintPZB[i*fgNParCh+2]=0.0;
633 fConstraintXYB[i*fgNParCh+0]=0.0;
634 fConstraintXYB[i*fgNParCh+1]=0.0;
635 fConstraintXYB[i*fgNParCh+2]=0.0;
636 fConstraintYYB[i*fgNParCh+0]=0.0;
637 fConstraintYYB[i*fgNParCh+1]=0.0;
638 fConstraintYYB[i*fgNParCh+2]=0.0;
639 fConstraintPYB[i*fgNParCh+0]=0.0;
640 fConstraintPYB[i*fgNParCh+1]=0.0;
641 fConstraintPYB[i*fgNParCh+2]=0.0;
642 fConstraintXR[i*fgNParCh+0]=0.0;
643 fConstraintXR[i*fgNParCh+1]=0.0;
644 fConstraintXR[i*fgNParCh+2]=0.0;
645 fConstraintYR[i*fgNParCh+0]=0.0;
646 fConstraintYR[i*fgNParCh+1]=0.0;
647 fConstraintYR[i*fgNParCh+2]=0.0;
648 fConstraintPR[i*fgNParCh+0]=0.0;
649 fConstraintPR[i*fgNParCh+1]=0.0;
650 fConstraintPR[i*fgNParCh+2]=0.0;
651 fConstraintXZR[i*fgNParCh+0]=0.0;
652 fConstraintXZR[i*fgNParCh+1]=0.0;
653 fConstraintXZR[i*fgNParCh+2]=0.0;
654 fConstraintYZR[i*fgNParCh+0]=0.0;
655 fConstraintYZR[i*fgNParCh+1]=0.0;
656 fConstraintYZR[i*fgNParCh+2]=0.0;
657 fConstraintPZR[i*fgNParCh+0]=0.0;
658 fConstraintPZR[i*fgNParCh+1]=0.0;
659 fConstraintPZR[i*fgNParCh+2]=0.0;
660 fConstraintPZR[i*fgNParCh+0]=0.0;
661 fConstraintPZR[i*fgNParCh+1]=0.0;
662 fConstraintPZR[i*fgNParCh+2]=0.0;
663 fConstraintXYR[i*fgNParCh+0]=0.0;
664 fConstraintXYR[i*fgNParCh+1]=0.0;
665 fConstraintXYR[i*fgNParCh+2]=0.0;
666 fConstraintYYR[i*fgNParCh+0]=0.0;
667 fConstraintYYR[i*fgNParCh+1]=0.0;
668 fConstraintYYR[i*fgNParCh+2]=0.0;
669 fConstraintPYR[i*fgNParCh+0]=0.0;
670 fConstraintPYR[i*fgNParCh+1]=0.0;
671 fConstraintPYR[i*fgNParCh+2]=0.0;
010eb601 672 }
673}
674
675void AliMUONAlignment::AddConstraint(Double_t *par, Double_t value) {
676 /// Constrain equation defined by par to value
677 fMillepede->SetGlobalConstraint(par, value);
678 AliInfo("Adding constraint");
679}
680
681void AliMUONAlignment::InitGlobalParameters(Double_t *par) {
682 /// Initialize global parameters with par array
683 fMillepede->SetGlobalParameters(par);
684 AliInfo("Init Global Parameters");
685}
686
687void AliMUONAlignment::FixParameter(Int_t iPar, Double_t value) {
688 /// Parameter iPar is encourage to vary in [-value;value].
689 /// If value == 0, parameter is fixed
690 fMillepede->SetParSigma(iPar, value);
691 if (value==0) AliInfo(Form("Parameter %i Fixed", iPar));
692}
693
694void AliMUONAlignment::ResetLocalEquation()
695{
696 /// Reset the derivative vectors
697 for(int i=0; i<fNLocal; i++) {
698 fLocalDerivatives[i] = 0.0;
699 }
700 for(int i=0; i<fNGlobal; i++) {
701 fGlobalDerivatives[i] = 0.0;
702 }
703}
704
705void AliMUONAlignment::AllowVariations(Bool_t *bStOnOff) {
706 /// Set allowed variation for selected stations based on fDoF and fAllowVar
707 for (Int_t iSt=1; iSt<=5; iSt++) {
708 if (bStOnOff[iSt-1]) {
709 Int_t iDetElemFirst = (iSt>1) ? fgSNDetElemCh[2*(iSt-1)-1] : 0;
710 Int_t iDetElemLast = fgSNDetElemCh[2*(iSt)-1];
711 for (int i=0; i<fgNParCh; i++) {
712 AliDebug(1,Form("fDoF[%d]= %d",i,fDoF[i]));
713 if (fDoF[i]) {
714 for (Int_t j=iDetElemFirst; j<iDetElemLast; j++){
715 FixParameter(j*fgNParCh+i, fAllowVar[i]);
716 }
717 }
718 }
719 }
720 }
721}
722
723void AliMUONAlignment::SetNonLinear(Int_t iPar /* set non linear flag */ ) {
724 /// Set nonlinear flag for parameter iPar
725 fMillepede->SetNonLinear(iPar);
726 AliInfo(Form("Parameter %i set to non linear", iPar));
727}
728
729void AliMUONAlignment::LocalEquationX() {
96ebe67e 730 /// Define local equation for current track and cluster in x coor. measurement
010eb601 731 // set local derivatives
732 SetLocalDerivative(0, fCosPhi);
733 SetLocalDerivative(1, fCosPhi * (fTrackPos[2] - fTrackPos0[2]));
734 SetLocalDerivative(2, fSinPhi);
735 SetLocalDerivative(3, fSinPhi * (fTrackPos[2] - fTrackPos0[2]));
736
737 // set global derivatives
3b2890be 738 SetGlobalDerivative(fDetElemNumber*fgNParCh+0, -fCosPhi);
739 SetGlobalDerivative(fDetElemNumber*fgNParCh+1, -fSinPhi);
010eb601 740 if (fBFieldOn){
741 SetGlobalDerivative(fDetElemNumber*fgNParCh+2,
742 -fSinPhi*(fTrackPos[0]-fDetElemPos[0])
743 +fCosPhi*(fTrackPos[1]-fDetElemPos[1]));
744 }
745 else {
746 SetGlobalDerivative(fDetElemNumber*fgNParCh+2,
747 -fSinPhi*(fTrackPos0[0]+fTrackSlope0[0]*
748 (fTrackPos[2]-fTrackPos0[2])-fDetElemPos[0])
749 +fCosPhi*(fTrackPos0[1]+fTrackSlope0[1]*
750 (fTrackPos[2]-fTrackPos0[2])-fDetElemPos[1]));
751 }
752
753 fMillepede->SetLocalEquation(fGlobalDerivatives, fLocalDerivatives, fMeas[0], fSigma[0]);
754}
755
756void AliMUONAlignment::LocalEquationY() {
96ebe67e 757 /// Define local equation for current track and cluster in y coor. measurement
010eb601 758 // set local derivatives
759 SetLocalDerivative(0,-fSinPhi);
760 SetLocalDerivative(1,-fSinPhi * (fTrackPos[2] - fTrackPos0[2]));
761 SetLocalDerivative(2, fCosPhi);
762 SetLocalDerivative(3, fCosPhi * (fTrackPos[2] - fTrackPos0[2]));
763
764 // set global derivatives
3b2890be 765 SetGlobalDerivative(fDetElemNumber*fgNParCh+0, fSinPhi);
766 SetGlobalDerivative(fDetElemNumber*fgNParCh+1, -fCosPhi);
010eb601 767 if (fBFieldOn){
768 SetGlobalDerivative(fDetElemNumber*fgNParCh+2,
769 -fCosPhi*(fTrackPos[0]-fDetElemPos[0])
770 -fSinPhi*(fTrackPos[1]-fDetElemPos[1]));
771 }
772 else {
773 SetGlobalDerivative(fDetElemNumber*fgNParCh+2,
774 -fCosPhi*(fTrackPos0[0]+fTrackSlope0[0]*
775 (fTrackPos[2]-fTrackPos0[2])-fDetElemPos[0])
776 -fSinPhi*(fTrackPos0[1]+fTrackSlope0[1]*
777 (fTrackPos[2]-fTrackPos0[2])-fDetElemPos[1]));
778 }
779
780 fMillepede->SetLocalEquation(fGlobalDerivatives, fLocalDerivatives, fMeas[1], fSigma[1]);
781}
782
783void AliMUONAlignment::FillRecPointData() {
96ebe67e 784 /// Get information of current cluster
785 fClustPos[0] = fCluster->GetX();
786 fClustPos[1] = fCluster->GetY();
787 fClustPos[2] = fCluster->GetZ();
010eb601 788 fTransform->Global2Local(fDetElemId,fClustPos[0],fClustPos[1],fClustPos[2],
789 fClustPosLoc[0],fClustPosLoc[1],fClustPosLoc[2]);
790}
791
792void AliMUONAlignment::FillTrackParamData() {
96ebe67e 793 /// Get information of current track at current cluster
010eb601 794 fTrackPos[0] = fTrackParam->GetNonBendingCoor();
795 fTrackPos[1] = fTrackParam->GetBendingCoor();
796 fTrackPos[2] = fTrackParam->GetZ();
797 fTrackSlope[0] = fTrackParam->GetNonBendingSlope();
798 fTrackSlope[1] = fTrackParam->GetBendingSlope();
799 fTransform->Global2Local(fDetElemId,fTrackPos[0],fTrackPos[1],fTrackPos[2],
800 fTrackPosLoc[0],fTrackPosLoc[1],fTrackPosLoc[2]);
801}
802
803void AliMUONAlignment::FillDetElemData() {
804 /// Get information of current detection element
805 Double_t lDetElemLocX = 0.;
806 Double_t lDetElemLocY = 0.;
807 Double_t lDetElemLocZ = 0.;
96ebe67e 808 fDetElemId = fCluster->GetDetElemId();
010eb601 809 fDetElemNumber = fDetElemId%100;
810 for (int iCh=0; iCh<fDetElemId/100-1; iCh++){
811 fDetElemNumber += fgNDetElemCh[iCh];
812 }
813 fTransform->Local2Global(fDetElemId,lDetElemLocX,lDetElemLocY,lDetElemLocZ,
814 fDetElemPos[0],fDetElemPos[1],fDetElemPos[2]);
010eb601 815}
816
817void AliMUONAlignment::ProcessTrack(AliMUONTrack * track) {
96ebe67e 818 /// Process track; Loop over clusters and set local equations
010eb601 819 fTrack = track;
820 // get tclones arrays.
96ebe67e 821 fTrackParamAtCluster = fTrack->GetTrackParamAtCluster();
010eb601 822
823 // get size of arrays
96ebe67e 824 Int_t nTrackParam = fTrackParamAtCluster->GetEntries();
3b2890be 825 AliDebug(1,Form("Number of track param entries : %i ", nTrackParam));
010eb601 826
96ebe67e 827 for(Int_t iCluster=0; iCluster<nTrackParam; iCluster++) {
828 fTrackParam = (AliMUONTrackParam *) fTrack->GetTrackParamAtCluster()->At(iCluster);
829 fCluster = fTrackParam->GetClusterPtr();
830 if (!fCluster || !fTrackParam) continue;
010eb601 831 // fill local variables for this position --> one measurement
832 FillDetElemData();
833 FillRecPointData();
834 FillTrackParamData();
835// if (fDetElemId<500) continue;
836 fTrackPos0[0] = fTrackPos[0];
837 fTrackPos0[1] = fTrackPos[1];
838 fTrackPos0[2] = fTrackPos[2];
839 fTrackSlope0[0] = fTrackSlope[0];
840 fTrackSlope0[1] = fTrackSlope[1];
841 break;
842 }
843
96ebe67e 844 for(Int_t iCluster=0; iCluster<nTrackParam; iCluster++) {
010eb601 845 // and get new pointers
96ebe67e 846 fTrackParam = (AliMUONTrackParam *) fTrack->GetTrackParamAtCluster()->At(iCluster);
847 fCluster = fTrackParam->GetClusterPtr();
848 if (!fCluster || !fTrackParam) continue;
010eb601 849 // fill local variables for this position --> one measurement
850 FillDetElemData();
851 FillRecPointData();
852 FillTrackParamData();
853// if (fDetElemId<500) continue;
96ebe67e 854 AliDebug(1,Form("cluster: %i", iCluster));
010eb601 855 AliDebug(1,Form("x: %f\t y: %f\t z: %f\t DetElemID: %i\t ", fClustPos[0], fClustPos[1], fClustPos[2], fDetElemId));
856 AliDebug(1,Form("fDetElemPos[0]: %f\t fDetElemPos[1]: %f\t fDetElemPos[2]: %f\t DetElemID: %i\t ", fDetElemPos[0],fDetElemPos[1],fDetElemPos[2], fDetElemId));
857
96ebe67e 858 AliDebug(1,Form("Track Parameter: %i", iCluster));
010eb601 859 AliDebug(1,Form("x: %f\t y: %f\t z: %f\t slopex: %f\t slopey: %f", fTrackPos[0], fTrackPos[1], fTrackPos[2], fTrackSlope[0], fTrackSlope[1]));
860 AliDebug(1,Form("x0: %f\t y0: %f\t z0: %f\t slopex0: %f\t slopey0: %f", fTrackPos0[0], fTrackPos0[1], fTrackPos0[2], fTrackSlope0[0], fTrackSlope0[1]));
861
862 fCosPhi = TMath::Cos(fPhi);
863 fSinPhi = TMath::Sin(fPhi);
864 if (fBFieldOn){
865 fMeas[0] = fTrackPos[0] - fClustPos[0];
866 fMeas[1] = fTrackPos[1] - fClustPos[1];
867 }
868 else {
869 fMeas[0] = - fClustPos[0];
870 fMeas[1] = - fClustPos[1];
871 }
872 AliDebug(1,Form("fMeas[0]: %f\t fMeas[1]: %f\t fSigma[0]: %f\t fSigma[1]: %f", fMeas[0], fMeas[1], fSigma[0], fSigma[1]));
873 // Set local equations
874 LocalEquationX();
875 LocalEquationY();
876 }
877}
878
879void AliMUONAlignment::LocalFit(Int_t iTrack, Double_t *lTrackParam, Int_t lSingleFit) {
880 /// Call local fit for this tracks
881 Int_t iRes = fMillepede->LocalFit(iTrack,lTrackParam,lSingleFit);
882 if (iRes && !lSingleFit) {
883 fMillepede->SetNLocalEquations(fMillepede->GetNLocalEquations()+1);
884 }
885}
886
887void AliMUONAlignment::GlobalFit(Double_t *parameters,Double_t *errors,Double_t *pulls) {
888 /// Call global fit; Global parameters are stored in parameters
889 fMillepede->GlobalFit(parameters,errors,pulls);
3b2890be 890
010eb601 891 AliInfo("Done fitting global parameters!");
892 for (int iGlob=0; iGlob<fgNDetElem; iGlob++){
893 printf("%d\t %f\t %f\t %f \n",iGlob,parameters[iGlob*fgNParCh+0],parameters[iGlob*fgNParCh+1],parameters[iGlob*fgNParCh+2]);
894 }
895}
896
897Double_t AliMUONAlignment::GetParError(Int_t iPar) {
898 /// Get error of parameter iPar
899 Double_t lErr = fMillepede->GetParError(iPar);
900 return lErr;
901}
902
903void AliMUONAlignment::PrintGlobalParameters() {
904 /// Print global parameters
905 fMillepede->PrintGlobalParameters();
906}
907
908//_________________________________________________________________________
3b2890be 909TGeoCombiTrans AliMUONAlignment::ReAlign(const TGeoCombiTrans & transform, double *lMisAlignment) const
010eb601 910{
911 /// Realign given transformation by given misalignment and return the misaligned transformation
912
913 Double_t cartMisAlig[3] = {0,0,0};
914 Double_t angMisAlig[3] = {0,0,0};
3b2890be 915// const Double_t *trans = transform.GetTranslation();
916// TGeoRotation *rot;
917// // check if the rotation we obtain is not NULL
918// if (transform.GetRotation()) {
919// rot = transform.GetRotation();
920// }
921// else {
922// rot = new TGeoRotation("rot");
923// } // default constructor.
924
925 cartMisAlig[0] = -lMisAlignment[0];
926 cartMisAlig[1] = -lMisAlignment[1];
927 angMisAlig[2] = -lMisAlignment[2]*180./TMath::Pi();
928
929 TGeoTranslation deltaTrans(cartMisAlig[0], cartMisAlig[1], cartMisAlig[2]);
930 TGeoRotation deltaRot;
931 deltaRot.RotateX(angMisAlig[0]);
932 deltaRot.RotateY(angMisAlig[1]);
933 deltaRot.RotateZ(angMisAlig[2]);
934
935 TGeoCombiTrans deltaTransf(deltaTrans,deltaRot);
936 TGeoHMatrix newTransfMat = transform * deltaTransf;
937
938 return TGeoCombiTrans(newTransfMat);
010eb601 939}
940
941//______________________________________________________________________
942AliMUONGeometryTransformer *
943AliMUONAlignment::ReAlign(const AliMUONGeometryTransformer * transformer,
944 double *misAlignments, Bool_t verbose)
945
946{
947 /////////////////////////////////////////////////////////////////////
948 // Takes the internal geometry module transformers, copies them
949 // and gets the Detection Elements from them.
950 // Takes misalignment parameters and applies these
951 // to the local transform of the Detection Element
952 // Obtains the global transform by multiplying the module transformer
953 // transformation with the local transformation
954 // Applies the global transform to a new detection element
955 // Adds the new detection element to a new module transformer
956 // Adds the new module transformer to a new geometry transformer
957 // Returns the new geometry transformer
958
3b2890be 959 Double_t lModuleMisAlignment[3] = {0.,0.,0.};
010eb601 960 Double_t lDetElemMisAlignment[3] = {0.,0.,0.};
3b2890be 961 Int_t iDetElemId = 0;
962 Int_t iDetElemNumber = 0;
010eb601 963
964 AliMUONGeometryTransformer *newGeometryTransformer =
ef4cb4f1 965 new AliMUONGeometryTransformer();
3b2890be 966 for (Int_t iMt = 0; iMt < transformer->GetNofModuleTransformers(); iMt++) {
967 // module transformers
968 const AliMUONGeometryModuleTransformer *kModuleTransformer =
969 transformer->GetModuleTransformer(iMt, true);
010eb601 970
3b2890be 971 AliMUONGeometryModuleTransformer *newModuleTransformer =
972 new AliMUONGeometryModuleTransformer(iMt);
973 newGeometryTransformer->AddModuleTransformer(newModuleTransformer);
974
975 TGeoCombiTrans moduleTransform =
976 TGeoCombiTrans(*kModuleTransformer->GetTransformation());
977 // New module transformation
978 TGeoCombiTrans newModuleTransform = ReAlign(moduleTransform,lModuleMisAlignment);
979 newModuleTransformer->SetTransformation(newModuleTransform);
980
981 // Get delta transformation:
982 // Tdelta = Tnew * Told.inverse
983 TGeoHMatrix deltaModuleTransform =
984 AliMUONGeometryBuilder::Multiply(newModuleTransform,
985 kModuleTransformer->GetTransformation()->Inverse());
986 // Create module mis alignment matrix
987 newGeometryTransformer
988 ->AddMisAlignModule(kModuleTransformer->GetModuleId(), deltaModuleTransform);
989
990 AliMpExMap *detElements = kModuleTransformer->GetDetElementStore();
991
992 if (verbose)
993 AliInfo(Form("%i DEs in old GeometryStore %i",detElements->GetSize(), iMt));
994
630711ed 995 TIter next(detElements->CreateIterator());
996 AliMUONGeometryDetElement* detElement;
997 Int_t iDe(-1);
998 while ( ( detElement = static_cast<AliMUONGeometryDetElement*>(next()) ) )
999 {
1000 ++iDe;
3b2890be 1001 /// make a new detection element
1002 AliMUONGeometryDetElement *newDetElement =
1003 new AliMUONGeometryDetElement(detElement->GetId(),
1004 detElement->GetVolumePath());
1005 TString lDetElemName(detElement->GetDEName());
1006 lDetElemName.ReplaceAll("DE","");
1007 iDetElemId = lDetElemName.Atoi();
1008 iDetElemNumber = iDetElemId%100;
1009 for (int iCh=0; iCh<iDetElemId/100-1; iCh++){
1010 iDetElemNumber += fgNDetElemCh[iCh];
1011 }
1012 for (int i=0; i<fgNParCh; i++) {
1013 lDetElemMisAlignment[i] = 0.0;
1014 if (iMt<fgNTrkMod) {
1015 AliInfo(Form("iMt %i, iCh %i, iDe %i, iDeId %i, iDeNb %i, iPar %i",iMt, iDetElemId/100, iDe, iDetElemId, iDetElemNumber, iDetElemNumber*fgNParCh+i));
1016 lDetElemMisAlignment[i] = misAlignments[iDetElemNumber*fgNParCh+i];
1017 }
1018 }
1019 // local transformation of this detection element.
1020 TGeoCombiTrans localTransform
1021 = TGeoCombiTrans(*detElement->GetLocalTransformation());
1022 TGeoCombiTrans newLocalTransform = ReAlign(localTransform,lDetElemMisAlignment);
1023 newDetElement->SetLocalTransformation(newLocalTransform);
1024
1025 // global transformation
1026 TGeoHMatrix newGlobalTransform =
1027 AliMUONGeometryBuilder::Multiply(newModuleTransform,
1028 newLocalTransform);
1029 newDetElement->SetGlobalTransformation(newGlobalTransform);
010eb601 1030
3b2890be 1031 // add this det element to module
1032 newModuleTransformer->GetDetElementStore()->Add(newDetElement->GetId(),
1033 newDetElement);
1034
1035 // In the Alice Alignment Framework misalignment objects store
1036 // global delta transformation
1037 // Get detection "intermediate" global transformation
1038 TGeoHMatrix newOldGlobalTransform = newModuleTransform * localTransform;
1039 // Get detection element global delta transformation:
1040 // Tdelta = Tnew * Told.inverse
1041 TGeoHMatrix deltaGlobalTransform
1042 = AliMUONGeometryBuilder::Multiply(newGlobalTransform,
1043 newOldGlobalTransform.Inverse());
010eb601 1044
3b2890be 1045 // Create mis alignment matrix
1046 newGeometryTransformer
1047 ->AddMisAlignDetElement(detElement->GetId(), deltaGlobalTransform);
010eb601 1048 }
3b2890be 1049
1050 if (verbose)
1051 AliInfo(Form("Added module transformer %i to the transformer", iMt));
1052 newGeometryTransformer->AddModuleTransformer(newModuleTransformer);
1053 }
010eb601 1054 return newGeometryTransformer;
1055}
1056