52 LOGP(info,
"{:*^90}",
" ITS3 LOCAL MISALIGNMENT START ");
64 std::unique_ptr<TFile> origFile{TFile::Open(oldHitFileDest.c_str(),
"READ")};
65 if (origFile ==
nullptr || origFile->IsZombie()) {
66 LOGP(fatal,
"Original file {} cannot be opened", oldHitFileDest.c_str());
69 std::unique_ptr<TTree> origTree{origFile->Get<TTree>(
"o2sim")};
70 if (origTree ==
nullptr) {
71 LOGP(fatal,
"Cannot get hit-tree from orignal file");
73 std::vector<o2::itsmft::Hit> origHits, *origHitsPtr{&origHits};
74 origTree->SetBranchAddress(
"IT3Hit", &origHitsPtr);
76 std::unique_ptr<TFile> newFile{TFile::Open(oldHitFileSrc.c_str(),
"RECREATE")};
77 if (newFile ==
nullptr || newFile->IsZombie()) {
78 LOGP(fatal,
"New file {} cannot be opened", oldHitFileSrc.c_str());
81 auto newTree = std::make_unique<TTree>(
"o2sim",
"o2sim");
82 std::vector<o2::itsmft::Hit> newHits, *newHitsPtr{
nullptr};
83 newTree->Branch(
"IT3Hit", &newHitsPtr);
85 LOGP(info,
"Preparations done; starting hit loop");
86 auto nEntries = origTree->GetEntries();
87 ULong64_t totalOrigHits{0}, totalNewHits{0};
88 for (Long64_t iEntry{0}; origTree->LoadTree(iEntry) >= 0; ++iEntry) {
89 if (origTree->GetEntry(iEntry) <= 0) {
93 const auto progress = (iEntry * 100) / nEntries;
94 LOG_IF(info, progress % 10 == 0) <<
"Processing event " << iEntry <<
" / " << nEntries;
97 newHits.reserve(origHits.size());
98 for (
const auto& origHit : origHits) {
99 if (
auto newHit =
MisAligner.processHit(iEntry, origHit)) {
100 newHits.emplace_back(*newHit);
104 newHitsPtr = &newHits;
107 totalNewHits += newHits.size();
108 totalOrigHits += origHits.size();
111 newFile->WriteTObject(newTree.get());
117 auto totalDiscardedHits = totalOrigHits - totalNewHits;
118 LOGP(info,
"Summary: Total orignal Hits {}", totalOrigHits);
119 LOGP(info,
"Summary: Total misaligned Hits {} ({:.2f}%)", totalNewHits,
static_cast<float>(totalNewHits) /
static_cast<float>(totalOrigHits) * 100);
120 LOGP(info,
"Summary: Total discarded Hits {} ({:.2f}%)", totalDiscardedHits,
static_cast<float>(totalDiscardedHits) /
static_cast<float>(totalOrigHits) * 100);
121 LOGP(info,
"Summary: Misalignment took {:.2f}s", timer.CpuTime());
122 LOGP(info,
"{:*^90}",
" ITS3 LOCAL MISALIGNMENT END ");
163 gGeoManager->CdTop();
164 TGeoHMatrix* pgMatrix{
nullptr};
165 TGeoHMatrix gAccMatrix;
166 std::string curPath{};
168 curPath +=
"/" + comp;
170 pgMatrix = gGeoManager->GetCurrentMatrix();
171 gAccMatrix.Multiply(pgMatrix);
174 auto node = gGeoManager->GetCurrentNode();
175 if (node ==
nullptr) {
176 LOGP(fatal,
"Nullptr for node at {}",
path);
178 auto motherVol = node->GetMotherVolume();
179 if (motherVol ==
nullptr) {
180 LOGP(fatal,
"Nullptr for motherVol at {}",
path);
183 auto gAccMatrix1 = gAccMatrix.Inverse();
185 auto relativeMatrix = globalMatrix;
186 relativeMatrix.MultiplyLeft(gAccMatrix1);
188 auto nodemat =
dynamic_cast<TGeoNodeMatrix*
>(node);
189 nodemat->SetMatrix(
new TGeoHMatrix(globalMatrix));
192 motherVol->Voxelize(
"");