]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONAlignment.cxx
Coverity fix.
[u/mrichter/AliRoot.git] / MUON / AliMUONAlignment.cxx
index 67afdc666de894fcf8ebb230cc6560bef1e0cceb..4ddb0e21e510aa5df8d2a6cc911c2c58904b9c1e 100644 (file)
@@ -35,7 +35,6 @@
 #include "AliMUONGeometryModuleTransformer.h"
 #include "AliMUONGeometryDetElement.h"
 #include "AliMUONGeometryBuilder.h"
-#include "AliMUONConstants.h"
 #include "AliMillepede.h"
 
 #include "AliMpExMap.h"
@@ -46,7 +45,6 @@
 
 #include "TMath.h"
 #include "TMatrixDSym.h"
-#include "TSystem.h"
 
 /// \cond CLASSIMP
 ClassImp(AliMUONAlignment)
@@ -55,7 +53,7 @@ ClassImp(AliMUONAlignment)
   Int_t AliMUONAlignment::fgNDetElem = 4*2+4*2+18*2+26*2+26*2;
   Int_t AliMUONAlignment::fgNDetElemCh[10] = {4,4,4,4,18,18,26,26,26,26};
   Int_t AliMUONAlignment::fgSNDetElemCh[10] = {4,8,12,16,34,52,78,104,130,156};
-  Int_t AliMUONAlignment::fgNParCh = 3;
+  Int_t AliMUONAlignment::fgNParCh = 4;
   Int_t AliMUONAlignment::fgNTrkMod = 16;
   Int_t AliMUONAlignment::fgNCh = 10;
   Int_t AliMUONAlignment::fgNSt = 5;
@@ -63,7 +61,7 @@ ClassImp(AliMUONAlignment)
 AliMUONAlignment::AliMUONAlignment() 
   : TObject(),
     fBFieldOn(kTRUE),
-    fStartFac(16.), 
+    fStartFac(256.), 
     fResCutInitial(100.), 
     fResCut(100.),
     fMillepede(0),
@@ -85,8 +83,10 @@ AliMUONAlignment::AliMUONAlignment()
   fSigma[0] = 1.0e-1;
   fSigma[1] = 1.0e-2;
 
-  fDoF[0] = kTRUE;  fDoF[1] = kTRUE;  fDoF[2] = kTRUE;
-  fAllowVar[0] = 0.05;  fAllowVar[1] = 0.05;  fAllowVar[2] = 0.001;
+  AliInfo(Form("fSigma[0]: %f\t fSigma[1]: %f",fSigma[0],fSigma[1]));
+
+  fDoF[0] = kTRUE;  fDoF[1] = kTRUE;  fDoF[2] = kTRUE;  fDoF[3] = kTRUE;
+  fAllowVar[0] = 0.05;  fAllowVar[1] = 0.05;  fAllowVar[2] = 0.001;  fAllowVar[3] = 0.5;
   
   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));
 
@@ -110,16 +110,19 @@ void AliMUONAlignment::Init(Int_t nGlobal,  /* number of global paramers */
   /// Initialization of AliMillepede. Fix parameters, define constraints ...
   fMillepede->InitMille(nGlobal,nLocal,nStdDev,fResCut,fResCutInitial);
 
-  Bool_t bStOnOff[5] = {kTRUE,kTRUE,kTRUE,kTRUE,kTRUE};
-  Bool_t bSpecLROnOff[2] = {kTRUE,kTRUE};
+//  Bool_t bStOnOff[5] = {kTRUE,kTRUE,kTRUE,kTRUE,kTRUE};
+//  Bool_t bChOnOff[10] = {kTRUE,kTRUE,kTRUE,kTRUE,kTRUE,kTRUE,kTRUE,kTRUE,kTRUE,kTRUE};
+//  Bool_t bSpecLROnOff[2] = {kTRUE,kTRUE};
 
-  AllowVariations(bStOnOff);
+//   AllowVariations(bChOnOff);
 
   // Fix parameters or add constraints here
-  for (Int_t iSt=0; iSt<5; iSt++)
-    if (!bStOnOff[iSt]) FixStation(iSt+1);
+//   for (Int_t iSt=0; iSt<5; iSt++)
+//     if (!bStOnOff[iSt]) FixStation(iSt+1);
+//   for (Int_t iCh=0; iCh<10; iCh++)
+//     if (!bChOnOff[iCh]) FixChamber(iCh+1);
 
-  FixHalfSpectrometer(bStOnOff,bSpecLROnOff);
+//   FixHalfSpectrometer(bChOnOff,bSpecLROnOff);
 
   ResetConstraints();
   
@@ -149,29 +152,63 @@ void AliMUONAlignment::FixStation(Int_t iSt){
     FixParameter(i*fgNParCh+0, 0.0);
     FixParameter(i*fgNParCh+1, 0.0);
     FixParameter(i*fgNParCh+2, 0.0);
+    FixParameter(i*fgNParCh+3, 0.0);
+  }
+}
+
+void AliMUONAlignment::FixChamber(Int_t iCh){
+  /// Fix all detection elements of chamber iCh
+  Int_t iDetElemFirst = (iCh>1) ? fgSNDetElemCh[iCh-2] : 0; 
+  Int_t iDetElemLast = fgSNDetElemCh[iCh-1]; 
+  for (Int_t i = iDetElemFirst; i < iDetElemLast; i++){    
+    FixParameter(i*fgNParCh+0, 0.0);
+    FixParameter(i*fgNParCh+1, 0.0);
+    FixParameter(i*fgNParCh+2, 0.0);
+    FixParameter(i*fgNParCh+3, 0.0);
+  }
+}
+
+void AliMUONAlignment::FixDetElem(Int_t iDetElemId, TString sVarXYT){
+  /// Fix a given detection element
+  Int_t iDetElemNumber = iDetElemId%100;
+  for (int iCh=0; iCh<iDetElemId/100-1; iCh++){
+    iDetElemNumber += fgNDetElemCh[iCh];
+  }
+  if (sVarXYT.Contains("X")) { // X constraint
+    FixParameter(iDetElemNumber*fgNParCh+0, 0.0);
+  }
+  if (sVarXYT.Contains("Y")) { // Y constraint
+    FixParameter(iDetElemNumber*fgNParCh+1, 0.0);
+  }
+  if (sVarXYT.Contains("T")) { // T constraint
+    FixParameter(iDetElemNumber*fgNParCh+2, 0.0);
+  }
+  if (sVarXYT.Contains("Z")) { // T constraint
+    FixParameter(iDetElemNumber*fgNParCh+3, 0.0);
   }
 }
 
-void AliMUONAlignment::FixHalfSpectrometer(Bool_t *lStOnOff, Bool_t *lSpecLROnOff){
+void AliMUONAlignment::FixHalfSpectrometer(const Bool_t *lChOnOff, const Bool_t *lSpecLROnOff){
   /// Fix left or right detector
   for (Int_t i = 0; i < fgNDetElem; i++){    
     Int_t iCh=0;
     for (iCh=1; iCh<=fgNCh; iCh++){
       if (i<fgSNDetElemCh[iCh-1]) break;
     }
-    Int_t iSt = lStOnOff[(iCh-1)/2] ? (iCh+1)/2 : 0; 
-    if (iSt){
+    if (lChOnOff[iCh-1]){
       Int_t lDetElemNumber = (iCh==1) ? i : i-fgSNDetElemCh[iCh-2];
       if (iCh>=1 && iCh<=4){
        if ((lDetElemNumber==1 || lDetElemNumber==2) && !lSpecLROnOff[0]){ // From track crossings
          FixParameter(i*fgNParCh+0, 0.0);
          FixParameter(i*fgNParCh+1, 0.0);
          FixParameter(i*fgNParCh+2, 0.0);
+         FixParameter(i*fgNParCh+3, 0.0);
        }
        if ((lDetElemNumber==0 || lDetElemNumber==3) && !lSpecLROnOff[1]){ // From track crossings
          FixParameter(i*fgNParCh+0, 0.0);
          FixParameter(i*fgNParCh+1, 0.0);
          FixParameter(i*fgNParCh+2, 0.0);
+         FixParameter(i*fgNParCh+3, 0.0);
        }
       }
       if (iCh>=5 && iCh<=6){
@@ -179,12 +216,14 @@ void AliMUONAlignment::FixHalfSpectrometer(Bool_t *lStOnOff, Bool_t *lSpecLROnOf
          FixParameter(i*fgNParCh+0, 0.0);
          FixParameter(i*fgNParCh+1, 0.0);
          FixParameter(i*fgNParCh+2, 0.0);
+         FixParameter(i*fgNParCh+3, 0.0);
        }
        if (((lDetElemNumber>=0&&lDetElemNumber<=4) || 
             (lDetElemNumber>=14&&lDetElemNumber<=17)) && !lSpecLROnOff[1]){
          FixParameter(i*fgNParCh+0, 0.0);
          FixParameter(i*fgNParCh+1, 0.0);
          FixParameter(i*fgNParCh+2, 0.0);
+         FixParameter(i*fgNParCh+3, 0.0);
        }
       }
       if (iCh>=7 && iCh<=10){
@@ -192,27 +231,28 @@ void AliMUONAlignment::FixHalfSpectrometer(Bool_t *lStOnOff, Bool_t *lSpecLROnOf
          FixParameter(i*fgNParCh+0, 0.0);
          FixParameter(i*fgNParCh+1, 0.0);
          FixParameter(i*fgNParCh+2, 0.0);
+         FixParameter(i*fgNParCh+3, 0.0);
        }
        if (((lDetElemNumber>=0&&lDetElemNumber<=6) || 
             (lDetElemNumber>=20&&lDetElemNumber<=25)) && !lSpecLROnOff[1]){
          FixParameter(i*fgNParCh+0, 0.0);
          FixParameter(i*fgNParCh+1, 0.0);
          FixParameter(i*fgNParCh+2, 0.0);
+         FixParameter(i*fgNParCh+3, 0.0);
        }
       }
     }
   }
 }
 
-void AliMUONAlignment::SetNonLinear(Bool_t *lStOnOff,Bool_t *lVarXYT){
-  /// Set non linear parameter flag selected stations and degrees of freedom
+void AliMUONAlignment::SetNonLinear(const Bool_t *lChOnOff, const Bool_t *lVarXYT){
+  /// Set non linear parameter flag selected chambers and degrees of freedom
   for (Int_t i = 0; i < fgNDetElem; i++){    
     Int_t iCh=0;
     for (iCh=1; iCh<=fgNCh; iCh++){
       if (i<fgSNDetElemCh[iCh-1]) break;
     }
-    Int_t iSt = lStOnOff[(iCh-1)/2] ? (iCh+1)/2 : 0; 
-    if (iSt){
+    if (lChOnOff[iCh-1]){
       if (lVarXYT[0]) { // X constraint
        SetNonLinear(i*fgNParCh+0);
       }
@@ -222,19 +262,21 @@ void AliMUONAlignment::SetNonLinear(Bool_t *lStOnOff,Bool_t *lVarXYT){
       if (lVarXYT[2]) { // T constraint
        SetNonLinear(i*fgNParCh+2);
       }
+      if (lVarXYT[3]) { // Z constraint
+       SetNonLinear(i*fgNParCh+3);
+      }
     }
   }
 }
 
-void AliMUONAlignment::AddConstraints(Bool_t *lStOnOff,Bool_t *lVarXYT){
-  /// Add constraint equations for selected stations and degrees of freedom 
+void AliMUONAlignment::AddConstraints(const Bool_t *lChOnOff, const Bool_t *lVarXYT){
+  /// Add constraint equations for selected chambers and degrees of freedom 
   for (Int_t i = 0; i < fgNDetElem; i++){    
     Int_t iCh=0;
     for (iCh=1; iCh<=fgNCh; iCh++){
       if (i<fgSNDetElemCh[iCh-1]) break;
     }
-    Int_t iSt = lStOnOff[(iCh-1)/2] ? (iCh+1)/2 : 0; 
-    if (iSt){
+    if (lChOnOff[iCh-1]){
       if (lVarXYT[0]) { // X constraint
        fConstraintX[i*fgNParCh+0]=1.0;
       }
@@ -244,6 +286,9 @@ void AliMUONAlignment::AddConstraints(Bool_t *lStOnOff,Bool_t *lVarXYT){
       if (lVarXYT[2]) { // T constraint
        fConstraintP[i*fgNParCh+2]=1.0;
       }
+//       if (lVarXYT[3]) { // Z constraint
+//     fConstraintP[i*fgNParCh+3]=1.0;
+//       }
     }
   }
   if (lVarXYT[0]) { // X constraint
@@ -255,10 +300,13 @@ void AliMUONAlignment::AddConstraints(Bool_t *lStOnOff,Bool_t *lVarXYT){
   if (lVarXYT[2]) { // T constraint
     AddConstraint(fConstraintP,0.0);
   }
+//   if (lVarXYT[3]) { // Z constraint
+//     AddConstraint(fConstraintP,0.0);
+//   }
 }
 
-void AliMUONAlignment::AddConstraints(Bool_t *lStOnOff,Bool_t *lVarXYT, Bool_t *lDetTLBR, Bool_t *lSpecLROnOff){
-  /// Add constraint equations for selected stations, degrees of freedom and detector half 
+void AliMUONAlignment::AddConstraints(const Bool_t *lChOnOff, const Bool_t *lVarXYT, const Bool_t *lDetTLBR, const Bool_t *lSpecLROnOff){
+  /// Add constraint equations for selected chambers, degrees of freedom and detector half 
   Double_t lDetElemLocX = 0.;
   Double_t lDetElemLocY = 0.;
   Double_t lDetElemLocZ = 0.;
@@ -275,8 +323,7 @@ void AliMUONAlignment::AddConstraints(Bool_t *lStOnOff,Bool_t *lVarXYT, Bool_t *
     for (iCh=1; iCh<=fgNCh; iCh++){
       if (i<fgSNDetElemCh[iCh-1]) break;
     }
-    Int_t iSt = lStOnOff[(iCh-1)/2] ? (iCh+1)/2 : 0; 
-    if (iSt){
+    if (lChOnOff[iCh-1]){ 
       Int_t lDetElemNumber = (iCh==1) ? i : i-fgSNDetElemCh[iCh-2];
       Int_t lDetElemId = iCh*100+lDetElemNumber;
       fTransform->Local2Global(lDetElemId,lDetElemLocX,lDetElemLocY,lDetElemLocZ,
@@ -346,8 +393,7 @@ void AliMUONAlignment::AddConstraints(Bool_t *lStOnOff,Bool_t *lVarXYT, Bool_t *
     for (iCh=1; iCh<=fgNCh; iCh++){
       if (i<fgSNDetElemCh[iCh-1]) break;
     }
-    Int_t iSt = lStOnOff[(iCh-1)/2] ? (iCh+1)/2 : 0; 
-    if (iSt){
+    if (lChOnOff[iCh-1]){
       Int_t lDetElemNumber = (iCh==1) ? i : i-fgSNDetElemCh[iCh-2];
       Int_t lDetElemId = iCh*100+lDetElemNumber;
       fTransform->Local2Global(lDetElemId,lDetElemLocX,lDetElemLocY,lDetElemLocZ,
@@ -464,7 +510,7 @@ void AliMUONAlignment::AddConstraints(Bool_t *lStOnOff,Bool_t *lVarXYT, Bool_t *
   }
 }
 
-void AliMUONAlignment::ConstrainT(Int_t lDetElem, Int_t lCh, Double_t *lConstraintT, Int_t iVar, Double_t /*lWeight*/){
+void AliMUONAlignment::ConstrainT(Int_t lDetElem, Int_t lCh, Double_t *lConstraintT, Int_t iVar, Double_t /*lWeight*/) const{
   /// Set constrain equation for top half of spectrometer
   Int_t lDetElemNumber = (lCh==1) ? lDetElem : lDetElem-fgSNDetElemCh[lCh-2];
   if (lCh>=1 && lCh<=4){
@@ -484,7 +530,7 @@ void AliMUONAlignment::ConstrainT(Int_t lDetElem, Int_t lCh, Double_t *lConstrai
   }
 }
 
-void AliMUONAlignment::ConstrainL(Int_t lDetElem, Int_t lCh, Double_t *lConstraintL, Int_t iVar, Double_t lWeight){
+void AliMUONAlignment::ConstrainL(Int_t lDetElem, Int_t lCh, Double_t *lConstraintL, Int_t iVar, Double_t lWeight) const{
   /// Set constrain equation for left half of spectrometer
   Int_t lDetElemNumber = (lCh==1) ? lDetElem : lDetElem-fgSNDetElemCh[lCh-2];
   if (lCh>=1 && lCh<=4){
@@ -504,7 +550,7 @@ void AliMUONAlignment::ConstrainL(Int_t lDetElem, Int_t lCh, Double_t *lConstrai
   }
 }
 
-void AliMUONAlignment::ConstrainB(Int_t lDetElem, Int_t lCh, Double_t *lConstraintB, Int_t iVar, Double_t /*lWeight*/){
+void AliMUONAlignment::ConstrainB(Int_t lDetElem, Int_t lCh, Double_t *lConstraintB, Int_t iVar, Double_t /*lWeight*/) const{
   /// Set constrain equation for bottom half of spectrometer
   Int_t lDetElemNumber = (lCh==1) ? lDetElem : lDetElem-fgSNDetElemCh[lCh-2];
   if (lCh>=1 && lCh<=4){
@@ -526,7 +572,7 @@ void AliMUONAlignment::ConstrainB(Int_t lDetElem, Int_t lCh, Double_t *lConstrai
   }
 }
 
-void AliMUONAlignment::ConstrainR(Int_t lDetElem, Int_t lCh, Double_t *lConstraintR, Int_t iVar, Double_t lWeight){
+void AliMUONAlignment::ConstrainR(Int_t lDetElem, Int_t lCh, Double_t *lConstraintR, Int_t iVar, Double_t lWeight) const{
   /// Set constrain equation for right half of spectrometer
   Int_t lDetElemNumber = (lCh==1) ? lDetElem : lDetElem-fgSNDetElemCh[lCh-2];
   if (lCh>=1 && lCh<=4){
@@ -690,7 +736,7 @@ void AliMUONAlignment::FixParameter(Int_t iPar, Double_t value) {
   /// Parameter iPar is encourage to vary in [-value;value]. 
   /// If value == 0, parameter is fixed
   fMillepede->SetParSigma(iPar, value);
-  if (value==0) AliInfo(Form("Parameter %i Fixed", iPar));
+  if (TMath::Abs(value)<1e-4) AliInfo(Form("Parameter %i Fixed", iPar));
 }
 
 void AliMUONAlignment::ResetLocalEquation()
@@ -704,12 +750,12 @@ void AliMUONAlignment::ResetLocalEquation()
   }
 }
 
-void AliMUONAlignment::AllowVariations(Bool_t *bStOnOff) {
-  /// Set allowed variation for selected stations based on fDoF and fAllowVar
-  for (Int_t iSt=1; iSt<=5; iSt++) {
-    if (bStOnOff[iSt-1]) {
-      Int_t iDetElemFirst = (iSt>1) ? fgSNDetElemCh[2*(iSt-1)-1] : 0; 
-      Int_t iDetElemLast = fgSNDetElemCh[2*(iSt)-1]; 
+void AliMUONAlignment::AllowVariations(const Bool_t *bChOnOff) {
+  /// Set allowed variation for selected chambers based on fDoF and fAllowVar
+  for (Int_t iCh=1; iCh<=10; iCh++) {
+    if (bChOnOff[iCh-1]) {
+      Int_t iDetElemFirst = (iCh>1) ? fgSNDetElemCh[iCh-2] : 0; 
+      Int_t iDetElemLast = fgSNDetElemCh[iCh-1]; 
       for (int i=0; i<fgNParCh; i++) {
        AliDebug(1,Form("fDoF[%d]= %d",i,fDoF[i]));    
        if (fDoF[i]) {
@@ -728,6 +774,14 @@ void AliMUONAlignment::SetNonLinear(Int_t iPar  /* set non linear flag */ ) {
   AliInfo(Form("Parameter %i set to non linear", iPar));
 }
 
+
+void AliMUONAlignment::SetSigmaXY(Double_t sigmaX, Double_t sigmaY) {
+  /// Set expected measurement resolution
+  fSigma[0] = sigmaX;   fSigma[1] = sigmaY;
+  AliInfo(Form("Using fSigma[0]=%f and fSigma[1]=%f",fSigma[0],fSigma[1]));
+}
+
+
 void AliMUONAlignment::LocalEquationX() {
   /// Define local equation for current track and cluster in x coor. measurement
   // set local derivatives
@@ -751,6 +805,8 @@ void AliMUONAlignment::LocalEquationX() {
                        +fCosPhi*(fTrackPos0[1]+fTrackSlope0[1]*
                                  (fTrackPos[2]-fTrackPos0[2])-fDetElemPos[1]));
   }
+  SetGlobalDerivative(fDetElemNumber*fgNParCh+3, 
+                     fCosPhi*fTrackSlope0[0]+fSinPhi*fTrackSlope0[1]);
 
   fMillepede->SetLocalEquation(fGlobalDerivatives, fLocalDerivatives, fMeas[0], fSigma[0]);
 }
@@ -778,6 +834,8 @@ void AliMUONAlignment::LocalEquationY() {
                        -fSinPhi*(fTrackPos0[1]+fTrackSlope0[1]*
                                  (fTrackPos[2]-fTrackPos0[2])-fDetElemPos[1]));
   }
+  SetGlobalDerivative(fDetElemNumber*fgNParCh+3,
+                     -fSinPhi*fTrackSlope0[0]+fCosPhi*fTrackSlope0[1]);
 
   fMillepede->SetLocalEquation(fGlobalDerivatives, fLocalDerivatives, fMeas[1], fSigma[1]);
 }
@@ -828,8 +886,9 @@ void AliMUONAlignment::ProcessTrack(AliMUONTrack * track) {
 
   for(Int_t iCluster=0; iCluster<nTrackParam; iCluster++) {
     fTrackParam = (AliMUONTrackParam *) fTrack->GetTrackParamAtCluster()->At(iCluster);
+    if (!fTrackParam) continue;
     fCluster = fTrackParam->GetClusterPtr();
-    if (!fCluster || !fTrackParam) continue;
+    if (!fCluster) continue;
     // fill local variables for this position --> one measurement
     FillDetElemData();
     FillRecPointData();
@@ -846,8 +905,9 @@ void AliMUONAlignment::ProcessTrack(AliMUONTrack * track) {
   for(Int_t iCluster=0; iCluster<nTrackParam; iCluster++) {
     // and get new pointers
     fTrackParam = (AliMUONTrackParam *) fTrack->GetTrackParamAtCluster()->At(iCluster);
+    if (!fTrackParam) continue;
     fCluster = fTrackParam->GetClusterPtr();
-    if (!fCluster || !fTrackParam) continue;
+    if (!fCluster) continue;
     // fill local variables for this position --> one measurement
     FillDetElemData();        
     FillRecPointData();
@@ -908,7 +968,7 @@ void AliMUONAlignment::PrintGlobalParameters() {
 }
 
 //_________________________________________________________________________
-TGeoCombiTrans AliMUONAlignment::ReAlign(const TGeoCombiTrans & transform, double *lMisAlignment) const
+TGeoCombiTrans AliMUONAlignment::ReAlign(const TGeoCombiTrans & transform, const double *lMisAlignment) const
 {
   /// Realign given transformation by given misalignment and return the misaligned transformation
   
@@ -924,9 +984,10 @@ TGeoCombiTrans AliMUONAlignment::ReAlign(const TGeoCombiTrans & transform, doubl
 //     rot = new TGeoRotation("rot");
 //   }                 // default constructor.
 
-  cartMisAlig[0] = -lMisAlignment[0];
-  cartMisAlig[1] = -lMisAlignment[1];
-  angMisAlig[2] = -lMisAlignment[2]*180./TMath::Pi();
+  cartMisAlig[0] = -TMath::Sign(1.0,transform.GetRotationMatrix()[0])*lMisAlignment[0];
+  cartMisAlig[1] = -TMath::Sign(1.0,transform.GetRotationMatrix()[4])*lMisAlignment[1];
+  cartMisAlig[2] = -TMath::Sign(1.0,transform.GetRotationMatrix()[8])*lMisAlignment[3];
+  angMisAlig[2] = -TMath::Sign(1.0,transform.GetRotationMatrix()[0]*transform.GetRotationMatrix()[4])*lMisAlignment[2]*180./TMath::Pi();
 
   TGeoTranslation deltaTrans(cartMisAlig[0], cartMisAlig[1], cartMisAlig[2]);
   TGeoRotation deltaRot;
@@ -943,11 +1004,13 @@ TGeoCombiTrans AliMUONAlignment::ReAlign(const TGeoCombiTrans & transform, doubl
 //______________________________________________________________________
 AliMUONGeometryTransformer *
 AliMUONAlignment::ReAlign(const AliMUONGeometryTransformer * transformer,
-                           double *misAlignments, Bool_t verbose)
+                           const double *misAlignments, Bool_t verbose)
                            
 {
-  /////////////////////////////////////////////////////////////////////
-  //   Takes the internal geometry module transformers, copies them
+  /// Returns a new AliMUONGeometryTransformer with the found misalignments
+  /// applied. 
+
+  // Takes the internal geometry module transformers, copies them
   // and gets the Detection Elements from them.
   // Takes misalignment parameters and applies these
   // to the local transform of the Detection Element
@@ -958,8 +1021,8 @@ AliMUONAlignment::ReAlign(const AliMUONGeometryTransformer * transformer,
   // Adds the new module transformer to a new geometry transformer
   // Returns the new geometry transformer
 
-  Double_t lModuleMisAlignment[3] = {0.,0.,0.};
-  Double_t lDetElemMisAlignment[3] = {0.,0.,0.};
+  Double_t lModuleMisAlignment[4] = {0.,0.,0.,0.};
+  Double_t lDetElemMisAlignment[4] = {0.,0.,0.,0.};
   Int_t iDetElemId = 0;
   Int_t iDetElemNumber = 0;
 
@@ -1000,7 +1063,7 @@ AliMUONAlignment::ReAlign(const AliMUONGeometryTransformer * transformer,
     while ( ( detElement = static_cast<AliMUONGeometryDetElement*>(next()) ) )
     {
       ++iDe;
-      /// make a new detection element
+      // make a new detection element
       AliMUONGeometryDetElement *newDetElement =
        new AliMUONGeometryDetElement(detElement->GetId(),
                                      detElement->GetVolumePath());
@@ -1058,7 +1121,7 @@ AliMUONAlignment::ReAlign(const AliMUONGeometryTransformer * transformer,
 
 //______________________________________________________________________
 void AliMUONAlignment::SetAlignmentResolution(const TClonesArray* misAlignArray, Int_t rChId, Double_t rChResX, Double_t rChResY, Double_t rDeResX, Double_t rDeResY){
-  //// Set alignment resolution to misalign objects to be stored in CDB
+  /// Set alignment resolution to misalign objects to be stored in CDB
   Int_t chIdMin = (rChId<0)? 0 : rChId;
   Int_t chIdMax = (rChId<0)? 9 : rChId;
   Double_t chResX = rChResX;