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#include <iostream>
6#include <fstream>
7#include <sstream>
8#include <ctype.h>
9#include <string>
10
14
16
17
18namespace LVL1TGCTrigger {
19
20int 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
65 fullName = PathResolver::find_file(fn, "PWD");
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) ) ) ){
87 m_totalNumberOfChannel = nChannel;
88 //coverity[TAINTED_SCALAR]
90 //coverity[TAINTED_SCALAR]
92 //coverity[TAINTED_SCALAR]
94 //coverity[TAINTED_SCALAR]
96 //coverity[TAINTED_SCALAR]
98 //coverity[TAINTED_SCALAR]
100
101
102 //******************************************************
103 // ChamberID in kmura's def. start from 1 in T1 station.
104 int chamberIdBase=0;
105 if (region == TGCRegionType::ENDCAP && (PPType=="EWT"||PPType=="EST")) chamberIdBase=1;
106 //******************************************************
107 int lineIdBase=0;
108 // initialize array
109 //coverity[TAINTED_SCALAR]
110 for(int i=0; i<m_totalNumberOfChannel; i+=1){
111 m_layerId[i] = 0;
112 m_chamberId[i] = 0;
113 m_lineId[i] = 0;
114 m_PPId[i] = 0;
115 m_connectorId[i] = 0;
116 m_channelId[i] = 0;
117 }
118 // read lines
119 for(int i=0; i<m_totalNumberOfChannel; i+=1){
120 file.getline(buf,BufferSize);
121 std::istringstream line(buf);
122 line >> m_layerId[i] >> m_chamberId[i] >> m_lineId[i]
123 >> m_PPId[i] >> m_connectorId[i] >> m_channelId[i];
124
125 // DB is Backward
126 if(PPType=="FST"||PPType=="FSD"||PPType=="EST"||PPType=="ESD"||PPType=="FSI"||PPType=="ESI"){
127 if(forwardBackward==ForwardSector){
128 //coverity[TAINTED_SCALAR]
130 }
131 }
132
133
134 //******************************************************
135 // ChamberID in kmura's def. start from 1 in T1 station.
136 m_chamberId[i]+=chamberIdBase;
137 //******************************************************
138 //******************************************************
139 // hitID assign for each Module in kmura's def.,
140 // not for each chamber like in hasuko's def.
142 if((i!=0)&&(m_chamberId[i]!=m_chamberId[i-1])){
143 if(m_layerId[i]==m_layerId[i-1])
144 lineIdBase=m_lineId[i-1]+1;
145 else
146 lineIdBase=0;
147 }
148 m_lineId[i]+=lineIdBase;
149 }
150 //******************************************************
151 }
152 break;
153 }
154 }
155 }
156 return true;
157}
158
160{
162 m_type = right.m_type;
164 m_layerId = 0;
165 m_chamberId = 0;
166 m_lineId = 0;
167 m_PPId = 0;
168 m_connectorId = 0;
169 m_channelId = 0;
170
175 m_PPId = new int [m_totalNumberOfChannel];
178
179 for( int i=0; i<m_totalNumberOfChannel; i+=1){
180 m_layerId[i]=right.m_layerId[i];
181 m_chamberId[i]=right.m_chamberId[i];
182 m_lineId[i]=right.m_lineId[i];
183 m_PPId[i]=right.m_PPId[i];
184 m_connectorId[i]=right.m_connectorId[i];
185 m_channelId[i]=right.m_channelId[i];
186 }
187 }
188}
189
192{
193 if(this != &right) {
194 m_type = right.m_type;
196
198 if(m_layerId!=0) {
199 delete [] m_layerId;
200 delete [] m_chamberId;
201 delete [] m_lineId;
202 delete [] m_PPId;
203 delete [] m_connectorId;
204 delete [] m_channelId;
205 }
210 m_PPId = new int [m_totalNumberOfChannel];
213 for( int i=0; i<m_totalNumberOfChannel; i+=1){
214 m_layerId[i]=right.m_layerId[i];
215 m_chamberId[i]=right.m_chamberId[i];
216 m_lineId[i]=right.m_lineId[i];
217 m_PPId[i]=right.m_PPId[i];
218 m_connectorId[i]=right.m_connectorId[i];
219 m_channelId[i]=right.m_channelId[i];
220 }
221 }
222 }
223 return *this;
224}
225
232
233
235{
236 if(m_layerId!=0) delete [] m_layerId;
237 m_layerId=0;
238 if(m_chamberId!=0) delete [] m_chamberId;
239 m_chamberId=0;
240 if(m_lineId!=0) delete [] m_lineId;
241 m_lineId=0;
242 if(m_PPId!=0) delete [] m_PPId;
243 m_PPId=0;
244 if(m_connectorId!=0) delete [] m_connectorId;
246 if(m_channelId!=0) delete [] m_channelId;
247 m_channelId=0;
248}
249
250} //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