]>
Commit | Line | Data |
---|---|---|
36903978 | 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 | |
0a69c1eb | 20 | // station 1 & 2 assuming 24 buspatches per quadrant |
36903978 | 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) | |
42c7b335 | 25 | // (Nov. 05, added DDL) |
26 | // (June 06, correction for St123) | |
36903978 | 27 | |
28 | TString dirPath2 = gSystem->Getenv("ALICE_ROOT"); | |
29 | dirPath2 += "/MUON/mapping/data/"; | |
30 | ||
31 | TString dirPath1 = dirPath2 + "station345/"; | |
32 | ||
33 | TString infile = dirPath1 + "DetElemIdToSlatType.dat"; | |
34 | TString outfile = dirPath2 + "DetElemIdToBusPatch.dat.out"; | |
35 | ||
36 | ifstream in(infile, ios::in); | |
37 | ofstream out(outfile, ios::out); | |
38 | char line[80]; | |
39 | char nameSlat[82]; | |
40 | Int_t idDE; | |
41 | Int_t i; | |
42 | Int_t cursor = 0; | |
43 | Int_t begin[800]; | |
44 | Int_t end[800]; | |
45 | Int_t nbBusPatch; | |
46 | Int_t listDE[800]; | |
47 | Int_t nbTB = 0; | |
48 | Int_t nbBB = 0; | |
49 | Int_t idSt12[] = {100, 101, 102, 103, | |
50 | 200, 201, 202, 203, | |
51 | 300, 301, 302, 303, | |
52 | 400, 401, 402, 403}; | |
53 | ||
42c7b335 | 54 | Int_t idSt3swp1 = 5; // 1/4 chamber for DDL on horizontal |
55 | Int_t idSt3swp2 = 9; // 1/4 chamber for DDL on horizontal | |
56 | Int_t idSt3swp3 = 14; // 1/4 chamber for DDL on horizontal | |
57 | ||
36903978 | 58 | Int_t idSt45swp1 = 7; // half chamber for DDL in vertical cutting twice the official numbering |
59 | Int_t idSt45swp2 = 20; | |
60 | ||
61 | Int_t iDDL = 0; | |
42c7b335 | 62 | const Int_t kFactor = 50; |
36903978 | 63 | // station 1 & 2 |
0a69c1eb | 64 | nbBusPatch = 24; |
36903978 | 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) { | |
42c7b335 | 72 | iDDL++; |
73 | begin[cursor] = iDDL * kFactor; | |
36903978 | 74 | cout << "# Chamber " << idDE/100 << endl; |
75 | out << "# Chamber " << idDE/100 << endl; | |
76 | } | |
42c7b335 | 77 | if (idDE % 100 == 1) { |
78 | iDDL++; | |
79 | begin[cursor] = iDDL * kFactor; | |
80 | } | |
81 | if (idDE % 100 == 3) { | |
82 | iDDL--; | |
83 | begin[cursor] = iDDL * kFactor + nbBusPatch; | |
84 | } | |
36903978 | 85 | end[cursor] = begin[cursor] + nbBusPatch - 1; |
86 | begin[++cursor] = end[cursor] + 1; | |
87 | ||
42c7b335 | 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 | ||
36903978 | 92 | } |
93 | ||
94 | // station 345 | |
95 | nbBusPatch = 0; | |
42c7b335 | 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 | |
36903978 | 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; | |
08ce37ff | 141 | if (nameSlat[len-1] == '1') { |
42c7b335 | 142 | nbTB += 2; |
143 | nbBusPatch+=2; | |
08ce37ff | 144 | } |
0a69c1eb | 145 | if (nameSlat[len-1] == '2' || nameSlat[len-1] == '3') { |
36903978 | 146 | nbTB += 1; |
0a69c1eb | 147 | nbBusPatch++; |
148 | } | |
42c7b335 | 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] = iDDL * kFactor; | |
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] = iDDL * kFactor; | |
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] = iDDL * kFactor + nbBusSt3Swap1; | |
182 | } | |
183 | // third 1/4 for chamber 5 | |
184 | if (idDE == 500+idSt3swp2) { | |
185 | iDDL = iDDLSt3Swap1+1; | |
186 | iDDLSt3Swap2 = iDDL++; | |
187 | begin[cursor] = iDDL * kFactor; | |
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] = iDDL * kFactor + nbBusSt3Swap2; | |
198 | } | |
199 | ||
200 | // fourth 1/4 chamber 5 | |
201 | if (idDE == 500+idSt3swp3) { | |
202 | iDDL = iDDLSt3Swap2+1; | |
203 | iDDLSt3Swap3 = iDDL++; | |
204 | begin[cursor] = iDDL * kFactor; | |
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] = iDDL * kFactor + nbBusSt3Swap3; | |
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] = iDDL * kFactor + nbBusSt3Swap4; | |
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 | ||
36903978 | 244 | if (idDE % 100 == 0) { |
42c7b335 | 245 | nbBusSt45Tot = 0; |
36903978 | 246 | iDDL++; |
247 | if (idDE >=800) | |
248 | iDDL++; | |
42c7b335 | 249 | begin[cursor] = iDDL * kFactor; |
36903978 | 250 | cout << "# Chamber " << idDE/100 << endl; |
251 | out << "# Chamber " << idDE/100 << endl; | |
252 | } | |
36903978 | 253 | |
42c7b335 | 254 | nbBusSt45Tot += nbBusPatch; |
36903978 | 255 | |
42c7b335 | 256 | if (idDE == 700+idSt45swp1 || idDE == 800+idSt45swp1 || idDE == 900+idSt45swp1 || idDE == 1000+idSt45swp1 ) { |
257 | iDDL++; | |
258 | begin[cursor] = iDDL * kFactor; | |
259 | nbBusSt45Swap = nbBusSt45Tot - nbBusPatch; | |
260 | nbBusSt45Tot = 0; | |
261 | } | |
262 | if (idDE == 700+idSt45swp2 || idDE == 800+idSt45swp2 || idDE == 900+idSt45swp2 || idDE == 1000+idSt45swp2 ) { | |
36903978 | 263 | iDDL--; |
42c7b335 | 264 | begin[cursor] = iDDL * kFactor + nbBusSt45Swap; |
265 | } | |
266 | end[cursor] = begin[cursor] + nbBusPatch - 1; | |
267 | begin[++cursor] = end[cursor] + 1; | |
36903978 | 268 | |
42c7b335 | 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 | } | |
36903978 | 272 | |
36903978 | 273 | } |
274 | printf(" Slat: number of TB %d and BB %d\n", nbTB, nbBB); | |
275 | in.close(); | |
276 | out.close(); | |
277 | } |