ATLAS Offline Software
Loading...
Searching...
No Matches
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
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
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
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 }
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
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;
239 if(m_channelId!=0) delete [] m_channelId;
240 m_channelId=0;
241}
242
243} //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