Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Detectors/Base/include/DetectorsBase/Aligner.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Aligner : public o2::conf::ConfigurableParamHelper<Aligner>
o2::detectors::DetID::mask_t getDetectorsMask() const;

bool isAlignmentRequested() const { return getDetectorsMask().any(); }
void applyAlignment(long timestamp = 0, o2::detectors::DetID::mask_t addMask = o2::detectors::DetID::FullMask) const;
void applyAlignment(long timestamp = 0, o2::detectors::DetID::mask_t addMask = o2::detectors::DetID::FullMask, bool keepPhysicalNodes = true) const;

private:
std::string mDetectors = "all"; // comma-separated list of modules to align, "all" or "none"
Expand Down
3 changes: 2 additions & 1 deletion Detectors/Base/include/DetectorsBase/GeometryManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ class GeometryManager : public TObject
~GeometryManager() override = default;

/// misalign geometry with alignment objects from the array, optionaly check overlaps
static bool applyAlignment(const std::vector<o2::detectors::AlignParam>& algPars);
/// with keepPhysicalNodes false, each physical node is deleted after its alignment (no original matrices are kept)
static bool applyAlignment(const std::vector<o2::detectors::AlignParam>& algPars, bool keepPhysicalNodes = true);
static bool applyAlignment(const std::vector<const std::vector<o2::detectors::AlignParam>*> algPars);

struct MatBudgetExt {
Expand Down
4 changes: 2 additions & 2 deletions Detectors/Base/src/Aligner.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ DetID::mask_t Aligner::getDetectorsMask() const
return DetID::getMask(mDetectors) & (~DetID::getMask(DetID::CTP));
}

void Aligner::applyAlignment(long timestamp, DetID::mask_t addMask) const
void Aligner::applyAlignment(long timestamp, DetID::mask_t addMask, bool keepPhysicalNodes) const
{
DetID::mask_t msk = getDetectorsMask() & addMask;
if (msk.none()) {
Expand Down Expand Up @@ -59,7 +59,7 @@ void Aligner::applyAlignment(long timestamp, DetID::mask_t addMask) const
}
if (!algV->empty()) {
done.set(id);
o2::base::GeometryManager::applyAlignment(*algV);
o2::base::GeometryManager::applyAlignment(*algV, keepPhysicalNodes);
} else {
skipped.set(id);
}
Expand Down
14 changes: 13 additions & 1 deletion Detectors/Base/src/GeometryManager.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ bool GeometryManager::applyAlignment(const std::vector<const std::vector<o2::det
}

//______________________________________________________________________
bool GeometryManager::applyAlignment(const std::vector<o2::detectors::AlignParam>& algPars)
bool GeometryManager::applyAlignment(const std::vector<o2::detectors::AlignParam>& algPars, bool keepPhysicalNodes)
{
/// misalign geometry with alignment objects from the array, optionaly check overlaps
int nvols = algPars.size();
Expand All @@ -286,11 +286,23 @@ bool GeometryManager::applyAlignment(const std::vector<o2::detectors::AlignParam
std::sort(std::begin(ord), std::end(ord), [&algPars](int a, int b) { return algPars[a].getLevel() < algPars[b].getLevel(); });

bool res = true;
auto pns = gGeoManager->GetListOfPhysicalNodes();
for (int i = 0; i < nvols; i++) {
int npn = pns->GetEntriesFast();
if (!algPars[ord[i]].applyToGeometry(GeometryManagerParam::Instance().printLevel)) {
res = false;
LOG(error) << "Error applying alignment object for volume" << algPars[ord[i]].getSymName();
}
if (!keepPhysicalNodes) { // delete the nodes this alignment created, so their memory is reused by the next one
for (int k = pns->GetEntriesFast() - 1; k >= npn; k--) {
auto pn = static_cast<TGeoPhysicalNode*>(pns->RemoveAt(k));
if (auto pne = gGeoManager->GetAlignableEntry(algPars[ord[i]].getSymName().c_str()); pne && pne->GetPhysicalNode() == pn) {
pne->SetPhysicalNode(nullptr);
}
delete pn;
}
pns->Compress();
}
}
return res;
}
Expand Down
3 changes: 2 additions & 1 deletion Steer/src/O2MCApplication.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,8 @@ bool O2MCApplicationBase::MisalignGeometry()

// apply alignment for included detectors AFTER exporting ideal geometry
auto& aligner = o2::base::Aligner::Instance();
aligner.applyAlignment(confref.getTimestamp());
// the simulation needs no original matrices, so the physical nodes are not kept
aligner.applyAlignment(confref.getTimestamp(), o2::detectors::DetID::FullMask, false);

// export aligned geometry into different file
auto alignedgeomfile = o2::base::NameConf::getAlignedGeomFileName(confref.getOutPrefix());
Expand Down
Loading