Project
Loading...
Searching...
No Matches
Aligner.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
17#include <chrono>
18
20
21using namespace o2::base;
22
24
26{
27 return DetID::getMask(mDetectors) & (~DetID::getMask(DetID::CTP));
28}
29
30void Aligner::applyAlignment(long timestamp, DetID::mask_t addMask) const
31{
32 DetID::mask_t msk = getDetectorsMask() & addMask;
33 if (msk.none()) {
34 return;
35 }
36 if (!gGeoManager) {
37 throw std::runtime_error("Geometry is not loaded, cannot apply alignment");
38 }
39 if (gGeoManager->IsLocked()) {
40 throw std::runtime_error("Geometry is locked, cannot apply alignment");
41 }
42
44 if (timestamp == 0) {
45 timestamp = getTimeStamp();
46 }
47 ccdbmgr.setURL(o2::base::NameConf::getCCDBServer());
48 ccdbmgr.setTimestamp(timestamp);
49 DetID::mask_t done, skipped;
50 DetID::mask_t detGeoMask(gGeoManager->GetUniqueID());
51 for (auto id = DetID::First; id <= DetID::Last; id++) {
52 if (!msk[id] || (detGeoMask.any() && !detGeoMask[id])) {
53 continue;
54 }
56 auto algV = ccdbmgr.get<std::vector<o2::detectors::AlignParam>>(path);
57 if (!algV) {
58 throw std::runtime_error(fmt::format("Failed to fetch alignment from {}:{}", o2::base::NameConf::getCCDBServer(), path));
59 }
60 if (!algV->empty()) {
61 done.set(id);
63 } else {
64 skipped.set(id);
65 }
66 }
67 std::string log = fmt::format("Alignment from {} for timestamp {}: ", o2::base::NameConf::getCCDBServer(), timestamp);
68 if (done.any()) {
69 log += fmt::format("applied to [{}]", DetID::getNames(done));
70 }
71 if (skipped.any()) {
72 log += fmt::format(", empty object for [{}]", DetID::getNames(skipped));
73 }
74 LOG(info) << log;
75 gGeoManager->RefreshPhysicalNodes(false);
76}
77
79{
80 return mTimeStamp > 0 ? mTimeStamp : std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
81}
Definition of the base alignment parameters class.
#define O2ParamImpl(classname)
Definition of the Names Generator class.
Definition of the GeometryManager class.
bool done
long getTimeStamp() const
Definition Aligner.cxx:78
o2::detectors::DetID::mask_t getDetectorsMask() const
Definition Aligner.cxx:25
void applyAlignment(long timestamp=0, o2::detectors::DetID::mask_t addMask=o2::detectors::DetID::FullMask) const
Definition Aligner.cxx:30
static std::string getAlignmentPath(DId d)
static bool applyAlignment(const std::vector< o2::detectors::AlignParam > &algPars)
misalign geometry with alignment objects from the array, optionaly check overlaps
static std::string getCCDBServer()
Definition NameConf.cxx:110
static BasicCCDBManager & instance()
Static class with identifiers, bitmasks and names for ALICE detectors.
Definition DetID.h:58
static constexpr ID CTP
Definition DetID.h:79
static std::string getNames(mask_t mask, char delimiter=',')
Definition DetID.cxx:74
static constexpr ID First
Definition DetID.h:94
static constexpr ID Last
if extra detectors added, update this !!!
Definition DetID.h:92
static mask_t getMask(const std::string_view detList)
detector masks from any non-alpha-num delimiter-separated list (empty if NONE is supplied)
Definition DetID.cxx:42
GLsizei const GLchar *const * path
Definition glcorearb.h:3591
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"