ATLAS Offline Software
Loading...
Searching...
No Matches
Lvl1MuCTPIInput.cxx
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 <iostream>
6#include <iomanip>
7
9
10namespace LVL1MUONIF {
11
15
18 *this = right;
19 }
20
21
23
25 if ( this != &right ) {
26 clearAll();
27 for (size_t idSys=0; idSys<NumberOfMuonSystem; idSys++){
28 for( size_t ip=0; ip<right.m_data[idSys].size(); ip++){
29 int bc=((right.m_data[idSys]).at(ip)).first;
30 Lvl1MuVect vSL(((right.m_data[idSys]).at(ip)).second);
31 m_data[idSys].emplace_back(bc,std::move(vSL));
32 }
34 }
35 }
36 return *this;
37 }
38
39
40
43 size_t subSystemAddress,
44 size_t sectorAddress,
45 int bcid ) const {
46
47 static const Lvl1MuBarrelSectorLogicData dummy;
48 for( size_t ip=0; ip<m_data[systemAddress].size(); ip++){
49 int bc=((m_data[systemAddress]).at(ip)).first;
50 if (bc != bcid) continue;
51 const Lvl1MuVect &vecSL( ((m_data[systemAddress]).at(ip)).second);
52 return *(vecSL.at(getSystemIndex(systemAddress,subSystemAddress,sectorAddress)));
53 }
54 return dummy;
55 }
56
59 size_t systemAddress,
60 size_t subSystemAddress,
61 size_t sectorAddress,
62 int bcid ) {
63 size_t ip=0;
64 if (isEmpty(systemAddress,bcid)) {
65 ip = reserve( systemAddress, bcid );
66 } else {
67 ip = getBcidIndex( systemAddress, bcid );
68 }
69
70 const Lvl1MuVect &vecSL((((m_data[systemAddress]).at(ip)).second));
71 size_t idx= getSystemIndex(systemAddress,subSystemAddress,sectorAddress);
72 if ( systemAddress == Barrel ) {
73 *static_cast<Lvl1MuBarrelSectorLogicData*>(vecSL.at(idx).get()) = data;
74 } else if ( systemAddress == Endcap ) {
75 *static_cast<Lvl1MuEndcapSectorLogicData*>(vecSL.at(idx).get())= data;
76 } else if ( systemAddress == Forward ) {
77 *static_cast<Lvl1MuForwardSectorLogicData*>(vecSL.at(idx).get())= data;
78 }
79 }
80
82 void Lvl1MuCTPIInput::setSectorLogicData( const unsigned int & sectorWord,
83 size_t systemAddress,
84 size_t subSystemAddress,
85 size_t sectorAddress,
86 int bcid ) {
87 // convert to SectorLogicData
89 if ( systemAddress == Barrel ) {
90 pData = new Lvl1MuBarrelSectorLogicData();
91 } else if ( systemAddress == Endcap ) {
92 pData = new Lvl1MuEndcapSectorLogicData();
93 } else if ( systemAddress == Forward ) {
94 pData = new Lvl1MuForwardSectorLogicData();
95 } else {
96 return ;
97 }
98 pData->convertFromWordFormat( sectorWord );
99 setSectorLogicData( *pData, systemAddress, subSystemAddress, sectorAddress, bcid );
100 delete pData;
101 }
102
105 if ( this == &right ) return;
106
107 for (size_t idSys=0; idSys<NumberOfMuonSystem; idSys++){
108 for( size_t ip=0; ip<right.m_data[idSys].size(); ip++){
109 int bc=((right.m_data[idSys]).at(ip)).first;
110 if (isEmpty( idSys, bc)){
111 Lvl1MuVect vSL(((right.m_data[idSys]).at(ip)).second);
112 m_data[idSys].emplace_back(bc,std::move(vSL));
114 }
115 }
116 }
117
118 }
119
121 size_t Lvl1MuCTPIInput::reserve( size_t systemAddress ,
122 int bcid) {
123
124 Lvl1MuVect vecSL;
125
126 if ( systemAddress == Barrel ) {
128 for ( size_t id = 0; id < NumberOfBarrelSector*NumberOfMuonSubSystem; id++ ) {
129 vecSL.emplace_back(std::make_shared<Lvl1MuBarrelSectorLogicData>());
130 }
131
132 } else if ( systemAddress == Endcap ) {
134 for ( size_t id = 0; id < NumberOfEndcapSector*NumberOfMuonSubSystem; id++ ) {
135 vecSL.emplace_back(std::make_shared<Lvl1MuEndcapSectorLogicData>());
136 }
137
138 } else if ( systemAddress == Forward ) {
140 for ( size_t id = 0; id < NumberOfForwardSector*NumberOfMuonSubSystem; id++ ) {
141 vecSL.emplace_back(std::make_shared<Lvl1MuForwardSectorLogicData>());
142 }
143 }
144
145 size_t ip = m_data[systemAddress].size();
146 m_data[systemAddress].emplace_back( bcid, std::move(vecSL) );
147
148 if (bcid!=0) m_isFilledOutOfTimeCandidates[systemAddress] = true;
149
150 return ip;
151 }
152
154 bool Lvl1MuCTPIInput::isEmpty( size_t systemAddress,
155 int bcid ) const {
156 for( size_t ip=0; ip<m_data[systemAddress].size(); ip++){
157 int bc=((m_data[systemAddress]).at(ip)).first;
158 if (bc == bcid) return false;
159 }
160 return true;
161 }
162
164 bool Lvl1MuCTPIInput::isEmptyAll(int bcid) const {
165 if ( isEmpty(Barrel,bcid) && isEmpty(Endcap,bcid) && isEmpty(Forward,bcid) ) {
166 return true;
167 } else {
168 return false;
169 }
170 }
171
173 void Lvl1MuCTPIInput::clear( size_t systemAddress ) {
174 std::cout << "TW: SysAd: in " << systemAddress << " size: " << m_data[systemAddress].size() << std::endl;
175 m_data[systemAddress].clear();
176 }
177
180 for ( size_t id = 0; id < NumberOfMuonSystem; id++ ) {
181 m_data[ id ].clear();
182 }
183
184
185 }
186
188 // void Lvl1MuCTPIInput::duplicateToOtherBC(int bcidOffset) {
189
190 // std::cout << "I am faking candidates for testing - do you really want that??" << std::endl;
191
192 // std::vector<Lvl1MuVectWithBC> dataCopy[ NumberOfMuonSystem ];
193
194 // for ( size_t id = 0; id < NumberOfMuonSystem; id++ ) {
195 // dataCopy[ id ] = m_data[ id ];
196 // }
197
198 // for (std::vector<Lvl1MuVectWithBC>::iterator itb = dataCopy[Barrel].begin(); itb !=dataCopy[Barrel].end(); ++itb){
199 // (*itb).first =bcidOffset ;
200 // }
201 // std::vector<Lvl1MuVectWithBC>::iterator itb = m_data[Barrel].end();
202 // m_data[Barrel].insert(itb, dataCopy[Barrel].begin(), dataCopy[Barrel].end());
203
204 // for (std::vector<Lvl1MuVectWithBC>::iterator ite = dataCopy[Endcap].begin(); ite !=dataCopy[Endcap].end(); ++ite){
205 // (*ite).first =bcidOffset ;
206 // }
207 // std::vector<Lvl1MuVectWithBC>::iterator ite = m_data[Endcap].end();
208 // m_data[Endcap].insert(ite, dataCopy[Endcap].begin(), dataCopy[Endcap].end());
209
210 // for (std::vector<Lvl1MuVectWithBC>::iterator itf = dataCopy[Forward].begin(); itf !=dataCopy[Forward].end(); ++itf){
211 // (*itf).first =bcidOffset ;
212 // }
213 // std::vector<Lvl1MuVectWithBC>::iterator itf = m_data[Forward].end();
214 // m_data[Forward].insert(itf, dataCopy[Forward].begin(), dataCopy[Forward].end());
215 // }
216
217
218 std::ostream& operator<<( std::ostream& out, const Lvl1MuCTPIInput& right ) {
219
220 size_t systemAddress;
221 size_t subSystemAddress;
222 size_t side, id;
223
224 out << "--------- Barrel Sector ---------------------------" << std::endl;
225 systemAddress = right.idBarrelSystem();
226 for ( side = 0; side < right.NumberOfMuonSubSystem; ++side ) {
227 if ( side == 0 ) {
228 out << " ------ A Side (Z>0) ---------------------------" << std::endl;
229 subSystemAddress = right.idSideA();
230 } else {
231 out << " ------ C Side (Z<0) ---------------------------" << std::endl;
232 subSystemAddress = right.idSideC();
233 }
234 for ( id = 0; id < right.numberOfBarrelSector() ;++id ) {
235 out << " --- Sector ID : " << id << " ----------" << std::endl;
236 for( size_t ip=0; ip < right.m_data[systemAddress].size(); ip++){
237 int bc=((right.m_data[systemAddress]).at(ip)).first;
238 out << right.getSectorLogicData( systemAddress, subSystemAddress, id, bc );
239 out << " BC: " << bc;
240 out << std::endl;
241 }
242 }
243 }
244
245 out << "--------- Endcap Sector ---------------------------" << std::endl;
246 systemAddress = right.idEndcapSystem();
247 for ( side = 0; side < right.NumberOfMuonSubSystem; ++side ) {
248 if ( side == 0 ) {
249 out << " ------ A Side (Z>0) ---------------------------" << std::endl;
250 subSystemAddress = right.idSideA();
251 } else {
252 out << " ------ C Side (Z<0) ---------------------------" << std::endl;
253 subSystemAddress = right.idSideC();
254 }
255 for ( id = 0; id < right.numberOfEndcapSector() ;++id ) {
256 out << " --- Sector ID : " << id << " ----------" << std::endl;
257 for( size_t ip=0; ip < right.m_data[systemAddress].size(); ip++){
258 int bc=((right.m_data[systemAddress]).at(ip)).first;
259 out << right.getSectorLogicData( systemAddress, subSystemAddress, id, bc );
260 out << " BC: " << bc;
261 out << std::endl;
262 }
263 }
264 }
265
266 out << "--------- Forward Sector ---------------------------" << std::endl;
267 systemAddress = right.idForwardSystem();
268 for ( side = 0; side < right.NumberOfMuonSubSystem; ++side ) {
269 if ( side == 0 ) {
270 out << " ------ A Side (Z>0) ---------------------------" << std::endl;
271 subSystemAddress = right.idSideA();
272 } else {
273 out << " ------ C Side (Z<0) ---------------------------" << std::endl;
274 subSystemAddress = right.idSideC();
275 }
276 for ( id = 0; id < right.numberOfForwardSector() ;++id ) {
277 out << " --- Sector ID : " << id << " ----------" << std::endl;
278 for( size_t ip=0; ip < right.m_data[systemAddress].size(); ip++){
279 int bc=((right.m_data[systemAddress]).at(ip)).first;
280 out << right.getSectorLogicData( systemAddress, subSystemAddress, id, bc );
281 out << " BC: " << bc;
282 out << std::endl;
283 }
284 }
285 }
286
287 return out;
288 }
289}
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
Class representing data from a barrel SL board.
void setSectorLogicData(const Lvl1MuSectorLogicData &data, size_t systemAddress, size_t subSystemAddress, size_t sectorAddress, int bcid=0)
void clear(size_t systemAddress)
static size_t numberOfBarrelSector()
std::array< bool, NumberOfMuonSystem > m_isFilledOutOfTimeCandidates
void merge(const Lvl1MuCTPIInput &another)
Merge SectorLogic data of another object into this data of a system (Barrel, Endcap or Forward) is no...
bool isEmpty(size_t systemAddress, int bcid=0) const
Return "true" if data of specified system is empty.
void clearAll()
Clear Sector Logic data.
const Lvl1MuSectorLogicData & getSectorLogicData(size_t systemAddress, size_t subSystemAddress, size_t sectorAddress, int bcid=0) const
std::vector< std::shared_ptr< Lvl1MuSectorLogicData > > Lvl1MuVect
size_t reserve(size_t systemAddress, int bcid=0)
To store object to file. (NOT TO BE USED ANYMORE...)
size_t getBcidIndex(size_t systemAddress, int bcid=0) const
Lvl1MuCTPIInput & operator=(const Lvl1MuCTPIInput &right)
static size_t numberOfForwardSector()
static size_t numberOfEndcapSector()
bool isEmptyAll(int bcid=0) const
Return "true" if data of all systems for this bcid is empty.
size_t getSystemIndex(size_t systemAddress, size_t subSystemAddress, size_t sectorAddress) const
std::vector< Lvl1MuVectWithBC > m_data[NumberOfMuonSystem]
Class representing data from an endcap SL board.
Class representing data from a forward SL board.
Base class for the data coming from one SL board.
virtual const Lvl1MuSectorLogicData & convertFromWordFormat(const SectorLogicWord &)=0
Convert SectorLogicData from 32 bit word data.
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition hcg.cxx:130
Namespace for the LVL1 muon interface classes.
std::ostream & operator<<(std::ostream &out, const Lvl1MuCTPIInput &right)