1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 void MUONGenerateBusPatch()
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 // (Feb. 07, add 1st manu list for St12 (starting on NB !) and new ddl sharing for station 3)
30 TString dirPath2 = gSystem->Getenv("ALICE_ROOT");
31 dirPath2 += "/MUON/mapping/data/";
33 TString dirPath1 = dirPath2 + "station345/";
35 TString infile = dirPath1 + "DetElemIdToSlatType.dat";
36 TString outfile = dirPath2 + "DetElemIdToBusPatch.dat.out";
38 ifstream in(infile, ios::in);
39 ofstream out(outfile, ios::out);
51 Int_t idSt12[] = {100, 101, 102, 103,
57 = " 1,27,53,79,105,131,157,183,201,214,224,232,1025,1051,1077,1103,1129,1155,1181,1207,1225,1238,1249,1257";
60 = " 1,27,53,79,105,131,157,183,201,214,226,246,1025,1051,1077,1103,1129,1155,1181,1207,1225,1238,1251,1269";
62 Int_t idCh5swp1 = 5; // 1/4 chamber for DDL on horizontal
63 Int_t idCh5swp2 = 10; // 1/4 chamber for DDL on horizontal
64 Int_t idCh5swp3 = 14; // 1/4 chamber for DDL on horizontal
66 Int_t idCh6swp1 = 5; // 1/4 chamber for DDL on horizontal
67 Int_t idCh6swp2 = 9; // 1/4 chamber for DDL on horizontal
68 Int_t idCh6swp3 = 14; // 1/4 chamber for DDL on horizontal
70 Int_t idSt45swp1 = 7; // half chamber for DDL in vertical cutting twice the official numbering
71 Int_t idSt45swp2 = 20;
76 Int_t nbHalfBusPatch = nbBusPatch/2;
77 cout << "#DE BusPatch DDL SlatName" << endl;
78 out << "#DE BusPatch DDL 1st manu in buspatch" << endl;
80 for (Int_t j = 0; j < 16; j++) {
83 if (idDE % 100 == 0) {
85 begin[cursor] = AliMpBusPatch::GetGlobalBusID(0, iDDL-1);
86 cout << "# Chamber " << idDE/100 << endl;
87 out << "# Chamber " << idDE/100 << endl;
89 if (idDE % 100 == 1) {
91 begin[cursor] = AliMpBusPatch::GetGlobalBusID(0, iDDL-1);
94 if (idDE % 100 == 3) {
96 begin[cursor] = AliMpBusPatch::GetGlobalBusID(0, iDDL-1) + nbBusPatch;
99 end[cursor] = begin[cursor] + nbBusPatch - 1;
100 begin[++cursor] = end[cursor] + 1;
102 cout << idDE << " " << begin[cursor-1] + nbHalfBusPatch << "-" <<end[cursor-1] << ";" <<
103 begin[cursor-1] << "-" << end[cursor-1] - nbHalfBusPatch << " " << iDDL-1 << endl;
106 out << idDE << " " << begin[cursor-1] + nbHalfBusPatch << "-" <<end[cursor-1] << ";" <<
107 begin[cursor-1] << "-" << end[cursor-1] - nbHalfBusPatch << " " << iDDL-1 <<
110 out << idDE << " " << begin[cursor-1] + nbHalfBusPatch << "-" <<end[cursor-1] << ";" <<
111 begin[cursor-1] << "-" << end[cursor-1] - nbHalfBusPatch << " " << iDDL-1 <<
113 if (idDE % 100 == 3) iDDL++;
119 Int_t nbBusSt3Tot1 = 0;
120 Int_t nbBusSt3Tot2 = 0;
121 Int_t nbBusSt3Tot3 = 0;
122 Int_t nbBusSt3Tot4 = 0;
124 Int_t nbBusSt3Swap1 = 0;
125 Int_t nbBusSt3Swap2 = 0;
126 Int_t nbBusSt3Swap3 = 0;
127 Int_t nbBusSt3Swap4 = 0;
129 Int_t iDDLSt3Swap1 = 0;
130 Int_t iDDLSt3Swap2 = 0;
131 Int_t iDDLSt3Swap3 = 0;
132 Int_t iDDLSt3Swap4 = 0;
134 Int_t nbBusSt45Tot = 0;
135 Int_t nbBusSt45Swap = 0;
137 Int_t nbBus500 = 4; // number of buspatch in DE 500
138 Int_t nbDDL500 = 11; // DDL number for DE 500
139 Int_t offsetBus500 = 13; // number of buspatches in DDL 11 before DE 500
142 while ( in.getline(line,80) ) {
144 if ( line[0] == '#' || line[0] == '\0' ) continue;
146 sscanf(line, "%d %s", &idDE, nameSlat);
149 while(nameSlat[i] < '4' && nameSlat[i] !='0') i++;
150 Int_t len = strlen(nameSlat);
152 // number of buspatch
153 if (i == 2 || i == 3)
158 // calculate the number of TB & BB
159 // R1: 2 bridges more per PCB
160 // R2 & R3: 1 translator more per PCB
161 if (i == 2) nbBB += 2;
162 if (i == 3) nbBB += 4;
163 if (i == 4) nbBB += 4;
164 if (i == 5) nbBB += 6;
165 if (i == 6) nbBB += 8;
168 if (nameSlat[len-1] == '1') {
172 if (nameSlat[len-1] == '2' || nameSlat[len-1] == '3') {
178 // for buspatch length reasons, one ddl connects one 1/4 of two chambers
179 // really messy isn't it ?
180 // much more with the new DDL sharing for station 3
186 begin[cursor] = AliMpBusPatch::GetGlobalBusID(0, iDDL-1);
190 if (idDE % 100 == 0) {
191 cout << "# Chamber " << idDE/100 << endl;
192 out << "# Chamber " << idDE/100 << endl;
195 // taking into account that idDE = 500 is connected to ddl = 11;
197 cout << idDE << " " << AliMpBusPatch::GetGlobalBusID(offsetBus500, nbDDL500)<<"-"
198 << AliMpBusPatch::GetGlobalBusID(offsetBus500, nbDDL500) + nbBus500 -1
199 << " " << nbDDL500 << " " <<nameSlat <<endl;
201 out << idDE << " " << AliMpBusPatch::GetGlobalBusID(offsetBus500, nbDDL500)<<"-"
202 << AliMpBusPatch::GetGlobalBusID(offsetBus500, nbDDL500) + nbBus500 -1
203 << " " << nbDDL500 <<endl;
206 nbBusSt3Tot1 += nbBusPatch;
208 // second 1/4 for chamber 5
209 if (idDE == 500+idCh5swp1) {
210 iDDLSt3Swap1 = iDDL++;
211 begin[cursor] = AliMpBusPatch::GetGlobalBusID(0, iDDL-1);
212 nbBusSt3Swap1 = nbBusSt3Tot1 - nbBusPatch;
217 // first 1/4 chamber 6
220 begin[cursor] = AliMpBusPatch::GetGlobalBusID(nbBusSt3Swap1, iDDL-1);
222 // third 1/4 for chamber 5
223 if (idDE == 500+idCh5swp2) {
224 iDDL = iDDLSt3Swap1+1;
225 iDDLSt3Swap2 = iDDL++;
226 begin[cursor] = AliMpBusPatch::GetGlobalBusID(0, iDDL-1);
227 nbBusSt3Swap2 = nbBusSt3Tot2;
231 nbBusSt3Tot2 += nbBusPatch;
233 // second 1/4 chamber 6
234 if (idDE == 600 +idCh6swp1) {
236 begin[cursor] = AliMpBusPatch::GetGlobalBusID(nbBusSt3Swap2, iDDL-1);
239 // fourth 1/4 chamber 5
240 if (idDE == 500+idCh5swp3) {
241 iDDL = iDDLSt3Swap2+1;
242 iDDLSt3Swap3 = iDDL++;
243 begin[cursor] = AliMpBusPatch::GetGlobalBusID(0, iDDL-1);
244 nbBusSt3Swap3 = nbBusSt3Tot3;
249 nbBusSt3Tot3 += nbBusPatch;
251 //third 1/4 chamber 6
253 nbBusSt3Swap4 = nbBusSt3Tot4;
255 if (idDE == 600 +idCh6swp2) {
257 begin[cursor] = AliMpBusPatch::GetGlobalBusID(nbBusSt3Swap3, iDDL-1);
258 nbBusSt3Tot4 += nbBusPatch;
260 nbBusSt3Tot4 += nbBusPatch;
262 // fourth 1/4 chamber 6
263 if (idDE == 600 +idCh6swp3) {
264 iDDL = iDDLSt3Swap3+1;
265 begin[cursor] = AliMpBusPatch::GetGlobalBusID(nbBusSt3Swap4 + nbBus500, iDDL-1);
268 end[cursor] = begin[cursor] + nbBusPatch - 1;
269 begin[++cursor] = end[cursor] + 1;
271 cout << idDE << " " << begin[cursor-1]<<"-"<<end[cursor-1] << " " << iDDL-1 << " " <<nameSlat <<endl;
272 out << idDE << " " << begin[cursor-1]<<"-"<<end[cursor-1] <<" " << iDDL-1 <<endl;
276 // back to normal one ddl connects one 1/2 chamber
279 iDDL = ((idDE-1)/100)*2;
283 if (idDE % 100 == 0) {
288 begin[cursor] = AliMpBusPatch::GetGlobalBusID(0, iDDL-1);
289 cout << "# Chamber " << idDE/100 << endl;
290 out << "# Chamber " << idDE/100 << endl;
293 nbBusSt45Tot += nbBusPatch;
295 if (idDE == 700+idSt45swp1 || idDE == 800+idSt45swp1 || idDE == 900+idSt45swp1 || idDE == 1000+idSt45swp1 ) {
297 begin[cursor] = AliMpBusPatch::GetGlobalBusID(0, iDDL-1);
298 nbBusSt45Swap = nbBusSt45Tot - nbBusPatch;
301 if (idDE == 700+idSt45swp2 || idDE == 800+idSt45swp2 || idDE == 900+idSt45swp2 || idDE == 1000+idSt45swp2 ) {
303 begin[cursor] = AliMpBusPatch::GetGlobalBusID(nbBusSt45Swap, iDDL-1);
305 end[cursor] = begin[cursor] + nbBusPatch - 1;
306 begin[++cursor] = end[cursor] + 1;
308 cout << idDE << " " << begin[cursor-1]<<"-"<<end[cursor-1] << " " << iDDL-1 << " " <<nameSlat <<endl;
309 out << idDE << " " << begin[cursor-1]<<"-"<<end[cursor-1] <<" " << iDDL-1 <<endl;
313 printf(" Slat: number of TB %d and BB %d\n", nbTB, nbBB);