]>
Commit | Line | Data |
---|---|---|
1 | /************************************************************************** | |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | ||
17 | void MUONGenerateBusPatch() | |
18 | { | |
19 | // Generates buspatch id and DDL id for given detection element id | |
20 | // station 1 & 2 assuming 24 buspatches per quadrant | |
21 | // station345, reading from DetElemIdToSlatType.dat file and calculates | |
22 | // the number of bus patches per slat (and also number of Translator and Bridge Boards). | |
23 | // Generates an output file DetElemIdToBusPatch.dat.out, preserve from overwriting | |
24 | // (Ch. Finck, July 05) | |
25 | // (Nov. 05, added DDL) | |
26 | // (June 06, correction for St123) | |
27 | ||
28 | ||
29 | TString dirPath2 = gSystem->Getenv("ALICE_ROOT"); | |
30 | dirPath2 += "/MUON/mapping/data/"; | |
31 | ||
32 | TString dirPath1 = dirPath2 + "station345/"; | |
33 | ||
34 | TString infile = dirPath1 + "DetElemIdToSlatType.dat"; | |
35 | TString outfile = dirPath2 + "DetElemIdToBusPatch.dat.out"; | |
36 | ||
37 | ifstream in(infile, ios::in); | |
38 | ofstream out(outfile, ios::out); | |
39 | char line[80]; | |
40 | char nameSlat[82]; | |
41 | Int_t idDE; | |
42 | Int_t i; | |
43 | Int_t cursor = 0; | |
44 | Int_t begin[800]; | |
45 | Int_t end[800]; | |
46 | Int_t nbBusPatch; | |
47 | Int_t listDE[800]; | |
48 | Int_t nbTB = 0; | |
49 | Int_t nbBB = 0; | |
50 | Int_t idSt12[] = {100, 101, 102, 103, | |
51 | 200, 201, 202, 203, | |
52 | 300, 301, 302, 303, | |
53 | 400, 401, 402, 403}; | |
54 | ||
55 | Int_t idSt3swp1 = 5; // 1/4 chamber for DDL on horizontal | |
56 | Int_t idSt3swp2 = 9; // 1/4 chamber for DDL on horizontal | |
57 | Int_t idSt3swp3 = 14; // 1/4 chamber for DDL on horizontal | |
58 | ||
59 | Int_t idSt45swp1 = 7; // half chamber for DDL in vertical cutting twice the official numbering | |
60 | Int_t idSt45swp2 = 20; | |
61 | ||
62 | Int_t iDDL = 0; | |
63 | // station 1 & 2 | |
64 | nbBusPatch = 24; | |
65 | cout << "#DE BusPatch DDL SlatName" << endl; | |
66 | out << "#DE BusPatch DDL " << endl; | |
67 | ||
68 | for (Int_t j = 0; j < 16; j++) { | |
69 | ||
70 | idDE = idSt12[j]; | |
71 | if (idDE % 100 == 0) { | |
72 | iDDL++; | |
73 | begin[cursor] = AliMpBusPatch::GetGlobalBusID(0, iDDL-1); | |
74 | cout << "# Chamber " << idDE/100 << endl; | |
75 | out << "# Chamber " << idDE/100 << endl; | |
76 | } | |
77 | if (idDE % 100 == 1) { | |
78 | iDDL++; | |
79 | begin[cursor] = AliMpBusPatch::GetGlobalBusID(0, iDDL-1); | |
80 | } | |
81 | if (idDE % 100 == 3) { | |
82 | iDDL--; | |
83 | begin[cursor] = AliMpBusPatch::GetGlobalBusID(0, iDDL-1) + nbBusPatch; | |
84 | } | |
85 | end[cursor] = begin[cursor] + nbBusPatch - 1; | |
86 | begin[++cursor] = end[cursor] + 1; | |
87 | ||
88 | cout << idDE << " " << begin[cursor-1]<<"-"<<end[cursor-1] <<" " << iDDL-1 << endl; | |
89 | out << idDE << " " << begin[cursor-1]<<"-"<<end[cursor-1] <<" " << iDDL-1 <<endl; | |
90 | if (idDE % 100 == 3) iDDL++; | |
91 | ||
92 | } | |
93 | ||
94 | // station 345 | |
95 | nbBusPatch = 0; | |
96 | Int_t nbBusSt3Tot1 = 0; | |
97 | Int_t nbBusSt3Tot2 = 0; | |
98 | Int_t nbBusSt3Tot3 = 0; | |
99 | Int_t nbBusSt3Tot4 = 0; | |
100 | ||
101 | Int_t nbBusSt3Swap1 = 0; | |
102 | Int_t nbBusSt3Swap2 = 0; | |
103 | Int_t nbBusSt3Swap3 = 0; | |
104 | Int_t nbBusSt3Swap4 = 0; | |
105 | ||
106 | Int_t iDDLSt3Swap1 = 0; | |
107 | Int_t iDDLSt3Swap2 = 0; | |
108 | Int_t iDDLSt3Swap3 = 0; | |
109 | Int_t iDDLSt3Swap4 = 0; | |
110 | ||
111 | Int_t nbBusSt45Tot = 0; | |
112 | Int_t nbBusSt45Swap = 0; | |
113 | ||
114 | // reads from file | |
115 | while ( in.getline(line,80) ) { | |
116 | ||
117 | if ( line[0] == '#' || line[0] == '\0' ) continue; | |
118 | i = 0; | |
119 | sscanf(line, "%d %s", &idDE, nameSlat); | |
120 | ||
121 | // number of PCB's | |
122 | while(nameSlat[i] < '4' && nameSlat[i] !='0') i++; | |
123 | Int_t len = strlen(nameSlat); | |
124 | ||
125 | // number of buspatch | |
126 | if (i == 2 || i == 3) | |
127 | nbBusPatch = 2; | |
128 | else | |
129 | nbBusPatch = 4; | |
130 | ||
131 | // calculate the number of TB & BB | |
132 | // R1: 2 bridges more per PCB | |
133 | // R2 & R3: 1 translator more per PCB | |
134 | if (i == 2) nbBB += 2; | |
135 | if (i == 3) nbBB += 4; | |
136 | if (i == 4) nbBB += 4; | |
137 | if (i == 5) nbBB += 6; | |
138 | if (i == 6) nbBB += 8; | |
139 | ||
140 | nbTB += nbBusPatch; | |
141 | if (nameSlat[len-1] == '1') { | |
142 | nbTB += 2; | |
143 | nbBusPatch+=2; | |
144 | } | |
145 | if (nameSlat[len-1] == '2' || nameSlat[len-1] == '3') { | |
146 | nbTB += 1; | |
147 | nbBusPatch++; | |
148 | } | |
149 | ||
150 | // station 3 | |
151 | // for buspatch length reasons, one ddl connects one 1/4 of two chambers | |
152 | // really messy isn't it ? | |
153 | ||
154 | if (idDE < 700 ) { | |
155 | ||
156 | if (idDE == 500) { | |
157 | iDDL++; | |
158 | begin[cursor] = AliMpBusPatch::GetGlobalBusID(0, iDDL-1); | |
159 | nbBusSt3Tot1 = 0; | |
160 | ||
161 | } | |
162 | if (idDE % 100 == 0) { | |
163 | cout << "# Chamber " << idDE/100 << endl; | |
164 | out << "# Chamber " << idDE/100 << endl; | |
165 | } | |
166 | ||
167 | nbBusSt3Tot1 += nbBusPatch; | |
168 | ||
169 | // second 1/4 for chamber 5 | |
170 | if (idDE == 500+idSt3swp1) { | |
171 | iDDLSt3Swap1 = iDDL++; | |
172 | begin[cursor] = AliMpBusPatch::GetGlobalBusID(0, iDDL-1); | |
173 | nbBusSt3Swap1 = nbBusSt3Tot1 - nbBusPatch; | |
174 | nbBusSt3Tot1 = 0; | |
175 | nbBusSt3Tot2 = 0; | |
176 | } | |
177 | ||
178 | // first 1/4 chamber 6 | |
179 | if (idDE == 600) { | |
180 | iDDL = iDDLSt3Swap1; | |
181 | begin[cursor] = AliMpBusPatch::GetGlobalBusID(nbBusSt3Swap1, iDDL-1); | |
182 | } | |
183 | // third 1/4 for chamber 5 | |
184 | if (idDE == 500+idSt3swp2) { | |
185 | iDDL = iDDLSt3Swap1+1; | |
186 | iDDLSt3Swap2 = iDDL++; | |
187 | begin[cursor] = AliMpBusPatch::GetGlobalBusID(0, iDDL-1); | |
188 | nbBusSt3Swap2 = nbBusSt3Tot2; | |
189 | nbBusSt3Tot2 = 0; | |
190 | nbBusSt3Tot3 = 0; | |
191 | } | |
192 | nbBusSt3Tot2 += nbBusPatch; | |
193 | ||
194 | // second 1/4 chamber 6 | |
195 | if (idDE == 600 +idSt3swp1) { | |
196 | iDDL = iDDLSt3Swap2; | |
197 | begin[cursor] = AliMpBusPatch::GetGlobalBusID(nbBusSt3Swap2, iDDL-1); | |
198 | } | |
199 | ||
200 | // fourth 1/4 chamber 5 | |
201 | if (idDE == 500+idSt3swp3) { | |
202 | iDDL = iDDLSt3Swap2+1; | |
203 | iDDLSt3Swap3 = iDDL++; | |
204 | begin[cursor] = AliMpBusPatch::GetGlobalBusID(0, iDDL-1); | |
205 | nbBusSt3Swap3 = nbBusSt3Tot3; | |
206 | nbBusSt3Tot2 = 0; | |
207 | nbBusSt3Tot3 = 0; | |
208 | nbBusSt3Tot4 = 0; | |
209 | } | |
210 | nbBusSt3Tot3 += nbBusPatch; | |
211 | ||
212 | //third 1/4 chamber 6 | |
213 | if (idDE == 600) | |
214 | nbBusSt3Swap4 = nbBusSt3Tot4; | |
215 | ||
216 | if (idDE == 600 +idSt3swp2) { | |
217 | iDDL = iDDLSt3Swap3; | |
218 | begin[cursor] = AliMpBusPatch::GetGlobalBusID(nbBusSt3Swap3, iDDL-1); | |
219 | nbBusSt3Tot4 += nbBusPatch; | |
220 | } | |
221 | nbBusSt3Tot4 += nbBusPatch; | |
222 | ||
223 | // fourth 1/4 chamber 6 | |
224 | if (idDE == 600 +idSt3swp3) { | |
225 | iDDL = iDDLSt3Swap3+1; | |
226 | begin[cursor] = AliMpBusPatch::GetGlobalBusID(nbBusSt3Swap4, iDDL-1); | |
227 | } | |
228 | ||
229 | end[cursor] = begin[cursor] + nbBusPatch - 1; | |
230 | begin[++cursor] = end[cursor] + 1; | |
231 | ||
232 | cout << idDE << " " << begin[cursor-1]<<"-"<<end[cursor-1] << " " << iDDL-1 << " " <<nameSlat <<endl; | |
233 | out << idDE << " " << begin[cursor-1]<<"-"<<end[cursor-1] <<" " << iDDL-1 <<endl; | |
234 | } | |
235 | ||
236 | // station 4 & 5 | |
237 | // back to normal one ddl connects one 1/2 chamber | |
238 | // finally ! | |
239 | if (idDE == 700) { | |
240 | iDDL = ((idDE-1)/100)*2; | |
241 | } | |
242 | if (idDE >= 700) { | |
243 | ||
244 | if (idDE % 100 == 0) { | |
245 | nbBusSt45Tot = 0; | |
246 | iDDL++; | |
247 | if (idDE >=800) | |
248 | iDDL++; | |
249 | begin[cursor] = AliMpBusPatch::GetGlobalBusID(0, iDDL-1); | |
250 | cout << "# Chamber " << idDE/100 << endl; | |
251 | out << "# Chamber " << idDE/100 << endl; | |
252 | } | |
253 | ||
254 | nbBusSt45Tot += nbBusPatch; | |
255 | ||
256 | if (idDE == 700+idSt45swp1 || idDE == 800+idSt45swp1 || idDE == 900+idSt45swp1 || idDE == 1000+idSt45swp1 ) { | |
257 | iDDL++; | |
258 | begin[cursor] = AliMpBusPatch::GetGlobalBusID(0, iDDL-1); | |
259 | nbBusSt45Swap = nbBusSt45Tot - nbBusPatch; | |
260 | nbBusSt45Tot = 0; | |
261 | } | |
262 | if (idDE == 700+idSt45swp2 || idDE == 800+idSt45swp2 || idDE == 900+idSt45swp2 || idDE == 1000+idSt45swp2 ) { | |
263 | iDDL--; | |
264 | begin[cursor] = AliMpBusPatch::GetGlobalBusID(nbBusSt45Swap, iDDL-1); | |
265 | } | |
266 | end[cursor] = begin[cursor] + nbBusPatch - 1; | |
267 | begin[++cursor] = end[cursor] + 1; | |
268 | ||
269 | cout << idDE << " " << begin[cursor-1]<<"-"<<end[cursor-1] << " " << iDDL-1 << " " <<nameSlat <<endl; | |
270 | out << idDE << " " << begin[cursor-1]<<"-"<<end[cursor-1] <<" " << iDDL-1 <<endl; | |
271 | } | |
272 | ||
273 | } | |
274 | printf(" Slat: number of TB %d and BB %d\n", nbTB, nbBB); | |
275 | in.close(); | |
276 | out.close(); | |
277 | } |