Skip to content

Commit

Permalink
DO NOT MERGE LOGGING!
Browse files Browse the repository at this point in the history
  • Loading branch information
f3sch committed Nov 19, 2024
1 parent 25651f3 commit 747ab56
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
1 change: 1 addition & 0 deletions Detectors/Align/src/AlignableDetector.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ void AlignableDetector::writeAlignmentResults() const
AlignableVolume* vol = getVolume(iv);
// call only for top level objects, they will take care of children
if (!vol->getParent()) {
LOGP(info, "++++ Creating alignment objects for {}", getName());
vol->createAlignmentObjects(arr);
}
}
Expand Down
28 changes: 26 additions & 2 deletions Detectors/Align/src/AlignableVolume.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -552,8 +552,9 @@ void AlignableVolume::writeLabeledPedeResults(FILE* parOut) const
{
// write parameters with labels
for (int i = 0; i < mNDOFs; i++) {
fprintf(parOut, "%9d %+e %+e\t! %s %d:%s vol:%d %s %s\n", getParLab(i), -getParVal(i), getParErr(i), GetName(), i, sDOFName[i], getVolID(),
isFreeDOF(i) ? " " : "FXU", isZeroAbs(getParVal(i)) ? "FXP" : " ");
auto a = fprintf(parOut, "%9d %+e %+e\t! %s %d:%s vol:%d %s %s\n", getParLab(i), -getParVal(i), getParErr(i), GetName(), i, sDOFName[i], getVolID(),
isFreeDOF(i) ? " " : "FXU",
isZeroAbs(getParVal(i)) ? "FXP" : " ");
}
// children volume
int nch = getNChildren();
Expand Down Expand Up @@ -690,13 +691,17 @@ bool AlignableVolume::createLocDeltaMatrix(TGeoHMatrix& deltaM) const
auto pars = getParVals();
double corr[kNDOFGeom] = {0.};
int nonZero = 0;
LOGP(info, "Applying parameters to create LocDeltaMatrix");
for (int i = kNDOFGeom; i--;) {
if (pars[i] != 0.) {
nonZero++;
corr[i] = pars[i];
LOGP(info, " - PAR {}: {}", i, pars[i]);
}
} // we need doubles
delta2Matrix(deltaM, corr);
LOGP(info, "Before deltaM:");
deltaM.Print();
if (isFrameTRA() && nonZero) { // we need corrections in local frame!
// l' = T2L * delta_t * t = T2L * delta_t * T2L^-1 * l = delta_l * l
// -> delta_l = T2L * delta_t * T2L^-1
Expand All @@ -705,6 +710,8 @@ bool AlignableVolume::createLocDeltaMatrix(TGeoHMatrix& deltaM) const
deltaM.Multiply(&t2li);
deltaM.MultiplyLeft(&t2l);
}
LOGP(info, "After isFrameTRA={}; nonZero={} deltaM:", isFrameTRA(), nonZero);
deltaM.Print();
return nonZero;
}

Expand All @@ -727,6 +734,7 @@ void AlignableVolume::createAlignmenMatrix(TGeoHMatrix& alg, const TGeoHMatrix*

const AlignableVolume* par = getParent();
bool nonTrivial = createGloDeltaMatrix(alg);
LOGP(info, "~ Has {} parent; nonTrivial={}; envelopeDelta={}", par != nullptr, nonTrivial, envelopeDelta != nullptr);
if (envelopeDelta) {
if (nonTrivial) {
alg.MultiplyLeft(envelopeDelta);
Expand All @@ -741,13 +749,23 @@ void AlignableVolume::createAlignmenMatrix(TGeoHMatrix& alg, const TGeoHMatrix*
// if envelopeDelta is provided, then there should be
TGeoHMatrix dchain;
while (par) {
LOGP(info, " attaching parent {} to chain", par->getSymName());
dchain.MultiplyLeft(&par->getGlobalDeltaRef());
par = par->getParent();
}
const TGeoHMatrix& dchaini = dchain.Inverse();
alg.Multiply(&dchain);
alg.MultiplyLeft(&dchaini);
} else {
if (!nonTrivial) {
LOGP(info, "TRIVIAL!");
}
if (par && par->isDummyEnvelope()) {
LOGP(info, "parent is a dummy enevelope");
}
}
LOGP(info, "GlobalDeltaRef is:");
getGlobalDeltaRef().Print();
alg *= getGlobalDeltaRef();

/* // bad precision ?
Expand Down Expand Up @@ -799,6 +817,7 @@ void AlignableVolume::createAlignmentObjects(std::vector<o2::detectors::AlignPar
}
TGeoHMatrix algM;
bool nonTrivial = false;
LOGP(info, "~ {}: {} isDummy={} isDummyEnvelope={}", getVolID(), getSymName(), isDummy(), isDummyEnvelope());
if (!isDummyEnvelope()) {
createAlignmenMatrix(algM, envelopeDelta);
arr.emplace_back(getSymName(), getVolID(), algM, true).rectify(AlignConfig::Instance().alignParamZero);
Expand All @@ -814,8 +833,13 @@ void AlignableVolume::createAlignmentObjects(std::vector<o2::detectors::AlignPar
nonTrivial = true;
}
envelopeDelta = &algM;
LOGP(info, " envelope delta:");
envelopeDelta->Print();
}

LOGP(info, " global delta:");
algM.Print();

int nch = getNChildren();
for (int ich = 0; ich < nch; ich++) {
getChild(ich)->createAlignmentObjects(arr, nonTrivial ? envelopeDelta : nullptr);
Expand Down

0 comments on commit 747ab56

Please sign in to comment.