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)
29 TString dirPath2 = gSystem->Getenv("ALICE_ROOT");
30 dirPath2 += "/MUON/mapping/data/";
32 TString dirPath1 = dirPath2 + "station345/";
34 TString infile = dirPath1 + "DetElemIdToSlatType.dat";
35 TString outfile = dirPath2 + "DetElemIdToBusPatch.dat.out";
37 ifstream in(infile, ios::in);
38 ofstream out(outfile, ios::out);
50 Int_t idSt12[] = {100, 101, 102, 103,
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
59 Int_t idSt45swp1 = 7; // half chamber for DDL in vertical cutting twice the official numbering
60 Int_t idSt45swp2 = 20;
65 cout << "#DE BusPatch DDL SlatName" << endl;
66 out << "#DE BusPatch DDL " << endl;
68 for (Int_t j = 0; j < 16; j++) {
71 if (idDE % 100 == 0) {
73 begin[cursor] = AliMpBusPatch::GetGlobalBusID(0, iDDL-1);
74 cout << "# Chamber " << idDE/100 << endl;
75 out << "# Chamber " << idDE/100 << endl;
77 if (idDE % 100 == 1) {
79 begin[cursor] = AliMpBusPatch::GetGlobalBusID(0, iDDL-1);
81 if (idDE % 100 == 3) {
83 begin[cursor] = AliMpBusPatch::GetGlobalBusID(0, iDDL-1) + nbBusPatch;
85 end[cursor] = begin[cursor] + nbBusPatch - 1;
86 begin[++cursor] = end[cursor] + 1;
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++;
96 Int_t nbBusSt3Tot1 = 0;
97 Int_t nbBusSt3Tot2 = 0;
98 Int_t nbBusSt3Tot3 = 0;
99 Int_t nbBusSt3Tot4 = 0;
101 Int_t nbBusSt3Swap1 = 0;
102 Int_t nbBusSt3Swap2 = 0;
103 Int_t nbBusSt3Swap3 = 0;
104 Int_t nbBusSt3Swap4 = 0;
106 Int_t iDDLSt3Swap1 = 0;
107 Int_t iDDLSt3Swap2 = 0;
108 Int_t iDDLSt3Swap3 = 0;
109 Int_t iDDLSt3Swap4 = 0;
111 Int_t nbBusSt45Tot = 0;
112 Int_t nbBusSt45Swap = 0;
115 while ( in.getline(line,80) ) {
117 if ( line[0] == '#' || line[0] == '\0' ) continue;
119 sscanf(line, "%d %s", &idDE, nameSlat);
122 while(nameSlat[i] < '4' && nameSlat[i] !='0') i++;
123 Int_t len = strlen(nameSlat);
125 // number of buspatch
126 if (i == 2 || i == 3)
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;
141 if (nameSlat[len-1] == '1') {
145 if (nameSlat[len-1] == '2' || nameSlat[len-1] == '3') {
151 // for buspatch length reasons, one ddl connects one 1/4 of two chambers
152 // really messy isn't it ?
158 begin[cursor] = AliMpBusPatch::GetGlobalBusID(0, iDDL-1);
162 if (idDE % 100 == 0) {
163 cout << "# Chamber " << idDE/100 << endl;
164 out << "# Chamber " << idDE/100 << endl;
167 nbBusSt3Tot1 += nbBusPatch;
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;
178 // first 1/4 chamber 6
181 begin[cursor] = AliMpBusPatch::GetGlobalBusID(nbBusSt3Swap1, iDDL-1);
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;
192 nbBusSt3Tot2 += nbBusPatch;
194 // second 1/4 chamber 6
195 if (idDE == 600 +idSt3swp1) {
197 begin[cursor] = AliMpBusPatch::GetGlobalBusID(nbBusSt3Swap2, iDDL-1);
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;
210 nbBusSt3Tot3 += nbBusPatch;
212 //third 1/4 chamber 6
214 nbBusSt3Swap4 = nbBusSt3Tot4;
216 if (idDE == 600 +idSt3swp2) {
218 begin[cursor] = AliMpBusPatch::GetGlobalBusID(nbBusSt3Swap3, iDDL-1);
219 nbBusSt3Tot4 += nbBusPatch;
221 nbBusSt3Tot4 += nbBusPatch;
223 // fourth 1/4 chamber 6
224 if (idDE == 600 +idSt3swp3) {
225 iDDL = iDDLSt3Swap3+1;
226 begin[cursor] = AliMpBusPatch::GetGlobalBusID(nbBusSt3Swap4, iDDL-1);
229 end[cursor] = begin[cursor] + nbBusPatch - 1;
230 begin[++cursor] = end[cursor] + 1;
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;
237 // back to normal one ddl connects one 1/2 chamber
240 iDDL = ((idDE-1)/100)*2;
244 if (idDE % 100 == 0) {
249 begin[cursor] = AliMpBusPatch::GetGlobalBusID(0, iDDL-1);
250 cout << "# Chamber " << idDE/100 << endl;
251 out << "# Chamber " << idDE/100 << endl;
254 nbBusSt45Tot += nbBusPatch;
256 if (idDE == 700+idSt45swp1 || idDE == 800+idSt45swp1 || idDE == 900+idSt45swp1 || idDE == 1000+idSt45swp1 ) {
258 begin[cursor] = AliMpBusPatch::GetGlobalBusID(0, iDDL-1);
259 nbBusSt45Swap = nbBusSt45Tot - nbBusPatch;
262 if (idDE == 700+idSt45swp2 || idDE == 800+idSt45swp2 || idDE == 900+idSt45swp2 || idDE == 1000+idSt45swp2 ) {
264 begin[cursor] = AliMpBusPatch::GetGlobalBusID(nbBusSt45Swap, iDDL-1);
266 end[cursor] = begin[cursor] + nbBusPatch - 1;
267 begin[++cursor] = end[cursor] + 1;
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;
274 printf(" Slat: number of TB %d and BB %d\n", nbTB, nbBB);