Loading [MathJax]/jax/input/TeX/config.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
TGCCableSLBToHPB.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
12 
13 namespace MuonTGC_Cabling {
14 
16  : TGCCable(TGCCable::SLBToHPB) {
17  m_database[TGCId::Endcap][TGCId::WT] = std::make_unique<TGCDatabasePPToSL>(filename,"SB EWT");
18  m_database[TGCId::Endcap][TGCId::WD] = std::make_unique<TGCDatabasePPToSL>(filename,"SB EWD");
19  m_database[TGCId::Endcap][TGCId::ST] = std::make_unique<TGCDatabasePPToSL>(filename,"SB EST");
20  m_database[TGCId::Endcap][TGCId::SD] = std::make_unique<TGCDatabasePPToSL>(filename,"SB ESD");
21  m_database[TGCId::Forward][TGCId::WT] = std::make_unique<TGCDatabasePPToSL>(filename,"SB FWT");
22  m_database[TGCId::Forward][TGCId::WD] = std::make_unique<TGCDatabasePPToSL>(filename,"SB FWD");
23  m_database[TGCId::Forward][TGCId::ST] = std::make_unique<TGCDatabasePPToSL>(filename,"SB FST");
24  m_database[TGCId::Forward][TGCId::SD] = std::make_unique<TGCDatabasePPToSL>(filename,"SB FSD");
25 }
26 
28  bool orChannel) const {
29  if(channelId){
30  if(channelId->getChannelIdType()==TGCChannelId::ChannelIdType::SLBOut)
31  return getChannelOut(channelId,orChannel);
32  if(channelId->getChannelIdType()==TGCChannelId::ChannelIdType::HPBIn)
33  return getChannelIn(channelId,orChannel);
34  }
35  return nullptr;
36 }
37 
39  if(moduleId){
40  if(moduleId->getModuleIdType()==TGCModuleId::SLB)
41  return getModuleOut(moduleId);
42  if(moduleId->getModuleIdType()==TGCModuleId::HPB)
43  return getModuleIn(moduleId);
44  }
45  return nullptr;
46 }
47 
49  bool orChannel) const {
50  if(orChannel) return nullptr;
51  if(hpbin->isValid()==false) return nullptr;
52  TGCChannelSLBOut* slbout = nullptr;
53 
54  // HPB module
55  TGCModuleId* hpb = hpbin->getModule();
56  if(!hpb) return nullptr;
57 
58  // HPB -> SLB module connection
59  TGCModuleMap* mapId = getModule(hpb);
60  delete hpb;
61  if(!mapId) return nullptr;
62 
63  int numOfBlock = TGCChannelSLBOut::getNumberOfBlock(TGCId::WD);//SD
64  if(numOfBlock==0) {
65  delete mapId;
66  mapId = nullptr;
67  return nullptr;
68  }
69 
71  int slbInBlock = TGCChannelHPBIn::getSlbInBlock();
72 
73  // SLB module
74  TGCModuleId* slb = nullptr;
75  int blockInHPB = hpbin->getBlock();
76  int nSlb = hpbin->getChannel()/(numOfBlock*2); // half block
77  int port = blockInHPB*slbInBlock+nSlb;
78  const int size = mapId->size();
79  for(int i=0;i<size;i++){
80  if(mapId->connector(i)==port){
81  slb = mapId->popModuleId(i);
82  break;
83  }
84  }
85 
86  delete mapId;
87  if(!slb) return nullptr;
88 
89  // HPB ->SLB channel connection
90  int nInSlb = hpbin->getChannel()/(numOfBlock*2); // half block
91  int blockInSlb = nInSlb/2;
92  int nInBlock = nInSlb%2;
93  int channel = (chInBlock/2)*nInBlock;
94 
95  slbout = new TGCChannelSLBOut(slb->getSideType(),
96  slb->getModuleType(),
97  slb->getRegionType(),
98  slb->getSector(),
99  slb->getId(),
100  blockInSlb,
101  channel);
102 
103  delete slb;
104  return slbout;
105 }
106 
108  TGCId::ModuleType moduleType,
109  bool orChannel) const
110 {
111  if(orChannel) return nullptr;
112  if(hpbin->isValid()==false) return nullptr;
113 
114  TGCChannelSLBOut* slbout = nullptr;
115 
116  // HPB module
117  TGCModuleId* hpb = hpbin->getModule();//This function is defined in TGCChannelHPBIn
118  //set current SideType,SignalType...
119  //ChannelID(HPBIn) is set in HPBIn constructor
120  if(!hpb) return nullptr;
121 
122  // HPB -> SLB module connection
123  TGCModuleMap* mapId = getModuleInforHPB(hpb,moduleType);
124  delete hpb;
125  if(!mapId) return nullptr;
126 
127  // need to check
128  int numOfBlock = TGCChannelSLBOut::getNumberOfBlock(moduleType);
129  if(numOfBlock==0) {
130  delete mapId;
131  mapId = nullptr;
132  return nullptr;
133  }
134 
135  int chInBlock = TGCChannelSLBOut::getChannelInBlock(moduleType);
136  int slbInBlock = 0;
137 
138  // SLB module
139  TGCModuleId* slb = nullptr;
140  int blockInHPB = 0;
141  int nSlb = 0; // half block
142  int port = 0; // input position for HPT
143 
144  // HPB ->SLB channel connection
145  int blockInSlb = 0;
146  int posInHpb = 0;
147  int channel = 0;
148  int size = 0;
149  switch(moduleType){
150 
151  case TGCId::WD:
152  case TGCId::SD:
153  slbInBlock = 3;
154  blockInHPB = hpbin->getBlock();
155  nSlb = hpbin->getChannel()/(numOfBlock*2);
156  port = blockInHPB*slbInBlock+nSlb;
157  size = mapId->size();
158  for(int i=0;i<size;i++){
159  if(mapId->connector(i)==port){
160  slb = mapId->popModuleId(i);
161  break;
162  }
163  }
164  blockInSlb = (hpbin->getChannel() - nSlb*(numOfBlock*2))/2;
165  posInHpb = (hpbin->getChannel() - (numOfBlock*2)*nSlb)%2;
166  channel = (chInBlock/2)*posInHpb;
167  break;
168 
169  case TGCId::WT:
170  slbInBlock = 2;
171  blockInHPB = hpbin->getBlock();
172  nSlb = hpbin->getChannel()/(numOfBlock*2);
173  port = blockInHPB*slbInBlock+nSlb;
174  size = mapId->size();
175  for(int i=0;i<size;i++){
176  if(mapId->connector(i)== -1*port){//triplet: - sign
177  slb = mapId->popModuleId(i);
178  break;
179  }
180  }
181  blockInSlb = (hpbin->getChannel() - nSlb*(numOfBlock*2))/2;
182  posInHpb = (hpbin->getChannel() - (numOfBlock*2)*nSlb)%2;
183  channel = (chInBlock/2)*posInHpb;
184  break;
185 
186  case TGCId::ST:
187  blockInHPB = hpbin->getBlock();
188  if(blockInHPB==0 && hpbin->getChannel()<numOfBlock) port=1;
189  else port=2;
190  size = mapId->size();
191  for(int i=0;i<size;i++){
192  if(mapId->connector(i)== -1*port){//triplet: - sign
193  slb = mapId->popModuleId(i);
194  break;
195  }
196  }
197  blockInSlb = (hpbin->getChannel())%numOfBlock;
198  if(blockInHPB == 1 && hpbin->getChannel() >= numOfBlock) blockInSlb = blockInSlb + numOfBlock/2;
199  channel = 0;
200  break;
201 
202  default:
203  break;
204 
205  }
206 
207  delete mapId; mapId = nullptr;
208  if(!slb) return nullptr;
209 
210  const int offset =6; // offset to get center of block
211  channel += offset;
212 
213  int SLBID = slb->getId();
214  if((chInBlock*blockInSlb+channel)>chInBlock*numOfBlock){
215  SLBID++;
216  channel = channel%chInBlock;
217  blockInSlb = 0;
218  } else if( channel > chInBlock){
219  channel = channel%chInBlock;
220  blockInSlb++;
221  }
222 
223  slbout = new TGCChannelSLBOut(slb->getSideType(),
224  moduleType,
225  slb->getRegionType(),
226  slb->getSector(),
227  SLBID,
228  blockInSlb,
229  channel );
230 
231  delete slb;
232  return slbout;
233 }
234 
235 
237  bool orChannel) const {
238  if(orChannel) return nullptr;
239  if(slbout->isValid()==false) return nullptr;
240  if(slbout->getMultipletType()==TGCId::Triplet) return nullptr;
241  TGCChannelHPBIn* hpbin = nullptr;
242 
243  // SLB module
244  TGCModuleId* slb = slbout->getModule();
245  if(!slb) return nullptr;
246 
247  // SLB -> HPB module connection
248  TGCModuleMap* mapId = getModule(slb);
249  delete slb;
250  if(!mapId) return nullptr;
251 
252  // HPB module
253  int port = mapId->connector(0);
254  TGCModuleId* hpb = mapId->popModuleId(0);
255  delete mapId;
256  if(!hpb) return nullptr;
257 
258  int chInBlock = TGCChannelSLBOut::getChannelInBlock(slbout->getModuleType());
259  if(chInBlock<=1) {
260  delete hpb;
261  hpb = nullptr;
262  return nullptr;
263  }
264  int slbInBlock = TGCChannelHPBIn::getSlbInBlock();
265 
266  // SLB ->HPB channel connection
267  int block = port/slbInBlock;
268  int hitId = (port%slbInBlock)*2+slbout->getBlock();
269  int pos = slbout->getChannel()/(chInBlock/2);
270  int channel = hitId*2 + pos;
271 
272  hpbin = new TGCChannelHPBIn(hpb->getSideType(),
273  hpb->getSignalType(),
274  hpb->getRegionType(),
275  hpb->getSector(),
276  hpb->getId(),
277  block,
278  channel);
279  delete hpb;
280 
281  return hpbin;
282 }
283 
285  if(hpb->isValid()==false) return nullptr;
286  const int hpbId = hpb->getId();
287 
290  if(hpb->getSignalType()==TGCId::Wire){
291  doublet = TGCId::WD;
292  triplet = TGCId::WT;
293  }
294  if(hpb->getSignalType()==TGCId::Strip){
295  doublet = TGCId::SD;
296  triplet = TGCId::ST;
297  }
298 
299  if(doublet==TGCId::NoModuleType || triplet==TGCId::NoModuleType) {
300  return nullptr;
301  }
302 
303  TGCDatabase* doubletP = m_database[hpb->getRegionType()][doublet].get();
304  TGCDatabase* tripletP = m_database[hpb->getRegionType()][triplet].get();
305 
306  TGCModuleMap* mapId = nullptr;
307  const int doubletMaxEntry = doubletP->getMaxEntry();
308  for(int i=0; i<doubletMaxEntry; i++){
309  if(doubletP->getEntry(i,1)==hpbId)
310  {
311  int id = doubletP->getEntry(i,0);
312  int block = doubletP->getEntry(i,2);
313  TGCModuleSLB* slb = new TGCModuleSLB(hpb->getSideType(),
314  doublet,
315  hpb->getRegionType(),
316  hpb->getSector(),
317  id);
318  if(mapId==nullptr) mapId = new TGCModuleMap();
319  mapId->insert(block,slb);
320  }
321  }
322  const int tripletMaxEntry = tripletP->getMaxEntry();
323  for(int i=0; i<tripletMaxEntry; i++){
324  if(tripletP->getEntry(i,1)==hpbId)
325  {
326  int id = tripletP->getEntry(i,0);
327  int block = -tripletP->getEntry(i,2);
328  TGCModuleSLB* slb = new TGCModuleSLB(hpb->getSideType(),
329  triplet,
330  hpb->getRegionType(),
331  hpb->getSector(),
332  id);
333  if(mapId==nullptr) mapId = new TGCModuleMap();
334  mapId->insert(block,slb);
335  }
336  }
337 
338  return mapId;
339 }
340 
342  TGCId::ModuleType moduleType) const {
343  if(hpb->isValid()==false) return nullptr;
344 
345  const int hpbId = hpb->getId();
346 
347  TGCDatabase* databaseP = m_database[hpb->getRegionType()][moduleType].get();
348 
349  TGCModuleMap* mapId = nullptr;
350  const int MaxEntry = databaseP->getMaxEntry();
351  for(int i=0; i<MaxEntry; i++){
352  if(databaseP->getEntry(i,1)==hpbId)
353  {
354  int id = databaseP->getEntry(i,0);
355  int block = -100;
356  switch(moduleType){
357  case TGCId::WD:
358  case TGCId::SD:
359  block = databaseP->getEntry(i,2);
360  break;
361 
362  case TGCId::WT:
363  case TGCId::ST:
364  block = -1*databaseP->getEntry(i,2);// check - sign
365  break;
366 
367  default:
368  break;
369  }
370  TGCModuleSLB* slb = new TGCModuleSLB(hpb->getSideType(),
371  moduleType,
372  hpb->getRegionType(),
373  hpb->getSector(),
374  id);
375  if(mapId==nullptr) mapId = new TGCModuleMap();
376  mapId->insert(block,slb);
377  }
378  }
379 
380  return mapId;
381 }
382 
384  if(slb->isValid()==false) return nullptr;
385 
386  const int slbId = slb->getId();
387 
388  TGCDatabase* databaseP =m_database[slb->getRegionType()][slb->getModuleType()].get();
389 
390  TGCModuleMap* mapId = nullptr;
391  const int MaxEntry = databaseP->getMaxEntry();
392  for(int i=0; i<MaxEntry; i++){
393  if(databaseP->getEntry(i,0)==slbId) {
394  int id = databaseP->getEntry(i,1);
395  int block = databaseP->getEntry(i,2);
396  if(slb->getMultipletType()==TGCId::Triplet)
397  block *=-1;
398 
399  TGCModuleHPB* hpb = new TGCModuleHPB(slb->getSideType(),
400  slb->getSignalType(),
401  slb->getRegionType(),
402  slb->getSector(),
403  id);
404 
405  mapId = new TGCModuleMap();
406  mapId->insert(block,hpb);
407  break;
408  }
409  }
410 
411  return mapId;
412 }
413 
414 } //end of namespace
TGCChannelHPBIn.h
MuonTGC_Cabling::TGCModuleId::getModuleIdType
ModuleIdType getModuleIdType(void) const
Definition: TGCModuleId.h:30
MuonTGC_Cabling::TGCChannelId::isValid
virtual bool isValid() const
Definition: TGCChannelId.h:34
MuonTGC_Cabling::TGCId::getMultipletType
MultipletType getMultipletType(void) const
Definition: TGCId.h:124
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:24
MuonTGC_Cabling::TGCId::getSideType
SideType getSideType(void) const
Definition: TGCId.h:121
MuonTGC_Cabling::TGCId::getSignalType
SignalType getSignalType(void) const
Definition: TGCId.h:123
MuonTGC_Cabling::TGCId::getRegionType
RegionType getRegionType(void) const
Definition: TGCId.h:125
MuonTGC_Cabling::TGCCableSLBToHPB::getModuleInforHPB
virtual TGCModuleMap * getModuleInforHPB(const TGCModuleId *hpb, TGCId::ModuleType moduleType) const
Definition: TGCCableSLBToHPB.cxx:341
MuonTGC_Cabling::TGCModuleSLB
Definition: TGCModuleSLB.h:14
MuonTGC_Cabling::TGCId::ModuleType
ModuleType
Definition: TGCId.h:47
MuonTGC_Cabling::TGCModuleId::SLB
@ SLB
Definition: TGCModuleId.h:16
MuonTGC_Cabling::TGCId::getModuleType
ModuleType getModuleType(void) const
Definition: TGCId.h:122
MuonTGC_Cabling::TGCChannelSLBOut::getNumberOfBlock
static int getNumberOfBlock(TGCId::ModuleType moduleType)
Definition: TGCChannelSLBOut.cxx:72
MuonTGC_Cabling::TGCChannelId::ChannelIdType::HPBIn
@ HPBIn
MuonTGC_Cabling::TGCModuleMap::connector
int connector(int entry)
Definition: TGCModuleMap.cxx:14
MuonTGC_Cabling::TGCChannelId::getModule
virtual TGCModuleId * getModule(void) const
Definition: TGCChannelId.h:30
MuonTGC_Cabling::TGCChannelSLBOut
Definition: TGCChannelSLBOut.h:14
MuonTGC_Cabling::TGCModuleMap
Definition: TGCModuleMap.h:16
MuonTGC_Cabling::TGCId::SD
@ SD
Definition: TGCId.h:47
MuonTGC_Cabling::TGCChannelId::getBlock
int getBlock() const
Definition: TGCChannelId.cxx:28
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
MuonTGC_Cabling::TGCDatabase
Definition: TGCDatabase.h:15
MuonTGC_Cabling::TGCModuleHPB
Definition: TGCModuleHPB.h:14
MuonTGC_Cabling::TGCDatabase::getEntry
virtual int getEntry(int entry, int column) const
Definition: TGCDatabase.cxx:28
lumiFormat.i
int i
Definition: lumiFormat.py:85
MuonTGC_Cabling::TGCCableSLBToHPB::getChannelInforHPB
TGCChannelId * getChannelInforHPB(const TGCChannelId *hpbin, TGCId::ModuleType moduleType, bool orChannel=false) const
Definition: TGCCableSLBToHPB.cxx:107
MuonTGC_Cabling::TGCCableSLBToHPB::getModule
virtual TGCModuleMap * getModule(const TGCModuleId *moduleId) const
Definition: TGCCableSLBToHPB.cxx:38
MuonTGC_Cabling::TGCId::WT
@ WT
Definition: TGCId.h:47
MuonTGC_Cabling
Definition: TGCCable.h:13
MuonTGC_Cabling::TGCDatabase::getMaxEntry
virtual int getMaxEntry(void) const
Definition: TGCDatabase.cxx:36
MuonTGC_Cabling::TGCId::getId
int getId() const
Definition: TGCId.h:131
MuonTGC_Cabling::TGCCableSLBToHPB::getChannelIn
virtual TGCChannelId * getChannelIn(const TGCChannelId *hpbin, bool orChannel=false) const
Definition: TGCCableSLBToHPB.cxx:48
MuonTGC_Cabling::TGCId::Strip
@ Strip
Definition: TGCId.h:49
TGCCableSLBToHPB.h
MuonTGC_Cabling::TGCCableSLBToHPB::m_database
std::array< std::array< std::unique_ptr< TGCDatabase >, TGCId::MaxModuleType >, TGCId::MaxRegionType > m_database
Definition: TGCCableSLBToHPB.h:41
MuonTGC_Cabling::TGCCable
Definition: TGCCable.h:16
MuonTGC_Cabling::TGCId::WD
@ WD
Definition: TGCId.h:47
CaloCondBlobAlgs_fillNoiseFromASCII.channelId
channelId
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:122
TGCDatabasePPToSL.h
MuonTGC_Cabling::TGCId::Endcap
@ Endcap
Definition: TGCId.h:53
MuonTGC_Cabling::TGCCableSLBToHPB::getChannel
virtual TGCChannelId * getChannel(const TGCChannelId *channelId, bool orChannel=false) const
Definition: TGCCableSLBToHPB.cxx:27
MuonTGC_Cabling::TGCModuleId::HPB
@ HPB
Definition: TGCModuleId.h:16
MuonTGC_Cabling::TGCModuleMap::insert
void insert(int connector, TGCModuleId *moduleId)
Definition: TGCModuleMap.cxx:34
MuonTGC_Cabling::TGCChannelHPBIn
Definition: TGCChannelHPBIn.h:14
MuonTGC_Cabling::TGCId::NoModuleType
@ NoModuleType
Definition: TGCId.h:47
MuonTGC_Cabling::TGCChannelHPBIn::getSlbInBlock
static int getSlbInBlock(void)
Definition: TGCChannelHPBIn.cxx:70
MuonTGC_Cabling::TGCModuleMap::popModuleId
TGCModuleId * popModuleId(int entry)
Definition: TGCModuleMap.cxx:26
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
MuonTGC_Cabling::TGCCableSLBToHPB::TGCCableSLBToHPB
TGCCableSLBToHPB(void)
Definition: TGCCableSLBToHPB.h:33
MuonTGC_Cabling::TGCId::ST
@ ST
Definition: TGCId.h:47
MuonTGC_Cabling::TGCCableSLBToHPB::getChannelOut
virtual TGCChannelId * getChannelOut(const TGCChannelId *slbout, bool orChannel=false) const
Definition: TGCCableSLBToHPB.cxx:236
TGCChannelSLBOut.h
MuonTGC_Cabling::TGCId::getSector
virtual int getSector() const
Definition: TGCId.h:129
MuonTGC_Cabling::TGCChannelId
Definition: TGCChannelId.h:15
MuonTGC_Cabling::TGCCableSLBToHPB::getModuleOut
virtual TGCModuleMap * getModuleOut(const TGCModuleId *slb) const
Definition: TGCCableSLBToHPB.cxx:383
convertTimingResiduals.offset
offset
Definition: convertTimingResiduals.py:71
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
MuonTGC_Cabling::TGCCableSLBToHPB::getModuleIn
virtual TGCModuleMap * getModuleIn(const TGCModuleId *hpb) const
Definition: TGCCableSLBToHPB.cxx:284
MuonTGC_Cabling::TGCId::Wire
@ Wire
Definition: TGCId.h:49
MuonTGC_Cabling::TGCModuleMap::size
int size(void)
Definition: TGCModuleMap.cxx:48
MuonTGC_Cabling::TGCId::Triplet
@ Triplet
Definition: TGCId.h:51
MuonTGC_Cabling::TGCChannelSLBOut::getChannelInBlock
static int getChannelInBlock(TGCId::ModuleType moduleType)
Definition: TGCChannelSLBOut.cxx:104
MuonTGC_Cabling::TGCModuleId
Definition: TGCModuleId.h:13
TGCModuleSLB.h
MuonTGC_Cabling::TGCId::Forward
@ Forward
Definition: TGCId.h:53
MuonTGC_Cabling::TGCChannelId::ChannelIdType::SLBOut
@ SLBOut
MuonTGC_Cabling::TGCModuleId::isValid
virtual bool isValid(void) const
Definition: TGCModuleId.h:34
MuonTGC_Cabling::TGCChannelId::getChannel
int getChannel() const
Definition: TGCChannelId.cxx:29
TGCModuleHPB.h