X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=MUON%2FAliMUONSurveyObj.cxx;h=d07a36a3795aa918b88e861489d8f8127cbc4e81;hb=1bd2ee2f8ef38e4987101a24d8bb6c3e7c9233ba;hp=b6832ecf4665ef4deb7dea72a023dd1a372e5b32;hpb=94bf739cea9ebace9338a41abff9fcb4dde0b628;p=u%2Fmrichter%2FAliRoot.git diff --git a/MUON/AliMUONSurveyObj.cxx b/MUON/AliMUONSurveyObj.cxx index b6832ecf466..d07a36a3795 100644 --- a/MUON/AliMUONSurveyObj.cxx +++ b/MUON/AliMUONSurveyObj.cxx @@ -60,16 +60,17 @@ AliMUONSurveyObj::AliMUONSurveyObj() , fOwnerLocalTrf(kFALSE) , fOwnerAlignTrf(kTRUE) , fOwnerBaseTrf(kFALSE) + , fUseCM(kTRUE) , fPlane(0x0) , fFitter(0x0) - , fXMin(-4000.) - , fXMax(4000.) - , fYMin(-4000.) - , fYMax(4000.) - , fZMin(-20000.) - , fZMax(20000.) + , fXMin(-400.) + , fXMax(400.) + , fYMin(-400.) + , fYMax(400.) + , fZMin(-2000.) + , fZMax(2000.) { -/// Default constructor + /// Default constructor fSTargets = new TObjArray(); fSTargets->SetOwner(kFALSE); @@ -120,22 +121,39 @@ AliMUONSurveyObj::~AliMUONSurveyObj() { } void AliMUONSurveyObj::AddStickerTarget(AliSurveyPoint *stPoint){ - fSTargets->Add(stPoint); + /// Add sticker target + if (fUseCM) { + fSTargets->Add(ConvertPointUnits(stPoint,0.1)); + } else { + fSTargets->Add(stPoint); + } } void AliMUONSurveyObj::AddGButtonTarget(AliSurveyPoint *btPoint){ - fGBTargets->Add(btPoint); + /// Add global button target + if (fUseCM) { + fGBTargets->Add(ConvertPointUnits(btPoint,0.1)); + } else { + fGBTargets->Add(btPoint); + } } void AliMUONSurveyObj::AddLButtonTarget(AliSurveyPoint *btPoint){ - fLBTargets->Add(btPoint); + /// Add local button target target; AliSurveyPoint + if (fUseCM) { + fLBTargets->Add(ConvertPointUnits(btPoint,0.1)); + } else { + fLBTargets->Add(btPoint); + } } void AliMUONSurveyObj::AddLButtonTarget(TVector3 *btVector){ + /// Add local button target target; TVector3 fLBTargets->Add(btVector); } Int_t AliMUONSurveyObj::AddStickerTargets(TObjArray *pArray, TString stBaseName, Int_t lTargetMax){ + /// Add a maximum of lTargetMax sticker targets with stBaseName from pArray if (!pArray) { AliError(Form("Survey points array is empty %p!",pArray)); return 0; @@ -172,6 +190,7 @@ Int_t AliMUONSurveyObj::AddStickerTargets(TObjArray *pArray, TString stBaseName, } Int_t AliMUONSurveyObj::AddGButtonTargets(TObjArray *pArray, TString btBaseName, Int_t lTargetMax){ + /// Add a maximum of lTargetMax global button targets with stBaseName from pArray printf("%s \n",btBaseName.Data()); if (!pArray) { AliError(Form("Survey points array is empty %p!",pArray)); @@ -209,6 +228,7 @@ Int_t AliMUONSurveyObj::AddGButtonTargets(TObjArray *pArray, TString btBaseName, } Int_t AliMUONSurveyObj::AddLButtonTargets(TObjArray *pArray, TString btBaseName, Int_t lTargetMax){ + /// Add a maximum of lTargetMax local button targets with stBaseName from pArray printf("%s \n",btBaseName.Data()); if (!pArray) { AliError(Form("Local points array is empty %p!",pArray)); @@ -246,10 +266,12 @@ Int_t AliMUONSurveyObj::AddLButtonTargets(TObjArray *pArray, TString btBaseName, } Int_t AliMUONSurveyObj::GetNStickerTargets() { + /// return number of sticker targets return fSTargets->GetEntriesFast(); } AliSurveyPoint* AliMUONSurveyObj::GetStickerTarget(Int_t stIndex){ + /// return sticker target at stIndex if (stIndex<0||stIndex>=fSTargets->GetEntriesFast()) { AliError(Form("No sticker target at index %d",stIndex)); return 0x0; @@ -260,10 +282,12 @@ AliSurveyPoint* AliMUONSurveyObj::GetStickerTarget(Int_t stIndex){ } Int_t AliMUONSurveyObj::GetNGButtonTargets() { + /// return number of global button targets return fGBTargets->GetEntriesFast(); } AliSurveyPoint* AliMUONSurveyObj::GetGButtonTarget(Int_t btIndex){ + /// return global button target at btIndex if (btIndex<0||btIndex>=fGBTargets->GetEntriesFast()) { AliError(Form("No surveyed button target at index %d",btIndex)); return 0x0; @@ -274,10 +298,12 @@ AliSurveyPoint* AliMUONSurveyObj::GetGButtonTarget(Int_t btIndex){ } Int_t AliMUONSurveyObj::GetNLButtonTargets() { + /// return number of local button targets return fGBTargets->GetEntriesFast(); } AliSurveyPoint* AliMUONSurveyObj::GetLButtonTarget(Int_t btIndex){ + /// return local button target at btIndex if (btIndex<0||btIndex>=fLBTargets->GetEntriesFast()) { AliError(Form("No surveyed button target at index %d",btIndex)); return 0x0; @@ -298,14 +324,16 @@ AliSurveyPoint* AliMUONSurveyObj::GetLButtonTarget(Int_t btIndex){ } void AliMUONSurveyObj::SetPlane(TString pName, Double_t xMin, Double_t xMax, Double_t yMin, Double_t yMax){ + /// Set the plane function for the plane fitting if(fPlane) { fPlane->Delete(); fPlane = 0x0; } - fPlane = new TF2(pName,this,&AliMUONSurveyObj::eqPlane,xMin,xMax,yMin,yMax,3,"AliMUONSurveyObj","eqPlane"); + fPlane = new TF2(pName,this,&AliMUONSurveyObj::EqPlane,xMin,xMax,yMin,yMax,3,"AliMUONSurveyObj","EqPlane"); } void AliMUONSurveyObj::SetPlaneParameters(Double_t p0, Double_t p1, Double_t p2) { + /// Set the parameters of plane function for the plane fitting if (!fPlane) { AliError("Must use SetPlane before SetPlaneParameters!!!"); } @@ -317,7 +345,7 @@ void AliMUONSurveyObj::SetPlaneParameters(Double_t p0, Double_t p1, Double_t p2) } void AliMUONSurveyObj::DrawSTargets() { - + /// Draw a graph of the sticker targets TGraph2DErrors *gST = new TGraph2DErrors(3); AliSurveyPoint *pST = 0x0; for (Int_t iPoint=0; iPointDrawClone("P0"); - if (gST) gST->Delete(); + delete gST; } Double_t AliMUONSurveyObj::FitPlane() { + /// Fit plane to sticker targets if (!fPlane) { AliError("Must use SetPlane before FitPlane!!!"); return 0.; @@ -359,13 +388,13 @@ Double_t AliMUONSurveyObj::FitPlane() { } gST->Fit(fPlane); - if (gST) gST->Delete(); + delete gST; return fPlane->GetChisquare(); } Double_t AliMUONSurveyObj::SurveyChi2(Double_t *par){ - + /// Returns the chisquare between local2global transform of local button targets and their surveyed position TGeoTranslation transTemp; TGeoRotation rotTemp; TGeoCombiTrans trfTemp; @@ -425,11 +454,10 @@ Double_t AliMUONSurveyObj::SurveyChi2(Double_t *par){ //_____________________________________________________________________________ void SurveyFcn(int &npar, double *g, double &f, double *par, int iflag) { - - // - // Standard function as needed by Minuit-like minimization procedures. - // For the set of parameters par calculates and returns chi-squared. - // + /// + /// Standard function as needed by Minuit-like minimization procedures. + /// For the set of parameters par calculates and returns chi-squared. + /// // smuggle a C++ object into a C function AliMUONSurveyObj *aSurveyObj = (AliMUONSurveyObj*) gMinuit->GetObjectFit(); @@ -443,7 +471,7 @@ void SurveyFcn(int &npar, double *g, double &f, double *par, int iflag) { //_____________________________________________________________________________ Int_t AliMUONSurveyObj::SurveyToAlign(TGeoCombiTrans &quadTransf, Double_t *parErr, Double_t psi, Double_t tht, Double_t epsi, Double_t etht) { - + /// Main function to obtain the misalignments from the surveyed position of the button targets; if (fGBTargets->GetEntries()!=fLBTargets->GetEntries()){ AliError(Form("Different number of button targets: %d survey points and %d local coord!", fGBTargets->GetEntries(),fLBTargets->GetEntries())); @@ -502,7 +530,7 @@ Int_t AliMUONSurveyObj::SurveyToAlign(TGeoCombiTrans &quadTransf, Double_t *parE //_____________________________________________________________________________ Int_t AliMUONSurveyObj::SurveyToAlign(Double_t psi, Double_t tht, Double_t epsi, Double_t etht) { - + /// Main function to obtain the misalignments from the surveyed position of the button targets; if (fGBTargets->GetEntries()!=fLBTargets->GetEntries()){ AliError(Form("Different number of button targets: %d survey points and %d local coord!", fGBTargets->GetEntries(),fLBTargets->GetEntries())); @@ -579,8 +607,8 @@ Int_t AliMUONSurveyObj::SurveyToAlign(Double_t psi, Double_t tht, Double_t epsi, } -Double_t AliMUONSurveyObj::EvalFunction(TF2 *lFunction, Int_t iP1, Int_t iP2, Char_t *lCoord) { - +Double_t AliMUONSurveyObj::EvalFunction(const TF2 *lFunction, Int_t iP1, Int_t iP2, const Char_t *lCoord) { + /// Evaluate the given function at the given points for the given coordinate if (!lFunction) { AliError("No function given!!!"); return 0; @@ -634,14 +662,14 @@ Double_t AliMUONSurveyObj::EvalFunction(TF2 *lFunction, Int_t iP1, Int_t iP2, Ch } default: { - AliError(Form("Coordinate %c is not valid, options are X Y Z",lCoord)); + AliError(Form("Coordinate %s is not valid, options are X Y Z",lCoord)); return 0; } } } void AliMUONSurveyObj::CalculateTranslation(TF2 *xFunc, TF2 *yFunc, TF2 *zFunc, Int_t iP1, Int_t iP2, Double_t *lCenTemp) { - + /// Calculate the center translation using analytic functions lCenTemp[0] = EvalFunction(xFunc,iP1,iP2,"X"); lCenTemp[1] = EvalFunction(yFunc,iP1,iP2,"Y"); lCenTemp[2] = EvalFunction(zFunc,iP1,iP2,"Z"); @@ -649,7 +677,7 @@ void AliMUONSurveyObj::CalculateTranslation(TF2 *xFunc, TF2 *yFunc, TF2 *zFunc, } Double_t AliMUONSurveyObj::CalculateGlobalDiff(TGeoCombiTrans &lTransf, Int_t nPoints, TArrayD &lDiff){ - + /// By hand computation of distance between local2global transform of target position and its surveyed position if (nPoints > GetNGButtonTargets()) { nPoints = GetNGButtonTargets(); } @@ -710,7 +738,7 @@ Double_t AliMUONSurveyObj::CalculateGlobalDiff(TGeoCombiTrans &lTransf, Int_t nP } Int_t AliMUONSurveyObj::CalculateBestTransf(Int_t iP1, Int_t iP2, Double_t *lXYZ, Double_t *lPTP) { - + /// By hand calculation of the best local to global transform using 2 button targets Double_t lPsi = lPTP[0]; Double_t lTht = lPTP[1]; @@ -755,58 +783,58 @@ Int_t AliMUONSurveyObj::CalculateBestTransf(Int_t iP1, Int_t iP2, Double_t *lXYZ AliMUONSurveyUtil *surveyUtil = AliMUONSurveyUtil::Instance(); // Xcenter functions - char *fxcName = "fXcn00"; + const char *fxcName = "fXcn00"; TF2 **fXc = new TF2*[2]; fxcName = "fXcn"; - fXc[0] = new TF2(fxcName,surveyUtil,&AliMUONSurveyUtil::xnCenter,fXMin,fXMax,fYMin,fYMax,7,"AliMUONSurveyUtil","xnCenter"); + fXc[0] = new TF2(fxcName,surveyUtil,&AliMUONSurveyUtil::XnCenter,fXMin,fXMax,fYMin,fYMax,7,"AliMUONSurveyUtil","XnCenter"); fxcName = "fXcp"; - fXc[1] = new TF2(fxcName,surveyUtil,&AliMUONSurveyUtil::xpCenter,fXMin,fXMax,fYMin,fYMax,7,"AliMUONSurveyUtil","xpCenter"); + fXc[1] = new TF2(fxcName,surveyUtil,&AliMUONSurveyUtil::XpCenter,fXMin,fXMax,fYMin,fYMax,7,"AliMUONSurveyUtil","XpCenter"); // Ycenter functions - char *fycName = "fYcn00"; + const char *fycName = "fYcn00"; TF2 **fYc = new TF2*[2]; fycName = "fYcn"; - fYc[0] = new TF2(fycName,surveyUtil,&AliMUONSurveyUtil::ynCenter,fYMin,fYMax,fYMin,fYMax,8,"AliMUONSurveyUtil","ynCenter"); + fYc[0] = new TF2(fycName,surveyUtil,&AliMUONSurveyUtil::YnCenter,fYMin,fYMax,fYMin,fYMax,8,"AliMUONSurveyUtil","YnCenter"); fycName = "fYcp"; - fYc[1] = new TF2(fycName,surveyUtil,&AliMUONSurveyUtil::ypCenter,fYMin,fYMax,fYMin,fYMax,8,"AliMUONSurveyUtil","ypCenter"); + fYc[1] = new TF2(fycName,surveyUtil,&AliMUONSurveyUtil::YpCenter,fYMin,fYMax,fYMin,fYMax,8,"AliMUONSurveyUtil","YpCenter"); // Zcenter functions - char *fzcName = "fZcn00"; + const char *fzcName = "fZcn00"; TF2 **fZc = new TF2*[2]; fzcName = "fZcn"; - fZc[0] = new TF2(fzcName,surveyUtil,&AliMUONSurveyUtil::znCenter,fZMin,fZMax,fZMin,fZMax,8,"AliMUONSurveyUtil","znCenter"); + fZc[0] = new TF2(fzcName,surveyUtil,&AliMUONSurveyUtil::ZnCenter,fZMin,fZMax,fZMin,fZMax,8,"AliMUONSurveyUtil","ZnCenter"); fzcName = "fZcp"; - fZc[1] = new TF2(fzcName,surveyUtil,&AliMUONSurveyUtil::zpCenter,fZMin,fZMax,fZMin,fZMax,8,"AliMUONSurveyUtil","zpCenter"); + fZc[1] = new TF2(fzcName,surveyUtil,&AliMUONSurveyUtil::ZpCenter,fZMin,fZMax,fZMin,fZMax,8,"AliMUONSurveyUtil","ZpCenter"); // Phi rotation using xglobal coords functions - char *fphixName = "fPhiXnn00"; + const char *fphixName = "fPhiXnn00"; TF2 ***fPhiX = new TF2**[2]; for (Int_t iX =0; iX<2; iX++) { fPhiX[iX] = new TF2*[2]; } fphixName = "fPhiXnn"; - fPhiX[0][0] = new TF2(fphixName,surveyUtil,&AliMUONSurveyUtil::phixnn,fXMin,fXMax,fXMin,fXMax,7,"AliMUONSurveyUtil","phixnn"); + fPhiX[0][0] = new TF2(fphixName,surveyUtil,&AliMUONSurveyUtil::PhiXnn,fXMin,fXMax,fXMin,fXMax,7,"AliMUONSurveyUtil","PhiXnn"); fphixName = "fPhiXnp"; - fPhiX[0][1] = new TF2(fphixName,surveyUtil,&AliMUONSurveyUtil::phixnp,fXMin,fXMax,fXMin,fXMax,7,"AliMUONSurveyUtil","phixnp"); + fPhiX[0][1] = new TF2(fphixName,surveyUtil,&AliMUONSurveyUtil::PhiXnp,fXMin,fXMax,fXMin,fXMax,7,"AliMUONSurveyUtil","PhiXnp"); fphixName = "fPhiXpn"; - fPhiX[1][0] = new TF2(fphixName,surveyUtil,&AliMUONSurveyUtil::phixpn,fXMin,fXMax,fXMin,fXMax,7,"AliMUONSurveyUtil","phixpn"); + fPhiX[1][0] = new TF2(fphixName,surveyUtil,&AliMUONSurveyUtil::PhiXpn,fXMin,fXMax,fXMin,fXMax,7,"AliMUONSurveyUtil","PhiXpn"); fphixName = "fPhiXpp"; - fPhiX[1][1] = new TF2(fphixName,surveyUtil,&AliMUONSurveyUtil::phixpp,fXMin,fXMax,fXMin,fXMax,7,"AliMUONSurveyUtil","phixpp"); + fPhiX[1][1] = new TF2(fphixName,surveyUtil,&AliMUONSurveyUtil::PhiXpp,fXMin,fXMax,fXMin,fXMax,7,"AliMUONSurveyUtil","PhiXpp"); // Phi rotation using yglobal coords functions - char *fphiyName = "fPhiYnn00"; + const char *fphiyName = "fPhiYnn00"; TF2 ***fPhiY = new TF2**[2]; for (Int_t iY =0; iY<2; iY++) { fPhiY[iY] = new TF2*[2]; } fphiyName = "fPhiYnn"; - fPhiY[0][0] = new TF2(fphiyName,surveyUtil,&AliMUONSurveyUtil::phiynn,fYMin,fYMax,fYMin,fYMax,8,"AliMUONSurveyUtil","phiynn"); + fPhiY[0][0] = new TF2(fphiyName,surveyUtil,&AliMUONSurveyUtil::PhiYnn,fYMin,fYMax,fYMin,fYMax,8,"AliMUONSurveyUtil","PhiYnn"); fphiyName = "fPhiYnp"; - fPhiY[0][1] = new TF2(fphiyName,surveyUtil,&AliMUONSurveyUtil::phiynp,fYMin,fYMax,fYMin,fYMax,8,"AliMUONSurveyUtil","phiynp"); + fPhiY[0][1] = new TF2(fphiyName,surveyUtil,&AliMUONSurveyUtil::PhiYnp,fYMin,fYMax,fYMin,fYMax,8,"AliMUONSurveyUtil","PhiYnp"); fphiyName = "fPhiYpn"; - fPhiY[1][0] = new TF2(fphiyName,surveyUtil,&AliMUONSurveyUtil::phiypn,fYMin,fYMax,fYMin,fYMax,8,"AliMUONSurveyUtil","phiypn"); + fPhiY[1][0] = new TF2(fphiyName,surveyUtil,&AliMUONSurveyUtil::PhiYpn,fYMin,fYMax,fYMin,fYMax,8,"AliMUONSurveyUtil","PhiYpn"); fphiyName = "fPhiYpp"; - fPhiY[1][1] = new TF2(fphiyName,surveyUtil,&AliMUONSurveyUtil::phiypp,fYMin,fYMax,fYMin,fYMax,8,"AliMUONSurveyUtil","phiypp"); + fPhiY[1][1] = new TF2(fphiyName,surveyUtil,&AliMUONSurveyUtil::PhiYpp,fYMin,fYMax,fYMin,fYMax,8,"AliMUONSurveyUtil","PhiYpp"); // Set Parameters of functions @@ -931,7 +959,7 @@ Int_t AliMUONSurveyObj::CalculateBestTransf(Int_t iP1, Int_t iP2, Double_t *lXYZ } void AliMUONSurveyObj::CalculateMeanTransf(Double_t *lXYZ, Double_t *lPTP) { - + /// By hand calculation of the mean (for nPairs of targets) of the best local to global transform using 2 button targets Double_t xce=0.; Double_t yce=0.; Double_t zce=0.; @@ -964,18 +992,21 @@ void AliMUONSurveyObj::CalculateMeanTransf(Double_t *lXYZ, Double_t *lPTP) { } void AliMUONSurveyObj::PrintLocalTrf() { + /// Print the local transformation Double_t lRotTemp[3]; AliMUONSurveyUtil::MatrixToAngles(fLocalTrf->GetRotationMatrix(),lRotTemp); printf("(%.3f %.3f %.3f), (%.6f %.6f %.6f)\n",fLocalTrf->GetTranslation()[0],fLocalTrf->GetTranslation()[1],fLocalTrf->GetTranslation()[2],lRotTemp[0],lRotTemp[1],lRotTemp[2]); } void AliMUONSurveyObj::PrintAlignTrf() { + /// Print the alignment transformation Double_t lRotTemp[3]; AliMUONSurveyUtil::MatrixToAngles(fAlignTrf->GetRotationMatrix(),lRotTemp); printf("(%.3f %.3f %.3f), (%.6f %.6f %.6f)\n",fAlignTrf->GetTranslation()[0],fAlignTrf->GetTranslation()[1],fAlignTrf->GetTranslation()[2],lRotTemp[0],lRotTemp[1],lRotTemp[2]); } void AliMUONSurveyObj::FillSTHistograms(TString baseNameC, TH2 *hSTc, TString baseNameA, TH2 *hSTa) { + /// Fill sticker target histograms for monitoring if(baseNameC.IsNull()||!hSTc){ AliError("Need base name for points on side C and/or a histogram for them!"); return; @@ -998,6 +1029,7 @@ void AliMUONSurveyObj::FillSTHistograms(TString baseNameC, TH2 *hSTc, TString ba } Double_t AliMUONSurveyObj::GetAlignResX() { + /// Returns the uncertainty of the x translation parameter if(!fFitter) { AliError("There is no fitter for this object! X resolution will be 0."); return 0.; @@ -1006,9 +1038,18 @@ Double_t AliMUONSurveyObj::GetAlignResX() { } Double_t AliMUONSurveyObj::GetAlignResY() { + /// Returns the uncertainty of the y translation parameter if(!fFitter) { AliError("There is no fitter for this object! Y resolution will be 0."); return 0.; } return fFitter->GetParError(1); } + +AliSurveyPoint* AliMUONSurveyObj::ConvertPointUnits(AliSurveyPoint *stPoint, Float_t lFactor) { + /// Return the AliSurveyPoint with new units. Default is from mm -> cm + return new AliSurveyPoint(stPoint->GetPointName(), + lFactor*stPoint->GetX(),lFactor*stPoint->GetY(),lFactor*stPoint->GetZ(), + lFactor*stPoint->GetPrecisionX(),lFactor*stPoint->GetPrecisionY(),lFactor*stPoint->GetPrecisionZ(), + stPoint->GetType(), stPoint->GetTarget()); +}