Analysis Software
Documentation for
sPHENIX
simulation software
Home page
Related Pages
Modules
Namespaces
Classes
Files
Examples
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
InternallyAlignedDetectorElement.hpp
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file InternallyAlignedDetectorElement.hpp
1
// This file is part of the Acts project.
2
//
3
// Copyright (C) 2019 CERN for the benefit of the Acts project
4
//
5
// This Source Code Form is subject to the terms of the Mozilla Public
6
// License, v. 2.0. If a copy of the MPL was not distributed with this
7
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
9
#pragma once
10
11
#include "
Acts/Definitions/Algebra.hpp
"
12
#include "
Acts/Geometry/GeometryContext.hpp
"
13
#include "
Acts/Geometry/GeometryIdentifier.hpp
"
14
#include "
Acts/Plugins/Identification/IdentifiedDetectorElement.hpp
"
15
#include "
Acts/Plugins/Identification/Identifier.hpp
"
16
#include "
Acts/Surfaces/Surface.hpp
"
17
#include "
ActsExamples/GenericDetector/GenericDetectorElement.hpp
"
18
19
#include <iostream>
20
#include <memory>
21
#include <mutex>
22
#include <unordered_map>
23
24
namespace
ActsExamples {
25
26
namespace
Contextual {
27
40
class
InternallyAlignedDetectorElement
41
:
public
Generic::GenericDetectorElement
{
42
public
:
43
struct
ContextType
{
45
unsigned
int
iov
= 0;
46
bool
nominal
=
false
;
47
};
48
49
// Inherit constructor
50
using
Generic::GenericDetectorElement::GenericDetectorElement
;
51
57
const
Acts::Transform3
&
transform
(
58
const
Acts::GeometryContext
&
gctx
)
const override
;
59
63
const
Acts::Transform3
&
nominalTransform
(
64
const
Acts::GeometryContext
&
gctx
)
const
;
65
70
void
addAlignedTransform
(
const
Acts::Transform3
& alignedTransform,
71
unsigned
int
iov);
72
73
void
clearAlignedTransform
(
unsigned
int
iov);
74
75
private
:
76
std::unordered_map<unsigned int, Acts::Transform3>
m_alignedTransforms
;
77
mutable
std::mutex
m_alignmentMutex
;
78
};
79
80
inline
const
Acts::Transform3
&
InternallyAlignedDetectorElement::transform
(
81
const
Acts::GeometryContext
&
gctx
)
const
{
82
if
(!gctx.hasValue()) {
83
// Return the standard transform if geo context is empty
84
return
nominalTransform
(gctx);
85
}
86
const
auto
& alignContext = gctx.get<
ContextType
&>();
87
88
std::lock_guard lock{
m_alignmentMutex
};
89
if
(alignContext.nominal) {
90
// nominal alignment
91
return
nominalTransform
(gctx);
92
}
93
auto
aTransform
=
m_alignedTransforms
.find(alignContext.iov);
94
if
(
aTransform
==
m_alignedTransforms
.end()) {
95
throw
std::runtime_error{
96
"Aligned transform for IOV "
+
std::to_string
(alignContext.iov) +
97
" not found. This can happen if the garbage collection runs too "
98
"early (--align-flushsize too low)"
};
99
}
100
return
aTransform
->second;
101
}
102
103
inline
const
Acts::Transform3
&
104
InternallyAlignedDetectorElement::nominalTransform
(
105
const
Acts::GeometryContext
&
gctx
)
const
{
106
return
GenericDetectorElement::transform
(gctx);
107
}
108
109
inline
void
InternallyAlignedDetectorElement::addAlignedTransform
(
110
const
Acts::Transform3
& alignedTransform,
unsigned
int
iov) {
111
std::lock_guard lock{
m_alignmentMutex
};
112
m_alignedTransforms
[iov] = alignedTransform;
113
}
114
115
inline
void
InternallyAlignedDetectorElement::clearAlignedTransform
(
116
unsigned
int
iov) {
117
std::lock_guard lock{
m_alignmentMutex
};
118
if
(
auto
it
=
m_alignedTransforms
.find(iov);
119
it
!=
m_alignedTransforms
.end()) {
120
m_alignedTransforms
.erase(
it
);
121
}
122
}
123
124
}
// namespace Contextual
125
}
// end of namespace ActsExamples
acts
blob
sPHENIX
Examples
Detectors
ContextualDetector
include
ActsExamples
ContextualDetector
InternallyAlignedDetectorElement.hpp
Built by
Jin Huang
. updated:
Sat Feb 17 2024 22:17:37
using
1.8.2 with
sPHENIX GitHub integration