fix finding of pad neighbours; remove methods to write them in OCDB
[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
56218672 20/// Alignment class for the ALICE DiMuon spectrometer
010eb601 21///
56218672 22/// MUON specific alignment class which interface to AliMillepede.
010eb601 23/// For each track ProcessTrack calculates the local and global derivatives
96ebe67e 24/// at each cluster and fill the corresponding local equations. Provide methods
56218672 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 "AliMillepede.h"
39
8c95578a 40#include "AliMpExMap.h"
630711ed 41#include "AliMpExMapIterator.h"
8c95578a 42
4818a9b7 43#include "AliAlignObjMatrix.h"
8c95578a 44#include "AliLog.h"
45
2060b217 46#include "TMath.h"
4818a9b7 47#include "TMatrixDSym.h"
ce8cd162 48#include "TClonesArray.h"
8c95578a 49
78649106 50/// \cond CLASSIMP
010eb601 51ClassImp(AliMUONAlignment)
78649106 52/// \endcond
53
56218672 54//_____________________________________________________________________
55// static variables
56Int_t AliMUONAlignment::fgNDetElem = 4*2+4*2+18*2+26*2+26*2;
57Int_t AliMUONAlignment::fgNDetElemCh[10] = {4,4,4,4,18,18,26,26,26,26};
58Int_t AliMUONAlignment::fgSNDetElemCh[10] = {4,8,12,16,34,52,78,104,130,156};
59Int_t AliMUONAlignment::fgNParCh = 4;
60Int_t AliMUONAlignment::fgNTrkMod = 16;
61Int_t AliMUONAlignment::fgNCh = 10;
62Int_t AliMUONAlignment::fgNSt = 5;
63
64//_____________________________________________________________________
65AliMUONAlignment::AliMUONAlignment()
8395bff1 66 : TObject(),
67 fBFieldOn(kTRUE),
56218672 68 fStartFac(256.),
69 fResCutInitial(100.),
8395bff1 70 fResCut(100.),
71 fMillepede(0),
8395bff1 72 fTrack(0),
96ebe67e 73 fCluster(0),
8395bff1 74 fTrackParam(0),
75 fNGlobal(fgNDetElem*fgNParCh),
76 fNLocal(4),
77 fNStdDev(3),
78 fDetElemId(0),
79 fDetElemNumber(0),
80 fPhi(0.),
81 fCosPhi(1.),
82 fSinPhi(0.),
56218672 83 fTrackRecord(),
8395bff1 84 fTransform(0)
010eb601 85{
88807319 86 /// Default constructor
56218672 87 fSigma[0] = 1.5e-1;
010eb601 88 fSigma[1] = 1.0e-2;
010eb601 89
64e2c144 90 AliInfo(Form("fSigma[0]: %f\t fSigma[1]: %f",fSigma[0],fSigma[1]));
91
723b0b5b 92 fDoF[0] = kTRUE; fDoF[1] = kTRUE; fDoF[2] = kTRUE; fDoF[3] = kTRUE;
93 fAllowVar[0] = 0.05; fAllowVar[1] = 0.05; fAllowVar[2] = 0.001; fAllowVar[3] = 0.5;
56218672 94
010eb601 95 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));
96
97 fMillepede = new AliMillepede();
98
99 Init(fNGlobal, fNLocal, fNStdDev);
100
101 ResetLocalEquation();
102 AliInfo("Parameters initialized to zero");
103
104}
105
56218672 106//_____________________________________________________________________
d9426e3f 107AliMUONAlignment::AliMUONAlignment(TRootIOCtor* /*dummy*/)
108: TObject(),
109fBFieldOn(kFALSE),
110fStartFac(0.),
111fResCutInitial(0.),
112fResCut(0.),
113fMillepede(0),
114fTrack(0),
115fCluster(0),
116fTrackParam(0),
117fNGlobal(0),
118fNLocal(0),
119fNStdDev(0),
120fDetElemId(0),
121fDetElemNumber(0),
122fPhi(0.),
123fCosPhi(0.),
124fSinPhi(0.),
125fTrackRecord(),
126fTransform(0)
127{
7fb4730e 128 /// Root IO constructor
129 ResetConstraints();
130 for (Int_t iCh=0; iCh<10; iCh++) {
131 fChOnOff[iCh] = kFALSE;
132 }
133 fSpecLROnOff[0] = kFALSE; fSpecLROnOff[1] = kFALSE;
134 for (Int_t iDoF=0; iDoF<4; iDoF++) {
135 fDoF[iDoF] = kFALSE;
136 fAllowVar[iDoF] = kFALSE;
137 }
138 for (Int_t i=0; i<3; i++) {
139 fClustPos[i] = 0;
140 fClustPosLoc[i] = 0;
141 fTrackPos0[i] = 0;
142 fTrackPos[i] = 0;
143 fTrackPosLoc[i] = 0;
88807319 144 fDetElemPos[i] = 0;
7fb4730e 145 }
146 fTrackSlope0[0]=0; fTrackSlope0[1]=0;
147 fTrackSlope[0]=0; fTrackSlope[1]=0;
148 fMeas[0]=0; fMeas[1]=0;
149 fSigma[0]=0; fSigma[1]=0;
150 for (Int_t iLPar=0; iLPar<4; iLPar++) {
151 fLocalDerivatives[iLPar]=0;
152 }
153 for (Int_t iGPar=0; iGPar<624; iGPar++) {
88807319 154 fGlobalDerivatives[iGPar]=0;
7fb4730e 155 }
d9426e3f 156}
157
158//_____________________________________________________________________
56218672 159AliMUONAlignment::~AliMUONAlignment()
160{}
010eb601 161
56218672 162//_____________________________________________________________________
163void AliMUONAlignment::Init(
164 Int_t nGlobal, /* number of global paramers */
165 Int_t nLocal, /* number of local parameters */
166 Int_t nStdDev /* std dev cut */ )
010eb601 167{
168 /// Initialization of AliMillepede. Fix parameters, define constraints ...
169 fMillepede->InitMille(nGlobal,nLocal,nStdDev,fResCut,fResCutInitial);
170
56218672 171 // Bool_t bStOnOff[5] = {kTRUE,kTRUE,kTRUE,kTRUE,kTRUE};
172 // Bool_t bChOnOff[10] = {kTRUE,kTRUE,kTRUE,kTRUE,kTRUE,kTRUE,kTRUE,kTRUE,kTRUE,kTRUE};
173 // Bool_t bSpecLROnOff[2] = {kTRUE,kTRUE};
010eb601 174
56218672 175 // AllowVariations(bChOnOff);
010eb601 176
177 // Fix parameters or add constraints here
56218672 178 // for (Int_t iSt=0; iSt<5; iSt++)
179 // { if (!bStOnOff[iSt]) FixStation(iSt+1); }
180
181 // for (Int_t iCh=0; iCh<10; iCh++)
182 // { if (!bChOnOff[iCh]) FixChamber(iCh+1); }
010eb601 183
d8ad38e5 184// FixHalfSpectrometer(bChOnOff,bSpecLROnOff);
3b2890be 185
010eb601 186 ResetConstraints();
56218672 187
3b2890be 188 // Define global constrains to be applied
189 // X, Y, P, XvsZ, YvsZ, PvsZ, XvsY, YvsY, PvsY
190 Bool_t bVarXYT[9] = {kTRUE,kTRUE,kTRUE,kTRUE,kTRUE,kTRUE,kTRUE,kTRUE,kTRUE};
191 Bool_t bDetTLBR[4] = {kFALSE,kTRUE,kFALSE,kTRUE};
192 // AddConstraints(bStOnOff,bVarXYT,bDetTLBR,bSpecLROnOff);
193
194 // Other possible way to add constrains
010eb601 195 bVarXYT[0] = kFALSE; bVarXYT[1] = kFALSE; bVarXYT[2] = kTRUE;
196 bDetTLBR[0] = kFALSE; bDetTLBR[1] = kTRUE; bDetTLBR[2] = kFALSE; bDetTLBR[3] = kFALSE;
56218672 197 // AddConstraints(bStOnOff,bVarXYT,bDetTLBR);
3b2890be 198
199 bVarXYT[0] = kTRUE; bVarXYT[1] = kTRUE; bVarXYT[2] = kFALSE;
200 // AddConstraints(bStOnOff,bVarXYT);
56218672 201
010eb601 202 // Set iterations
56218672 203 if (fStartFac>1) fMillepede->SetIterations(fStartFac);
010eb601 204}
205
56218672 206//_____________________________________________________________________
207void AliMUONAlignment::FixStation(Int_t iSt)
208{
010eb601 209 /// Fix all detection elements of station iSt
56218672 210 Int_t iDetElemFirst = (iSt>1) ? fgSNDetElemCh[2*(iSt-1)-1] : 0;
211 Int_t iDetElemLast = fgSNDetElemCh[2*(iSt)-1];
212 for (Int_t i = iDetElemFirst; i < iDetElemLast; i++)
213 {
010eb601 214 FixParameter(i*fgNParCh+0, 0.0);
215 FixParameter(i*fgNParCh+1, 0.0);
216 FixParameter(i*fgNParCh+2, 0.0);
723b0b5b 217 FixParameter(i*fgNParCh+3, 0.0);
010eb601 218 }
56218672 219
010eb601 220}
221
56218672 222//_____________________________________________________________________
223void AliMUONAlignment::FixChamber(Int_t iCh)
224{
d8ad38e5 225 /// Fix all detection elements of chamber iCh
56218672 226 Int_t iDetElemFirst = (iCh>1) ? fgSNDetElemCh[iCh-2] : 0;
227 Int_t iDetElemLast = fgSNDetElemCh[iCh-1];
228 for (Int_t i = iDetElemFirst; i < iDetElemLast; i++)
229 {
d8ad38e5 230 FixParameter(i*fgNParCh+0, 0.0);
231 FixParameter(i*fgNParCh+1, 0.0);
232 FixParameter(i*fgNParCh+2, 0.0);
723b0b5b 233 FixParameter(i*fgNParCh+3, 0.0);
234 }
235}
236
56218672 237//_____________________________________________________________________
238void AliMUONAlignment::FixDetElem(Int_t iDetElemId, TString sVarXYT)
239{
240
723b0b5b 241 /// Fix a given detection element
242 Int_t iDetElemNumber = iDetElemId%100;
56218672 243 for (int iCh=0; iCh<iDetElemId/100-1; iCh++)
244 {
723b0b5b 245 iDetElemNumber += fgNDetElemCh[iCh];
246 }
56218672 247
248 if (sVarXYT.Contains("X"))
249 {
250 // X constraint
723b0b5b 251 FixParameter(iDetElemNumber*fgNParCh+0, 0.0);
252 }
56218672 253
254 if (sVarXYT.Contains("Y"))
255 {
256 // Y constraint
723b0b5b 257 FixParameter(iDetElemNumber*fgNParCh+1, 0.0);
258 }
56218672 259
260 if (sVarXYT.Contains("T"))
261 {
262 // T constraint
723b0b5b 263 FixParameter(iDetElemNumber*fgNParCh+2, 0.0);
264 }
56218672 265
266 if (sVarXYT.Contains("Z"))
267 {
268 // T constraint
723b0b5b 269 FixParameter(iDetElemNumber*fgNParCh+3, 0.0);
d8ad38e5 270 }
56218672 271
d8ad38e5 272}
273
56218672 274//_____________________________________________________________________
275void AliMUONAlignment::FixHalfSpectrometer(const Bool_t *lChOnOff, const Bool_t *lSpecLROnOff)
276{
277
3b2890be 278 /// Fix left or right detector
56218672 279 for (Int_t i = 0; i < fgNDetElem; i++)
280 {
281
3b2890be 282 Int_t iCh=0;
56218672 283 for (iCh=1; iCh<=fgNCh; iCh++)
284 { if (i<fgSNDetElemCh[iCh-1]) break; }
285
286 if (lChOnOff[iCh-1])
287 {
288
3b2890be 289 Int_t lDetElemNumber = (iCh==1) ? i : i-fgSNDetElemCh[iCh-2];
56218672 290 if (iCh>=1 && iCh<=4)
291 {
292
293 if ((lDetElemNumber==1 || lDetElemNumber==2) && !lSpecLROnOff[0])
294 {
295 // From track crossings
296 FixParameter(i*fgNParCh+0, 0.0);
297 FixParameter(i*fgNParCh+1, 0.0);
298 FixParameter(i*fgNParCh+2, 0.0);
299 FixParameter(i*fgNParCh+3, 0.0);
300 }
301
302 if ((lDetElemNumber==0 || lDetElemNumber==3) && !lSpecLROnOff[1])
303 {
304 // From track crossings
305 FixParameter(i*fgNParCh+0, 0.0);
306 FixParameter(i*fgNParCh+1, 0.0);
307 FixParameter(i*fgNParCh+2, 0.0);
308 FixParameter(i*fgNParCh+3, 0.0);
309 }
310
3b2890be 311 }
56218672 312
313 if (iCh>=5 && iCh<=6)
314 {
315
316 if ((lDetElemNumber>=5&&lDetElemNumber<=13) && !lSpecLROnOff[0])
317 {
318 FixParameter(i*fgNParCh+0, 0.0);
319 FixParameter(i*fgNParCh+1, 0.0);
320 FixParameter(i*fgNParCh+2, 0.0);
321 FixParameter(i*fgNParCh+3, 0.0);
322 }
323
324 if (((lDetElemNumber>=0&&lDetElemNumber<=4) ||
325 (lDetElemNumber>=14&&lDetElemNumber<=17)) && !lSpecLROnOff[1])
326 {
327
328 FixParameter(i*fgNParCh+0, 0.0);
329 FixParameter(i*fgNParCh+1, 0.0);
330 FixParameter(i*fgNParCh+2, 0.0);
331 FixParameter(i*fgNParCh+3, 0.0);
332 }
333
3b2890be 334 }
56218672 335
336 if (iCh>=7 && iCh<=10)
337 {
338
339 if ((lDetElemNumber>=7&&lDetElemNumber<=19) && !lSpecLROnOff[0])
340 {
341 FixParameter(i*fgNParCh+0, 0.0);
342 FixParameter(i*fgNParCh+1, 0.0);
343 FixParameter(i*fgNParCh+2, 0.0);
344 FixParameter(i*fgNParCh+3, 0.0);
345 }
346
347 if (((lDetElemNumber>=0&&lDetElemNumber<=6) ||
348 (lDetElemNumber>=20&&lDetElemNumber<=25)) && !lSpecLROnOff[1])
349 {
350 FixParameter(i*fgNParCh+0, 0.0);
351 FixParameter(i*fgNParCh+1, 0.0);
352 FixParameter(i*fgNParCh+2, 0.0);
353 FixParameter(i*fgNParCh+3, 0.0);
354 }
355
3b2890be 356 }
56218672 357
3b2890be 358 }
56218672 359
3b2890be 360 }
56218672 361
3b2890be 362}
363
56218672 364//______________________________________________________________________
365void AliMUONAlignment::SetNonLinear(const Bool_t *lChOnOff, const Bool_t *lVarXYT)
366{
367
d8ad38e5 368 /// Set non linear parameter flag selected chambers and degrees of freedom
56218672 369 for (Int_t i = 0; i < fgNDetElem; i++)
370 {
371
010eb601 372 Int_t iCh=0;
56218672 373 for (iCh=1; iCh<=fgNCh; iCh++)
374 { if (i<fgSNDetElemCh[iCh-1]) break; }
375
376 if (lChOnOff[iCh-1])
377 {
378
379 if (lVarXYT[0])
380 {
381 // X constraint
382 SetNonLinear(i*fgNParCh+0);
010eb601 383 }
56218672 384
385 if (lVarXYT[1])
386 {
387 // Y constraint
388 SetNonLinear(i*fgNParCh+1);
010eb601 389 }
56218672 390
391 if (lVarXYT[2])
392 {
393 // T constraint
394 SetNonLinear(i*fgNParCh+2);
010eb601 395 }
56218672 396
397 if (lVarXYT[3])
398 {
399 // Z constraint
400 SetNonLinear(i*fgNParCh+3);
723b0b5b 401 }
56218672 402
010eb601 403 }
56218672 404
010eb601 405 }
56218672 406
010eb601 407}
408
56218672 409//______________________________________________________________________
410void AliMUONAlignment::AddConstraints(const Bool_t *lChOnOff, const Bool_t *lVarXYT)
411{
412
413 /// Add constraint equations for selected chambers and degrees of freedom
414 for (Int_t i = 0; i < fgNDetElem; i++)
415 {
416
010eb601 417 Int_t iCh=0;
56218672 418 for (iCh=1; iCh<=fgNCh; iCh++)
419 {
010eb601 420 if (i<fgSNDetElemCh[iCh-1]) break;
421 }
56218672 422
423 if (lChOnOff[iCh-1])
424 {
425 if (lVarXYT[0])
426 {
427 // X constraint
428 fConstraintX[i*fgNParCh+0]=1.0;
010eb601 429 }
56218672 430
431 if (lVarXYT[1])
432 {
433 // Y constraint
434 fConstraintY[i*fgNParCh+1]=1.0;
010eb601 435 }
56218672 436
437 if (lVarXYT[2])
438 {
439 // T constraint
440 fConstraintP[i*fgNParCh+2]=1.0;
010eb601 441 }
56218672 442 // if (lVarXYT[3]) { // Z constraint
443 // fConstraintP[i*fgNParCh+3]=1.0;
444 // }
445
010eb601 446 }
447 }
56218672 448
449 if (lVarXYT[0])
450 {
451 // X constraint
010eb601 452 AddConstraint(fConstraintX,0.0);
453 }
56218672 454
455 if (lVarXYT[1])
456 {
457 // Y constraint
010eb601 458 AddConstraint(fConstraintY,0.0);
459 }
56218672 460
461 if (lVarXYT[2])
462 {
463 // T constraint
010eb601 464 AddConstraint(fConstraintP,0.0);
465 }
56218672 466
723b0b5b 467// if (lVarXYT[3]) { // Z constraint
468// AddConstraint(fConstraintP,0.0);
469// }
010eb601 470}
471
56218672 472//______________________________________________________________________
473void AliMUONAlignment::AddConstraints(const Bool_t *lChOnOff, const Bool_t *lVarXYT, const Bool_t *lDetTLBR, const Bool_t *lSpecLROnOff)
474{
475 /// Add constraint equations for selected chambers, degrees of freedom and detector half
3b2890be 476 Double_t lDetElemLocX = 0.;
477 Double_t lDetElemLocY = 0.;
478 Double_t lDetElemLocZ = 0.;
479 Double_t lDetElemGloX = 0.;
480 Double_t lDetElemGloY = 0.;
481 Double_t lDetElemGloZ = 0.;
482 Double_t lMeanY = 0.;
483 Double_t lSigmaY = 0.;
484 Double_t lMeanZ = 0.;
485 Double_t lSigmaZ = 0.;
486 Int_t lNDetElem = 0;
56218672 487 for (Int_t i = 0; i < fgNDetElem; i++)
488 {
489
010eb601 490 Int_t iCh=0;
491 for (iCh=1; iCh<=fgNCh; iCh++){
492 if (i<fgSNDetElemCh[iCh-1]) break;
493 }
56218672 494 if (lChOnOff[iCh-1]){
3b2890be 495 Int_t lDetElemNumber = (iCh==1) ? i : i-fgSNDetElemCh[iCh-2];
496 Int_t lDetElemId = iCh*100+lDetElemNumber;
497 fTransform->Local2Global(lDetElemId,lDetElemLocX,lDetElemLocY,lDetElemLocZ,
56218672 498 lDetElemGloX,lDetElemGloY,lDetElemGloZ);
3b2890be 499 if (iCh>=1 && iCh<=4){
56218672 500 if ((lDetElemNumber==1 || lDetElemNumber==2) && lSpecLROnOff[0]){ // From track crossings
501 lMeanY += lDetElemGloY;
502 lSigmaY += lDetElemGloY*lDetElemGloY;
503 lMeanZ += lDetElemGloZ;
504 lSigmaZ += lDetElemGloZ*lDetElemGloZ;
505 lNDetElem++;
506 }
507 if ((lDetElemNumber==0 || lDetElemNumber==3) && lSpecLROnOff[1]){ // From track crossings
508 lMeanY += lDetElemGloY;
509 lSigmaY += lDetElemGloY*lDetElemGloY;
510 lMeanZ += lDetElemGloZ;
511 lSigmaZ += lDetElemGloZ*lDetElemGloZ;
512 lNDetElem++;
513 }
3b2890be 514 }
515 if (iCh>=5 && iCh<=6){
56218672 516 if ((lDetElemNumber>=5&&lDetElemNumber<=13) && lSpecLROnOff[0]){
517 lMeanY += lDetElemGloY;
518 lSigmaY += lDetElemGloY*lDetElemGloY;
519 lMeanZ += lDetElemGloZ;
520 lSigmaZ += lDetElemGloZ*lDetElemGloZ;
521 lNDetElem++;
522 }
523 if (((lDetElemNumber>=0&&lDetElemNumber<=4) ||
524 (lDetElemNumber>=14&&lDetElemNumber<=17)) && lSpecLROnOff[1]){
525 lMeanY += lDetElemGloY;
526 lSigmaY += lDetElemGloY*lDetElemGloY;
527 lMeanZ += lDetElemGloZ;
528 lSigmaZ += lDetElemGloZ*lDetElemGloZ;
529 lNDetElem++;
530 }
3b2890be 531 }
532 if (iCh>=7 && iCh<=10){
56218672 533 if ((lDetElemNumber>=7&&lDetElemNumber<=19) && lSpecLROnOff[0]){
534 lMeanY += lDetElemGloY;
535 lSigmaY += lDetElemGloY*lDetElemGloY;
536 lMeanZ += lDetElemGloZ;
537 lSigmaZ += lDetElemGloZ*lDetElemGloZ;
538 lNDetElem++;
539 }
540 if (((lDetElemNumber>=0&&lDetElemNumber<=6) ||
541 (lDetElemNumber>=20&&lDetElemNumber<=25)) && lSpecLROnOff[1]){
542 lMeanY += lDetElemGloY;
543 lSigmaY += lDetElemGloY*lDetElemGloY;
544 lMeanZ += lDetElemGloZ;
545 lSigmaZ += lDetElemGloZ*lDetElemGloZ;
546 lNDetElem++;
547 }
3b2890be 548 }
549 }
550 }
877567ef 551 if (lNDetElem) {
552 lMeanY /= lNDetElem;
553 lSigmaY /= lNDetElem;
554 lSigmaY = TMath::Sqrt(lSigmaY-lMeanY*lMeanY);
555 lMeanZ /= lNDetElem;
556 lSigmaZ /= lNDetElem;
557 lSigmaZ = TMath::Sqrt(lSigmaZ-lMeanZ*lMeanZ);
558 AliInfo(Form("Used %i DetElem, MeanZ= %f , SigmaZ= %f", lNDetElem,lMeanZ,lSigmaZ));
559 } else {
560 AliError("No detection elements to constrain!!!");
561 return;
562 }
563
56218672 564 for (Int_t i = 0; i < fgNDetElem; i++){
3b2890be 565 Int_t iCh=0;
566 for (iCh=1; iCh<=fgNCh; iCh++){
567 if (i<fgSNDetElemCh[iCh-1]) break;
568 }
d8ad38e5 569 if (lChOnOff[iCh-1]){
3b2890be 570 Int_t lDetElemNumber = (iCh==1) ? i : i-fgSNDetElemCh[iCh-2];
571 Int_t lDetElemId = iCh*100+lDetElemNumber;
572 fTransform->Local2Global(lDetElemId,lDetElemLocX,lDetElemLocY,lDetElemLocZ,
56218672 573 lDetElemGloX,lDetElemGloY,lDetElemGloZ);
010eb601 574 if (lVarXYT[0]) { // X constraint
56218672 575 if (lDetTLBR[0]) ConstrainT(i,iCh,fConstraintXT,0); // Top half
576 if (lDetTLBR[1]) ConstrainL(i,iCh,fConstraintXL,0); // Left half
577 if (lDetTLBR[2]) ConstrainB(i,iCh,fConstraintXB,0); // Bottom half
578 if (lDetTLBR[3]) ConstrainR(i,iCh,fConstraintXR,0); // Right half
010eb601 579 }
3b2890be 580 if (lVarXYT[1]) { // Y constraint
56218672 581 if (lDetTLBR[0]) ConstrainT(i,iCh,fConstraintYT,1); // Top half
582 if (lDetTLBR[1]) ConstrainL(i,iCh,fConstraintYL,1); // Left half
583 if (lDetTLBR[2]) ConstrainB(i,iCh,fConstraintYB,1); // Bottom half
584 if (lDetTLBR[3]) ConstrainR(i,iCh,fConstraintYR,1); // Right half
010eb601 585 }
3b2890be 586 if (lVarXYT[2]) { // P constraint
56218672 587 if (lDetTLBR[0]) ConstrainT(i,iCh,fConstraintPT,2); // Top half
588 if (lDetTLBR[1]) ConstrainL(i,iCh,fConstraintPL,2); // Left half
589 if (lDetTLBR[2]) ConstrainB(i,iCh,fConstraintPB,2); // Bottom half
590 if (lDetTLBR[3]) ConstrainR(i,iCh,fConstraintPR,2); // Right half
010eb601 591 }
3b2890be 592 if (lVarXYT[3]) { // X-Z shearing
56218672 593 if (lDetTLBR[0]) ConstrainT(i,iCh,fConstraintXZT,0,(lDetElemGloZ-lMeanZ)/lSigmaZ); // Top half
594 if (lDetTLBR[1]) ConstrainL(i,iCh,fConstraintXZL,0,(lDetElemGloZ-lMeanZ)/lSigmaZ); // Left half
595 if (lDetTLBR[2]) ConstrainB(i,iCh,fConstraintXZB,0,(lDetElemGloZ-lMeanZ)/lSigmaZ); // Bottom half
596 if (lDetTLBR[3]) ConstrainR(i,iCh,fConstraintXZR,0,(lDetElemGloZ-lMeanZ)/lSigmaZ); // Right half
3b2890be 597 }
598 if (lVarXYT[4]) { // Y-Z shearing
56218672 599 if (lDetTLBR[0]) ConstrainT(i,iCh,fConstraintYZT,1,(lDetElemGloZ-lMeanZ)/lSigmaZ); // Top half
600 if (lDetTLBR[1]) ConstrainL(i,iCh,fConstraintYZL,1,(lDetElemGloZ-lMeanZ)/lSigmaZ); // Left half
601 if (lDetTLBR[2]) ConstrainB(i,iCh,fConstraintYZB,1,(lDetElemGloZ-lMeanZ)/lSigmaZ); // Bottom half
602 if (lDetTLBR[3]) ConstrainR(i,iCh,fConstraintYZR,1,(lDetElemGloZ-lMeanZ)/lSigmaZ); // Right half
3b2890be 603 }
604 if (lVarXYT[5]) { // P-Z rotation
56218672 605 if (lDetTLBR[0]) ConstrainT(i,iCh,fConstraintPZT,2,(lDetElemGloZ-lMeanZ)/lSigmaZ); // Top half
606 if (lDetTLBR[1]) ConstrainL(i,iCh,fConstraintPZL,2,(lDetElemGloZ-lMeanZ)/lSigmaZ); // Left half
607 if (lDetTLBR[2]) ConstrainB(i,iCh,fConstraintPZB,2,(lDetElemGloZ-lMeanZ)/lSigmaZ); // Bottom half
608 if (lDetTLBR[3]) ConstrainR(i,iCh,fConstraintPZR,2,(lDetElemGloZ-lMeanZ)/lSigmaZ); // Right half
3b2890be 609 }
610 if (lVarXYT[6]) { // X-Y shearing
56218672 611 if (lDetTLBR[0]) ConstrainT(i,iCh,fConstraintXYT,0,(lDetElemGloY-lMeanY)/lSigmaY); // Top half
612 if (lDetTLBR[1]) ConstrainL(i,iCh,fConstraintXYL,0,(lDetElemGloY-lMeanY)/lSigmaY); // Left half
613 if (lDetTLBR[2]) ConstrainB(i,iCh,fConstraintXYB,0,(lDetElemGloY-lMeanY)/lSigmaY); // Bottom half
614 if (lDetTLBR[3]) ConstrainR(i,iCh,fConstraintXYR,0,(lDetElemGloY-lMeanY)/lSigmaY); // Right half
3b2890be 615 }
616 if (lVarXYT[7]) { // Y-Y scaling
56218672 617 if (lDetTLBR[0]) ConstrainT(i,iCh,fConstraintYYT,1,(lDetElemGloY-lMeanY)/lSigmaY); // Top half
618 if (lDetTLBR[1]) ConstrainL(i,iCh,fConstraintYYL,1,(lDetElemGloY-lMeanY)/lSigmaY); // Left half
619 if (lDetTLBR[2]) ConstrainB(i,iCh,fConstraintYYB,1,(lDetElemGloY-lMeanY)/lSigmaY); // Bottom half
620 if (lDetTLBR[3]) ConstrainR(i,iCh,fConstraintYYR,1,(lDetElemGloY-lMeanY)/lSigmaY); // Right half
3b2890be 621 }
622 if (lVarXYT[8]) { // P-Y rotation
56218672 623 if (lDetTLBR[0]) ConstrainT(i,iCh,fConstraintPYT,2,(lDetElemGloY-lMeanY)/lSigmaY); // Top half
624 if (lDetTLBR[1]) ConstrainL(i,iCh,fConstraintPYL,2,(lDetElemGloY-lMeanY)/lSigmaY); // Left half
625 if (lDetTLBR[2]) ConstrainB(i,iCh,fConstraintPYB,2,(lDetElemGloY-lMeanY)/lSigmaY); // Bottom half
626 if (lDetTLBR[3]) ConstrainR(i,iCh,fConstraintPYR,2,(lDetElemGloY-lMeanY)/lSigmaY); // Right half
3b2890be 627 }
010eb601 628 }
629 }
630 if (lVarXYT[0]) { // X constraint
631 if (lDetTLBR[0]) AddConstraint(fConstraintXT,0.0); // Top half
632 if (lDetTLBR[1]) AddConstraint(fConstraintXL,0.0); // Left half
633 if (lDetTLBR[2]) AddConstraint(fConstraintXB,0.0); // Bottom half
634 if (lDetTLBR[3]) AddConstraint(fConstraintXR,0.0); // Right half
635 }
636 if (lVarXYT[1]) { // Y constraint
637 if (lDetTLBR[0]) AddConstraint(fConstraintYT,0.0); // Top half
638 if (lDetTLBR[1]) AddConstraint(fConstraintYL,0.0); // Left half
639 if (lDetTLBR[2]) AddConstraint(fConstraintYB,0.0); // Bottom half
640 if (lDetTLBR[3]) AddConstraint(fConstraintYR,0.0); // Right half
641 }
642 if (lVarXYT[2]) { // T constraint
643 if (lDetTLBR[0]) AddConstraint(fConstraintPT,0.0); // Top half
644 if (lDetTLBR[1]) AddConstraint(fConstraintPL,0.0); // Left half
645 if (lDetTLBR[2]) AddConstraint(fConstraintPB,0.0); // Bottom half
646 if (lDetTLBR[3]) AddConstraint(fConstraintPR,0.0); // Right half
647 }
3b2890be 648 if (lVarXYT[3]) { // X-Z constraint
649 if (lDetTLBR[0]) AddConstraint(fConstraintXZT,0.0); // Top half
650 if (lDetTLBR[1]) AddConstraint(fConstraintXZL,0.0); // Left half
651 if (lDetTLBR[2]) AddConstraint(fConstraintXZB,0.0); // Bottom half
652 if (lDetTLBR[3]) AddConstraint(fConstraintXZR,0.0); // Right half
653 }
654 if (lVarXYT[4]) { // Y-Z constraint
655 if (lDetTLBR[0]) AddConstraint(fConstraintYZT,0.0); // Top half
656 if (lDetTLBR[1]) AddConstraint(fConstraintYZL,0.0); // Left half
657 if (lDetTLBR[2]) AddConstraint(fConstraintYZB,0.0); // Bottom half
658 if (lDetTLBR[3]) AddConstraint(fConstraintYZR,0.0); // Right half
659 }
660 if (lVarXYT[5]) { // P-Z constraint
661 if (lDetTLBR[0]) AddConstraint(fConstraintPZT,0.0); // Top half
662 if (lDetTLBR[1]) AddConstraint(fConstraintPZL,0.0); // Left half
663 if (lDetTLBR[2]) AddConstraint(fConstraintPZB,0.0); // Bottom half
664 if (lDetTLBR[3]) AddConstraint(fConstraintPZR,0.0); // Right half
665 }
666 if (lVarXYT[6]) { // X-Y constraint
667 if (lDetTLBR[0]) AddConstraint(fConstraintXYT,0.0); // Top half
668 if (lDetTLBR[1]) AddConstraint(fConstraintXYL,0.0); // Left half
669 if (lDetTLBR[2]) AddConstraint(fConstraintXYB,0.0); // Bottom half
670 if (lDetTLBR[3]) AddConstraint(fConstraintXYR,0.0); // Right half
671 }
672 if (lVarXYT[7]) { // Y-Y constraint
673 if (lDetTLBR[0]) AddConstraint(fConstraintYYT,0.0); // Top half
674 if (lDetTLBR[1]) AddConstraint(fConstraintYYL,0.0); // Left half
675 if (lDetTLBR[2]) AddConstraint(fConstraintYYB,0.0); // Bottom half
676 if (lDetTLBR[3]) AddConstraint(fConstraintYYR,0.0); // Right half
677 }
678 if (lVarXYT[8]) { // P-Y constraint
679 if (lDetTLBR[0]) AddConstraint(fConstraintPYT,0.0); // Top half
680 if (lDetTLBR[1]) AddConstraint(fConstraintPYL,0.0); // Left half
681 if (lDetTLBR[2]) AddConstraint(fConstraintPYB,0.0); // Bottom half
682 if (lDetTLBR[3]) AddConstraint(fConstraintPYR,0.0); // Right half
683 }
010eb601 684}
685
a6ec842d 686void AliMUONAlignment::ConstrainT(Int_t lDetElem, Int_t lCh, Double_t *lConstraintT, Int_t iVar, Double_t /*lWeight*/) const{
010eb601 687 /// Set constrain equation for top half of spectrometer
688 Int_t lDetElemNumber = (lCh==1) ? lDetElem : lDetElem-fgSNDetElemCh[lCh-2];
689 if (lCh>=1 && lCh<=4){
690 if (lDetElemNumber==0 || lDetElemNumber==1){ // From track crossings
691 lConstraintT[lDetElem*fgNParCh+iVar]=1.0;
692 }
693 }
694 if (lCh>=5 && lCh<=6){
695 if (lDetElemNumber>=0&&lDetElemNumber<=9){
696 lConstraintT[lDetElem*fgNParCh+iVar]=1.0;
697 }
698 }
699 if (lCh>=7 && lCh<=10){
700 if (lDetElemNumber>=0&&lDetElemNumber<=13){
701 lConstraintT[lDetElem*fgNParCh+iVar]=1.0;
702 }
703 }
704}
705
56218672 706//______________________________________________________________________
a6ec842d 707void AliMUONAlignment::ConstrainL(Int_t lDetElem, Int_t lCh, Double_t *lConstraintL, Int_t iVar, Double_t lWeight) const{
010eb601 708 /// Set constrain equation for left half of spectrometer
709 Int_t lDetElemNumber = (lCh==1) ? lDetElem : lDetElem-fgSNDetElemCh[lCh-2];
710 if (lCh>=1 && lCh<=4){
711 if (lDetElemNumber==1 || lDetElemNumber==2){ // From track crossings
3b2890be 712 lConstraintL[lDetElem*fgNParCh+iVar]=lWeight;
010eb601 713 }
714 }
715 if (lCh>=5 && lCh<=6){
716 if (lDetElemNumber>=5&&lDetElemNumber<=13){
3b2890be 717 lConstraintL[lDetElem*fgNParCh+iVar]=lWeight;
010eb601 718 }
719 }
720 if (lCh>=7 && lCh<=10){
721 if (lDetElemNumber>=7&&lDetElemNumber<=19){
3b2890be 722 lConstraintL[lDetElem*fgNParCh+iVar]=lWeight;
010eb601 723 }
724 }
725}
726
56218672 727//______________________________________________________________________
a6ec842d 728void AliMUONAlignment::ConstrainB(Int_t lDetElem, Int_t lCh, Double_t *lConstraintB, Int_t iVar, Double_t /*lWeight*/) const{
010eb601 729 /// Set constrain equation for bottom half of spectrometer
730 Int_t lDetElemNumber = (lCh==1) ? lDetElem : lDetElem-fgSNDetElemCh[lCh-2];
731 if (lCh>=1 && lCh<=4){
3b2890be 732 if (lDetElemNumber==2 || lDetElemNumber==3){ // From track crossings
010eb601 733 lConstraintB[lDetElem*fgNParCh+iVar]=1.0;
734 }
735 }
736 if (lCh>=5 && lCh<=6){
56218672 737 if ((lDetElemNumber>=9&&lDetElemNumber<=17) ||
738 (lDetElemNumber==0)){
010eb601 739 lConstraintB[lDetElem*fgNParCh+iVar]=1.0;
740 }
741 }
742 if (lCh>=7 && lCh<=10){
56218672 743 if ((lDetElemNumber>=13&&lDetElemNumber<=25) ||
744 (lDetElemNumber==0)){
010eb601 745 lConstraintB[lDetElem*fgNParCh+iVar]=1.0;
746 }
747 }
748}
749
56218672 750//______________________________________________________________________
a6ec842d 751void AliMUONAlignment::ConstrainR(Int_t lDetElem, Int_t lCh, Double_t *lConstraintR, Int_t iVar, Double_t lWeight) const{
010eb601 752 /// Set constrain equation for right half of spectrometer
753 Int_t lDetElemNumber = (lCh==1) ? lDetElem : lDetElem-fgSNDetElemCh[lCh-2];
754 if (lCh>=1 && lCh<=4){
3b2890be 755 if (lDetElemNumber==0 || lDetElemNumber==3){ // From track crossings
756 lConstraintR[lDetElem*fgNParCh+iVar]=lWeight;
010eb601 757 }
758 }
759 if (lCh>=5 && lCh<=6){
56218672 760 if ((lDetElemNumber>=0&&lDetElemNumber<=4) ||
761 (lDetElemNumber>=14&&lDetElemNumber<=17)){
3b2890be 762 lConstraintR[lDetElem*fgNParCh+iVar]=lWeight;
010eb601 763 }
764 }
765 if (lCh>=7 && lCh<=10){
56218672 766 if ((lDetElemNumber>=0&&lDetElemNumber<=6) ||
767 (lDetElemNumber>=20&&lDetElemNumber<=25)){
3b2890be 768 lConstraintR[lDetElem*fgNParCh+iVar]=lWeight;
010eb601 769 }
770 }
771}
772
56218672 773//______________________________________________________________________
010eb601 774void AliMUONAlignment::ResetConstraints(){
775 /// Reset all constraint equations
56218672 776 for (Int_t i = 0; i < fgNDetElem; i++){
88807319 777 fConstraintX3[i*fgNParCh+0]=0.0;
778 fConstraintY3[i*fgNParCh+0]=0.0;
779 fConstraintX4[i*fgNParCh+0]=0.0;
780 fConstraintY4[i*fgNParCh+0]=0.0;
781 fConstraintP4[i*fgNParCh+0]=0.0;
782 fConstraintX5[i*fgNParCh+0]=0.0;
783 fConstraintY5[i*fgNParCh+0]=0.0;
784 fConstraintX[i*fgNParCh+0]=0.0;
3b2890be 785 fConstraintX[i*fgNParCh+1]=0.0;
786 fConstraintX[i*fgNParCh+2]=0.0;
787 fConstraintY[i*fgNParCh+0]=0.0;
788 fConstraintY[i*fgNParCh+1]=0.0;
789 fConstraintY[i*fgNParCh+2]=0.0;
790 fConstraintP[i*fgNParCh+0]=0.0;
791 fConstraintP[i*fgNParCh+1]=0.0;
792 fConstraintP[i*fgNParCh+2]=0.0;
793 fConstraintXT[i*fgNParCh+0]=0.0;
794 fConstraintXT[i*fgNParCh+1]=0.0;
795 fConstraintXT[i*fgNParCh+2]=0.0;
796 fConstraintYT[i*fgNParCh+0]=0.0;
797 fConstraintYT[i*fgNParCh+1]=0.0;
798 fConstraintYT[i*fgNParCh+2]=0.0;
799 fConstraintPT[i*fgNParCh+0]=0.0;
800 fConstraintPT[i*fgNParCh+1]=0.0;
801 fConstraintPT[i*fgNParCh+2]=0.0;
802 fConstraintXZT[i*fgNParCh+0]=0.0;
803 fConstraintXZT[i*fgNParCh+1]=0.0;
804 fConstraintXZT[i*fgNParCh+2]=0.0;
805 fConstraintYZT[i*fgNParCh+0]=0.0;
806 fConstraintYZT[i*fgNParCh+1]=0.0;
807 fConstraintYZT[i*fgNParCh+2]=0.0;
808 fConstraintPZT[i*fgNParCh+0]=0.0;
809 fConstraintPZT[i*fgNParCh+1]=0.0;
810 fConstraintPZT[i*fgNParCh+2]=0.0;
811 fConstraintXYT[i*fgNParCh+0]=0.0;
812 fConstraintXYT[i*fgNParCh+1]=0.0;
813 fConstraintXYT[i*fgNParCh+2]=0.0;
814 fConstraintYYT[i*fgNParCh+0]=0.0;
815 fConstraintYYT[i*fgNParCh+1]=0.0;
816 fConstraintYYT[i*fgNParCh+2]=0.0;
817 fConstraintPYT[i*fgNParCh+0]=0.0;
818 fConstraintPYT[i*fgNParCh+1]=0.0;
819 fConstraintPYT[i*fgNParCh+2]=0.0;
820 fConstraintXL[i*fgNParCh+0]=0.0;
821 fConstraintXL[i*fgNParCh+1]=0.0;
822 fConstraintXL[i*fgNParCh+2]=0.0;
823 fConstraintYL[i*fgNParCh+0]=0.0;
824 fConstraintYL[i*fgNParCh+1]=0.0;
825 fConstraintYL[i*fgNParCh+2]=0.0;
826 fConstraintPL[i*fgNParCh+0]=0.0;
827 fConstraintPL[i*fgNParCh+1]=0.0;
828 fConstraintPL[i*fgNParCh+2]=0.0;
829 fConstraintXZL[i*fgNParCh+0]=0.0;
830 fConstraintXZL[i*fgNParCh+1]=0.0;
831 fConstraintXZL[i*fgNParCh+2]=0.0;
832 fConstraintYZL[i*fgNParCh+0]=0.0;
833 fConstraintYZL[i*fgNParCh+1]=0.0;
834 fConstraintYZL[i*fgNParCh+2]=0.0;
835 fConstraintPZL[i*fgNParCh+0]=0.0;
836 fConstraintPZL[i*fgNParCh+1]=0.0;
837 fConstraintPZL[i*fgNParCh+2]=0.0;
838 fConstraintXYL[i*fgNParCh+0]=0.0;
839 fConstraintXYL[i*fgNParCh+1]=0.0;
840 fConstraintXYL[i*fgNParCh+2]=0.0;
841 fConstraintYYL[i*fgNParCh+0]=0.0;
842 fConstraintYYL[i*fgNParCh+1]=0.0;
843 fConstraintYYL[i*fgNParCh+2]=0.0;
844 fConstraintPYL[i*fgNParCh+0]=0.0;
845 fConstraintPYL[i*fgNParCh+1]=0.0;
846 fConstraintPYL[i*fgNParCh+2]=0.0;
847 fConstraintXB[i*fgNParCh+0]=0.0;
848 fConstraintXB[i*fgNParCh+1]=0.0;
849 fConstraintXB[i*fgNParCh+2]=0.0;
850 fConstraintYB[i*fgNParCh+0]=0.0;
851 fConstraintYB[i*fgNParCh+1]=0.0;
852 fConstraintYB[i*fgNParCh+2]=0.0;
853 fConstraintPB[i*fgNParCh+0]=0.0;
854 fConstraintPB[i*fgNParCh+1]=0.0;
855 fConstraintPB[i*fgNParCh+2]=0.0;
856 fConstraintXZB[i*fgNParCh+0]=0.0;
857 fConstraintXZB[i*fgNParCh+1]=0.0;
858 fConstraintXZB[i*fgNParCh+2]=0.0;
859 fConstraintYZB[i*fgNParCh+0]=0.0;
860 fConstraintYZB[i*fgNParCh+1]=0.0;
861 fConstraintYZB[i*fgNParCh+2]=0.0;
862 fConstraintPZB[i*fgNParCh+0]=0.0;
863 fConstraintPZB[i*fgNParCh+1]=0.0;
864 fConstraintPZB[i*fgNParCh+2]=0.0;
865 fConstraintXYB[i*fgNParCh+0]=0.0;
866 fConstraintXYB[i*fgNParCh+1]=0.0;
867 fConstraintXYB[i*fgNParCh+2]=0.0;
868 fConstraintYYB[i*fgNParCh+0]=0.0;
869 fConstraintYYB[i*fgNParCh+1]=0.0;
870 fConstraintYYB[i*fgNParCh+2]=0.0;
871 fConstraintPYB[i*fgNParCh+0]=0.0;
872 fConstraintPYB[i*fgNParCh+1]=0.0;
873 fConstraintPYB[i*fgNParCh+2]=0.0;
874 fConstraintXR[i*fgNParCh+0]=0.0;
875 fConstraintXR[i*fgNParCh+1]=0.0;
876 fConstraintXR[i*fgNParCh+2]=0.0;
877 fConstraintYR[i*fgNParCh+0]=0.0;
878 fConstraintYR[i*fgNParCh+1]=0.0;
879 fConstraintYR[i*fgNParCh+2]=0.0;
880 fConstraintPR[i*fgNParCh+0]=0.0;
881 fConstraintPR[i*fgNParCh+1]=0.0;
882 fConstraintPR[i*fgNParCh+2]=0.0;
883 fConstraintXZR[i*fgNParCh+0]=0.0;
884 fConstraintXZR[i*fgNParCh+1]=0.0;
885 fConstraintXZR[i*fgNParCh+2]=0.0;
886 fConstraintYZR[i*fgNParCh+0]=0.0;
887 fConstraintYZR[i*fgNParCh+1]=0.0;
888 fConstraintYZR[i*fgNParCh+2]=0.0;
889 fConstraintPZR[i*fgNParCh+0]=0.0;
890 fConstraintPZR[i*fgNParCh+1]=0.0;
891 fConstraintPZR[i*fgNParCh+2]=0.0;
892 fConstraintPZR[i*fgNParCh+0]=0.0;
893 fConstraintPZR[i*fgNParCh+1]=0.0;
894 fConstraintPZR[i*fgNParCh+2]=0.0;
895 fConstraintXYR[i*fgNParCh+0]=0.0;
896 fConstraintXYR[i*fgNParCh+1]=0.0;
897 fConstraintXYR[i*fgNParCh+2]=0.0;
898 fConstraintYYR[i*fgNParCh+0]=0.0;
899 fConstraintYYR[i*fgNParCh+1]=0.0;
900 fConstraintYYR[i*fgNParCh+2]=0.0;
901 fConstraintPYR[i*fgNParCh+0]=0.0;
902 fConstraintPYR[i*fgNParCh+1]=0.0;
903 fConstraintPYR[i*fgNParCh+2]=0.0;
010eb601 904 }
905}
906
56218672 907//______________________________________________________________________
010eb601 908void AliMUONAlignment::AddConstraint(Double_t *par, Double_t value) {
909 /// Constrain equation defined by par to value
910 fMillepede->SetGlobalConstraint(par, value);
911 AliInfo("Adding constraint");
912}
913
56218672 914//______________________________________________________________________
010eb601 915void AliMUONAlignment::InitGlobalParameters(Double_t *par) {
916 /// Initialize global parameters with par array
917 fMillepede->SetGlobalParameters(par);
918 AliInfo("Init Global Parameters");
919}
56218672 920
921//______________________________________________________________________
010eb601 922void AliMUONAlignment::FixParameter(Int_t iPar, Double_t value) {
56218672 923 /// Parameter iPar is encourage to vary in [-value;value].
010eb601 924 /// If value == 0, parameter is fixed
925 fMillepede->SetParSigma(iPar, value);
a6ec842d 926 if (TMath::Abs(value)<1e-4) AliInfo(Form("Parameter %i Fixed", iPar));
010eb601 927}
928
56218672 929//______________________________________________________________________
010eb601 930void AliMUONAlignment::ResetLocalEquation()
931{
932 /// Reset the derivative vectors
933 for(int i=0; i<fNLocal; i++) {
934 fLocalDerivatives[i] = 0.0;
935 }
936 for(int i=0; i<fNGlobal; i++) {
937 fGlobalDerivatives[i] = 0.0;
938 }
939}
940
56218672 941//______________________________________________________________________
942void AliMUONAlignment::AllowVariations(const Bool_t *bChOnOff)
943{
944
d8ad38e5 945 /// Set allowed variation for selected chambers based on fDoF and fAllowVar
56218672 946 for (Int_t iCh=1; iCh<=10; iCh++)
947 {
948 if (bChOnOff[iCh-1])
949 {
950
951 Int_t iDetElemFirst = (iCh>1) ? fgSNDetElemCh[iCh-2] : 0;
952 Int_t iDetElemLast = fgSNDetElemCh[iCh-1];
953 for (int i=0; i<fgNParCh; i++)
954 {
955 AliDebug(1,Form("fDoF[%d]= %d",i,fDoF[i]));
956 if (fDoF[i])
957 {
958 for (Int_t j=iDetElemFirst; j<iDetElemLast; j++){
959 FixParameter(j*fgNParCh+i, fAllowVar[i]);
960 }
961 }
962
010eb601 963 }
56218672 964
010eb601 965 }
56218672 966
010eb601 967 }
56218672 968
010eb601 969}
970
56218672 971//______________________________________________________________________
972void AliMUONAlignment::SetNonLinear(Int_t iPar /* set non linear flag */ )
973{
010eb601 974 /// Set nonlinear flag for parameter iPar
975 fMillepede->SetNonLinear(iPar);
976 AliInfo(Form("Parameter %i set to non linear", iPar));
977}
978
56218672 979//______________________________________________________________________
980void AliMUONAlignment::SetSigmaXY(Double_t sigmaX, Double_t sigmaY)
981{
64e2c144 982
64e2c144 983 /// Set expected measurement resolution
984 fSigma[0] = sigmaX; fSigma[1] = sigmaY;
985 AliInfo(Form("Using fSigma[0]=%f and fSigma[1]=%f",fSigma[0],fSigma[1]));
986}
987
988
56218672 989//______________________________________________________________________
990void AliMUONAlignment::LocalEquationX( Bool_t doAlignment )
991{
992
993
994 // local cluster record
995 AliMUONAlignmentClusterRecord clusterRecord;
996
997 // store detector and measurement
998 clusterRecord.SetDetElemId( fDetElemId );
999 clusterRecord.SetDetElemNumber( fDetElemNumber );
1000 clusterRecord.SetMeas( fMeas[0] );
1001 clusterRecord.SetSigma( fSigma[0] );
1002
1003 // store local derivatives
1004 clusterRecord.SetLocalDerivative( 0, fCosPhi );
1005 clusterRecord.SetLocalDerivative( 1, fCosPhi*(fTrackPos[2] - fTrackPos0[2]) );
1006 clusterRecord.SetLocalDerivative( 2, fSinPhi );
1007 clusterRecord.SetLocalDerivative( 3, fSinPhi*(fTrackPos[2] - fTrackPos0[2]) );
1008
1009 // store global derivatives
1010 clusterRecord.SetGlobalDerivative( 0, -fCosPhi );
1011 clusterRecord.SetGlobalDerivative( 1, -fSinPhi );
1012
1013 if (fBFieldOn)
1014 {
1015
1016 clusterRecord.SetGlobalDerivative(
1017 2,
1018 -fSinPhi*(fTrackPos[0]-fDetElemPos[0])
1019 +fCosPhi*(fTrackPos[1]-fDetElemPos[1]) );
1020
1021 } else {
1022
1023 clusterRecord.SetGlobalDerivative(
1024 2,
1025 -fSinPhi*(fTrackPos0[0]+fTrackSlope0[0]*(fTrackPos[2]-fTrackPos0[2])-fDetElemPos[0])
1026 +fCosPhi*(fTrackPos0[1]+fTrackSlope0[1]*(fTrackPos[2]-fTrackPos0[2])-fDetElemPos[1]) );
010eb601 1027
010eb601 1028 }
1029
56218672 1030 clusterRecord.SetGlobalDerivative( 3, fCosPhi*fTrackSlope0[0]+fSinPhi*fTrackSlope0[1] );
1031
1032 // append to trackRecord
1033 fTrackRecord.AddClusterRecord( clusterRecord );
1034
1035 // store local equation
1036 if( doAlignment ) LocalEquation( clusterRecord );
1037
010eb601 1038}
1039
56218672 1040//______________________________________________________________________
1041void AliMUONAlignment::LocalEquationY(Bool_t doAlignment )
1042{
1043
1044 // local cluster record
1045 AliMUONAlignmentClusterRecord clusterRecord;
1046
1047 // store detector and measurement
1048 clusterRecord.SetDetElemId( fDetElemId );
1049 clusterRecord.SetDetElemNumber( fDetElemNumber );
1050 clusterRecord.SetMeas( fMeas[1] );
1051 clusterRecord.SetSigma( fSigma[1] );
1052
1053 // store local derivatives
1054 clusterRecord.SetLocalDerivative( 0, -fSinPhi );
1055 clusterRecord.SetLocalDerivative( 1, -fSinPhi*(fTrackPos[2] - fTrackPos0[2] ) );
1056 clusterRecord.SetLocalDerivative( 2, fCosPhi );
1057 clusterRecord.SetLocalDerivative( 3, fCosPhi*(fTrackPos[2] - fTrackPos0[2] ) );
010eb601 1058
1059 // set global derivatives
56218672 1060 clusterRecord.SetGlobalDerivative( 0, fSinPhi);
1061 clusterRecord.SetGlobalDerivative( 1, -fCosPhi);
1062
1063 if (fBFieldOn)
1064 {
1065
1066 clusterRecord.SetGlobalDerivative(
1067 2,
1068 -fCosPhi*(fTrackPos[0]-fDetElemPos[0])
1069 -fSinPhi*(fTrackPos[1]-fDetElemPos[1]));
1070
1071 } else {
1072
1073 clusterRecord.SetGlobalDerivative(
1074 2,
1075 -fCosPhi*(fTrackPos0[0]+fTrackSlope0[0]*(fTrackPos[2]-fTrackPos0[2])-fDetElemPos[0])
1076 -fSinPhi*(fTrackPos0[1]+fTrackSlope0[1]*(fTrackPos[2]-fTrackPos0[2])-fDetElemPos[1]));
010eb601 1077 }
56218672 1078
1079 clusterRecord.SetGlobalDerivative( 3, -fSinPhi*fTrackSlope0[0]+fCosPhi*fTrackSlope0[1]);
1080
1081 // append to trackRecord
1082 fTrackRecord.AddClusterRecord( clusterRecord );
1083
1084 // store local equation
1085 if( doAlignment ) LocalEquation( clusterRecord );
1086
1087}
1088
1089//_____________________________________________________
1090void AliMUONAlignment::LocalEquation( const AliMUONAlignmentClusterRecord& clusterRecord )
1091{
1092
1093 // copy to local variables
1094 for( Int_t index = 0; index < 4; ++index )
1095 {
1096 SetLocalDerivative( index, clusterRecord.GetLocalDerivative( index ) );
1097 SetGlobalDerivative( clusterRecord.GetDetElemNumber()*fgNParCh + index, clusterRecord.GetGlobalDerivative( index ) );
010eb601 1098 }
1099
56218672 1100 // pass equation parameters to millepede
1101 fMillepede->SetLocalEquation( fGlobalDerivatives, fLocalDerivatives, clusterRecord.GetMeas(), clusterRecord.GetSigma() );
1102
010eb601 1103}
1104
56218672 1105//______________________________________________________________________
1106void AliMUONAlignment::FillRecPointData()
1107{
1108
96ebe67e 1109 /// Get information of current cluster
1110 fClustPos[0] = fCluster->GetX();
1111 fClustPos[1] = fCluster->GetY();
1112 fClustPos[2] = fCluster->GetZ();
56218672 1113 fTransform->Global2Local(
1114 fDetElemId,fClustPos[0],fClustPos[1],fClustPos[2],
1115 fClustPosLoc[0],fClustPosLoc[1],fClustPosLoc[2]);
1116
010eb601 1117}
1118
56218672 1119//______________________________________________________________________
1120void AliMUONAlignment::FillTrackParamData()
1121{
1122
96ebe67e 1123 /// Get information of current track at current cluster
010eb601 1124 fTrackPos[0] = fTrackParam->GetNonBendingCoor();
1125 fTrackPos[1] = fTrackParam->GetBendingCoor();
1126 fTrackPos[2] = fTrackParam->GetZ();
1127 fTrackSlope[0] = fTrackParam->GetNonBendingSlope();
1128 fTrackSlope[1] = fTrackParam->GetBendingSlope();
56218672 1129 fTransform->Global2Local(
1130 fDetElemId,fTrackPos[0],fTrackPos[1],fTrackPos[2],
1131 fTrackPosLoc[0],fTrackPosLoc[1],fTrackPosLoc[2]);
1132
010eb601 1133}
1134
56218672 1135//_____________________________________________________
1136void AliMUONAlignment::FillDetElemData()
1137{
1138
010eb601 1139 /// Get information of current detection element
1140 Double_t lDetElemLocX = 0.;
1141 Double_t lDetElemLocY = 0.;
1142 Double_t lDetElemLocZ = 0.;
96ebe67e 1143 fDetElemId = fCluster->GetDetElemId();
010eb601 1144 fDetElemNumber = fDetElemId%100;
56218672 1145 for (int iCh=0; iCh<fDetElemId/100-1; iCh++)
1146 { fDetElemNumber += fgNDetElemCh[iCh]; }
1147
1148 fTransform->Local2Global(
1149 fDetElemId,lDetElemLocX,lDetElemLocY,lDetElemLocZ,
1150 fDetElemPos[0],fDetElemPos[1],fDetElemPos[2]);
1151
010eb601 1152}
1153
56218672 1154//_____________________________________________________
1155AliMUONAlignmentTrackRecord* AliMUONAlignment::ProcessTrack( AliMUONTrack* track, Bool_t doAlignment )
1156{
88807319 1157 /// Process track and set Local Equations
56218672 1158 // store current track in running member.
010eb601 1159 fTrack = track;
56218672 1160
1161 // clear track record
1162 fTrackRecord.Clear();
1163
1164 // get number of tracks
1165 Int_t nTrackParam = fTrack->GetTrackParamAtCluster()->GetEntries();
3b2890be 1166 AliDebug(1,Form("Number of track param entries : %i ", nTrackParam));
010eb601 1167
56218672 1168 Bool_t first( kTRUE );
1169 for(Int_t iCluster=0; iCluster<nTrackParam; iCluster++)
1170 {
010eb601 1171
010eb601 1172 // and get new pointers
96ebe67e 1173 fTrackParam = (AliMUONTrackParam *) fTrack->GetTrackParamAtCluster()->At(iCluster);
7e96937a 1174 if ( ! fTrackParam ) continue;
96ebe67e 1175 fCluster = fTrackParam->GetClusterPtr();
7e96937a 1176 if ( ! fCluster ) continue;
56218672 1177 // if (fDetElemId<500) continue;
1178
010eb601 1179 // fill local variables for this position --> one measurement
56218672 1180 FillDetElemData();
010eb601 1181 FillRecPointData();
1182 FillTrackParamData();
010eb601 1183
56218672 1184 if( first )
1185 {
1186
1187 // for first valid cluster, save track position as "starting" values
1188 first = kFALSE;
1189
1190 fTrackPos0[0] = fTrackPos[0];
1191 fTrackPos0[1] = fTrackPos[1];
1192 fTrackPos0[2] = fTrackPos[2];
1193 fTrackSlope0[0] = fTrackSlope[0];
1194 fTrackSlope0[1] = fTrackSlope[1];
1195
1196 }
1197
1198 // calculate measurements
010eb601 1199 fCosPhi = TMath::Cos(fPhi);
1200 fSinPhi = TMath::Sin(fPhi);
56218672 1201 if( fBFieldOn )
1202 {
1203
010eb601 1204 fMeas[0] = fTrackPos[0] - fClustPos[0];
1205 fMeas[1] = fTrackPos[1] - fClustPos[1];
56218672 1206
1207 } else {
1208
010eb601 1209 fMeas[0] = - fClustPos[0];
1210 fMeas[1] = - fClustPos[1];
56218672 1211
010eb601 1212 }
56218672 1213
1214 // soùe debugging
1215 AliDebug(1,Form("cluster: %i", iCluster));
1216 AliDebug(1,Form("x: %f\t y: %f\t z: %f\t DetElemID: %i\t ", fClustPos[0], fClustPos[1], fClustPos[2], fDetElemId));
1217 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));
1218
1219 AliDebug(1,Form("Track Parameter: %i", iCluster));
1220 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]));
1221 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]));
1222
1223 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]));
1224
010eb601 1225 // Set local equations
56218672 1226 LocalEquationX( doAlignment );
1227 LocalEquationY( doAlignment );
1228
010eb601 1229 }
56218672 1230
1231 return &fTrackRecord;
1232
010eb601 1233}
1234
56218672 1235//______________________________________________________________________________
1236void AliMUONAlignment::ProcessTrack( AliMUONAlignmentTrackRecord* track, Bool_t doAlignment )
1237{
88807319 1238 /// Process track (from record) and set Local Equations
56218672 1239 if( !( track && doAlignment ) ) return;
1240
1241 // loop over clusters
1242 for( Int_t index = 0; index < track->GetNRecords(); ++index )
1243 { if( AliMUONAlignmentClusterRecord* record = track->GetRecord( index ) ) LocalEquation( *record ); }
1244
1245 return;
1246
1247}
1248
1249//_____________________________________________________
1250void AliMUONAlignment::LocalFit(Int_t iTrack, Double_t *lTrackParam, Int_t lSingleFit)
1251{
1252
010eb601 1253 /// Call local fit for this tracks
1254 Int_t iRes = fMillepede->LocalFit(iTrack,lTrackParam,lSingleFit);
56218672 1255 if (iRes && !lSingleFit)
1256 { fMillepede->SetNLocalEquations(fMillepede->GetNLocalEquations()+1); }
1257
010eb601 1258}
1259
56218672 1260//_____________________________________________________
1261void AliMUONAlignment::GlobalFit(Double_t *parameters,Double_t *errors,Double_t *pulls)
1262{
1263
010eb601 1264 /// Call global fit; Global parameters are stored in parameters
1265 fMillepede->GlobalFit(parameters,errors,pulls);
3b2890be 1266
010eb601 1267 AliInfo("Done fitting global parameters!");
56218672 1268 for (int iGlob=0; iGlob<fgNDetElem; iGlob++)
1269 { printf("%d\t %f\t %f\t %f\t %f \n",iGlob,parameters[iGlob*fgNParCh+0],parameters[iGlob*fgNParCh+1],parameters[iGlob*fgNParCh+3],parameters[iGlob*fgNParCh+2]); }
1270
1271
010eb601 1272}
1273
56218672 1274//_____________________________________________________
1275Double_t AliMUONAlignment::GetParError(Int_t iPar)
1276{
010eb601 1277 /// Get error of parameter iPar
1278 Double_t lErr = fMillepede->GetParError(iPar);
1279 return lErr;
1280}
1281
56218672 1282//_____________________________________________________
1283void AliMUONAlignment::PrintGlobalParameters()
1284{
010eb601 1285 /// Print global parameters
1286 fMillepede->PrintGlobalParameters();
1287}
1288
1289//_________________________________________________________________________
a6ec842d 1290TGeoCombiTrans AliMUONAlignment::ReAlign(const TGeoCombiTrans & transform, const double *lMisAlignment) const
010eb601 1291{
1292 /// Realign given transformation by given misalignment and return the misaligned transformation
56218672 1293
010eb601 1294 Double_t cartMisAlig[3] = {0,0,0};
1295 Double_t angMisAlig[3] = {0,0,0};
3b2890be 1296// const Double_t *trans = transform.GetTranslation();
1297// TGeoRotation *rot;
1298// // check if the rotation we obtain is not NULL
56218672 1299// if (transform.GetRotation()) {
3b2890be 1300// rot = transform.GetRotation();
1301// }
56218672 1302// else {
3b2890be 1303// rot = new TGeoRotation("rot");
1304// } // default constructor.
1305
723b0b5b 1306 cartMisAlig[0] = -TMath::Sign(1.0,transform.GetRotationMatrix()[0])*lMisAlignment[0];
1307 cartMisAlig[1] = -TMath::Sign(1.0,transform.GetRotationMatrix()[4])*lMisAlignment[1];
1308 cartMisAlig[2] = -TMath::Sign(1.0,transform.GetRotationMatrix()[8])*lMisAlignment[3];
1309 angMisAlig[2] = -TMath::Sign(1.0,transform.GetRotationMatrix()[0]*transform.GetRotationMatrix()[4])*lMisAlignment[2]*180./TMath::Pi();
3b2890be 1310
1311 TGeoTranslation deltaTrans(cartMisAlig[0], cartMisAlig[1], cartMisAlig[2]);
1312 TGeoRotation deltaRot;
1313 deltaRot.RotateX(angMisAlig[0]);
1314 deltaRot.RotateY(angMisAlig[1]);
1315 deltaRot.RotateZ(angMisAlig[2]);
1316
1317 TGeoCombiTrans deltaTransf(deltaTrans,deltaRot);
1318 TGeoHMatrix newTransfMat = transform * deltaTransf;
1319
1320 return TGeoCombiTrans(newTransfMat);
010eb601 1321}
1322
1323//______________________________________________________________________
1324AliMUONGeometryTransformer *
1325AliMUONAlignment::ReAlign(const AliMUONGeometryTransformer * transformer,
56218672 1326 const double *misAlignments, Bool_t verbose)
1327
010eb601 1328{
625f657d 1329 /// Returns a new AliMUONGeometryTransformer with the found misalignments
56218672 1330 /// applied.
625f657d 1331
1332 // Takes the internal geometry module transformers, copies them
010eb601 1333 // and gets the Detection Elements from them.
1334 // Takes misalignment parameters and applies these
1335 // to the local transform of the Detection Element
1336 // Obtains the global transform by multiplying the module transformer
56218672 1337 // transformation with the local transformation
010eb601 1338 // Applies the global transform to a new detection element
1339 // Adds the new detection element to a new module transformer
1340 // Adds the new module transformer to a new geometry transformer
1341 // Returns the new geometry transformer
1342
64e2c144 1343 Double_t lModuleMisAlignment[4] = {0.,0.,0.,0.};
723b0b5b 1344 Double_t lDetElemMisAlignment[4] = {0.,0.,0.,0.};
3b2890be 1345 Int_t iDetElemId = 0;
1346 Int_t iDetElemNumber = 0;
010eb601 1347
1348 AliMUONGeometryTransformer *newGeometryTransformer =
ef4cb4f1 1349 new AliMUONGeometryTransformer();
3b2890be 1350 for (Int_t iMt = 0; iMt < transformer->GetNofModuleTransformers(); iMt++) {
56218672 1351 // module transformers
3b2890be 1352 const AliMUONGeometryModuleTransformer *kModuleTransformer =
1353 transformer->GetModuleTransformer(iMt, true);
56218672 1354
3b2890be 1355 AliMUONGeometryModuleTransformer *newModuleTransformer =
1356 new AliMUONGeometryModuleTransformer(iMt);
1357 newGeometryTransformer->AddModuleTransformer(newModuleTransformer);
56218672 1358
3b2890be 1359 TGeoCombiTrans moduleTransform =
1360 TGeoCombiTrans(*kModuleTransformer->GetTransformation());
1361 // New module transformation
1362 TGeoCombiTrans newModuleTransform = ReAlign(moduleTransform,lModuleMisAlignment);
1363 newModuleTransformer->SetTransformation(newModuleTransform);
56218672 1364
1365 // Get delta transformation:
3b2890be 1366 // Tdelta = Tnew * Told.inverse
56218672 1367 TGeoHMatrix deltaModuleTransform =
1368 AliMUONGeometryBuilder::Multiply(newModuleTransform,
1369 kModuleTransformer->GetTransformation()->Inverse());
3b2890be 1370 // Create module mis alignment matrix
1371 newGeometryTransformer
1372 ->AddMisAlignModule(kModuleTransformer->GetModuleId(), deltaModuleTransform);
56218672 1373
3b2890be 1374 AliMpExMap *detElements = kModuleTransformer->GetDetElementStore();
56218672 1375
3b2890be 1376 if (verbose)
1377 AliInfo(Form("%i DEs in old GeometryStore %i",detElements->GetSize(), iMt));
1378
630711ed 1379 TIter next(detElements->CreateIterator());
1380 AliMUONGeometryDetElement* detElement;
1381 Int_t iDe(-1);
1382 while ( ( detElement = static_cast<AliMUONGeometryDetElement*>(next()) ) )
1383 {
1384 ++iDe;
625f657d 1385 // make a new detection element
3b2890be 1386 AliMUONGeometryDetElement *newDetElement =
56218672 1387 new AliMUONGeometryDetElement(detElement->GetId(),
1388 detElement->GetVolumePath());
3b2890be 1389 TString lDetElemName(detElement->GetDEName());
1390 lDetElemName.ReplaceAll("DE","");
1391 iDetElemId = lDetElemName.Atoi();
1392 iDetElemNumber = iDetElemId%100;
1393 for (int iCh=0; iCh<iDetElemId/100-1; iCh++){
56218672 1394 iDetElemNumber += fgNDetElemCh[iCh];
3b2890be 1395 }
1396 for (int i=0; i<fgNParCh; i++) {
56218672 1397 lDetElemMisAlignment[i] = 0.0;
1398 if (iMt<fgNTrkMod) {
1399 AliInfo(Form("iMt %i, iCh %i, iDe %i, iDeId %i, iDeNb %i, iPar %i",iMt, iDetElemId/100, iDe, iDetElemId, iDetElemNumber, iDetElemNumber*fgNParCh+i));
1400 lDetElemMisAlignment[i] = misAlignments[iDetElemNumber*fgNParCh+i];
1401 }
3b2890be 1402 }
1403 // local transformation of this detection element.
1404 TGeoCombiTrans localTransform
56218672 1405 = TGeoCombiTrans(*detElement->GetLocalTransformation());
3b2890be 1406 TGeoCombiTrans newLocalTransform = ReAlign(localTransform,lDetElemMisAlignment);
56218672 1407 newDetElement->SetLocalTransformation(newLocalTransform);
3b2890be 1408
1409 // global transformation
1410 TGeoHMatrix newGlobalTransform =
56218672 1411 AliMUONGeometryBuilder::Multiply(newModuleTransform,
1412 newLocalTransform);
3b2890be 1413 newDetElement->SetGlobalTransformation(newGlobalTransform);
56218672 1414
3b2890be 1415 // add this det element to module
1416 newModuleTransformer->GetDetElementStore()->Add(newDetElement->GetId(),
56218672 1417 newDetElement);
3b2890be 1418
1419 // In the Alice Alignment Framework misalignment objects store
1420 // global delta transformation
1421 // Get detection "intermediate" global transformation
1422 TGeoHMatrix newOldGlobalTransform = newModuleTransform * localTransform;
56218672 1423 // Get detection element global delta transformation:
3b2890be 1424 // Tdelta = Tnew * Told.inverse
1425 TGeoHMatrix deltaGlobalTransform
56218672 1426 = AliMUONGeometryBuilder::Multiply(newGlobalTransform,
1427 newOldGlobalTransform.Inverse());
1428
3b2890be 1429 // Create mis alignment matrix
1430 newGeometryTransformer
56218672 1431 ->AddMisAlignDetElement(detElement->GetId(), deltaGlobalTransform);
010eb601 1432 }
56218672 1433
3b2890be 1434 if (verbose)
1435 AliInfo(Form("Added module transformer %i to the transformer", iMt));
1436 newGeometryTransformer->AddModuleTransformer(newModuleTransformer);
1437 }
010eb601 1438 return newGeometryTransformer;
1439}
1440
4818a9b7 1441//______________________________________________________________________
56218672 1442void AliMUONAlignment::SetAlignmentResolution(const TClonesArray* misAlignArray, Int_t rChId, Double_t rChResX, Double_t rChResY, Double_t rDeResX, Double_t rDeResY)
1443{
1444
625f657d 1445 /// Set alignment resolution to misalign objects to be stored in CDB
4818a9b7 1446 Int_t chIdMin = (rChId<0)? 0 : rChId;
1447 Int_t chIdMax = (rChId<0)? 9 : rChId;
1448 Double_t chResX = rChResX;
1449 Double_t chResY = rChResY;
1450 Double_t deResX = rDeResX;
1451 Double_t deResY = rDeResY;
1452
1453 TMatrixDSym mChCorrMatrix(6);
1454 mChCorrMatrix[0][0]=chResX*chResX;
1455 mChCorrMatrix[1][1]=chResY*chResY;
1456 // mChCorrMatrix.Print();
1457
1458 TMatrixDSym mDECorrMatrix(6);
1459 mDECorrMatrix[0][0]=deResX*deResX;
1460 mDECorrMatrix[1][1]=deResY*deResY;
1461 // mDECorrMatrix.Print();
1462
1463 AliAlignObjMatrix *alignMat = 0x0;
1464
1465 for(Int_t chId=chIdMin; chId<=chIdMax; chId++) {
1466 TString chName1;
1467 TString chName2;
1468 if (chId<4){
1469 chName1 = Form("GM%d",chId);
1470 chName2 = Form("GM%d",chId);
1471 } else {
1472 chName1 = Form("GM%d",4+(chId-4)*2);
1473 chName2 = Form("GM%d",4+(chId-4)*2+1);
1474 }
56218672 1475
4818a9b7 1476 for (int i=0; i<misAlignArray->GetEntries(); i++) {
1477 alignMat = (AliAlignObjMatrix*)misAlignArray->At(i);
1478 TString volName(alignMat->GetSymName());
1479 if((volName.Contains(chName1)&&
56218672 1480 ((volName.Last('/')==volName.Index(chName1)+chName1.Length())||
1481 (volName.Length()==volName.Index(chName1)+chName1.Length())))||
1482 (volName.Contains(chName2)&&
1483 ((volName.Last('/')==volName.Index(chName2)+chName2.Length())||
1484 (volName.Length()==volName.Index(chName2)+chName2.Length())))){
1485 volName.Remove(0,volName.Last('/')+1);
1486 if (volName.Contains("GM")) {
1487 // alignMat->Print("NULL");
1488 alignMat->SetCorrMatrix(mChCorrMatrix);
1489 } else if (volName.Contains("DE")) {
1490 // alignMat->Print("NULL");
1491 alignMat->SetCorrMatrix(mDECorrMatrix);
1492 }
4818a9b7 1493 }
1494 }
1495 }
1496}