ATLAS Offline Software
Loading...
Searching...
No Matches
TGCConnectionASDToPP.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5
6
10
12#include <iostream>
13#include <fstream>
14#include <sstream>
15#include <ctype.h>
16#include <string>
17
18
19namespace LVL1TGCTrigger {
20
21int TGCConnectionASDToPP::getConnection(const int /*sideId*/, const int layer, const int chamber,
22 const int line, int* pp, int* connector, int* channel) const
23{
24 int i;
25 for( i=0; i<m_totalNumberOfChannel; i+=1){
26 // wiregroupID assign in ASDOut and ASD2PP.db are different.
27 if((m_layerId[i]==layer)&&(m_chamberId[i]==chamber)&&(m_lineId[i]==line)){
28 // if((m_layerId[i]==layer)&&(m_lineId[i]==line)){
29 *pp = m_PPId[i];
30 *connector = m_connectorId[i];
31 *channel = m_channelId[i];
32 return 0;
33 }
34 }
35 *pp=-2;
36 *connector=-2;
37 *channel=-2;
38 return -1;
39}
40
42{
43#ifdef TGCCOUT
44 int i;
45 std::cout << "TGCConnectionASDToPP::dump "<<m_totalNumberOfChannel<< std::endl;
46 std::cout << "layerId chamberID line(WIRE) PPID ConnectorID" << std::endl;
47 for( i=0; i<m_totalNumberOfChannel; i+=1)
48 std::cout<<m_layerId[i]<<" "<<m_chamberId[i]<<" "<<m_lineId[i]<<" "<<m_PPId[i]<<" "<<m_connectorId[i]<<" "<<m_channelId[i]<< std::endl;
49#endif
50}
51
52
54 TGCForwardBackwardType forwardBackward)
55{
56 this->m_type = type;
57 this->m_forwardBackward = forwardBackward;
58
59 enum { BufferSize = 1024 };
60 char buf[BufferSize];
61
62 std::string fn, fullName ;
63// fn = "ASD2PP.db" ;
65
66 fullName = PathResolver::find_file(fn, "PWD");
67 if( fullName.length() == 0 )
68 fullName = PathResolver::find_file(fn, "DATAPATH");
69 std::ifstream file(fullName.c_str() ,std::ios::in);
70 if (!file) return false;
71
72 std::string PPType;
73 while(file.getline(buf,BufferSize)){
74 if((buf[0]=='E')||(buf[0]=='F')){
75
76 std::istringstream line(buf);
77 int nChannel;
78 line >> PPType >> nChannel;
79 // find a entry matches in region and Patch Panel m_type.
80 if(((region == TGCRegionType::ENDCAP) &&
81 ( (PPType=="EWT"&&m_type==TGCSector::WTPP)||(PPType=="EWD"&&m_type==TGCSector::WDPP)
82 ||(PPType=="EST"&&m_type==TGCSector::STPP)||(PPType=="ESD"&&m_type==TGCSector::SDPP)
83 ||(PPType=="EWI"&&m_type==TGCSector::WIPP)||(PPType=="ESI"&&m_type==TGCSector::SIPP) ) )||
84 ((region == TGCRegionType::FORWARD) &&
85 ( (PPType=="FWT"&&m_type==TGCSector::WTPP)||(PPType=="FWD"&&m_type==TGCSector::WDPP)
86 ||(PPType=="FST"&&m_type==TGCSector::STPP)||(PPType=="FSD"&&m_type==TGCSector::SDPP)
87 ||(PPType=="FWI"&&m_type==TGCSector::WIPP)||(PPType=="FSI"&&m_type==TGCSector::SIPP) ) ) ){
88 m_totalNumberOfChannel = nChannel;
89 //coverity[TAINTED_SCALAR]
91 //coverity[TAINTED_SCALAR]
93 //coverity[TAINTED_SCALAR]
95 //coverity[TAINTED_SCALAR]
97 //coverity[TAINTED_SCALAR]
99 //coverity[TAINTED_SCALAR]
101
102
103 //******************************************************
104 // ChamberID in kmura's def. start from 1 in T1 station.
105 int chamberIdBase=0;
106 if (region == TGCRegionType::ENDCAP && (PPType=="EWT"||PPType=="EST")) chamberIdBase=1;
107 //******************************************************
108 int lineIdBase=0;
109 // initialize array
110 //coverity[TAINTED_SCALAR]
111 for(int i=0; i<m_totalNumberOfChannel; i+=1){
112 m_layerId[i] = 0;
113 m_chamberId[i] = 0;
114 m_lineId[i] = 0;
115 m_PPId[i] = 0;
116 m_connectorId[i] = 0;
117 m_channelId[i] = 0;
118 }
119 // read lines
120 for(int i=0; i<m_totalNumberOfChannel; i+=1){
121 file.getline(buf,BufferSize);
122 std::istringstream line(buf);
123 line >> m_layerId[i] >> m_chamberId[i] >> m_lineId[i]
124 >> m_PPId[i] >> m_connectorId[i] >> m_channelId[i];
125
126 // DB is Backward
127 if(PPType=="FST"||PPType=="FSD"||PPType=="EST"||PPType=="ESD"||PPType=="FSI"||PPType=="ESI"){
128 if(forwardBackward==ForwardSector){
129 //coverity[TAINTED_SCALAR]
130 //coverity[INTEGER_OVERFLOW]
132 }
133 }
134
135
136 //******************************************************
137 // ChamberID in kmura's def. start from 1 in T1 station.
138 m_chamberId[i]+=chamberIdBase;
139 //******************************************************
140 //******************************************************
141 // hitID assign for each Module in kmura's def.,
142 // not for each chamber like in hasuko's def.
144 if((i!=0)&&(m_chamberId[i]!=m_chamberId[i-1])){
145 if(m_layerId[i]==m_layerId[i-1])
146 lineIdBase=m_lineId[i-1]+1;
147 else
148 lineIdBase=0;
149 }
150 m_lineId[i]+=lineIdBase;
151 }
152 //******************************************************
153 }
154 break;
155 }
156 }
157 }
158 return true;
159}
160
162{
164 m_type = right.m_type;
166 m_layerId = 0;
167 m_chamberId = 0;
168 m_lineId = 0;
169 m_PPId = 0;
170 m_connectorId = 0;
171 m_channelId = 0;
172
177 m_PPId = new int [m_totalNumberOfChannel];
180
181 for( int i=0; i<m_totalNumberOfChannel; i+=1){
182 m_layerId[i]=right.m_layerId[i];
183 m_chamberId[i]=right.m_chamberId[i];
184 m_lineId[i]=right.m_lineId[i];
185 m_PPId[i]=right.m_PPId[i];
186 m_connectorId[i]=right.m_connectorId[i];
187 m_channelId[i]=right.m_channelId[i];
188 }
189 }
190}
191
194{
195 if(this != &right) {
196 m_type = right.m_type;
198
200 if(m_layerId!=0) {
201 delete [] m_layerId;
202 delete [] m_chamberId;
203 delete [] m_lineId;
204 delete [] m_PPId;
205 delete [] m_connectorId;
206 delete [] m_channelId;
207 }
212 m_PPId = new int [m_totalNumberOfChannel];
215 for( int i=0; i<m_totalNumberOfChannel; i+=1){
216 m_layerId[i]=right.m_layerId[i];
217 m_chamberId[i]=right.m_chamberId[i];
218 m_lineId[i]=right.m_lineId[i];
219 m_PPId[i]=right.m_PPId[i];
220 m_connectorId[i]=right.m_connectorId[i];
221 m_channelId[i]=right.m_channelId[i];
222 }
223 }
224 }
225 return *this;
226}
227
234
235
237{
238 if(m_layerId!=0) delete [] m_layerId;
239 m_layerId=0;
240 if(m_chamberId!=0) delete [] m_chamberId;
241 m_chamberId=0;
242 if(m_lineId!=0) delete [] m_lineId;
243 m_lineId=0;
244 if(m_PPId!=0) delete [] m_PPId;
245 m_PPId=0;
246 if(m_connectorId!=0) delete [] m_connectorId;
248 if(m_channelId!=0) delete [] m_channelId;
249 m_channelId=0;
250}
251
252} //end of namespace bracket
TGCConnectionASDToPP & operator=(const TGCConnectionASDToPP &right)
int getConnection(const int sideId, const int layer, const int chamber, const int line, int *pp, int *connector, int *channel) const
bool readData(TGCRegionType region, int type, TGCForwardBackwardType forward)
static std::string getFilename(int type)
static std::string find_file(const std::string &logical_file_name, const std::string &search_path)
TFile * file