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