, 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);
}
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;
}
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));
}
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));
}
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;
}
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;
}
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;
}
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!!!");
}
}
void AliMUONSurveyObj::DrawSTargets() {
-
+ /// Draw a graph of the sticker targets
TGraph2DErrors *gST = new TGraph2DErrors(3);
AliSurveyPoint *pST = 0x0;
for (Int_t iPoint=0; iPoint<GetNStickerTargets(); iPoint++) {
}
gST->DrawClone("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.;
}
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;
//_____________________________________________________________________________
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();
//_____________________________________________________________________________
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()));
//_____________________________________________________________________________
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()));
}
-Double_t AliMUONSurveyObj::EvalFunction(TF2 *lFunction, Int_t iP1, Int_t iP2, const 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;
}
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");
}
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();
}
}
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];
}
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.;
}
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;
}
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.;
}
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());
+}