ATLAS Offline Software
DetectorAlignStore.cxx
Go to the documentation of this file.
1 
3 #include "CxxUtils/ArrayHelper.h"
4 
5 namespace{
6  std::mutex s_ticketMutex{};
7 }
8 
9 namespace ActsTrk{
10 
12  detType{type} {}
13 
17  TicketCounterArr DetectorAlignStore::TrackingAlignStore::s_clientCounter{};
18  ReturnedTicketArr DetectorAlignStore::TrackingAlignStore::s_returnedTickets{};
19  ReturnedHintArr DetectorAlignStore::TrackingAlignStore::s_returnedHints{};
20 
23  }
25  std::lock_guard guard{s_ticketMutex};
26  const unsigned int idx = static_cast<unsigned>(type);
27  std::vector<bool>& returnedPool = s_returnedTickets[idx];
28  int& returnedHint = s_returnedHints[idx];
29  if (returnedPool.size() && returnedHint >= 0) {
30  for (size_t i = returnedHint; i < returnedPool.size(); i++) {
31  if (returnedPool[i]) {
32  returnedPool[i] = false;
33 
34  returnedHint = i+1;
35  if (static_cast<size_t>(returnedHint) >= returnedPool.size()) {
36  returnedHint = 0;
37  }
38  return i;
39  }
40  }
41 
42  for (size_t i = 0; i < static_cast<size_t>(returnedHint); i++) {
43  if (returnedPool[i]) {
44  returnedPool[i] = false;
45  returnedHint = i+1;
46  return i;
47  }
48  }
49 
50  returnedHint = -1;
51  }
52  else {
53  returnedHint = -1;
54  }
55  return s_clientCounter[idx]++;
56  }
58  return s_clientCounter[static_cast<unsigned int>(type)];
59  }
61  std::lock_guard guard{s_ticketMutex};
62  const unsigned int idx = static_cast<unsigned int>(type);
63  std::vector<bool>& returnedPool = s_returnedTickets[idx];
64  int& returnedHint = s_returnedHints[idx];
66  if (ticketNo == distributedTickets(type) -1) {
67 
68  if (ticketNo > 0 && ticketNo-1 < returnedPool.size()) {
69  for (; ticketNo > 0 && returnedPool[ticketNo-1]; --ticketNo)
70  ;
71  returnedPool.resize (ticketNo);
72  }
74  s_clientCounter[idx] = ticketNo;
75  if (returnedHint >= static_cast<int>(ticketNo)) {
76  returnedHint = 0;
77  }
78  } else {
79  if (returnedPool.size() <= ticketNo) {
80  returnedPool.resize (ticketNo+1);
81  }
82  returnedPool[ticketNo] = true;
83  if (returnedHint < 0 || static_cast<int>(ticketNo) < returnedHint) {
84  returnedHint = ticketNo;
85  }
86  }
87  }
88 
89 }
ActsTrk::ReturnedHintArr
DetectorAlignStore::TrackingAlignStore::ReturnedHintArr ReturnedHintArr
Definition: DetectorAlignStore.cxx:16
ActsTrk::DetectorType
DetectorType
Simple enum to Identify the Type of the ACTS sub detector.
Definition: GeometryDefs.h:17
BeamSpot::mutex
std::mutex mutex
Definition: InDetBeamSpotVertex.cxx:18
ActsTrk::DetectorAlignStore::TrackingAlignStore::TicketCounterArr
std::array< std::atomic< unsigned >, s_techs > TicketCounterArr
Definition: DetectorAlignStore.h:54
lumiFormat.i
int i
Definition: lumiFormat.py:85
ActsTrk::DetectorAlignStore::DetectorAlignStore
DetectorAlignStore(const DetectorAlignStore &other)=default
Copy constructor.
ActsTrk::DetectorAlignStore::TrackingAlignStore::ReturnedTicketArr
std::array< std::vector< bool >, s_techs > ReturnedTicketArr
Definition: DetectorAlignStore.h:55
ActsTrk::DetectorAlignStore::TrackingAlignStore::TrackingAlignStore
TrackingAlignStore(const DetectorType detType)
Definition: DetectorAlignStore.cxx:21
ActsTrk::DetectorAlignStore::TrackingAlignStore::m_transforms
std::vector< CxxUtils::CachedUniquePtr< Amg::Transform3D > > m_transforms
Definition: DetectorAlignStore.h:61
ArrayHelper.h
ActsTrk::DetectorAlignStore::TrackingAlignStore::giveBackTicket
static void giveBackTicket(const DetectorType detType, unsigned int ticketNo)
Definition: DetectorAlignStore.cxx:60
ActsTrk::DetectorAlignStore::TrackingAlignStore::drawTicket
static unsigned int drawTicket(const DetectorType detType)
Returns a unique ID to the client under which the client can store its transformation inside the cont...
Definition: DetectorAlignStore.cxx:24
ActsTrk::TicketCounterArr
DetectorAlignStore::TrackingAlignStore::TicketCounterArr TicketCounterArr
Definition: DetectorAlignStore.cxx:14
DetectorAlignStore.h
ActsTrk::DetectorAlignStore::TrackingAlignStore::distributedTickets
static unsigned int distributedTickets(const DetectorType detType)
Returns the number of all distributed tickets.
Definition: DetectorAlignStore.cxx:57
ActsTrk::DetectorAlignStore::TrackingAlignStore::ReturnedHintArr
std::array< int, s_techs > ReturnedHintArr
Definition: DetectorAlignStore.h:56
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
ActsTrk::ReturnedTicketArr
DetectorAlignStore::TrackingAlignStore::ReturnedTicketArr ReturnedTicketArr
Definition: DetectorAlignStore.cxx:15
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
ActsTrk
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
Definition: MuonDetectorBuilderTool.cxx:49