1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //-----------------------------------------------------------------------------
19 /// \class AliMUONAlignment
20 /// Alignment class for the ALICE DiMuon spectrometer
22 /// MUON specific alignment class which interface to AliMillepede.
23 /// For each track ProcessTrack calculates the local and global derivatives
24 /// at each cluster and fill the corresponding local equations. Provide methods
25 /// for fixing or constraining detection elements for best results.
27 /// \author Bruce Becker, Javier Castillo
28 //-----------------------------------------------------------------------------
30 #include "AliMUONAlignment.h"
31 #include "AliMUONTrack.h"
32 #include "AliMUONTrackParam.h"
33 #include "AliMUONVCluster.h"
34 #include "AliMUONGeometryTransformer.h"
35 #include "AliMUONGeometryModuleTransformer.h"
36 #include "AliMUONGeometryDetElement.h"
37 #include "AliMUONGeometryBuilder.h"
38 #include "AliMillepede.h"
40 #include "AliMpExMap.h"
41 #include "AliMpExMapIterator.h"
43 #include "AliAlignObjMatrix.h"
47 #include "TMatrixDSym.h"
48 #include "TClonesArray.h"
51 ClassImp(AliMUONAlignment)
54 //_____________________________________________________________________
56 Int_t AliMUONAlignment::fgNDetElem = 4*2+4*2+18*2+26*2+26*2;
57 Int_t AliMUONAlignment::fgNDetElemCh[10] = {4,4,4,4,18,18,26,26,26,26};
58 Int_t AliMUONAlignment::fgSNDetElemCh[10] = {4,8,12,16,34,52,78,104,130,156};
59 Int_t AliMUONAlignment::fgNParCh = 4;
60 Int_t AliMUONAlignment::fgNTrkMod = 16;
61 Int_t AliMUONAlignment::fgNCh = 10;
62 Int_t AliMUONAlignment::fgNSt = 5;
64 //_____________________________________________________________________
65 AliMUONAlignment::AliMUONAlignment()
75 fNGlobal(fgNDetElem*fgNParCh),
86 /// Default constructor
90 AliInfo(Form("fSigma[0]: %f\t fSigma[1]: %f",fSigma[0],fSigma[1]));
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;
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));
97 fMillepede = new AliMillepede();
99 Init(fNGlobal, fNLocal, fNStdDev);
101 ResetLocalEquation();
102 AliInfo("Parameters initialized to zero");
106 //_____________________________________________________________________
107 AliMUONAlignment::AliMUONAlignment(TRootIOCtor* /*dummy*/)
128 /// Root IO constructor
130 for (Int_t iCh=0; iCh<10; iCh++) {
131 fChOnOff[iCh] = kFALSE;
133 fSpecLROnOff[0] = kFALSE; fSpecLROnOff[1] = kFALSE;
134 for (Int_t iDoF=0; iDoF<4; iDoF++) {
136 fAllowVar[iDoF] = kFALSE;
138 for (Int_t i=0; i<3; i++) {
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;
153 for (Int_t iGPar=0; iGPar<624; iGPar++) {
154 fGlobalDerivatives[iGPar]=0;
158 //_____________________________________________________________________
159 AliMUONAlignment::~AliMUONAlignment()
162 //_____________________________________________________________________
163 void 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 */ )
168 /// Initialization of AliMillepede. Fix parameters, define constraints ...
169 fMillepede->InitMille(nGlobal,nLocal,nStdDev,fResCut,fResCutInitial);
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};
175 // AllowVariations(bChOnOff);
177 // Fix parameters or add constraints here
178 // for (Int_t iSt=0; iSt<5; iSt++)
179 // { if (!bStOnOff[iSt]) FixStation(iSt+1); }
181 // for (Int_t iCh=0; iCh<10; iCh++)
182 // { if (!bChOnOff[iCh]) FixChamber(iCh+1); }
184 // FixHalfSpectrometer(bChOnOff,bSpecLROnOff);
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);
194 // Other possible way to add constrains
195 bVarXYT[0] = kFALSE; bVarXYT[1] = kFALSE; bVarXYT[2] = kTRUE;
196 bDetTLBR[0] = kFALSE; bDetTLBR[1] = kTRUE; bDetTLBR[2] = kFALSE; bDetTLBR[3] = kFALSE;
197 // AddConstraints(bStOnOff,bVarXYT,bDetTLBR);
199 bVarXYT[0] = kTRUE; bVarXYT[1] = kTRUE; bVarXYT[2] = kFALSE;
200 // AddConstraints(bStOnOff,bVarXYT);
203 if (fStartFac>1) fMillepede->SetIterations(fStartFac);
206 //_____________________________________________________________________
207 void AliMUONAlignment::FixStation(Int_t iSt)
209 /// Fix all detection elements of station iSt
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++)
214 FixParameter(i*fgNParCh+0, 0.0);
215 FixParameter(i*fgNParCh+1, 0.0);
216 FixParameter(i*fgNParCh+2, 0.0);
217 FixParameter(i*fgNParCh+3, 0.0);
222 //_____________________________________________________________________
223 void AliMUONAlignment::FixChamber(Int_t iCh)
225 /// Fix all detection elements of chamber iCh
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++)
230 FixParameter(i*fgNParCh+0, 0.0);
231 FixParameter(i*fgNParCh+1, 0.0);
232 FixParameter(i*fgNParCh+2, 0.0);
233 FixParameter(i*fgNParCh+3, 0.0);
237 //_____________________________________________________________________
238 void AliMUONAlignment::FixDetElem(Int_t iDetElemId, TString sVarXYT)
241 /// Fix a given detection element
242 Int_t iDetElemNumber = iDetElemId%100;
243 for (int iCh=0; iCh<iDetElemId/100-1; iCh++)
245 iDetElemNumber += fgNDetElemCh[iCh];
248 if (sVarXYT.Contains("X"))
251 FixParameter(iDetElemNumber*fgNParCh+0, 0.0);
254 if (sVarXYT.Contains("Y"))
257 FixParameter(iDetElemNumber*fgNParCh+1, 0.0);
260 if (sVarXYT.Contains("T"))
263 FixParameter(iDetElemNumber*fgNParCh+2, 0.0);
266 if (sVarXYT.Contains("Z"))
269 FixParameter(iDetElemNumber*fgNParCh+3, 0.0);
274 //_____________________________________________________________________
275 void AliMUONAlignment::FixHalfSpectrometer(const Bool_t *lChOnOff, const Bool_t *lSpecLROnOff)
278 /// Fix left or right detector
279 for (Int_t i = 0; i < fgNDetElem; i++)
283 for (iCh=1; iCh<=fgNCh; iCh++)
284 { if (i<fgSNDetElemCh[iCh-1]) break; }
289 Int_t lDetElemNumber = (iCh==1) ? i : i-fgSNDetElemCh[iCh-2];
290 if (iCh>=1 && iCh<=4)
293 if ((lDetElemNumber==1 || lDetElemNumber==2) && !lSpecLROnOff[0])
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);
302 if ((lDetElemNumber==0 || lDetElemNumber==3) && !lSpecLROnOff[1])
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);
313 if (iCh>=5 && iCh<=6)
316 if ((lDetElemNumber>=5&&lDetElemNumber<=13) && !lSpecLROnOff[0])
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);
324 if (((lDetElemNumber>=0&&lDetElemNumber<=4) ||
325 (lDetElemNumber>=14&&lDetElemNumber<=17)) && !lSpecLROnOff[1])
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);
336 if (iCh>=7 && iCh<=10)
339 if ((lDetElemNumber>=7&&lDetElemNumber<=19) && !lSpecLROnOff[0])
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);
347 if (((lDetElemNumber>=0&&lDetElemNumber<=6) ||
348 (lDetElemNumber>=20&&lDetElemNumber<=25)) && !lSpecLROnOff[1])
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);
364 //______________________________________________________________________
365 void AliMUONAlignment::SetNonLinear(const Bool_t *lChOnOff, const Bool_t *lVarXYT)
368 /// Set non linear parameter flag selected chambers and degrees of freedom
369 for (Int_t i = 0; i < fgNDetElem; i++)
373 for (iCh=1; iCh<=fgNCh; iCh++)
374 { if (i<fgSNDetElemCh[iCh-1]) break; }
382 SetNonLinear(i*fgNParCh+0);
388 SetNonLinear(i*fgNParCh+1);
394 SetNonLinear(i*fgNParCh+2);
400 SetNonLinear(i*fgNParCh+3);
409 //______________________________________________________________________
410 void AliMUONAlignment::AddConstraints(const Bool_t *lChOnOff, const Bool_t *lVarXYT)
413 /// Add constraint equations for selected chambers and degrees of freedom
414 for (Int_t i = 0; i < fgNDetElem; i++)
418 for (iCh=1; iCh<=fgNCh; iCh++)
420 if (i<fgSNDetElemCh[iCh-1]) break;
428 fConstraintX[i*fgNParCh+0]=1.0;
434 fConstraintY[i*fgNParCh+1]=1.0;
440 fConstraintP[i*fgNParCh+2]=1.0;
442 // if (lVarXYT[3]) { // Z constraint
443 // fConstraintP[i*fgNParCh+3]=1.0;
452 AddConstraint(fConstraintX,0.0);
458 AddConstraint(fConstraintY,0.0);
464 AddConstraint(fConstraintP,0.0);
467 // if (lVarXYT[3]) { // Z constraint
468 // AddConstraint(fConstraintP,0.0);
472 //______________________________________________________________________
473 void AliMUONAlignment::AddConstraints(const Bool_t *lChOnOff, const Bool_t *lVarXYT, const Bool_t *lDetTLBR, const Bool_t *lSpecLROnOff)
475 /// Add constraint equations for selected chambers, degrees of freedom and detector half
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.;
487 for (Int_t i = 0; i < fgNDetElem; i++)
491 for (iCh=1; iCh<=fgNCh; iCh++){
492 if (i<fgSNDetElemCh[iCh-1]) break;
494 if (lChOnOff[iCh-1]){
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,
498 lDetElemGloX,lDetElemGloY,lDetElemGloZ);
499 if (iCh>=1 && iCh<=4){
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;
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;
515 if (iCh>=5 && iCh<=6){
516 if ((lDetElemNumber>=5&&lDetElemNumber<=13) && lSpecLROnOff[0]){
517 lMeanY += lDetElemGloY;
518 lSigmaY += lDetElemGloY*lDetElemGloY;
519 lMeanZ += lDetElemGloZ;
520 lSigmaZ += lDetElemGloZ*lDetElemGloZ;
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;
532 if (iCh>=7 && iCh<=10){
533 if ((lDetElemNumber>=7&&lDetElemNumber<=19) && lSpecLROnOff[0]){
534 lMeanY += lDetElemGloY;
535 lSigmaY += lDetElemGloY*lDetElemGloY;
536 lMeanZ += lDetElemGloZ;
537 lSigmaZ += lDetElemGloZ*lDetElemGloZ;
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;
553 lSigmaY /= lNDetElem;
554 lSigmaY = TMath::Sqrt(lSigmaY-lMeanY*lMeanY);
556 lSigmaZ /= lNDetElem;
557 lSigmaZ = TMath::Sqrt(lSigmaZ-lMeanZ*lMeanZ);
558 AliInfo(Form("Used %i DetElem, MeanZ= %f , SigmaZ= %f", lNDetElem,lMeanZ,lSigmaZ));
560 AliError("No detection elements to constrain!!!");
564 for (Int_t i = 0; i < fgNDetElem; i++){
566 for (iCh=1; iCh<=fgNCh; iCh++){
567 if (i<fgSNDetElemCh[iCh-1]) break;
569 if (lChOnOff[iCh-1]){
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,
573 lDetElemGloX,lDetElemGloY,lDetElemGloZ);
574 if (lVarXYT[0]) { // X constraint
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
580 if (lVarXYT[1]) { // Y constraint
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
586 if (lVarXYT[2]) { // P constraint
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
592 if (lVarXYT[3]) { // X-Z shearing
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
598 if (lVarXYT[4]) { // Y-Z shearing
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
604 if (lVarXYT[5]) { // P-Z rotation
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
610 if (lVarXYT[6]) { // X-Y shearing
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
616 if (lVarXYT[7]) { // Y-Y scaling
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
622 if (lVarXYT[8]) { // P-Y rotation
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
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
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
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
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
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
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
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
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
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
686 void AliMUONAlignment::ConstrainT(Int_t lDetElem, Int_t lCh, Double_t *lConstraintT, Int_t iVar, Double_t /*lWeight*/) const{
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;
694 if (lCh>=5 && lCh<=6){
695 if (lDetElemNumber>=0&&lDetElemNumber<=9){
696 lConstraintT[lDetElem*fgNParCh+iVar]=1.0;
699 if (lCh>=7 && lCh<=10){
700 if (lDetElemNumber>=0&&lDetElemNumber<=13){
701 lConstraintT[lDetElem*fgNParCh+iVar]=1.0;
706 //______________________________________________________________________
707 void AliMUONAlignment::ConstrainL(Int_t lDetElem, Int_t lCh, Double_t *lConstraintL, Int_t iVar, Double_t lWeight) const{
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
712 lConstraintL[lDetElem*fgNParCh+iVar]=lWeight;
715 if (lCh>=5 && lCh<=6){
716 if (lDetElemNumber>=5&&lDetElemNumber<=13){
717 lConstraintL[lDetElem*fgNParCh+iVar]=lWeight;
720 if (lCh>=7 && lCh<=10){
721 if (lDetElemNumber>=7&&lDetElemNumber<=19){
722 lConstraintL[lDetElem*fgNParCh+iVar]=lWeight;
727 //______________________________________________________________________
728 void AliMUONAlignment::ConstrainB(Int_t lDetElem, Int_t lCh, Double_t *lConstraintB, Int_t iVar, Double_t /*lWeight*/) const{
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){
732 if (lDetElemNumber==2 || lDetElemNumber==3){ // From track crossings
733 lConstraintB[lDetElem*fgNParCh+iVar]=1.0;
736 if (lCh>=5 && lCh<=6){
737 if ((lDetElemNumber>=9&&lDetElemNumber<=17) ||
738 (lDetElemNumber==0)){
739 lConstraintB[lDetElem*fgNParCh+iVar]=1.0;
742 if (lCh>=7 && lCh<=10){
743 if ((lDetElemNumber>=13&&lDetElemNumber<=25) ||
744 (lDetElemNumber==0)){
745 lConstraintB[lDetElem*fgNParCh+iVar]=1.0;
750 //______________________________________________________________________
751 void AliMUONAlignment::ConstrainR(Int_t lDetElem, Int_t lCh, Double_t *lConstraintR, Int_t iVar, Double_t lWeight) const{
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){
755 if (lDetElemNumber==0 || lDetElemNumber==3){ // From track crossings
756 lConstraintR[lDetElem*fgNParCh+iVar]=lWeight;
759 if (lCh>=5 && lCh<=6){
760 if ((lDetElemNumber>=0&&lDetElemNumber<=4) ||
761 (lDetElemNumber>=14&&lDetElemNumber<=17)){
762 lConstraintR[lDetElem*fgNParCh+iVar]=lWeight;
765 if (lCh>=7 && lCh<=10){
766 if ((lDetElemNumber>=0&&lDetElemNumber<=6) ||
767 (lDetElemNumber>=20&&lDetElemNumber<=25)){
768 lConstraintR[lDetElem*fgNParCh+iVar]=lWeight;
773 //______________________________________________________________________
774 void AliMUONAlignment::ResetConstraints(){
775 /// Reset all constraint equations
776 for (Int_t i = 0; i < fgNDetElem; i++){
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;
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;
907 //______________________________________________________________________
908 void 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");
914 //______________________________________________________________________
915 void AliMUONAlignment::InitGlobalParameters(Double_t *par) {
916 /// Initialize global parameters with par array
917 fMillepede->SetGlobalParameters(par);
918 AliInfo("Init Global Parameters");
921 //______________________________________________________________________
922 void AliMUONAlignment::FixParameter(Int_t iPar, Double_t value) {
923 /// Parameter iPar is encourage to vary in [-value;value].
924 /// If value == 0, parameter is fixed
925 fMillepede->SetParSigma(iPar, value);
926 if (TMath::Abs(value)<1e-4) AliInfo(Form("Parameter %i Fixed", iPar));
929 //______________________________________________________________________
930 void AliMUONAlignment::ResetLocalEquation()
932 /// Reset the derivative vectors
933 for(int i=0; i<fNLocal; i++) {
934 fLocalDerivatives[i] = 0.0;
936 for(int i=0; i<fNGlobal; i++) {
937 fGlobalDerivatives[i] = 0.0;
941 //______________________________________________________________________
942 void AliMUONAlignment::AllowVariations(const Bool_t *bChOnOff)
945 /// Set allowed variation for selected chambers based on fDoF and fAllowVar
946 for (Int_t iCh=1; iCh<=10; iCh++)
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++)
955 AliDebug(1,Form("fDoF[%d]= %d",i,fDoF[i]));
958 for (Int_t j=iDetElemFirst; j<iDetElemLast; j++){
959 FixParameter(j*fgNParCh+i, fAllowVar[i]);
971 //______________________________________________________________________
972 void AliMUONAlignment::SetNonLinear(Int_t iPar /* set non linear flag */ )
974 /// Set nonlinear flag for parameter iPar
975 fMillepede->SetNonLinear(iPar);
976 AliInfo(Form("Parameter %i set to non linear", iPar));
979 //______________________________________________________________________
980 void AliMUONAlignment::SetSigmaXY(Double_t sigmaX, Double_t sigmaY)
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]));
989 //______________________________________________________________________
990 void AliMUONAlignment::LocalEquationX( Bool_t doAlignment )
994 // local cluster record
995 AliMUONAlignmentClusterRecord clusterRecord;
997 // store detector and measurement
998 clusterRecord.SetDetElemId( fDetElemId );
999 clusterRecord.SetDetElemNumber( fDetElemNumber );
1000 clusterRecord.SetMeas( fMeas[0] );
1001 clusterRecord.SetSigma( fSigma[0] );
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]) );
1009 // store global derivatives
1010 clusterRecord.SetGlobalDerivative( 0, -fCosPhi );
1011 clusterRecord.SetGlobalDerivative( 1, -fSinPhi );
1016 clusterRecord.SetGlobalDerivative(
1018 -fSinPhi*(fTrackPos[0]-fDetElemPos[0])
1019 +fCosPhi*(fTrackPos[1]-fDetElemPos[1]) );
1023 clusterRecord.SetGlobalDerivative(
1025 -fSinPhi*(fTrackPos0[0]+fTrackSlope0[0]*(fTrackPos[2]-fTrackPos0[2])-fDetElemPos[0])
1026 +fCosPhi*(fTrackPos0[1]+fTrackSlope0[1]*(fTrackPos[2]-fTrackPos0[2])-fDetElemPos[1]) );
1030 clusterRecord.SetGlobalDerivative( 3, fCosPhi*fTrackSlope0[0]+fSinPhi*fTrackSlope0[1] );
1032 // append to trackRecord
1033 fTrackRecord.AddClusterRecord( clusterRecord );
1035 // store local equation
1036 if( doAlignment ) LocalEquation( clusterRecord );
1040 //______________________________________________________________________
1041 void AliMUONAlignment::LocalEquationY(Bool_t doAlignment )
1044 // local cluster record
1045 AliMUONAlignmentClusterRecord clusterRecord;
1047 // store detector and measurement
1048 clusterRecord.SetDetElemId( fDetElemId );
1049 clusterRecord.SetDetElemNumber( fDetElemNumber );
1050 clusterRecord.SetMeas( fMeas[1] );
1051 clusterRecord.SetSigma( fSigma[1] );
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] ) );
1059 // set global derivatives
1060 clusterRecord.SetGlobalDerivative( 0, fSinPhi);
1061 clusterRecord.SetGlobalDerivative( 1, -fCosPhi);
1066 clusterRecord.SetGlobalDerivative(
1068 -fCosPhi*(fTrackPos[0]-fDetElemPos[0])
1069 -fSinPhi*(fTrackPos[1]-fDetElemPos[1]));
1073 clusterRecord.SetGlobalDerivative(
1075 -fCosPhi*(fTrackPos0[0]+fTrackSlope0[0]*(fTrackPos[2]-fTrackPos0[2])-fDetElemPos[0])
1076 -fSinPhi*(fTrackPos0[1]+fTrackSlope0[1]*(fTrackPos[2]-fTrackPos0[2])-fDetElemPos[1]));
1079 clusterRecord.SetGlobalDerivative( 3, -fSinPhi*fTrackSlope0[0]+fCosPhi*fTrackSlope0[1]);
1081 // append to trackRecord
1082 fTrackRecord.AddClusterRecord( clusterRecord );
1084 // store local equation
1085 if( doAlignment ) LocalEquation( clusterRecord );
1089 //_____________________________________________________
1090 void AliMUONAlignment::LocalEquation( const AliMUONAlignmentClusterRecord& clusterRecord )
1093 // copy to local variables
1094 for( Int_t index = 0; index < 4; ++index )
1096 SetLocalDerivative( index, clusterRecord.GetLocalDerivative( index ) );
1097 SetGlobalDerivative( clusterRecord.GetDetElemNumber()*fgNParCh + index, clusterRecord.GetGlobalDerivative( index ) );
1100 // pass equation parameters to millepede
1101 fMillepede->SetLocalEquation( fGlobalDerivatives, fLocalDerivatives, clusterRecord.GetMeas(), clusterRecord.GetSigma() );
1105 //______________________________________________________________________
1106 void AliMUONAlignment::FillRecPointData()
1109 /// Get information of current cluster
1110 fClustPos[0] = fCluster->GetX();
1111 fClustPos[1] = fCluster->GetY();
1112 fClustPos[2] = fCluster->GetZ();
1113 fTransform->Global2Local(
1114 fDetElemId,fClustPos[0],fClustPos[1],fClustPos[2],
1115 fClustPosLoc[0],fClustPosLoc[1],fClustPosLoc[2]);
1119 //______________________________________________________________________
1120 void AliMUONAlignment::FillTrackParamData()
1123 /// Get information of current track at current cluster
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();
1129 fTransform->Global2Local(
1130 fDetElemId,fTrackPos[0],fTrackPos[1],fTrackPos[2],
1131 fTrackPosLoc[0],fTrackPosLoc[1],fTrackPosLoc[2]);
1135 //_____________________________________________________
1136 void AliMUONAlignment::FillDetElemData()
1139 /// Get information of current detection element
1140 Double_t lDetElemLocX = 0.;
1141 Double_t lDetElemLocY = 0.;
1142 Double_t lDetElemLocZ = 0.;
1143 fDetElemId = fCluster->GetDetElemId();
1144 fDetElemNumber = fDetElemId%100;
1145 for (int iCh=0; iCh<fDetElemId/100-1; iCh++)
1146 { fDetElemNumber += fgNDetElemCh[iCh]; }
1148 fTransform->Local2Global(
1149 fDetElemId,lDetElemLocX,lDetElemLocY,lDetElemLocZ,
1150 fDetElemPos[0],fDetElemPos[1],fDetElemPos[2]);
1154 //_____________________________________________________
1155 AliMUONAlignmentTrackRecord* AliMUONAlignment::ProcessTrack( AliMUONTrack* track, Bool_t doAlignment )
1157 /// Process track and set Local Equations
1158 // store current track in running member.
1161 // clear track record
1162 fTrackRecord.Clear();
1164 // get number of tracks
1165 Int_t nTrackParam = fTrack->GetTrackParamAtCluster()->GetEntries();
1166 AliDebug(1,Form("Number of track param entries : %i ", nTrackParam));
1168 Bool_t first( kTRUE );
1169 for(Int_t iCluster=0; iCluster<nTrackParam; iCluster++)
1172 // and get new pointers
1173 fTrackParam = (AliMUONTrackParam *) fTrack->GetTrackParamAtCluster()->At(iCluster);
1174 if ( ! fTrackParam ) continue;
1175 fCluster = fTrackParam->GetClusterPtr();
1176 if ( ! fCluster ) continue;
1177 // if (fDetElemId<500) continue;
1179 // fill local variables for this position --> one measurement
1182 FillTrackParamData();
1187 // for first valid cluster, save track position as "starting" values
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];
1198 // calculate measurements
1199 fCosPhi = TMath::Cos(fPhi);
1200 fSinPhi = TMath::Sin(fPhi);
1204 fMeas[0] = fTrackPos[0] - fClustPos[0];
1205 fMeas[1] = fTrackPos[1] - fClustPos[1];
1209 fMeas[0] = - fClustPos[0];
1210 fMeas[1] = - fClustPos[1];
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));
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]));
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]));
1225 // Set local equations
1226 LocalEquationX( doAlignment );
1227 LocalEquationY( doAlignment );
1231 return &fTrackRecord;
1235 //______________________________________________________________________________
1236 void AliMUONAlignment::ProcessTrack( AliMUONAlignmentTrackRecord* track, Bool_t doAlignment )
1238 /// Process track (from record) and set Local Equations
1239 if( !( track && doAlignment ) ) return;
1241 // loop over clusters
1242 for( Int_t index = 0; index < track->GetNRecords(); ++index )
1243 { if( AliMUONAlignmentClusterRecord* record = track->GetRecord( index ) ) LocalEquation( *record ); }
1249 //_____________________________________________________
1250 void AliMUONAlignment::LocalFit(Int_t iTrack, Double_t *lTrackParam, Int_t lSingleFit)
1253 /// Call local fit for this tracks
1254 Int_t iRes = fMillepede->LocalFit(iTrack,lTrackParam,lSingleFit);
1255 if (iRes && !lSingleFit)
1256 { fMillepede->SetNLocalEquations(fMillepede->GetNLocalEquations()+1); }
1260 //_____________________________________________________
1261 void AliMUONAlignment::GlobalFit(Double_t *parameters,Double_t *errors,Double_t *pulls)
1264 /// Call global fit; Global parameters are stored in parameters
1265 fMillepede->GlobalFit(parameters,errors,pulls);
1267 AliInfo("Done fitting global parameters!");
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]); }
1274 //_____________________________________________________
1275 Double_t AliMUONAlignment::GetParError(Int_t iPar)
1277 /// Get error of parameter iPar
1278 Double_t lErr = fMillepede->GetParError(iPar);
1282 //_____________________________________________________
1283 void AliMUONAlignment::PrintGlobalParameters()
1285 /// Print global parameters
1286 fMillepede->PrintGlobalParameters();
1289 //_________________________________________________________________________
1290 TGeoCombiTrans AliMUONAlignment::ReAlign(const TGeoCombiTrans & transform, const double *lMisAlignment) const
1292 /// Realign given transformation by given misalignment and return the misaligned transformation
1294 Double_t cartMisAlig[3] = {0,0,0};
1295 Double_t angMisAlig[3] = {0,0,0};
1296 // const Double_t *trans = transform.GetTranslation();
1297 // TGeoRotation *rot;
1298 // // check if the rotation we obtain is not NULL
1299 // if (transform.GetRotation()) {
1300 // rot = transform.GetRotation();
1303 // rot = new TGeoRotation("rot");
1304 // } // default constructor.
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();
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]);
1317 TGeoCombiTrans deltaTransf(deltaTrans,deltaRot);
1318 TGeoHMatrix newTransfMat = transform * deltaTransf;
1320 return TGeoCombiTrans(newTransfMat);
1323 //______________________________________________________________________
1324 AliMUONGeometryTransformer *
1325 AliMUONAlignment::ReAlign(const AliMUONGeometryTransformer * transformer,
1326 const double *misAlignments, Bool_t verbose)
1329 /// Returns a new AliMUONGeometryTransformer with the found misalignments
1332 // Takes the internal geometry module transformers, copies them
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
1337 // transformation with the local transformation
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
1343 Double_t lModuleMisAlignment[4] = {0.,0.,0.,0.};
1344 Double_t lDetElemMisAlignment[4] = {0.,0.,0.,0.};
1345 Int_t iDetElemId = 0;
1346 Int_t iDetElemNumber = 0;
1348 AliMUONGeometryTransformer *newGeometryTransformer =
1349 new AliMUONGeometryTransformer();
1350 for (Int_t iMt = 0; iMt < transformer->GetNofModuleTransformers(); iMt++) {
1351 // module transformers
1352 const AliMUONGeometryModuleTransformer *kModuleTransformer =
1353 transformer->GetModuleTransformer(iMt, true);
1355 AliMUONGeometryModuleTransformer *newModuleTransformer =
1356 new AliMUONGeometryModuleTransformer(iMt);
1357 newGeometryTransformer->AddModuleTransformer(newModuleTransformer);
1359 TGeoCombiTrans moduleTransform =
1360 TGeoCombiTrans(*kModuleTransformer->GetTransformation());
1361 // New module transformation
1362 TGeoCombiTrans newModuleTransform = ReAlign(moduleTransform,lModuleMisAlignment);
1363 newModuleTransformer->SetTransformation(newModuleTransform);
1365 // Get delta transformation:
1366 // Tdelta = Tnew * Told.inverse
1367 TGeoHMatrix deltaModuleTransform =
1368 AliMUONGeometryBuilder::Multiply(newModuleTransform,
1369 kModuleTransformer->GetTransformation()->Inverse());
1370 // Create module mis alignment matrix
1371 newGeometryTransformer
1372 ->AddMisAlignModule(kModuleTransformer->GetModuleId(), deltaModuleTransform);
1374 AliMpExMap *detElements = kModuleTransformer->GetDetElementStore();
1377 AliInfo(Form("%i DEs in old GeometryStore %i",detElements->GetSize(), iMt));
1379 TIter next(detElements->CreateIterator());
1380 AliMUONGeometryDetElement* detElement;
1382 while ( ( detElement = static_cast<AliMUONGeometryDetElement*>(next()) ) )
1385 // make a new detection element
1386 AliMUONGeometryDetElement *newDetElement =
1387 new AliMUONGeometryDetElement(detElement->GetId(),
1388 detElement->GetVolumePath());
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++){
1394 iDetElemNumber += fgNDetElemCh[iCh];
1396 for (int i=0; i<fgNParCh; i++) {
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];
1403 // local transformation of this detection element.
1404 TGeoCombiTrans localTransform
1405 = TGeoCombiTrans(*detElement->GetLocalTransformation());
1406 TGeoCombiTrans newLocalTransform = ReAlign(localTransform,lDetElemMisAlignment);
1407 newDetElement->SetLocalTransformation(newLocalTransform);
1409 // global transformation
1410 TGeoHMatrix newGlobalTransform =
1411 AliMUONGeometryBuilder::Multiply(newModuleTransform,
1413 newDetElement->SetGlobalTransformation(newGlobalTransform);
1415 // add this det element to module
1416 newModuleTransformer->GetDetElementStore()->Add(newDetElement->GetId(),
1419 // In the Alice Alignment Framework misalignment objects store
1420 // global delta transformation
1421 // Get detection "intermediate" global transformation
1422 TGeoHMatrix newOldGlobalTransform = newModuleTransform * localTransform;
1423 // Get detection element global delta transformation:
1424 // Tdelta = Tnew * Told.inverse
1425 TGeoHMatrix deltaGlobalTransform
1426 = AliMUONGeometryBuilder::Multiply(newGlobalTransform,
1427 newOldGlobalTransform.Inverse());
1429 // Create mis alignment matrix
1430 newGeometryTransformer
1431 ->AddMisAlignDetElement(detElement->GetId(), deltaGlobalTransform);
1435 AliInfo(Form("Added module transformer %i to the transformer", iMt));
1436 newGeometryTransformer->AddModuleTransformer(newModuleTransformer);
1438 return newGeometryTransformer;
1441 //______________________________________________________________________
1442 void AliMUONAlignment::SetAlignmentResolution(const TClonesArray* misAlignArray, Int_t rChId, Double_t rChResX, Double_t rChResY, Double_t rDeResX, Double_t rDeResY)
1445 /// Set alignment resolution to misalign objects to be stored in CDB
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;
1453 TMatrixDSym mChCorrMatrix(6);
1454 mChCorrMatrix[0][0]=chResX*chResX;
1455 mChCorrMatrix[1][1]=chResY*chResY;
1456 // mChCorrMatrix.Print();
1458 TMatrixDSym mDECorrMatrix(6);
1459 mDECorrMatrix[0][0]=deResX*deResX;
1460 mDECorrMatrix[1][1]=deResY*deResY;
1461 // mDECorrMatrix.Print();
1463 AliAlignObjMatrix *alignMat = 0x0;
1465 for(Int_t chId=chIdMin; chId<=chIdMax; chId++) {
1469 chName1 = Form("GM%d",chId);
1470 chName2 = Form("GM%d",chId);
1472 chName1 = Form("GM%d",4+(chId-4)*2);
1473 chName2 = Form("GM%d",4+(chId-4)*2+1);
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)&&
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);