ATLAS Offline Software
TGCCableInASD.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
10 
11 namespace MuonTGC_Cabling {
12 
13 // Constructor & Destructor
15  : TGCCable(TGCCable::InASD)
16 {
18  new TGCDatabaseASDToPP(filename,"EWD");
20  new TGCDatabaseASDToPP(filename,"EWT");
22  new TGCDatabaseASDToPP(filename,"ESD");
24  new TGCDatabaseASDToPP(filename,"EST");
26  new TGCDatabaseASDToPP(filename,"EWI");
28  new TGCDatabaseASDToPP(filename,"ESI");
30  new TGCDatabaseASDToPP(filename,"FWD");
32  new TGCDatabaseASDToPP(filename,"FWT");
34  new TGCDatabaseASDToPP(filename,"FSD");
36  new TGCDatabaseASDToPP(filename,"FST");
38  new TGCDatabaseASDToPP(filename,"FWI");
40  new TGCDatabaseASDToPP(filename,"FSI");
41 }
42 
44 {
57 }
58 
60  bool orChannel) const {
61  if(channelId){
62  if(channelId->getChannelIdType()==TGCChannelId::ChannelIdType::ASDIn)
63  return getChannelOut(channelId,orChannel);
64  if(channelId->getChannelIdType()==TGCChannelId::ChannelIdType::ASDOut)
65  return getChannelIn(channelId,orChannel);
66  }
67  return nullptr;
68 }
69 
71  bool orChannel) const {
72  if(orChannel) return nullptr;
73  if(asdout->isValid()==false) return nullptr;
74 
75  TGCDatabase* databaseP =
76  m_database[asdout->getRegionType()][asdout->getModuleType()];
77 
78  TGCChannelASDIn* asdin = nullptr;
79 
80  // sector ASDIn [1..48, 1..24], ASDOut [0..47, 0..23]
81  int sector;
82  if(asdout->isEndcap() && !asdout->isInner()){
83  sector = asdout->getSector()-1;
84  if(sector<=0) sector += TGCId::NUM_ENDCAP_SECTOR;
85  } else {
86  sector = asdout->getSector();
87  if(sector<=0) sector += TGCId::NUM_FORWARD_SECTOR;
88  }
89 
90  // chamber ASDIn [1(F),1,2,3,4,5(E)], ASDOut [0(F),4,3,2,1,0(E)]
91  int chamber;
92  if(asdout->isEndcap() && !asdout->isInner()){
93  chamber = 5-asdout->getChamber();
94  } else {
95  chamber = asdout->getChamber()+1;
96  }
97 
98  int channel=-1;
99  // channel ASDIn [1..32(S),1..n(W chamber)], ASDOut [0..31(S),n..0(W sector)]
100  if(asdout->isWire()){
101  // Endcap Triplet chamberId start from 1 in ASDOut
102  int dbChamber = asdout->getChamber();
103  if(asdout->isEndcap() && asdout->isTriplet()) dbChamber = dbChamber-1;
104  int indexIn[TGCDatabaseASDToPP::NIndexIn] =
105  {asdout->getLayer(), dbChamber, asdout->getChannel()};
106  int i = databaseP->getIndexDBIn(indexIn);
107  if(i<0) return nullptr;
108  channel = databaseP->getEntry(i,7)+1;
109  } else {
110  if(( asdout->isBackward() && asdout->isAside()) ||
111  (!asdout->isBackward() && asdout->isCside()))
112  channel = 32-asdout->getChannel();
113  else
114  channel = asdout->getChannel()+1;
115  }
116  if(channel==-1) return nullptr;
117 
118  asdin = new TGCChannelASDIn(asdout->getSideType(),
119  asdout->getSignalType(),
120  asdout->getRegionType(),
121  sector,
122  asdout->getLayer(),
123  chamber,
124  channel);
125 
126  return asdin;
127 }
128 
130  bool orChannel) const {
131  if(orChannel) return nullptr;
132  if(asdin->isValid()==false) return nullptr;
133 
134  const bool asdinisEndcap = asdin->isEndcap();
135  const bool asdinisTriplet = asdin->isTriplet();
136  const int asdinLayer = asdin->getLayer();
137  const int asdinChannel = asdin->getChannel();
138 
139  TGCDatabase* databaseP =
140  m_database[asdin->getRegionType()][asdin->getModuleType()];
141 
142  TGCChannelASDOut* asdout = nullptr;
143 
144  // sector ASDIn [1..48, 1..24], ASDOut [2..47.0.1, 1..23.0]
145  int sector;
146  if(asdin->isEndcap()) {
147  if(!asdin->isInner()){
148  // Endcap
149  sector = (asdin->getSector()+1) % TGCId::NUM_ENDCAP_SECTOR;
150  } else {
151  // EI
152  sector = (asdin->getSector()) % TGCId::NUM_INNER_SECTOR;
153  }
154  } else {
155  if(!asdin->isInner()){
156  // Forward
157  sector = (asdin->getSector()) % TGCId::NUM_FORWARD_SECTOR;
158  } else {
159  // FI
160  sector = (asdin->getSector()) % TGCId::NUM_INNER_SECTOR;
161  }
162  }
163 
164  // chamber ASDIn [1(F),1,2,3,4,5(E)], ASDOut [0(F),4,3,2,1,0(E)]
165  int chamber;
166  if(asdin->isEndcap()&&!asdin->isInner()){
167  chamber = 5-asdin->getChamber();
168  } else {
169  chamber = asdin->getChamber()-1;
170  }
171 
172  int channel=-1;
173  // channel ASDIn [1..32(S),1..n(W chamber)], ASDOut [0..31(S),n..0(W sector)]
174  if(asdin->isWire()){
175  const int MaxEntry = databaseP->getMaxEntry();
176  for(int i=0; i<MaxEntry; i++){
177  // Endcap Triplet chamberId start from 1 in ASDOut
178  int dbChamber = chamber;
179  if(asdinisEndcap&&asdinisTriplet)
180  dbChamber = dbChamber-1;
181 
182  int dbChannel = asdinChannel-1;
183  if(databaseP->getEntry(i,7)==dbChannel&&
184  databaseP->getEntry(i,1)==dbChamber&&
185  databaseP->getEntry(i,0)==asdinLayer)
186  {
187  channel = databaseP->getEntry(i,6);
188  break;
189  }
190  }
191  } else {
192  // asdin->isBackward() can not be used because this method rely on sector number for asdout
193  bool is_Backward = false;
194  if(asdin->isEndcap()){
195  if(!asdin->isInner()) {
196  if(asdin->isAside()) is_Backward = (sector%2==1);
197  else is_Backward = (sector%2==0);
198  } else {
199  // EI
200  // Special case of EI11
201  if(sector == 15) {
202  if(asdin->isAside()) is_Backward = false;
203  else is_Backward = true;
204  } else if(sector == 16) {
205  if(asdin->isAside()) is_Backward = true;
206  else is_Backward = false;
207  } else {
208  // A-side phi0 F: phi1 F: phi2 B
209  // C-side phi0 B: phi1 B: phi2 F
210  if(asdin->isAside()) is_Backward = (sector%3==2);
211  else is_Backward = (sector%3!=2);
212  }
213  }
214  } else {
215  if(asdin->isAside()) is_Backward = true; //All Backward for A-side
216  }
217  if(( is_Backward && asdin->isAside()) ||
218  (!is_Backward && asdin->isCside()))
219  channel = 32-asdin->getChannel();
220  else
221  channel = asdin->getChannel()-1;
222  }
223  if(channel==-1) return nullptr;
224 
225  asdout = new TGCChannelASDOut(asdin->getSideType(),
226  asdin->getSignalType(),
227  asdin->getRegionType(),
228  sector,
229  asdin->getLayer(),
230  chamber,
231  channel);
232 
233  return asdout;
234 }
235 
236 
237 } //end of namespace
MuonTGC_Cabling::TGCId::getChamber
int getChamber() const
Definition: TGCId.h:131
MuonTGC_Cabling::TGCId::isEndcap
bool isEndcap() const
Definition: TGCId.h:142
MuonTGC_Cabling::TGCChannelId::isValid
virtual bool isValid() const
Definition: TGCChannelId.h:34
MuonTGC_Cabling::TGCId::SI
@ SI
Definition: TGCId.h:47
TGCChannelASDOut.h
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:24
MuonTGC_Cabling::TGCId::getSideType
SideType getSideType(void) const
Definition: TGCId.h:122
MuonTGC_Cabling::TGCId::getSignalType
SignalType getSignalType(void) const
Definition: TGCId.h:124
MuonTGC_Cabling::TGCCableInASD::getChannelOut
virtual TGCChannelId * getChannelOut(const TGCChannelId *asdin, bool orChannel=false) const
Definition: TGCCableInASD.cxx:129
calibdata.chamber
chamber
Definition: calibdata.py:32
MuonTGC_Cabling::TGCChannelASDIn
Definition: TGCChannelASDIn.h:14
MuonTGC_Cabling::TGCId::getRegionType
RegionType getRegionType(void) const
Definition: TGCId.h:126
MuonTGC_Cabling::TGCChannelId::ChannelIdType::ASDOut
@ ASDOut
MuonTGC_Cabling::TGCId::isAside
bool isAside() const
Definition: TGCId.h:134
MuonTGC_Cabling::TGCId::getModuleType
ModuleType getModuleType(void) const
Definition: TGCId.h:123
MuonTGC_Cabling::TGCDatabaseASDToPP::NIndexIn
@ NIndexIn
Definition: TGCDatabaseASDToPP.h:31
MuonTGC_Cabling::TGCChannelId::ChannelIdType::ASDIn
@ ASDIn
MuonTGC_Cabling::TGCId::NUM_INNER_SECTOR
static constexpr int NUM_INNER_SECTOR
Definition: TGCId.h:42
MuonTGC_Cabling::TGCDatabaseASDToPP
Definition: TGCDatabaseASDToPP.h:14
MuonTGC_Cabling::TGCCableInASD::getChannelIn
virtual TGCChannelId * getChannelIn(const TGCChannelId *asdout, bool orChannel=false) const
Definition: TGCCableInASD.cxx:70
MuonTGC_Cabling::TGCId::isTriplet
bool isTriplet() const
Definition: TGCId.h:138
MuonTGC_Cabling::TGCId::SD
@ SD
Definition: TGCId.h:47
MuonTGC_Cabling::TGCId::NUM_FORWARD_SECTOR
static constexpr int NUM_FORWARD_SECTOR
Definition: TGCId.h:41
MuonTGC_Cabling::TGCId::isBackward
bool isBackward() const
Definition: TGCId.cxx:39
MuonTGC_Cabling::TGCDatabase
Definition: TGCDatabase.h:15
MuonTGC_Cabling::TGCCableInASD::getChannel
virtual TGCChannelId * getChannel(const TGCChannelId *channelId, bool orChannel=false) const
Definition: TGCCableInASD.cxx:59
MuonTGC_Cabling::TGCDatabase::getIndexDBIn
virtual int getIndexDBIn(int *indexIn) const
Definition: TGCDatabase.cxx:52
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::TGCCableInASD::TGCCableInASD
TGCCableInASD(void)
Definition: TGCCableInASD.h:31
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::TGCCable
Definition: TGCCable.h:16
MuonTGC_Cabling::TGCId::WD
@ WD
Definition: TGCId.h:47
CaloCondBlobAlgs_fillNoiseFromASCII.channelId
channelId
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:122
MuonTGC_Cabling::TGCId::Endcap
@ Endcap
Definition: TGCId.h:53
MuonTGC_Cabling::TGCId::WI
@ WI
Definition: TGCId.h:47
TGCCableInASD.h
MuonTGC_Cabling::TGCId::ST
@ ST
Definition: TGCId.h:47
MuonTGC_Cabling::TGCId::isWire
bool isWire() const
Definition: TGCId.h:137
MuonTGC_Cabling::TGCId::getSector
virtual int getSector() const
Definition: TGCId.h:130
MuonTGC_Cabling::TGCId::isCside
bool isCside() const
Definition: TGCId.h:135
MuonTGC_Cabling::TGCCableInASD::m_database
TGCDatabase * m_database[TGCId::MaxRegionType][TGCId::MaxModuleType]
Definition: TGCCableInASD.h:36
MuonTGC_Cabling::TGCId::isInner
bool isInner() const
Definition: TGCId.h:140
MuonTGC_Cabling::TGCChannelId
Definition: TGCChannelId.h:15
MuonTGC_Cabling::TGCId::NUM_ENDCAP_SECTOR
static constexpr int NUM_ENDCAP_SECTOR
Definition: TGCId.h:40
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
MuonTGC_Cabling::TGCChannelId::getLayer
int getLayer() const
Definition: TGCChannelId.cxx:27
MuonTGC_Cabling::TGCChannelASDOut
Definition: TGCChannelASDOut.h:12
TGCDatabaseASDToPP.h
MuonTGC_Cabling::TGCId::Forward
@ Forward
Definition: TGCId.h:53
MuonTGC_Cabling::TGCChannelId::getChannel
int getChannel() const
Definition: TGCChannelId.cxx:29
MuonTGC_Cabling::TGCCableInASD::~TGCCableInASD
virtual ~TGCCableInASD(void)
Definition: TGCCableInASD.cxx:43
TGCChannelASDIn.h