ATLAS Offline Software
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 
10 namespace LVL1MUONIF {
11 
14  }
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 
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
88  Lvl1MuSectorLogicData * pData;
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 
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 }
LVL1MUONIF::Lvl1MuCTPIInput::merge
void merge(const Lvl1MuCTPIInput &another)
Merge SectorLogic data of another object into this data of a system (Barrel, Endcap or Forward) is no...
Definition: Lvl1MuCTPIInput.cxx:104
python.SystemOfUnits.second
int second
Definition: SystemOfUnits.py:120
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
LVL1MUONIF::Lvl1MuSectorLogicData
Base class for the data coming from one SL board.
Definition: Lvl1MuSectorLogicData.h:34
LVL1MUONIF::Lvl1MuCTPIInput::setSectorLogicData
void setSectorLogicData(const Lvl1MuSectorLogicData &data, size_t systemAddress, size_t subSystemAddress, size_t sectorAddress, int bcid=0)
Definition: Lvl1MuCTPIInput.cxx:58
LVL1MUONIF::Lvl1MuCTPIInput::Endcap
@ Endcap
Definition: Lvl1MuCTPIInput.h:51
LVL1MUONIF::Lvl1MuCTPIInput::Forward
@ Forward
Definition: Lvl1MuCTPIInput.h:51
LVL1MUONIF::Lvl1MuCTPIInput
Class representing (part of) the input data to the MuCTPI.
Definition: Lvl1MuCTPIInput.h:37
LVL1MUONIF::Lvl1MuCTPIInput::operator=
Lvl1MuCTPIInput & operator=(const Lvl1MuCTPIInput &right)
Definition: Lvl1MuCTPIInput.cxx:24
LVL1MUONIF
Namespace for the LVL1 muon interface classes.
Definition: Lvl1MuBarrelSectorLogicData.cxx:9
LVL1MUONIF::Lvl1MuCTPIInput::reserve
size_t reserve(size_t systemAddress, int bcid=0)
To store object to file. (NOT TO BE USED ANYMORE...)
Definition: Lvl1MuCTPIInput.cxx:121
LVL1MUONIF::Lvl1MuCTPIInput::getSectorLogicData
const Lvl1MuSectorLogicData & getSectorLogicData(size_t systemAddress, size_t subSystemAddress, size_t sectorAddress, int bcid=0) const
Definition: Lvl1MuCTPIInput.cxx:42
LVL1MUONIF::Lvl1MuCTPIInput::m_isFilledOutOfTimeCandidates
std::array< bool, NumberOfMuonSystem > m_isFilledOutOfTimeCandidates
Definition: Lvl1MuCTPIInput.h:156
LVL1MUONIF::Lvl1MuCTPIInput::numberOfBarrelSector
static size_t numberOfBarrelSector()
Definition: Lvl1MuCTPIInput.h:61
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
LVL1MUONIF::Lvl1MuCTPIInput::Lvl1MuVect
std::vector< std::shared_ptr< Lvl1MuSectorLogicData > > Lvl1MuVect
Definition: Lvl1MuCTPIInput.h:161
LVL1MUONIF::Lvl1MuCTPIInput::isEmptyAll
bool isEmptyAll(int bcid=0) const
Return "true" if data of all systems for this bcid is empty.
Definition: Lvl1MuCTPIInput.cxx:164
LVL1MUONIF::Lvl1MuCTPIInput::NumberOfForwardSector
@ NumberOfForwardSector
Definition: Lvl1MuCTPIInput.h:57
LVL1MUONIF::Lvl1MuCTPIInput::getSystemIndex
size_t getSystemIndex(size_t systemAddress, size_t subSystemAddress, size_t sectorAddress) const
Definition: Lvl1MuCTPIInput.h:135
LVL1MUONIF::Lvl1MuCTPIInput::idForwardSystem
static size_t idForwardSystem()
Definition: Lvl1MuCTPIInput.h:64
TRT::Hit::side
@ side
Definition: HitInfo.h:83
LVL1MUONIF::Lvl1MuCTPIInput::NumberOfEndcapSector
@ NumberOfEndcapSector
Definition: Lvl1MuCTPIInput.h:56
LVL1MUONIF::Lvl1MuCTPIInput::clearAll
void clearAll()
Clear Sector Logic data.
Definition: Lvl1MuCTPIInput.cxx:179
LVL1MUONIF::Lvl1MuBarrelSectorLogicData
Class representing data from a barrel SL board.
Definition: Lvl1MuBarrelSectorLogicData.h:27
LVL1MUONIF::Lvl1MuCTPIInput::isEmpty
bool isEmpty(size_t systemAddress, int bcid=0) const
Return "true" if data of specified system is empty.
Definition: Lvl1MuCTPIInput.cxx:154
LVL1MUONIF::Lvl1MuCTPIInput::idBarrelSystem
static size_t idBarrelSystem()
Definition: Lvl1MuCTPIInput.h:60
find_tgc_unfilled_channelids.ip
ip
Definition: find_tgc_unfilled_channelids.py:3
python.xAODType.dummy
dummy
Definition: xAODType.py:4
LVL1MUONIF::Lvl1MuForwardSectorLogicData
Class representing data from a forward SL board.
Definition: Lvl1MuForwardSectorLogicData.h:27
LVL1MUONIF::Lvl1MuCTPIInput::getBcidIndex
size_t getBcidIndex(size_t systemAddress, int bcid=0) const
Definition: Lvl1MuCTPIInput.h:148
LVL1MUONIF::Lvl1MuCTPIInput::m_data
std::vector< Lvl1MuVectWithBC > m_data[NumberOfMuonSystem]
Definition: Lvl1MuCTPIInput.h:163
LVL1MUONIF::Lvl1MuCTPIInput::idEndcapSystem
static size_t idEndcapSystem()
Definition: Lvl1MuCTPIInput.h:62
LVL1MUONIF::Lvl1MuCTPIInput::idSideC
static size_t idSideC()
Definition: Lvl1MuCTPIInput.h:67
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:220
LVL1MUONIF::Lvl1MuEndcapSectorLogicData
Class representing data from an endcap SL board.
Definition: Lvl1MuEndcapSectorLogicData.h:27
xAOD::bcid
setEventNumber setTimeStamp bcid
Definition: EventInfo_v1.cxx:133
LVL1MUONIF::Lvl1MuCTPIInput::clear
void clear(size_t systemAddress)
Definition: Lvl1MuCTPIInput.cxx:173
LVL1MUONIF::Lvl1MuCTPIInput::numberOfForwardSector
static size_t numberOfForwardSector()
Definition: Lvl1MuCTPIInput.h:65
LVL1MUONIF::Lvl1MuSectorLogicData::convertFromWordFormat
virtual const Lvl1MuSectorLogicData & convertFromWordFormat(const SectorLogicWord &)=0
Convert SectorLogicData from 32 bit word data.
LVL1MUONIF::Lvl1MuCTPIInput::NumberOfMuonSubSystem
@ NumberOfMuonSubSystem
Definition: Lvl1MuCTPIInput.h:54
LVL1MUONIF::Lvl1MuCTPIInput::Barrel
@ Barrel
Definition: Lvl1MuCTPIInput.h:51
DeMoScan.first
bool first
Definition: DeMoScan.py:536
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
LVL1MUONIF::Lvl1MuCTPIInput::NumberOfBarrelSector
@ NumberOfBarrelSector
Definition: Lvl1MuCTPIInput.h:55
LVL1MUONIF::Lvl1MuCTPIInput::numberOfEndcapSector
static size_t numberOfEndcapSector()
Definition: Lvl1MuCTPIInput.h:63
LVL1MUONIF::Lvl1MuCTPIInput::NumberOfMuonSystem
@ NumberOfMuonSystem
Definition: Lvl1MuCTPIInput.h:53
LVL1MUONIF::Lvl1MuCTPIInput::idSideA
static size_t idSideA()
Definition: Lvl1MuCTPIInput.h:66
LVL1MUONIF::Lvl1MuCTPIInput::Lvl1MuCTPIInput
Lvl1MuCTPIInput()
Definition: Lvl1MuCTPIInput.cxx:12
Lvl1MuCTPIInput.h
LVL1MUONIF::operator<<
std::ostream & operator<<(std::ostream &out, const Lvl1MuCTPIInput &right)
Definition: Lvl1MuCTPIInput.cxx:218