ATLAS Offline Software
Loading...
Searching...
No Matches
TBDetDescrManager.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
5//========================================
6// file TBDetDescrManager.cxx
7//
8//========================================
9
10#include "GaudiKernel/MsgStream.h"
11
14
15
17 : m_elements(0)
18{
20
21 // instead of creating yet another vector with all the names
22 // for all elements in CTB simulation, let's keep them in the same vector
23 // these names are needed only when we initialize manager from FADS
24
26 m_TBElementVec[TBElementID::BEAMPIPE1 ].m_name = "BEAMPIPE1";
27 m_TBElementVec[TBElementID::BEAMPIPE2 ].m_name = "BEAMPIPE2";
28 m_TBElementVec[TBElementID::SMV ].m_name = "SMV";
29 m_TBElementVec[TBElementID::S1 ].m_name = "S1";
30 m_TBElementVec[TBElementID::S3 ].m_name = "S3";
31 m_TBElementVec[TBElementID::S2 ].m_name = "S2";
32 m_TBElementVec[TBElementID::SH ].m_name = "SH";
33 m_TBElementVec[TBElementID::SNEW ].m_name = "SNEW";
34 m_TBElementVec[TBElementID::MBPSID ].m_name = "MBPSID";
35 m_TBElementVec[TBElementID::IDET ].m_name = "IDET";
36 m_TBElementVec[TBElementID::Pixel ].m_name = "Pixel";
37 m_TBElementVec[TBElementID::SCT ].m_name = "SCT";
38 m_TBElementVec[TBElementID::CTBTRT ].m_name = "CTBTRT";
39 m_TBElementVec[TBElementID::TRT ].m_name = "TRT";
40 m_TBElementVec[TBElementID::CALO ].m_name = "CALO";
41 m_TBElementVec[TBElementID::LArTBBarrel ].m_name = "LArTBBarrel";
42 m_TBElementVec[TBElementID::Tile ].m_name = "Tile";
43 m_TBElementVec[TBElementID::MuonWall ].m_name = "MuonWall";
44 m_TBElementVec[TBElementID::PhantomBarrel ].m_name = "PhantomBarrel";
45 m_TBElementVec[TBElementID::CombinedScintillator ].m_name = "CombinedScintillator";
46 m_TBElementVec[TBElementID::DeadMaterial ].m_name = "DeadMaterial";
47 m_TBElementVec[TBElementID::LArCrate ].m_name = "LArCrate";
48 m_TBElementVec[TBElementID::MUON ].m_name = "MUON";
49 m_TBElementVec[TBElementID::Muon ].m_name = "Muon";
50 m_TBElementVec[TBElementID::DUMPIRON ].m_name = "DUMPIRON";
51 m_TBElementVec[TBElementID::MBPL ].m_name = "MBPL";
52 m_TBElementVec[TBElementID::MBPS2 ].m_name = "MBPS2";
53 m_TBElementVec[TBElementID::SCDUMP ].m_name = "SCDUMP";
54 m_TBElementVec[TBElementID::SMT ].m_name = "SMT";
55 m_TBElementVec[TBElementID::MUON10x10A ].m_name = "MUON10x10A";
56 m_TBElementVec[TBElementID::MUON10x10B ].m_name = "MUON10x10B";
57 m_TBElementVec[TBElementID::MUON10x10C ].m_name = "MUON10x10C";
58 m_TBElementVec[TBElementID::MUON10x10D ].m_name = "MUON10x10D";
59 m_TBElementVec[TBElementID::MUONHODOSELECTOR ].m_name = "MUONHODOSELECTOR";
60 m_TBElementVec[TBElementID::MUONHODOPLANE11 ].m_name = "MUONHODOPLANE11";
61 m_TBElementVec[TBElementID::MUONHODOPLANE12 ].m_name = "MUONHODOPLANE12";
62 m_TBElementVec[TBElementID::MUONHODOPLANE13 ].m_name = "MUONHODOPLANE13";
63 m_TBElementVec[TBElementID::MUONHODOPLANE14 ].m_name = "MUONHODOPLANE14";
64 m_TBElementVec[TBElementID::MUONHODOPLANE15 ].m_name = "MUONHODOPLANE15";
65 m_TBElementVec[TBElementID::MUONHODOPLANE16 ].m_name = "MUONHODOPLANE16";
66 m_TBElementVec[TBElementID::MUONHODOPLANE21 ].m_name = "MUONHODOPLANE21";
67 m_TBElementVec[TBElementID::MUONHODOPLANE22 ].m_name = "MUONHODOPLANE22";
68 m_TBElementVec[TBElementID::MUONHODOPLANE23 ].m_name = "MUONHODOPLANE23";
69 m_TBElementVec[TBElementID::MUONHODOPLANE24 ].m_name = "MUONHODOPLANE24";
70 m_TBElementVec[TBElementID::MUONHODOPLANE25 ].m_name = "MUONHODOPLANE25";
71 m_TBElementVec[TBElementID::MUONHODOPLANE26 ].m_name = "MUONHODOPLANE26";
72}
73
74void TBDetDescrManager::initialize(const std::vector<TBElement> & vec)
75{
76 if (m_elements>0)
77 m_TBElementVec.clear();
78
79 m_elements = 0;
81
82 std::vector<TBElement>::const_iterator itr=vec.begin();
83 std::vector<TBElement>::const_iterator end=vec.end();
84
85 for ( ; itr!=end; ++itr) {
86 unsigned int iid = itr->id();
87 if ( iid >= m_TBElementVec.size() )
88 m_TBElementVec.resize(iid+1);
89 m_TBElementVec[iid] = (*itr);
90 if ( m_TBElementVec[iid].id() != TBElementID::Unknown )
91 ++m_elements;
92 }
93}
94
95void TBDetDescrManager::initialize(const TBElementContainer * pTBElementContainer)
96{
97 TBElementContainer::const_iterator itr = pTBElementContainer->begin();
98 TBElementContainer::const_iterator end = pTBElementContainer->end();
99
100 std::vector<TBElement> vec;
101
102 for (; itr!=end; ++itr)
103 vec.push_back(*(*itr));
104
106}
107
108void TBDetDescrManager::getAll(TBElementContainer * pTBElementContainer) const
109{
110 std::vector<TBElement>::const_iterator itr=m_TBElementVec.begin();
111 std::vector<TBElement>::const_iterator end=m_TBElementVec.end();
112
113 for ( ; itr!=end; ++itr) {
114 if (itr->id() != TBElementID::Unknown) {
115 TBElement* pTBElement = new TBElement(*itr);
116 pTBElementContainer->push_back(pTBElement);
117 }
118 }
119}
120
122{
123 // no check here if element is initialized or not
124 // all the checks should be done by caller (element.id() != TBElementID::Unknown)
125 return m_TBElementVec[id];
126}
127
129{
130 unsigned int iid = element.id();
131
132 if ( iid >= m_TBElementVec.size())
133 m_TBElementVec.resize(iid+1);
134
135 // we clear old element, so number of elements decreased
136 if ( m_TBElementVec[iid].id() != TBElementID::Unknown )
137 --m_elements;
138
139 m_TBElementVec[iid] = element;
140
141 // we probably created new element, so number of elements increased
142 if ( m_TBElementVec[iid].id() != TBElementID::Unknown )
143 ++m_elements;
144}
145
146void TBDetDescrManager::print(MsgStream &log) const
147{
148 std::vector<TBElement>::const_iterator itr=m_TBElementVec.begin();
149 std::vector<TBElement>::const_iterator end=m_TBElementVec.end();
150
151 log << MSG::DEBUG
152 << "Total number of TBElements in TBDetDescrManager = "
153 << m_elements
154 << endmsg;
155
156 for ( ; itr!=end; ++itr) {
157 if (itr->id() != TBElementID::Unknown) {
158 log << MSG::DEBUG
159 << (std::string) (*itr)
160 << endmsg;
161 }
162 }
163}
#define endmsg
std::vector< size_t > vec
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
value_type push_back(value_type pElem)
Add an element to the end of the collection.
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
void getAll(TBElementContainer *pTBElementContainer) const
void print(MsgStream &log) const
std::vector< TBElement > m_TBElementVec
unsigned int m_elements
const TBElement & getElement(TBElementID::TBElementID id) const
void initialize(const std::vector< TBElement > &vec)
void setElement(const TBElement &element)
TBElementID::TBElementID id() const
Definition TBElement.h:33
@ CombinedScintillator
Definition TBElementID.h:32
void initialize()