]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - MUON/MUONGenerateBusPatch.C
- Adding a new group for macros
[u/mrichter/AliRoot.git] / MUON / MUONGenerateBusPatch.C
... / ...
CommitLineData
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// $Id$
17
18#if !defined(__CINT__) || defined(__MAKECINT__)
19// ROOT includes
20#include <Riostream.h>
21#include <TROOT.h>
22#include <TSystem.h>
23#include <TString.h>
24
25// MUON includes
26#include "AliMpBusPatch.h"
27
28#endif
29
30// Generates buspatch id and DDL id for given detection element id
31// station 1 & 2 assuming 24 buspatches per quadrant
32// station345, reading from DetElemIdToSlatType.dat file and calculates
33// the number of bus patches per slat (and also number of Translator and Bridge Boards).
34// Generates an output file DetElemIdToBusPatch.dat.out, preserve from overwriting
35// (Ch. Finck, July 05)
36// (Nov. 05, added DDL)
37// (June 06, correction for St123)
38// (Feb. 07, add 1st manu list for St12 (starting on NB !) and new ddl sharing for station 3)
39// (June. 07, new numbering of station 345, and buspatch starts at 1)
40
41
42void MUONGenerateBusPatch()
43{
44
45 TString dirPath2 = gSystem->Getenv("ALICE_ROOT");
46 dirPath2 += "/MUON/mapping/data/";
47
48 TString dirPath1 = dirPath2 + "station345/";
49
50 TString infile = dirPath1 + "DetElemIdToSlatType.dat";
51 TString outfile = dirPath2 + "DetElemIdToBusPatch.dat.out";
52
53 ifstream in(infile, ios::in);
54 ofstream out(outfile, ios::out);
55 char line[80];
56 char nameSlat[82];
57 Int_t idDE;
58 Int_t i;
59 Int_t cursor = 0;
60 Int_t begin[900];
61 Int_t end[900];
62 Int_t nbBusPatch;
63 Int_t nbTB = 0;
64 Int_t nbBB = 0;
65 Int_t idSt12[] = {100, 101, 102, 103,
66 200, 201, 202, 203,
67 300, 301, 302, 303,
68 400, 401, 402, 403};
69
70 Char_t manuListSt1[]
71 = " 1,27,53,79,105,131,157,183,201,214,224,232,1025,1051,1077,1103,1129,1155,1181,1207,1225,1238,1249,1257";
72
73 Char_t manuListSt2[]
74 = " 1,27,53,79,105,131,157,183,201,214,226,246,1025,1051,1077,1103,1129,1155,1181,1207,1225,1238,1251,1269";
75
76
77
78 Int_t iDDL = 0;
79 // station 1 & 2
80 nbBusPatch = 24;
81 Int_t nbHalfBusPatch = nbBusPatch/2;
82 cout << "#DE BusPatch DDL SlatName" << endl;
83 out << "#DE BusPatch DDL 1st manu in buspatch" << endl;
84
85 for (Int_t j = 0; j < 16; j++) {
86
87 idDE = idSt12[j];
88 if (idDE % 100 == 0) {
89 iDDL++;
90 begin[cursor] = AliMpBusPatch::GetGlobalBusID(1, iDDL-1);
91 cout << "# Chamber " << idDE/100 << endl;
92 out << "# Chamber " << idDE/100 << endl;
93 }
94 if (idDE % 100 == 1) {
95 iDDL++;
96 begin[cursor] = AliMpBusPatch::GetGlobalBusID(1, iDDL-1);
97 }
98
99 if (idDE % 100 == 3) {
100 iDDL--;
101 begin[cursor] = AliMpBusPatch::GetGlobalBusID(1, iDDL-1) + nbBusPatch;
102 }
103
104 end[cursor] = begin[cursor] + nbBusPatch - 1;
105 ++cursor; // it seems that vec[++i] does not work in Cint
106 begin[cursor] = end[cursor-1] + 1;
107
108 cout << idDE << " " << begin[cursor-1] + nbHalfBusPatch << "-" <<end[cursor-1] << ";" <<
109 begin[cursor-1] << "-" << end[cursor-1] - nbHalfBusPatch << " " << iDDL-1 << endl;
110
111 if (idDE < 300 )
112 out << idDE << " " << begin[cursor-1] + nbHalfBusPatch << "-" <<end[cursor-1] << ";" <<
113 begin[cursor-1] << "-" << end[cursor-1] - nbHalfBusPatch << " " << iDDL-1 <<
114 manuListSt1 << endl;
115 else
116 out << idDE << " " << begin[cursor-1] + nbHalfBusPatch << "-" <<end[cursor-1] << ";" <<
117 begin[cursor-1] << "-" << end[cursor-1] - nbHalfBusPatch << " " << iDDL-1 <<
118 manuListSt2 << endl;
119 if (idDE % 100 == 3) iDDL++;
120
121 }
122
123 // station 345
124 nbBusPatch = 0;
125 Int_t idCh5swp1 = 501; // 1/4 chamber for DDL on horizontal
126 Int_t idCh5swp2 = 505; // 1/4 chamber for DDL on horizontal
127 Int_t idCh5swp3 = 510; // 1/4 chamber for DDL on horizontal
128 Int_t idCh5swp4 = 514; // 1/4 chamber for DDL on horizontal
129
130 Int_t idCh6swp1 = 600; // 1/4 chamber for DDL on horizontal
131 Int_t idCh6swp2 = 605; // 1/4 chamber for DDL on horizontal
132 Int_t idCh6swp3 = 609; // 1/4 chamber for DDL on horizontal
133 Int_t idCh6swp4 = 614; // 1/4 chamber for DDL on horizontal
134
135 Int_t idSt45swp1 = 7; // half chamber for DDL in vertical cutting twice the official numbering
136 Int_t idSt45swp2 = 20;
137
138 Int_t offsetBusCh5swp1 = 13; // number of buspatches between DE 501-504
139 Int_t offsetBusCh5swp2 = 17; // number of buspatches before DE 510
140
141 Int_t offsetBusCh6swp1 = 17; // number of buspatches before DE 600-604
142 Int_t offsetBusCh6swp2 = 13; // number of buspatches between DE 614-617
143
144 Int_t offsetBusSt4 = 25; // number of buspatches before DE 700-800
145 Int_t offsetBusSt4swp = 46; // number of buspatches between 801-806 (701-706)
146
147 Int_t offsetBusSt5 = 27; // number of buspatches before DE 900-1000
148 Int_t offsetBusSt5swp = 50; // number of buspatches between 901-906 (1001-1006)
149
150 // reads from file
151 while ( in.getline(line,80) ) {
152
153 if ( line[0] == '#' || line[0] == '\0' ) continue;
154 i = 0;
155 sscanf(line, "%d %s", &idDE, nameSlat);
156
157 // number of PCB's
158 while(nameSlat[i] < '4' && nameSlat[i] !='0') i++;
159 Int_t len = strlen(nameSlat);
160
161 // number of buspatch
162 if (i == 2 || i == 3)
163 nbBusPatch = 2;
164 else
165 nbBusPatch = 4;
166
167 // calculate the number of TB & BB
168 // R1: 2 bridges more per PCB
169 // R2 & R3: 1 translator more per PCB
170 if (i == 2) nbBB += 2;
171 if (i == 3) nbBB += 4;
172 if (i == 4) nbBB += 4;
173 if (i == 5) nbBB += 6;
174 if (i == 6) nbBB += 8;
175
176 nbTB += nbBusPatch;
177 if (nameSlat[len-1] == '1') {
178 nbTB += 2;
179 nbBusPatch+=2;
180 }
181 if (nameSlat[len-1] == '2' || nameSlat[len-1] == '3') {
182 nbTB += 1;
183 nbBusPatch++;
184 }
185
186 // station 3
187 // for buspatch length reasons, one ddl connects one 1/4 of two chambers
188 // really messy isn't it ?
189 // much more with the new DDL sharing for station 3
190
191 if (idDE < 700 ) {
192
193 if (idDE % 100 == 0) {
194 cout << "# Chamber " << idDE/100 << endl;
195 out << "# Chamber " << idDE/100 << endl;
196 }
197
198 // chamber 5
199 if (idDE == 500 ) {
200 iDDL = (idDE/100)*2+2;
201 begin[cursor] = AliMpBusPatch::GetGlobalBusID(1, iDDL-1);
202
203 end[cursor] = begin[cursor] + nbBusPatch - 1;
204 ++cursor;
205 begin[cursor] = end[cursor-1] + 1;
206
207 cout << idDE << " " << begin[cursor-1]<<"-"<<end[cursor-1] << " " << iDDL-1 << " " <<nameSlat <<endl;
208 out << idDE << " " << begin[cursor-1]<<"-"<<end[cursor-1] <<" " << iDDL-1 <<endl;
209 }
210
211 if (idDE >= idCh5swp1 && idDE < idCh5swp2) {
212
213 if ( idDE == idCh5swp1) {
214 iDDL = (idDE/100)*2 ;
215 begin[cursor] = AliMpBusPatch::GetGlobalBusID(offsetBusCh5swp1, iDDL-1);
216 }
217
218 end[cursor] = begin[cursor] - nbBusPatch + 1;
219 ++cursor;
220 begin[cursor] = end[cursor-1] - 1;
221
222 cout << idDE << " " << end[cursor-1]<<"-"<<begin[cursor-1] << " " << iDDL-1 << " " <<nameSlat <<endl;
223 out << idDE << " " << end[cursor-1]<<"-"<<begin[cursor-1] <<" " << iDDL-1 <<endl;
224 }
225
226 if (idDE >= idCh5swp2 && idDE < idCh5swp3) {
227
228 if (idDE == idCh5swp2) {
229 iDDL = (idDE/100)*2-1;
230 begin[cursor] = AliMpBusPatch::GetGlobalBusID(1, iDDL-1);
231 }
232
233 end[cursor] = begin[cursor] + nbBusPatch - 1;
234 ++cursor;
235 begin[cursor] = end[cursor-1] + 1;
236
237 cout << idDE << " " << begin[cursor-1]<<"-"<<end[cursor-1] << " " << iDDL-1 << " " <<nameSlat <<endl;
238 out << idDE << " " << begin[cursor-1]<<"-"<<end[cursor-1] <<" " << iDDL-1 <<endl;
239 }
240
241 if (idDE >= idCh5swp3 && idDE < idCh5swp4) {
242
243 if (idDE == idCh5swp3) {
244 iDDL = (idDE/100)*2+1;
245 begin[cursor] = AliMpBusPatch::GetGlobalBusID(1, iDDL-1);
246 }
247
248 end[cursor] = begin[cursor] + nbBusPatch - 1;
249 ++cursor;
250 begin[cursor] = end[cursor-1] + 1;
251
252 cout << idDE << " " << begin[cursor-1]<<"-"<<end[cursor-1] << " " << iDDL-1 << " " <<nameSlat <<endl;
253 out << idDE << " " << begin[cursor-1]<<"-"<<end[cursor-1] <<" " << iDDL-1 <<endl;
254 }
255
256 if (idDE >= idCh5swp4 && idDE < 600) {
257
258 if ( idDE == idCh5swp4) {
259 iDDL = (idDE/100)*2+2 ;
260 begin[cursor] = AliMpBusPatch::GetGlobalBusID(offsetBusCh5swp2, iDDL-1);
261 }
262
263 end[cursor] = begin[cursor] - nbBusPatch + 1;
264 ++cursor;
265 begin[cursor] = end[cursor-1] - 1;
266
267 cout << idDE << " " << end[cursor-1]<<"-"<<begin[cursor-1] << " " << iDDL-1 << " " <<nameSlat <<endl;
268 out << idDE << " " << end[cursor-1]<<"-"<<begin[cursor-1] <<" " << iDDL-1 <<endl;
269 }
270
271 // chamber 6
272 if (idDE >= idCh6swp1 && idDE < idCh6swp2) {
273
274 if ( idDE == idCh6swp1) {
275 iDDL = (idDE/100)*2-2 ;
276 begin[cursor] = AliMpBusPatch::GetGlobalBusID(offsetBusCh5swp1+offsetBusCh6swp1, iDDL-1);
277 }
278
279 end[cursor] = begin[cursor] - nbBusPatch + 1;
280 ++cursor;
281 begin[cursor] = end[cursor-1] - 1;
282
283 cout << idDE << " " << end[cursor-1]<<"-"<<begin[cursor-1] << " " << iDDL-1 << " " <<nameSlat <<endl;
284 out << idDE << " " << end[cursor-1]<<"-"<<begin[cursor-1] <<" " << iDDL-1 <<endl;
285 }
286
287 if (idDE >= idCh6swp2 && idDE < idCh6swp3) {
288
289 if (idDE == idCh6swp2) {
290 iDDL = (idDE/100)*2-3;
291 begin[cursor] = AliMpBusPatch::GetGlobalBusID(offsetBusCh5swp2+1, iDDL-1);
292 }
293
294 end[cursor] = begin[cursor] + nbBusPatch - 1;
295 ++cursor;
296 begin[cursor] = end[cursor-1] + 1;
297
298 cout << idDE << " " << begin[cursor-1]<<"-"<<end[cursor-1] << " " << iDDL-1 << " " <<nameSlat <<endl;
299 out << idDE << " " << begin[cursor-1]<<"-"<<end[cursor-1] <<" " << iDDL-1 <<endl;
300 }
301
302 if (idDE >= idCh6swp3 && idDE < idCh6swp4) {
303
304 if (idDE == idCh6swp3) {
305 iDDL = (idDE/100)*2-1;
306 begin[cursor] = AliMpBusPatch::GetGlobalBusID(offsetBusCh5swp1+1, iDDL-1);
307 }
308
309 end[cursor] = begin[cursor] + nbBusPatch - 1;
310 ++cursor;
311 begin[cursor] = end[cursor-1] + 1;
312
313 cout << idDE << " " << begin[cursor-1]<<"-"<<end[cursor-1] << " " << iDDL-1 << " " <<nameSlat <<endl;
314 out << idDE << " " << begin[cursor-1]<<"-"<<end[cursor-1] <<" " << iDDL-1 <<endl;
315 }
316
317 if (idDE >= idCh6swp4 && idDE < 700) {
318
319 if ( idDE == idCh6swp4) {
320 iDDL = (idDE/100)*2 ;
321 begin[cursor] = AliMpBusPatch::GetGlobalBusID(offsetBusCh5swp2+offsetBusCh6swp2, iDDL-1);
322 }
323
324 end[cursor] = begin[cursor] - nbBusPatch + 1;
325 ++cursor;
326 begin[cursor] = end[cursor-1] - 1;
327
328 cout << idDE << " " << end[cursor-1]<<"-"<<begin[cursor-1] << " " << iDDL-1 << " " <<nameSlat <<endl;
329 out << idDE << " " << end[cursor-1]<<"-"<<begin[cursor-1] <<" " << iDDL-1 <<endl;
330 }
331
332 }
333
334 // station 4 & 5
335 // back to normal one ddl connects one 1/2 chamber
336 // finally !
337
338 if (idDE >= 700) {
339
340 if (idDE % 100 == 0) {
341 cout << "# Chamber " << idDE/100 << endl;
342 out << "# Chamber " << idDE/100 << endl;
343 }
344
345 if ((idDE % 100) >= idSt45swp1 && (idDE % 100) < idSt45swp2) {
346 if ((idDE % 100) == idSt45swp1) {
347 iDDL = (idDE/100)*2-1;
348 begin[cursor] = AliMpBusPatch::GetGlobalBusID(1, iDDL-1);
349 }
350 end[cursor] = begin[cursor] + nbBusPatch - 1;
351 ++cursor;
352 begin[cursor] = end[cursor-1] + 1;
353
354 cout << idDE << " " << begin[cursor-1]<<"-"<<end[cursor-1] << " " << iDDL-1 << " " <<nameSlat <<endl;
355 out << idDE << " " << begin[cursor-1]<<"-"<<end[cursor-1] <<" " << iDDL-1 <<endl;
356 }
357
358 if (idDE % 100 >= idSt45swp2) {
359
360 if ((idDE % 100) == idSt45swp2 ) {
361 iDDL = (idDE/100)*2 ;
362 if (idDE/100 == 7 || idDE/100 == 8)
363 begin[cursor] = AliMpBusPatch::GetGlobalBusID(offsetBusSt4swp, iDDL-1);
364 else
365 begin[cursor] = AliMpBusPatch::GetGlobalBusID(offsetBusSt5swp, iDDL-1);
366
367 }
368 end[cursor] = begin[cursor] - nbBusPatch + 1;
369 ++cursor;
370 begin[cursor] = end[cursor-1] - 1;
371
372 cout << idDE << " " << end[cursor-1]<<"-"<<begin[cursor-1] << " " << iDDL-1 << " " <<nameSlat <<endl;
373 out << idDE << " " << end[cursor-1]<<"-"<<begin[cursor-1] <<" " << iDDL-1 <<endl;
374 }
375
376 if ((idDE % 100) >= 0 && (idDE % 100) < idSt45swp1) {
377
378 if ((idDE % 100) == 0 ) {
379 iDDL = (idDE/100)*2;
380 if (idDE/100 == 7 || idDE/100 == 8)
381 begin[cursor] = AliMpBusPatch::GetGlobalBusID(offsetBusSt4, iDDL-1);
382 else
383 begin[cursor] = AliMpBusPatch::GetGlobalBusID(offsetBusSt5, iDDL-1);
384
385 }
386 end[cursor] = begin[cursor] - nbBusPatch + 1;
387 ++cursor;
388 begin[cursor] = end[cursor-1] - 1;
389
390 cout << idDE << " " << end[cursor-1]<<"-"<<begin[cursor-1] << " " << iDDL-1 << " " <<nameSlat <<endl;
391 out << idDE << " " << end[cursor-1]<<"-"<<begin[cursor-1] <<" " << iDDL-1 <<endl;
392 }
393
394 }
395
396 }
397 printf(" Slat: number of TB %d and BB %d\n", nbTB, nbBB);
398 in.close();
399 out.close();
400}