31 #include "TGeoMatrix.h"
35 #include <TGeoPhysicalNode.h>
37 #include "AliAlignObjParams.h"
38 #include "AliGeomManager.h"
39 #include "AliCDBManager.h"
40 #include "AliCDBEntry.h"
44 fXShift(0.),fYShift(0.),fZShift(0.),
45 fRotPhiA(0.),fRotPhiC(0.),
55 fMatrixGlobalDelta(0),
135 Double_t delta[3]={0};
138 TGeoHMatrix matrixScaled;
139 const Double_t *rotMatrix = matrixW.GetRotationMatrix();
140 const Double_t *transMatrix = matrixW.GetTranslation();
141 matrixScaled.RotateZ(-rotMatrix[1]*TMath::RadToDeg()*weight);
142 matrixScaled.RotateY(rotMatrix[2]*TMath::RadToDeg()*weight);
143 matrixScaled.RotateX(-rotMatrix[5]*TMath::RadToDeg()*weight);
144 for (Int_t i=0; i<3; i++) delta[i]=weight*transMatrix[i];
145 matrixScaled.SetTranslation(delta);
156 TGeoHMatrix matrixScaled;
157 const Double_t *rotMatrix = matrixW.GetRotationMatrix();
158 const Double_t *transMatrix = matrixW.GetTranslation();
159 matrixScaled.RotateZ(-rotMatrix[1]*TMath::RadToDeg()*weight);
160 matrixScaled.RotateY(rotMatrix[2]*TMath::RadToDeg()*weight);
161 matrixScaled.RotateX(-rotMatrix[5]*TMath::RadToDeg()*weight);
162 for (Int_t i=0; i<3; i++) delta[i]=weight*transMatrix[i];
163 matrixScaled.SetTranslation(delta);
175 for (Int_t isec=0; isec<72; isec++)
fArraySector->AddAt(
new TGeoHMatrix,isec);
177 for (Int_t isec=0; isec<72; isec++){
178 TGeoHMatrix *mat0= (TGeoHMatrix*)
fArraySector->At(isec);
179 TGeoHMatrix *mat1= (TGeoHMatrix*)add.
fArraySector->At(isec);
181 TGeoHMatrix matrixW=*(mat1);
182 TGeoHMatrix matrixScaled;
183 const Double_t *rotMatrix = matrixW.GetRotationMatrix();
184 const Double_t *transMatrix = matrixW.GetTranslation();
185 matrixScaled.RotateZ(-rotMatrix[1]*TMath::RadToDeg()*weight);
186 matrixScaled.RotateY(rotMatrix[2]*TMath::RadToDeg()*weight);
187 matrixScaled.RotateX(-rotMatrix[5]*TMath::RadToDeg()*weight);
188 for (Int_t i=0; i<3; i++) delta[i]=weight*transMatrix[i];
189 matrixScaled.SetTranslation(delta);
190 mat0->Multiply(&matrixScaled);
205 if (quadrantQ0)
fQuadrantQ0 =
new TVectorD(*quadrantQ0);
206 if (quadrantRQ0)
fQuadrantRQ0 =
new TVectorD(*quadrantRQ0);
208 if (quadrantQ1)
fQuadrantQ1 =
new TVectorD(*quadrantQ1);
209 if (quadrantQ1)
fQuadrantRQ1 =
new TVectorD(*quadrantRQ1);
210 if (quadrantQ2)
fQuadrantQ2 =
new TVectorD(*quadrantQ2);
211 if (quadrantQ2)
fQuadrantRQ2 =
new TVectorD(*quadrantRQ2);
222 if (matrixGlobal)
fMatrixGlobal =
new TGeoHMatrix(*matrixGlobal);
272 r = TMath::Sqrt( x[0]*x[0] + x[1]*x[1] );
273 phi = TMath::ATan2(x[1],x[0]);
275 Double_t sec=TMath::Nint(-0.5+(phi*9./TMath::Pi()));
277 Int_t isec = TMath::Nint(sec);
278 if (roc%36>=18) isec+=18;
282 Double_t alpha=(sec+0.5)*TMath::Pi()/9;
283 Double_t pos[3]={0,0,x[2]};
284 pos[0]= TMath::Cos(alpha)*x[0]+TMath::Sin(alpha)*x[1];
285 pos[1]= -TMath::Sin(alpha)*x[0]+TMath::Cos(alpha)*x[1];
292 Double_t posQG[3]={x[0],x[1],x[2]};
295 Bool_t isQ0 = (pos[0]<xquadrant)&&(pos[0]>xIO);
296 Bool_t isQ1 = (pos[0]>xquadrant);
297 Double_t sign = (pos[1]>0)? 1.: -1.;
299 if (
fQuadrantQ0) dly+=sign*(*fQuadrantQ0)[isec%36];
300 if (
fQuadrantRQ0) dly+=sign*(*fQuadrantRQ0)[isec%36]*(pos[0]-xref);
303 if (
fQuadrantQ1) dly+=sign*(*fQuadrantQ1)[isec%36];
304 if (
fQuadrantRQ1) dly+=sign*(*fQuadrantRQ1)[isec%36]*(pos[0]-xref);
306 if (
fQuadrantRQ2) dly+=(*fQuadrantRQ2)[isec%36]*(pos[0]-xref);
309 posQG[0]= TMath::Cos(alpha)*pos[0]-TMath::Sin(alpha)*(pos[1]+dly);
310 posQG[1]= TMath::Sin(alpha)*pos[0]+TMath::Cos(alpha)*(pos[1]+dly);
325 dx[0] = r * TMath::Cos(phi) - x[0];
326 dx[1] = r * TMath::Sin(phi) - x[1];
334 dx[0] += (posQG[0]-x[0]);
335 dx[1] += (posQG[1]-x[1]);
340 Double_t ppos[3]={x[0],x[1],x[2]};
341 Double_t pposC[3]={x[0],x[1],x[2]};
343 dx[0]+=pposC[0]-ppos[0];
344 dx[1]+=pposC[1]-ppos[1];
345 dx[2]+=pposC[2]-ppos[2];
349 Double_t ppos[3]={x[0],x[1],x[2]};
350 Double_t pposC[3]={x[0],x[1],x[2]};
352 Double_t ssign=(roc%36<18) ? 1.:-1.;
353 dx[0]+=ssign*(pposC[0]-ppos[0]);
354 dx[1]+=ssign*(pposC[1]-ppos[1]);
355 dx[2]+=ssign*(pposC[2]-ppos[2]);
362 Double_t ppos[3]={x[0],x[1],x[2]};
363 Double_t pposC[3]={x[0],x[1],x[2]};
364 mat->LocalToMaster(ppos,pposC);
365 dx[0]+=pposC[0]-ppos[0];
366 dx[1]+=pposC[1]-ppos[1];
367 dx[2]+=pposC[2]-ppos[2];
376 printf(
" - Trivial Misalignments for calibration purposes: \n");
380 TString opt = option; opt.ToLower();
381 if (opt.Contains(
"a")){
383 printf(
"GetAlignGlobal()\n");
387 printf(
"GetAlignGlobalDelta()\n");
391 printf(
"GetAlignSectors()\n");
447 for (Int_t isec=0; isec<72; isec++){
448 TGeoHMatrix *mat0= (TGeoHMatrix*)
fArraySector->At(isec);
449 TGeoHMatrix *mat1= (TGeoHMatrix*)add.
fArraySector->At(isec);
450 if (mat0&&mat1) mat0->Multiply(mat1);
462 AliCDBEntry * entry = AliCDBManager::Instance()->Get(
"TPC/Align/Data");
464 printf(
"Missing alignmnet entry. OCDB not initialized?\n");
467 TClonesArray *
array = (TClonesArray*)entry->GetObject();
468 Int_t entries = array->GetEntries();
469 TGeoHMatrix matrixGlobal;
473 {
for (Int_t i=0;i<entries; i++){
477 AliAlignObjParams *alignP = (AliAlignObjParams*)array->UncheckedAt(i);
478 alignP->GetMatrix(matrix);
480 AliGeomManager::ELayerID ilayer;
481 alignP->GetVolUID(ilayer, imod);
482 if (ilayer==AliGeomManager::kInvalidLayer) {
483 alignArrayOCDB->AddAt(matrix.Clone(),72);
484 alignP->GetMatrix(matrixGlobal);
487 if (ilayer==AliGeomManager::kTPC2) sector+=36;
488 alignArrayOCDB->AddAt(matrix.Clone(),sector);
511 {
for (Int_t isec=0; isec<72; isec++){
512 const TGeoMatrix* cmatrix=(TGeoMatrix*)array->At(isec);
513 if (!cmatrix)
continue;
514 matrix.Multiply(cmatrix);
516 TGeoHMatrix matrixMean(matrix);
517 matrixMean.SetDx(matrix.GetTranslation()[0]/72.);
518 matrixMean.SetDy(matrix.GetTranslation()[1]/72.);
519 matrixMean.SetDz(matrix.GetTranslation()[2]/72.);
520 Double_t rotation[12];
521 {
for (Int_t i=0; i<12; i++) {
523 if (TMath::Abs(matrix.GetRotationMatrix()[i]-1.)>0.1){
524 rotation[i]=matrix.GetRotationMatrix()[i]/72.;
527 matrixMean.SetRotation(rotation);
528 TGeoHMatrix matrixInv = matrixMean.Inverse();
530 {
for (Int_t isec=0; isec<72; isec++){
531 TGeoHMatrix* amatrix=(TGeoHMatrix*)(array->At(isec)->Clone());
532 if (!amatrix)
continue;
533 amatrix->Multiply(&matrixInv);
534 arrayNew->AddAt(amatrix,isec);
581 {
for (Int_t isec=0; isec<72; isec++){
582 TGeoHMatrix* cmatrix=(TGeoHMatrix*)array->At(isec);
583 TGeoHMatrix* cmatrixDown=(TGeoHMatrix*)array->At(isec%36);
584 TGeoHMatrix* cmatrixUp=(TGeoHMatrix*)array->At(isec%36+36);
585 TGeoHMatrix diff(*cmatrixDown);
586 diff.Multiply(&(cmatrixUp->Inverse()));
void AddAlign(const AliTPCCalibGlobalMisalignment &add)
static AliTPCCalibGlobalMisalignment * CreateMeanAlign(const AliTPCCalibGlobalMisalignment *alignIn)
printf("Chi2/npoints = %f\n", TMath::Sqrt(chi2/npoints))
TGeoMatrix * GetAlignGlobalDelta() const
Float_t fRotPhiC
simple rotation of C side read-out plane around the Z axis [rad]
TObjArray * fArraySector
local Alignmnet Sector
void SetQuadranAlign(const TVectorD *quadrantQ0, const TVectorD *quadrantRQ0, const TVectorD *quadrantQ1, const TVectorD *quadrantRQ1, const TVectorD *quadrantQ2, const TVectorD *quadrantRQ2)
Float_t fYShift
Shift in global Y [cm].
TGeoMatrix * GetAlignGlobal() const
UInt_t GetNRows(UInt_t sector) const
virtual void GetCorrection(const Float_t x[], const Short_t roc, Float_t dx[])
virtual ~AliTPCCalibGlobalMisalignment()
Float_t fXShift
Shift in global X [cm].
TTreeSRedirector * pcstream
TVectorD * fQuadrantQ1
OROC long pads -delta ly+ - ly - shift.
virtual void Print(Option_t *option="") const
TVectorD * fQuadrantQ2
OROC long pads -shift.
static void DumpAlignment(AliTPCCalibGlobalMisalignment *align, TTreeSRedirector *pcstream, const char *name)
void SetAlignSectors(const TObjArray *arraySector)
TObjArray * GetAlignSectors() const
Float_t GetPadRowRadiiUp(UInt_t irow) const
Geometry class for a single ROC.
TGeoMatrix * fMatrixGlobal
global Alignment common
Float_t fdRPhiOffsetA
add a constant offset of dRPhi (or local Y) in [cm]: purely for calibration purposes! ...
void SetAlignGlobalDelta(const TGeoMatrix *matrixGlobalDelta)
TGeoMatrix * fMatrixGlobalDelta
global Alignment common A side-C side
void SetAlignGlobal(const TGeoMatrix *matrixGlobal)
Float_t fZShift
Shift in global Z [cm].
AliTPCCalibGlobalMisalignment()
virtual Bool_t AddCorrectionCompact(AliTPCCorrection *corr, Double_t weight)
Float_t fRotPhiA
simple rotation of A side read-out plane around the Z axis [rad]
static AliTPCROC * Instance()
TVectorD * fQuadrantRQ1
OROC long pads -delta ly+ - ly - rotation.
TVectorD * fQuadrantQ0
OROC medium pads -delta ly+ - ly - shift (cm)
Float_t GetPadRowRadii(UInt_t isec, UInt_t irow) const
static AliTPCCalibGlobalMisalignment * CreateOCDBAlign()
Float_t fdRPhiOffsetC
add a constant offset of dRPhi (or local Y) in [cm]: purely for calibration purposes! ...
TVectorD * fQuadrantRQ0
OROC medium pads -delta ly+ - ly - rotation (rad)
TVectorD * fQuadrantRQ2
OROC long pads -rotation.