ATLAS Offline Software
Loading...
Searching...
No Matches
GeoStraightAccSection.icc
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "CxxUtils/CachedUniquePtr.h"
6#include <stdexcept>
7class GeoStraightAccSection::Clockwork {
8
9public:
10
11 Clockwork():r1(NULL){};
12
13 ~Clockwork() {
14 }
15
16 void buildSmallCache();
17
18
19 class Rep1 {
20
21 public:
22
23 double xcent[1024][14];
24 double ycent[1024][14];
25 double cosu[1024][14];
26 double sinu[1024][14];
27 double halfLength[1024][14];
28
29 };
30
31 class Rep2 {
32
33 public:
34
35 std::unique_ptr<GeoXF::Function> transfunction[14];
36 double halfLength[14];
37 };
38
39 CxxUtils::CachedUniquePtrT<Rep1> r1;
40 std::unique_ptr<Rep2> r2;
41
42 const Rep1& getFastCache() const;
43 Rep1& getWritableFastCache();
44 Rep2& getWritableSmallCache();
45
46private:
47 void fillFastCache (Rep1& rep1) const;
48
49 Clockwork( const Clockwork &);
50
51 Clockwork & operator = ( const Clockwork &);
52};
53
54
55inline
56const GeoStraightAccSection::Clockwork::Rep1&
57GeoStraightAccSection::Clockwork::getFastCache() const
58{
59 if (!r1) {
60 auto rep = std::make_unique<Rep1>();
61 fillFastCache (*rep);
62 r1.set (std::move (rep));
63 }
64 return *r1.get();
65}
66
67
68inline
69GeoStraightAccSection::Clockwork::Rep1&
70GeoStraightAccSection::Clockwork::getWritableFastCache()
71{
72 if (r2) throw std::runtime_error("Error in GeoStraightAccSection: Illegal Modification Sequence");
73 if (!r1) {
74 r1.store (std::make_unique<Rep1>());
75 }
76 return *r1.get();
77}
78
79
80inline
81GeoStraightAccSection::Clockwork::Rep2&
82GeoStraightAccSection::Clockwork::getWritableSmallCache()
83{
84 if (r1) throw std::runtime_error("Error in GeoStraightAccSection: Illegal Modification Sequence");
85 if (!r2) buildSmallCache();
86 return *r2;
87}
88
89
90inline const double & GeoStraightAccSection::XCent(int stackid, int cellid) const
91{
92 return m_c->getFastCache().xcent[stackid][cellid];
93}
94inline const double & GeoStraightAccSection::YCent(int stackid, int cellid) const
95{
96 return m_c->getFastCache().ycent[stackid][cellid];
97}
98inline const double & GeoStraightAccSection::Sinu(int stackid, int cellid) const
99{
100 return m_c->getFastCache().sinu[stackid][cellid];
101}
102inline const double & GeoStraightAccSection::Cosu(int stackid, int cellid) const
103{
104 return m_c->getFastCache().cosu[stackid][cellid];
105}
106inline const double & GeoStraightAccSection::HalfLength(int stackid, int cellid) const
107{
108 return m_c->getFastCache().halfLength[stackid][cellid];
109}
110