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< TGCChannelIdgetChannel (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< TGCChannelIdgetChannelIn (const TGCChannelId &ppin, bool orChannel=false) const
std::unique_ptr< TGCChannelIdgetChannelOut (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, const std::string &blockname)
TGCDatabaseASDToPPgetDatabase (const int side, const int region, const int sector, const int module) const
void updateIndividualDatabase (const int side, const int sector, const std::vector< std::string > &diffFile, const std::string &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, 9 > s_stripForward

Detailed Description

Definition at line 18 of file TGCCableASDToPP.h.

Member Typedef Documentation

◆ CommonDB

Initial value:
std::array<
std::array<std::shared_ptr<TGCDatabaseASDToPP>, TGCId::MaxModuleType>,

Pointers of common databases are recorded in this array.

Definition at line 83 of file TGCCableASDToPP.h.

◆ EndcapSectorDB

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

Definition at line 63 of file TGCCableASDToPP.h.

◆ ForwardSectorDB

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

Definition at line 55 of file TGCCableASDToPP.h.

◆ InnerSectorDB

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

Definition at line 59 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 281 of file TGCCableASDToPP.cxx.

282 {
283 if (channelId.getChannelIdType() == TGCChannelId::ChannelIdType::ASDOut) {
284 return getChannelOut(channelId, orChannel);
285 }
286 if (channelId.getChannelIdType() == TGCChannelId::ChannelIdType::PPIn) {
287 return getChannelIn(channelId, orChannel);
288 }
289
290 return nullptr;
291}
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 293 of file TGCCableASDToPP.cxx.

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

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

◆ getDatabase()

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

Definition at line 195 of file TGCCableASDToPP.cxx.

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

◆ getUpdateInfo()

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

Definition at line 133 of file TGCCableASDToPP.cxx.

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

◆ 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::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::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, const std::string &blockname, std::shared_ptr< TGCDatabaseASDToPP > &database)

◆ updateIndividualDatabase()

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

Definition at line 387 of file TGCCableASDToPP.cxx.

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

Member Data Documentation

◆ m_commonDb

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

Definition at line 86 of file TGCCableASDToPP.h.

86{{{nullptr}}};

◆ m_ESDdb

EndcapSectorDB MuonTGC_Cabling::TGCCableASDToPP::m_ESDdb {}
private

Definition at line 76 of file TGCCableASDToPP.h.

76{};

◆ m_ESIdb

InnerSectorDB MuonTGC_Cabling::TGCCableASDToPP::m_ESIdb {}
private

Definition at line 80 of file TGCCableASDToPP.h.

80{};

◆ m_ESTdb

EndcapSectorDB MuonTGC_Cabling::TGCCableASDToPP::m_ESTdb {}
private

Definition at line 78 of file TGCCableASDToPP.h.

78{};

◆ m_EWDdb

EndcapSectorDB MuonTGC_Cabling::TGCCableASDToPP::m_EWDdb {}
private

Definition at line 75 of file TGCCableASDToPP.h.

75{};

◆ m_EWIdb

InnerSectorDB MuonTGC_Cabling::TGCCableASDToPP::m_EWIdb {}
private

Definition at line 79 of file TGCCableASDToPP.h.

79{};

◆ m_EWTdb

EndcapSectorDB MuonTGC_Cabling::TGCCableASDToPP::m_EWTdb {}
private

Definition at line 77 of file TGCCableASDToPP.h.

77{};

◆ m_FSDdb

ForwardSectorDB MuonTGC_Cabling::TGCCableASDToPP::m_FSDdb {}
private

Definition at line 69 of file TGCCableASDToPP.h.

69{};

◆ m_FSIdb

InnerSectorDB MuonTGC_Cabling::TGCCableASDToPP::m_FSIdb {}
private

Definition at line 73 of file TGCCableASDToPP.h.

73{};

◆ m_FSTdb

ForwardSectorDB MuonTGC_Cabling::TGCCableASDToPP::m_FSTdb {}
private

Definition at line 71 of file TGCCableASDToPP.h.

71{};

◆ m_FWDdb

ForwardSectorDB MuonTGC_Cabling::TGCCableASDToPP::m_FWDdb {}
private

Definition at line 68 of file TGCCableASDToPP.h.

68{};

◆ m_FWIdb

InnerSectorDB MuonTGC_Cabling::TGCCableASDToPP::m_FWIdb {}
private

Definition at line 72 of file TGCCableASDToPP.h.

72{};

◆ m_FWTdb

ForwardSectorDB MuonTGC_Cabling::TGCCableASDToPP::m_FWTdb {}
private

Definition at line 70 of file TGCCableASDToPP.h.

70{};

◆ m_type

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

Definition at line 37 of file TGCCable.h.

◆ s_stripForward

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

Definition at line 51 of file TGCCableASDToPP.h.

51 {2, 1, 0, 4, 3,
52 6, 5, 8, 7};

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