ATLAS Offline Software
TGCConnectionASDToPP.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include <iostream>
6 #include <fstream>
7 #include <sstream>
8 #include <ctype.h>
9 #include <string>
10 
14 
16 
17 
18 namespace LVL1TGCTrigger {
19 
20 int TGCConnectionASDToPP::getConnection(const int /*sideId*/, const int layer, const int chamber,
21  const int line, int* pp, int* connector, int* channel) const
22 {
23  int i;
24  for( i=0; i<m_totalNumberOfChannel; i+=1){
25  // wiregroupID assign in ASDOut and ASD2PP.db are different.
26  if((m_layerId[i]==layer)&&(m_chamberId[i]==chamber)&&(m_lineId[i]==line)){
27  // if((m_layerId[i]==layer)&&(m_lineId[i]==line)){
28  *pp = m_PPId[i];
29  *connector = m_connectorId[i];
30  *channel = m_channelId[i];
31  return 0;
32  }
33  }
34  *pp=-2;
35  *connector=-2;
36  *channel=-2;
37  return -1;
38 }
39 
41 {
42 #ifdef TGCCOUT
43  int i;
44  std::cout << "TGCConnectionASDToPP::dump "<<m_totalNumberOfChannel<< std::endl;
45  std::cout << "layerId chamberID line(WIRE) PPID ConnectorID" << std::endl;
46  for( i=0; i<m_totalNumberOfChannel; i+=1)
47  std::cout<<m_layerId[i]<<" "<<m_chamberId[i]<<" "<<m_lineId[i]<<" "<<m_PPId[i]<<" "<<m_connectorId[i]<<" "<<m_channelId[i]<< std::endl;
48 #endif
49 }
50 
51 
53  TGCForwardBackwardType forwardBackward)
54 {
55  this->m_type = type;
56  this->m_forwardBackward = forwardBackward;
57 
58  enum { BufferSize = 1024 };
59  char buf[BufferSize];
60 
61  std::string fn, fullName ;
62 // fn = "ASD2PP.db" ;
64 
66  if( fullName.length() == 0 )
67  fullName = PathResolver::find_file(fn, "DATAPATH");
68  std::ifstream file(fullName.c_str() ,std::ios::in);
69  if (!file) return false;
70 
71  std::string PPType;
72  while(file.getline(buf,BufferSize)){
73  if((buf[0]=='E')||(buf[0]=='F')){
74 
75  std::istringstream line(buf);
76  int nChannel;
77  line >> PPType >> nChannel;
78  // find a entry matches in region and Patch Panel m_type.
79  if(((region == TGCRegionType::ENDCAP) &&
80  ( (PPType=="EWT"&&m_type==TGCSector::WTPP)||(PPType=="EWD"&&m_type==TGCSector::WDPP)
81  ||(PPType=="EST"&&m_type==TGCSector::STPP)||(PPType=="ESD"&&m_type==TGCSector::SDPP)
82  ||(PPType=="EWI"&&m_type==TGCSector::WIPP)||(PPType=="ESI"&&m_type==TGCSector::SIPP) ) )||
83  ((region == TGCRegionType::FORWARD) &&
84  ( (PPType=="FWT"&&m_type==TGCSector::WTPP)||(PPType=="FWD"&&m_type==TGCSector::WDPP)
85  ||(PPType=="FST"&&m_type==TGCSector::STPP)||(PPType=="FSD"&&m_type==TGCSector::SDPP)
86  ||(PPType=="FWI"&&m_type==TGCSector::WIPP)||(PPType=="FSI"&&m_type==TGCSector::SIPP) ) ) ){
88 
89  m_layerId = new int [m_totalNumberOfChannel];
91  m_lineId = new int [m_totalNumberOfChannel];
92  m_PPId = new int [m_totalNumberOfChannel];
95 
96 
97  //******************************************************
98  // ChamberID in kmura's def. start from 1 in T1 station.
99  int chamberIdBase=0;
100  if (region == TGCRegionType::ENDCAP && (PPType=="EWT"||PPType=="EST")) chamberIdBase=1;
101  //******************************************************
102  int lineIdBase=0;
103  // initialize array
104  for(int i=0; i<m_totalNumberOfChannel; i+=1){
105  m_layerId[i] = 0;
106  m_chamberId[i] = 0;
107  m_lineId[i] = 0;
108  m_PPId[i] = 0;
109  m_connectorId[i] = 0;
110  m_channelId[i] = 0;
111  }
112  // read lines
113  for(int i=0; i<m_totalNumberOfChannel; i+=1){
114  file.getline(buf,BufferSize);
115  std::istringstream line(buf);
116  line >> m_layerId[i] >> m_chamberId[i] >> m_lineId[i]
117  >> m_PPId[i] >> m_connectorId[i] >> m_channelId[i];
118 
119  // DB is Backward
120  if(PPType=="FST"||PPType=="FSD"||PPType=="EST"||PPType=="ESD"||PPType=="FSI"||PPType=="ESI"){
121  if(forwardBackward==ForwardSector){
123  }
124  }
125 
126 
127  //******************************************************
128  // ChamberID in kmura's def. start from 1 in T1 station.
129  m_chamberId[i]+=chamberIdBase;
130  //******************************************************
131  //******************************************************
132  // hitID assign for each Module in kmura's def.,
133  // not for each chamber like in hasuko's def.
135  if((i!=0)&&(m_chamberId[i]!=m_chamberId[i-1])){
136  if(m_layerId[i]==m_layerId[i-1])
137  lineIdBase=m_lineId[i-1]+1;
138  else
139  lineIdBase=0;
140  }
141  m_lineId[i]+=lineIdBase;
142  }
143  //******************************************************
144  }
145  break;
146  }
147  }
148  }
149  return true;
150 }
151 
153 {
155  m_type = right.m_type;
157  m_layerId = 0;
158  m_chamberId = 0;
159  m_lineId = 0;
160  m_PPId = 0;
161  m_connectorId = 0;
162  m_channelId = 0;
163 
164  if(m_totalNumberOfChannel!=0){
165  m_layerId = new int [m_totalNumberOfChannel];
167  m_lineId = new int [m_totalNumberOfChannel];
168  m_PPId = new int [m_totalNumberOfChannel];
171 
172  for( int i=0; i<m_totalNumberOfChannel; i+=1){
173  m_layerId[i]=right.m_layerId[i];
174  m_chamberId[i]=right.m_chamberId[i];
175  m_lineId[i]=right.m_lineId[i];
176  m_PPId[i]=right.m_PPId[i];
177  m_connectorId[i]=right.m_connectorId[i];
178  m_channelId[i]=right.m_channelId[i];
179  }
180  }
181 }
182 
185 {
186  if(this != &right) {
187  m_type = right.m_type;
189 
191  if(m_layerId!=0) {
192  delete [] m_layerId;
193  delete [] m_chamberId;
194  delete [] m_lineId;
195  delete [] m_PPId;
196  delete [] m_connectorId;
197  delete [] m_channelId;
198  }
199  if(m_totalNumberOfChannel!=0){
200  m_layerId = new int [m_totalNumberOfChannel];
202  m_lineId = new int [m_totalNumberOfChannel];
203  m_PPId = new int [m_totalNumberOfChannel];
206  for( int i=0; i<m_totalNumberOfChannel; i+=1){
207  m_layerId[i]=right.m_layerId[i];
208  m_chamberId[i]=right.m_chamberId[i];
209  m_lineId[i]=right.m_lineId[i];
210  m_PPId[i]=right.m_PPId[i];
211  m_connectorId[i]=right.m_connectorId[i];
212  m_channelId[i]=right.m_channelId[i];
213  }
214  }
215  }
216  return *this;
217 }
218 
220  m_totalNumberOfChannel(0),m_type(0),m_forwardBackward(ForwardSector),
221  m_layerId(0),m_chamberId(0),m_lineId(0),
222  m_PPId(0),m_connectorId(0),m_channelId(0)
223 {
224 }
225 
226 
228 {
229  if(m_layerId!=0) delete [] m_layerId;
230  m_layerId=0;
231  if(m_chamberId!=0) delete [] m_chamberId;
232  m_chamberId=0;
233  if(m_lineId!=0) delete [] m_lineId;
234  m_lineId=0;
235  if(m_PPId!=0) delete [] m_PPId;
236  m_PPId=0;
237  if(m_connectorId!=0) delete [] m_connectorId;
238  m_connectorId=0;
239  if(m_channelId!=0) delete [] m_channelId;
240  m_channelId=0;
241 }
242 
243 } //end of namespace bracket
LVL1TGCTrigger::TGCRegionType::ENDCAP
@ ENDCAP
LVL1TGCTrigger::TGCSector::STPP
@ STPP
Definition: TGCSector.h:36
checkFileSG.line
line
Definition: checkFileSG.py:75
StateLessPT_NewConfig.BufferSize
BufferSize
Definition: StateLessPT_NewConfig.py:370
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:28
PathResolver::find_file
static std::string find_file(const std::string &logical_file_name, const std::string &search_path, SearchType search_type=LocalSearch)
Definition: PathResolver.cxx:251
LVL1TGCTrigger::TGCConnectionASDToPP::m_lineId
int * m_lineId
Definition: TGCConnectionASDToPP.h:33
calibdata.chamber
chamber
Definition: calibdata.py:32
TGCConnectionPPToSB.h
WriteCellNoiseToCool.fullName
fullName
Definition: WriteCellNoiseToCool.py:461
LVL1TGCTrigger::TGCConnectionASDToPP::dump
void dump() const
Definition: TGCConnectionASDToPP.cxx:40
LVL1TGCTrigger::TGCSector::WTPP
@ WTPP
Definition: TGCSector.h:36
CaloCondBlobAlgs_fillNoiseFromASCII.nChannel
nChannel
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:91
LVL1TGCTrigger::TGCConnectionASDToPP::m_channelId
int * m_channelId
Definition: TGCConnectionASDToPP.h:37
LVL1TGCTrigger::TGCRegionType::FORWARD
@ FORWARD
LVL1TGCTrigger::TGCConnectionASDToPP::m_type
int m_type
Definition: TGCConnectionASDToPP.h:28
LVL1TGCTrigger::TGCConnectionASDToPP::m_forwardBackward
TGCForwardBackwardType m_forwardBackward
Definition: TGCConnectionASDToPP.h:29
TGCDatabaseManager.h
LVL1TGCTrigger::TGCForwardBackwardType
TGCForwardBackwardType
Definition: TGCNumbering.h:59
LVL1TGCTrigger::TGCSector::WDPP
@ WDPP
Definition: TGCSector.h:36
LVL1TGCTrigger::TGCConnectionASDToPP::readData
bool readData(TGCRegionType region, int type, TGCForwardBackwardType forward)
Definition: TGCConnectionASDToPP.cxx:52
m_type
TokenType m_type
the type
Definition: TProperty.cxx:44
LVL1TGCTrigger::TGCConnectionASDToPP::m_connectorId
int * m_connectorId
Definition: TGCConnectionASDToPP.h:36
LVL1TGCTrigger::TGCSector::SIPP
@ SIPP
Definition: TGCSector.h:36
LVL1TGCTrigger::TGCDatabaseManager::getFilename
static std::string getFilename(int type)
Definition: TGCDatabaseManager.cxx:239
python.getCurrentFolderTag.fn
fn
Definition: getCurrentFolderTag.py:65
LVL1TGCTrigger::TGCConnectionASDToPP::m_chamberId
int * m_chamberId
Definition: TGCConnectionASDToPP.h:32
lumiFormat.i
int i
Definition: lumiFormat.py:92
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
file
TFile * file
Definition: tile_monitor.h:29
LVL1TGCTrigger::TGCConnectionASDToPP::~TGCConnectionASDToPP
~TGCConnectionASDToPP()
Definition: TGCConnectionASDToPP.cxx:227
LVL1TGCTrigger
Definition: LVL1TGCTrigger.cxx:47
LVL1TGCTrigger::TGCSector::WIPP
@ WIPP
Definition: TGCSector.h:36
LVL1TGCTrigger::TGCConnectionASDToPP::s_forwardLayer
static constexpr int s_forwardLayer[]
Definition: TGCConnectionASDToPP.h:40
PathResolver.h
LVL1TGCTrigger::TGCSector::SDPP
@ SDPP
Definition: TGCSector.h:36
LVL1TGCTrigger::TGCConnectionASDToPP::m_layerId
int * m_layerId
Definition: TGCConnectionASDToPP.h:31
LVL1TGCTrigger::TGCConnectionASDToPP::TGCConnectionASDToPP
TGCConnectionASDToPP()
Definition: TGCConnectionASDToPP.cxx:219
LVL1TGCTrigger::TGCRegionType
TGCRegionType
Definition: TGCNumbering.h:49
TGCConnectionASDToPP.h
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
LVL1TGCTrigger::TGCConnectionASDToPP::m_PPId
int * m_PPId
Definition: TGCConnectionASDToPP.h:35
LVL1TGCTrigger::TGCConnectionASDToPP::m_totalNumberOfChannel
int m_totalNumberOfChannel
Definition: TGCConnectionASDToPP.h:27
LVL1TGCTrigger::ForwardSector
@ ForwardSector
Definition: TGCNumbering.h:59
LVL1TGCTrigger::TGCConnectionASDToPP
Definition: TGCConnectionASDToPP.h:13
LVL1TGCTrigger::TGCConnectionASDToPP::operator=
TGCConnectionASDToPP & operator=(const TGCConnectionASDToPP &right)
Definition: TGCConnectionASDToPP.cxx:184
LVL1TGCTrigger::TGCConnectionASDToPP::getConnection
int getConnection(const int sideId, const int layer, const int chamber, const int line, int *pp, int *connector, int *channel) const
Definition: TGCConnectionASDToPP.cxx:20