ATLAS Offline Software
Loading...
Searching...
No Matches
MuonTGC_Cabling::TGCCableASDToPP Class Reference

#include <TGCCableASDToPP.h>

Inheritance diagram for MuonTGC_Cabling::TGCCableASDToPP:
Collaboration diagram for MuonTGC_Cabling::TGCCableASDToPP:

Public Types

enum  CableType {
  NoCableType = -1 , InASD , ASDToPP , InPP ,
  PPToSLB , InSLB , SLBToHPB , HPBToSL ,
  SLBToSSW , SSWToROD , MaxCableType
}

Public Member Functions

 TGCCableASDToPP (const std::string &fileName, const std::string &diffFile)
virtual ~TGCCableASDToPP ()
std::unique_ptr< TGCChannelId > getChannel (const TGCChannelId &channelId, bool orChannel=false) const
CableType getCableType () const

Private Types

using ForwardSectorDB
using InnerSectorDB
using EndcapSectorDB
using CommonDB
 Pointers of common databases are recorded in this array.

Private Member Functions

void initialize (const std::string &filename, const std::string &diffFile)
void updateDatabase (const std::string &diffFile)
std::unique_ptr< TGCChannelId > getChannelIn (const TGCChannelId &ppin, bool orChannel=false) const
std::unique_ptr< TGCChannelId > getChannelOut (const TGCChannelId &asdout, bool orChannel=false) const
std::vector< std::vector< int > > getUpdateInfo (const int side, const int sector, const std::vector< std::string > &diffFile, std::string_view blockname)
TGCDatabaseASDToPP * getDatabase (const TGCId::SideType side, const TGCId::RegionType region, const int sector, const TGCId::ModuleType module) const
void updateIndividualDatabase (const int side, const int sector, const std::vector< std::string > &diffFile, std::string_view blockname, std::shared_ptr< TGCDatabaseASDToPP > &database)

Private Attributes

ForwardSectorDB m_FWDdb {}
ForwardSectorDB m_FSDdb {}
ForwardSectorDB m_FWTdb {}
ForwardSectorDB m_FSTdb {}
InnerSectorDB m_FWIdb {}
InnerSectorDB m_FSIdb {}
EndcapSectorDB m_EWDdb {}
EndcapSectorDB m_ESDdb {}
EndcapSectorDB m_EWTdb {}
EndcapSectorDB m_ESTdb {}
InnerSectorDB m_EWIdb {}
InnerSectorDB m_ESIdb {}
CommonDB m_commonDb {{{nullptr}}}
CableType m_type {CableType::NoCableType}

Static Private Attributes

static constexpr std::array< int, 10 > s_stripForward

Detailed Description

Definition at line 20 of file TGCCableASDToPP.h.

Member Typedef Documentation

◆ CommonDB

Initial value:

Pointers of common databases are recorded in this array.

Definition at line 85 of file TGCCableASDToPP.h.

◆ EndcapSectorDB

Initial value:
std::array<std::array<std::shared_ptr<TGCDatabaseASDToPP>,
static constexpr int NUM_ENDCAP_SECTOR
Definition TGCId.h:43

Definition at line 65 of file TGCCableASDToPP.h.

◆ ForwardSectorDB

Initial value:
std::array<std::array<std::shared_ptr<TGCDatabaseASDToPP>,
static constexpr int NUM_FORWARD_SECTOR
Definition TGCId.h:44

Definition at line 57 of file TGCCableASDToPP.h.

◆ InnerSectorDB

Initial value:
std::array<std::array<std::shared_ptr<TGCDatabaseASDToPP>,
static constexpr int NUM_INNER_SECTOR
Definition TGCId.h:45

Definition at line 61 of file TGCCableASDToPP.h.

Member Enumeration Documentation

◆ CableType

Enumerator
NoCableType 
InASD 
ASDToPP 
InPP 
PPToSLB 
InSLB 
SLBToHPB 
HPBToSL 
SLBToSSW 
SSWToROD 
MaxCableType 

Definition at line 16 of file TGCCable.h.

Constructor & Destructor Documentation

◆ TGCCableASDToPP()

MuonTGC_Cabling::TGCCableASDToPP::TGCCableASDToPP ( const std::string & fileName,
const std::string & diffFile )

Definition at line 17 of file TGCCableASDToPP.cxx.

20 initialize(filename, diffFile);
21}
TGCCable(CableType type=NoCableType)
Definition TGCCable.h:31
void initialize()

◆ ~TGCCableASDToPP()

MuonTGC_Cabling::TGCCableASDToPP::~TGCCableASDToPP ( )
virtualdefault

Member Function Documentation

◆ getCableType()

CableType MuonTGC_Cabling::TGCCable::getCableType ( ) const
inlineinherited

Definition at line 34 of file TGCCable.h.

34{ return m_type; }

◆ getChannel()

std::unique_ptr< TGCChannelId > MuonTGC_Cabling::TGCCableASDToPP::getChannel ( const TGCChannelId & channelId,
bool orChannel = false ) const

Definition at line 280 of file TGCCableASDToPP.cxx.

281 {
282 if (channelId.getChannelIdType() == TGCChannelId::ChannelIdType::ASDOut) {
283 return getChannelOut(channelId, orChannel);
284 }
285 if (channelId.getChannelIdType() == TGCChannelId::ChannelIdType::PPIn) {
286 return getChannelIn(channelId, orChannel);
287 }
288
289 return nullptr;
290}
std::unique_ptr< TGCChannelId > getChannelOut(const TGCChannelId &asdout, bool orChannel=false) const
std::unique_ptr< TGCChannelId > getChannelIn(const TGCChannelId &ppin, bool orChannel=false) const

◆ getChannelIn()

std::unique_ptr< TGCChannelId > MuonTGC_Cabling::TGCCableASDToPP::getChannelIn ( const TGCChannelId & ppin,
bool orChannel = false ) const
private

Definition at line 292 of file TGCCableASDToPP.cxx.

293 {
294 if (orChannel || !ppin.isValid()) {
295 return nullptr;
296 }
297
298 TGCDatabaseASDToPP* databaseP =
299 getDatabase(ppin.getSideType(), ppin.getRegionType(), ppin.getSector(),
300 ppin.getModuleType());
301
302 if (databaseP == nullptr) {
303 return nullptr;
304 }
305
306 int indexOut[TGCDatabaseASDToPP::NIndexOut] = {
307 ppin.getId(), ppin.getBlock(), ppin.getChannel()};
308 int i = databaseP->getIndexDBOut(indexOut);
309 if (i < 0) {
310 return nullptr;
311 }
312
313 // ASD2PP.db is Backward connection
314 int layer = databaseP->getEntry(i, 0);
315 if (ppin.isStrip()) {
316 if (!ppin.isBackward()) {
318 }
319 }
320 int offset = (ppin.isWire()) ? 4 : 0;
321 int channel = databaseP->getEntry(i, 2 + offset);
322
323 // Endcap Triplet chamberId start from 1 in ASDOut
324 int chamber = databaseP->getEntry(i, 1);
325 if (ppin.isEndcap() && ppin.isTriplet()) {
326 chamber = chamber + 1;
327 }
328 return std::make_unique<TGCChannelASDOut>(
329 ppin.getSideType(), ppin.getSignalType(), ppin.getRegionType(),
330 ppin.getSector(), layer, chamber, channel);
331}
TGCDatabaseASDToPP * getDatabase(const TGCId::SideType side, const TGCId::RegionType region, const int sector, const TGCId::ModuleType module) const
static constexpr std::array< int, 10 > s_stripForward
@ layer
Definition HitInfo.h:79

◆ getChannelOut()

std::unique_ptr< TGCChannelId > MuonTGC_Cabling::TGCCableASDToPP::getChannelOut ( const TGCChannelId & asdout,
bool orChannel = false ) const
private

Definition at line 333 of file TGCCableASDToPP.cxx.

334 {
335 if (orChannel || !asdout.isValid()) {
336 return nullptr;
337 }
338
339 const bool asdoutisStrip = asdout.isStrip();
340 const bool asdoutisBackward = asdout.isBackward();
341 const bool asdoutisEndcap = asdout.isEndcap();
342 const bool asdoutisM1 = (asdout.getStation() == TGCId::StationType::M1);
343 const int asdoutLayer = asdout.getLayer();
344 const int asdoutChamber = asdout.getChamber();
345 const int asdoutChannel = asdout.getChannel();
346
347 TGCDatabaseASDToPP* databaseP =
348 getDatabase(asdout.getSideType(), asdout.getRegionType(),
349 asdout.getSector(), asdout.getModuleType());
350
351 if (databaseP == nullptr) {
352 return nullptr;
353 }
354
355 const int MaxEntry = databaseP->getMaxEntry();
356 for (int i = 0; i < MaxEntry; i++) {
357 // ASD2PP.db is Backward connection
358 int layer = asdoutLayer;
359 if (asdoutisStrip && !asdoutisBackward) {
361 }
362
363 int elecChannel = asdoutChannel;
364
365 // Endcap Triplet chamberId start from 1 in ASDOut
366 int chamber = asdoutChamber;
367 if (asdoutisEndcap && asdoutisM1) {
368 chamber = chamber - 1;
369 }
370 int offset = (asdout.isWire()) ? 4 : 0;
371 if (databaseP->getEntry(i, 0) == layer &&
372 databaseP->getEntry(i, 1) == chamber &&
373 databaseP->getEntry(i, 2 + offset) == elecChannel) {
374 int id = databaseP->getEntry(i, 3);
375 int block = databaseP->getEntry(i, 4);
376 int channel = databaseP->getEntry(i, 5);
377
378 return std::make_unique<TGCChannelPPIn>(
379 asdout.getSideType(), asdout.getStation(), asdout.getModuleType(),
380 asdout.getRegionType(), asdout.getSector(), id, block, channel);
381 }
382 }
383 return nullptr;
384}

◆ getDatabase()

TGCDatabaseASDToPP * MuonTGC_Cabling::TGCCableASDToPP::getDatabase ( const TGCId::SideType side,
const TGCId::RegionType region,
const int sector,
const TGCId::ModuleType module ) const
private

Definition at line 194 of file TGCCableASDToPP.cxx.

197 {
198 if (side >= TGCId::SideType::MaxSideType) {
199 return nullptr;
200 }
201 if (sector < 0) {
202 return nullptr;
203 }
204
205 TGCDatabaseASDToPP* db = nullptr;
206 if (region == TGCId::RegionType::Endcap) {
207 switch (module) {
209 if (sector < TGCId::NUM_ENDCAP_SECTOR) {
210 db = m_EWDdb[+side][sector].get();
211 }
212 break;
214 if (sector < TGCId::NUM_ENDCAP_SECTOR) {
215 db = m_ESDdb[+side][sector].get();
216 }
217 break;
219 if (sector < TGCId::NUM_ENDCAP_SECTOR) {
220 db = m_EWTdb[+side][sector].get();
221 }
222 break;
224 if (sector < TGCId::NUM_ENDCAP_SECTOR) {
225 db = m_ESTdb[+side][sector].get();
226 }
227 break;
229 if (sector < TGCId::NUM_INNER_SECTOR) {
230 db = m_EWIdb[+side][sector].get();
231 }
232 break;
234 if (sector < TGCId::NUM_INNER_SECTOR) {
235 db = m_ESIdb[+side][sector].get();
236 }
237 break;
238 default:
239 break;
240 }
241 } else if (region == TGCId::RegionType::Forward) {
242 switch (module) {
244 if (sector < TGCId::NUM_FORWARD_SECTOR) {
245 db = m_FWDdb[+side][sector].get();
246 }
247 break;
249 if (sector < TGCId::NUM_FORWARD_SECTOR) {
250 db = m_FSDdb[+side][sector].get();
251 }
252 break;
254 if (sector < TGCId::NUM_FORWARD_SECTOR) {
255 db = m_FWTdb[+side][sector].get();
256 }
257 break;
259 if (sector < TGCId::NUM_FORWARD_SECTOR) {
260 db = m_FSTdb[+side][sector].get();
261 }
262 break;
264 if (sector < TGCId::NUM_INNER_SECTOR) {
265 db = m_FWIdb[+side][sector].get();
266 }
267 break;
269 if (sector < TGCId::NUM_INNER_SECTOR) {
270 db = m_FSIdb[+side][sector].get();
271 }
272 break;
273 default:
274 break;
275 }
276 }
277 return db;
278}

◆ getUpdateInfo()

std::vector< std::vector< int > > MuonTGC_Cabling::TGCCableASDToPP::getUpdateInfo ( const int side,
const int sector,
const std::vector< std::string > & diffFile,
std::string_view blockname )
private

Definition at line 133 of file TGCCableASDToPP.cxx.

135 {
136 // clear info
137 std::vector<std::vector<int>> info{};
138
139 std::vector<std::string>::const_iterator it = diffFile.begin();
140 std::vector<std::string>::const_iterator it_e = diffFile.end();
141 int size = 0;
142
143 // search block name
144 while (it != it_e) {
145 const std::string& buf = (*it);
146 ++it;
147 char firstl = buf.at(0);
148 if (firstl == '/' || firstl == '*') {
149 continue;
150 }
151 if (std::string_view{buf}.starts_with(blockname)) {
152 std::istringstream line(buf);
153 std::string temp;
154 line >> temp >> size;
155 break;
156 }
157 }
158
159 // loop over entries of specified block
160 while (it != it_e) {
161 const std::string& buf = (*it);
162 ++it;
163 char firstl = buf.at(0);
164 if (firstl == '/' || firstl == '*') {
165 continue;
166 }
167 if (firstl == 'E' || firstl == 'F') {
168 break;
169 }
170 std::istringstream line(buf);
171 std::vector<int> entry;
172 int t_side{}, t_sector{};
173 line >> t_side;
174 line >> t_sector;
175 bool isOK = false;
176 if ((t_side == side) && (t_sector == sector)) {
177 for (int i = 2; i < 8; i++) {
178 int temp = -1;
179 if (line >> temp) {
180 entry.push_back(temp);
181 } else {
182 break;
183 }
184 isOK = (i == 7);
185 }
186 if (isOK) {
187 info.push_back(std::move(entry));
188 }
189 }
190 }
191 return info;
192}
size_t size() const
Number of registered mappings.

◆ initialize()

void MuonTGC_Cabling::TGCCableASDToPP::initialize ( const std::string & filename,
const std::string & diffFile )
private

Definition at line 25 of file TGCCableASDToPP.cxx.

26 {
28 std::make_shared<TGCDatabaseASDToPP>(filename, "FWD");
30 std::make_shared<TGCDatabaseASDToPP>(filename, "FSD");
32 std::make_shared<TGCDatabaseASDToPP>(filename, "FWT");
34 std::make_shared<TGCDatabaseASDToPP>(filename, "FST");
35
37 std::make_shared<TGCDatabaseASDToPP>(filename, "EWD");
39 std::make_shared<TGCDatabaseASDToPP>(filename, "ESD");
41 std::make_shared<TGCDatabaseASDToPP>(filename, "EWT");
43 std::make_shared<TGCDatabaseASDToPP>(filename, "EST");
44
46 std::make_shared<TGCDatabaseASDToPP>(filename, "FWI");
48 std::make_shared<TGCDatabaseASDToPP>(filename, "FSI");
50 std::make_shared<TGCDatabaseASDToPP>(filename, "EWI");
52 std::make_shared<TGCDatabaseASDToPP>(filename, "ESI");
53
54 for (int side = 0; side < +TGCId::SideType::MaxSideType; side++) {
55 for (int sector = 0; sector < TGCId::NUM_FORWARD_SECTOR; sector++) {
60 }
61 for (int sector = 0; sector < TGCId::NUM_ENDCAP_SECTOR; sector++) {
66 }
67 for (int sector = 0; sector < TGCId::NUM_INNER_SECTOR; sector++) {
72 }
73 }
74 updateDatabase(diffFile);
75}
void updateDatabase(const std::string &diffFile)

◆ updateDatabase()

void MuonTGC_Cabling::TGCCableASDToPP::updateDatabase ( const std::string & diffFile)
private

Definition at line 77 of file TGCCableASDToPP.cxx.

77 {
78
79 std::vector<std::string> fileContent{};
80 std::ifstream inASDToPP;
81 inASDToPP.open(diffFile);
82 if (inASDToPP.bad()) {
83 throw std::runtime_error("Failed to open " + diffFile);
84 return;
85 }
86
87 std::string buf{};
88 // Copy database into m_ASD2PP_DIFF_12
89 while (getline(inASDToPP, buf)) {
90 char letter = buf.at(0);
91 // Truncation saves initialization CPU time of about 30 ms.
92 if (letter == '/' || letter == '*') {
93 continue;
94 }
95
96 fileContent.push_back(buf);
97 }
98
99 for (int side = 0; side < +TGCId::SideType::MaxSideType; side++) {
100 for (int sector = 0; sector < TGCId::NUM_FORWARD_SECTOR; sector++) {
101 updateIndividualDatabase(side, sector, fileContent, "FWD",
102 m_FWDdb[side][sector]);
103 updateIndividualDatabase(side, sector, fileContent, "FSD",
104 m_FSDdb[side][sector]);
105 updateIndividualDatabase(side, sector, fileContent, "FWT",
106 m_FWTdb[side][sector]);
107 updateIndividualDatabase(side, sector, fileContent, "FST",
108 m_FSTdb[side][sector]);
109 }
110 for (int sector = 0; sector < TGCId::NUM_ENDCAP_SECTOR; sector++) {
111 updateIndividualDatabase(side, sector, fileContent, "EWD",
112 m_EWDdb[side][sector]);
113 updateIndividualDatabase(side, sector, fileContent, "ESD",
114 m_ESDdb[side][sector]);
115 updateIndividualDatabase(side, sector, fileContent, "EWT",
116 m_EWTdb[side][sector]);
117 updateIndividualDatabase(side, sector, fileContent, "EST",
118 m_ESTdb[side][sector]);
119 }
120 for (int sector = 0; sector < TGCId::NUM_INNER_SECTOR; sector++) {
121 updateIndividualDatabase(side, sector, fileContent, "EWI",
122 m_EWIdb[side][sector]);
123 updateIndividualDatabase(side, sector, fileContent, "ESI",
124 m_ESIdb[side][sector]);
125 updateIndividualDatabase(side, sector, fileContent, "FWI",
126 m_FWIdb[side][sector]);
127 updateIndividualDatabase(side, sector, fileContent, "FSI",
128 m_FSIdb[side][sector]);
129 }
130 }
131}
void updateIndividualDatabase(const int side, const int sector, const std::vector< std::string > &diffFile, std::string_view blockname, std::shared_ptr< TGCDatabaseASDToPP > &database)

◆ updateIndividualDatabase()

void MuonTGC_Cabling::TGCCableASDToPP::updateIndividualDatabase ( const int side,
const int sector,
const std::vector< std::string > & diffFile,
std::string_view blockname,
std::shared_ptr< TGCDatabaseASDToPP > & database )
private

Definition at line 386 of file TGCCableASDToPP.cxx.

389 {
390 if (!database) {
391 return;
392 }
393 std::vector<std::vector<int>> info =
394 getUpdateInfo(side, sector, diffFile, blockname);
395
396 if (info.empty()) {
397 return;
398 }
399
400 if (database->isCommon()) {
401 database = std::make_unique<TGCDatabaseASDToPP>(
402 *database,
403 false); // false means this database is not commonly used.
404 }
405
406 for (auto& i : info) {
407 database->update(i);
408 }
409}
std::vector< std::vector< int > > getUpdateInfo(const int side, const int sector, const std::vector< std::string > &diffFile, std::string_view blockname)

Member Data Documentation

◆ m_commonDb

CommonDB MuonTGC_Cabling::TGCCableASDToPP::m_commonDb {{{nullptr}}}
private

Definition at line 88 of file TGCCableASDToPP.h.

88{{{nullptr}}};

◆ m_ESDdb

EndcapSectorDB MuonTGC_Cabling::TGCCableASDToPP::m_ESDdb {}
private

Definition at line 78 of file TGCCableASDToPP.h.

78{};

◆ m_ESIdb

InnerSectorDB MuonTGC_Cabling::TGCCableASDToPP::m_ESIdb {}
private

Definition at line 82 of file TGCCableASDToPP.h.

82{};

◆ m_ESTdb

EndcapSectorDB MuonTGC_Cabling::TGCCableASDToPP::m_ESTdb {}
private

Definition at line 80 of file TGCCableASDToPP.h.

80{};

◆ m_EWDdb

EndcapSectorDB MuonTGC_Cabling::TGCCableASDToPP::m_EWDdb {}
private

Definition at line 77 of file TGCCableASDToPP.h.

77{};

◆ m_EWIdb

InnerSectorDB MuonTGC_Cabling::TGCCableASDToPP::m_EWIdb {}
private

Definition at line 81 of file TGCCableASDToPP.h.

81{};

◆ m_EWTdb

EndcapSectorDB MuonTGC_Cabling::TGCCableASDToPP::m_EWTdb {}
private

Definition at line 79 of file TGCCableASDToPP.h.

79{};

◆ m_FSDdb

ForwardSectorDB MuonTGC_Cabling::TGCCableASDToPP::m_FSDdb {}
private

Definition at line 71 of file TGCCableASDToPP.h.

71{};

◆ m_FSIdb

InnerSectorDB MuonTGC_Cabling::TGCCableASDToPP::m_FSIdb {}
private

Definition at line 75 of file TGCCableASDToPP.h.

75{};

◆ m_FSTdb

ForwardSectorDB MuonTGC_Cabling::TGCCableASDToPP::m_FSTdb {}
private

Definition at line 73 of file TGCCableASDToPP.h.

73{};

◆ m_FWDdb

ForwardSectorDB MuonTGC_Cabling::TGCCableASDToPP::m_FWDdb {}
private

Definition at line 70 of file TGCCableASDToPP.h.

70{};

◆ m_FWIdb

InnerSectorDB MuonTGC_Cabling::TGCCableASDToPP::m_FWIdb {}
private

Definition at line 74 of file TGCCableASDToPP.h.

74{};

◆ m_FWTdb

ForwardSectorDB MuonTGC_Cabling::TGCCableASDToPP::m_FWTdb {}
private

Definition at line 72 of file TGCCableASDToPP.h.

72{};

◆ m_type

CableType MuonTGC_Cabling::TGCCable::m_type {CableType::NoCableType}
privateinherited

Definition at line 37 of file TGCCable.h.

◆ s_stripForward

std::array<int, 10> MuonTGC_Cabling::TGCCableASDToPP::s_stripForward
staticconstexprprivate
Initial value:
{2, 1, 0, 4, 3,
6, 5, 8, 7, 9}

Definition at line 53 of file TGCCableASDToPP.h.

53 {2, 1, 0, 4, 3,
54 6, 5, 8, 7, 9};

The documentation for this class was generated from the following files: