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 **************************************************************************/
18 #if !defined(__CINT__) || defined(__MAKECINT__)
20 #include <Riostream.h>
26 #include "AliMpBusPatch.h"
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)
41 void MUONGenerateBusPatch()
44 TString dirPath2 = gSystem->Getenv("ALICE_ROOT");
45 dirPath2 += "/MUON/mapping/data/";
47 TString dirPath1 = dirPath2 + "station345/";
49 TString infile = dirPath1 + "DetElemIdToSlatType.dat";
50 TString outfile = dirPath2 + "DetElemIdToBusPatch.dat.out";
52 ifstream in(infile, ios::in);
53 ofstream out(outfile, ios::out);
64 Int_t idSt12[] = {100, 101, 102, 103,
70 = " 1,27,53,79,105,131,157,183,201,214,224,232,1025,1051,1077,1103,1129,1155,1181,1207,1225,1238,1249,1257";
73 = " 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 Int_t idCh5swp1 = 5; // 1/4 chamber for DDL on horizontal
76 Int_t idCh5swp2 = 10; // 1/4 chamber for DDL on horizontal
77 Int_t idCh5swp3 = 14; // 1/4 chamber for DDL on horizontal
79 Int_t idCh6swp1 = 5; // 1/4 chamber for DDL on horizontal
80 Int_t idCh6swp2 = 9; // 1/4 chamber for DDL on horizontal
81 Int_t idCh6swp3 = 14; // 1/4 chamber for DDL on horizontal
83 Int_t idSt45swp1 = 7; // half chamber for DDL in vertical cutting twice the official numbering
84 Int_t idSt45swp2 = 20;
89 Int_t nbHalfBusPatch = nbBusPatch/2;
90 cout << "#DE BusPatch DDL SlatName" << endl;
91 out << "#DE BusPatch DDL 1st manu in buspatch" << endl;
93 for (Int_t j = 0; j < 16; j++) {
96 if (idDE % 100 == 0) {
98 begin[cursor] = AliMpBusPatch::GetGlobalBusID(0, iDDL-1);
99 cout << "# Chamber " << idDE/100 << endl;
100 out << "# Chamber " << idDE/100 << endl;
102 if (idDE % 100 == 1) {
104 begin[cursor] = AliMpBusPatch::GetGlobalBusID(0, iDDL-1);
107 if (idDE % 100 == 3) {
109 begin[cursor] = AliMpBusPatch::GetGlobalBusID(0, iDDL-1) + nbBusPatch;
112 end[cursor] = begin[cursor] + nbBusPatch - 1;
113 ++cursor; // it seems that vec[++i] does not work in Cint
114 begin[cursor] = end[cursor-1] + 1;
116 cout << idDE << " " << begin[cursor-1] + nbHalfBusPatch << "-" <<end[cursor-1] << ";" <<
117 begin[cursor-1] << "-" << end[cursor-1] - nbHalfBusPatch << " " << iDDL-1 << endl;
120 out << idDE << " " << begin[cursor-1] + nbHalfBusPatch << "-" <<end[cursor-1] << ";" <<
121 begin[cursor-1] << "-" << end[cursor-1] - nbHalfBusPatch << " " << iDDL-1 <<
124 out << idDE << " " << begin[cursor-1] + nbHalfBusPatch << "-" <<end[cursor-1] << ";" <<
125 begin[cursor-1] << "-" << end[cursor-1] - nbHalfBusPatch << " " << iDDL-1 <<
127 if (idDE % 100 == 3) iDDL++;
133 Int_t nbBusSt3Tot1 = 0;
134 Int_t nbBusSt3Tot2 = 0;
135 Int_t nbBusSt3Tot3 = 0;
136 Int_t nbBusSt3Tot4 = 0;
138 Int_t nbBusSt3Swap1 = 0;
139 Int_t nbBusSt3Swap2 = 0;
140 Int_t nbBusSt3Swap3 = 0;
141 Int_t nbBusSt3Swap4 = 0;
143 Int_t iDDLSt3Swap1 = 0;
144 Int_t iDDLSt3Swap2 = 0;
145 Int_t iDDLSt3Swap3 = 0;
147 Int_t nbBusSt45Tot = 0;
148 Int_t nbBusSt45Swap = 0;
150 Int_t nbBus500 = 4; // number of buspatch in DE 500
151 Int_t nbDDL500 = 11; // DDL number for DE 500
152 Int_t offsetBus500 = 13; // number of buspatches in DDL 11 before DE 500
155 while ( in.getline(line,80) ) {
157 if ( line[0] == '#' || line[0] == '\0' ) continue;
159 sscanf(line, "%d %s", &idDE, nameSlat);
162 while(nameSlat[i] < '4' && nameSlat[i] !='0') i++;
163 Int_t len = strlen(nameSlat);
165 // number of buspatch
166 if (i == 2 || i == 3)
171 // calculate the number of TB & BB
172 // R1: 2 bridges more per PCB
173 // R2 & R3: 1 translator more per PCB
174 if (i == 2) nbBB += 2;
175 if (i == 3) nbBB += 4;
176 if (i == 4) nbBB += 4;
177 if (i == 5) nbBB += 6;
178 if (i == 6) nbBB += 8;
181 if (nameSlat[len-1] == '1') {
185 if (nameSlat[len-1] == '2' || nameSlat[len-1] == '3') {
191 // for buspatch length reasons, one ddl connects one 1/4 of two chambers
192 // really messy isn't it ?
193 // much more with the new DDL sharing for station 3
199 begin[cursor] = AliMpBusPatch::GetGlobalBusID(0, iDDL-1);
203 if (idDE % 100 == 0) {
204 cout << "# Chamber " << idDE/100 << endl;
205 out << "# Chamber " << idDE/100 << endl;
208 // taking into account that idDE = 500 is connected to ddl = 11;
210 cout << idDE << " " << AliMpBusPatch::GetGlobalBusID(offsetBus500, nbDDL500)<<"-"
211 << AliMpBusPatch::GetGlobalBusID(offsetBus500, nbDDL500) + nbBus500 -1
212 << " " << nbDDL500 << " " <<nameSlat <<endl;
214 out << idDE << " " << AliMpBusPatch::GetGlobalBusID(offsetBus500, nbDDL500)<<"-"
215 << AliMpBusPatch::GetGlobalBusID(offsetBus500, nbDDL500) + nbBus500 -1
216 << " " << nbDDL500 <<endl;
219 nbBusSt3Tot1 += nbBusPatch;
221 // second 1/4 for chamber 5
222 if (idDE == 500+idCh5swp1) {
223 iDDLSt3Swap1 = iDDL++;
224 begin[cursor] = AliMpBusPatch::GetGlobalBusID(0, iDDL-1);
225 nbBusSt3Swap1 = nbBusSt3Tot1 - nbBusPatch;
230 // first 1/4 chamber 6
233 begin[cursor] = AliMpBusPatch::GetGlobalBusID(nbBusSt3Swap1, iDDL-1);
235 // third 1/4 for chamber 5
236 if (idDE == 500+idCh5swp2) {
237 iDDL = iDDLSt3Swap1+1;
238 iDDLSt3Swap2 = iDDL++;
239 begin[cursor] = AliMpBusPatch::GetGlobalBusID(0, iDDL-1);
240 nbBusSt3Swap2 = nbBusSt3Tot2;
244 nbBusSt3Tot2 += nbBusPatch;
246 // second 1/4 chamber 6
247 if (idDE == 600 +idCh6swp1) {
249 begin[cursor] = AliMpBusPatch::GetGlobalBusID(nbBusSt3Swap2, iDDL-1);
252 // fourth 1/4 chamber 5
253 if (idDE == 500+idCh5swp3) {
254 iDDL = iDDLSt3Swap2+1;
255 iDDLSt3Swap3 = iDDL++;
256 begin[cursor] = AliMpBusPatch::GetGlobalBusID(0, iDDL-1);
257 nbBusSt3Swap3 = nbBusSt3Tot3;
262 nbBusSt3Tot3 += nbBusPatch;
264 //third 1/4 chamber 6
266 nbBusSt3Swap4 = nbBusSt3Tot4;
268 if (idDE == 600 +idCh6swp2) {
270 begin[cursor] = AliMpBusPatch::GetGlobalBusID(nbBusSt3Swap3, iDDL-1);
271 nbBusSt3Tot4 += nbBusPatch;
273 nbBusSt3Tot4 += nbBusPatch;
275 // fourth 1/4 chamber 6
276 if (idDE == 600 +idCh6swp3) {
277 iDDL = iDDLSt3Swap3+1;
278 begin[cursor] = AliMpBusPatch::GetGlobalBusID(nbBusSt3Swap4 + nbBus500, iDDL-1);
281 end[cursor] = begin[cursor] + nbBusPatch - 1;
283 begin[cursor] = end[cursor-1] + 1;
285 cout << idDE << " " << begin[cursor-1]<<"-"<<end[cursor-1] << " " << iDDL-1 << " " <<nameSlat <<endl;
286 out << idDE << " " << begin[cursor-1]<<"-"<<end[cursor-1] <<" " << iDDL-1 <<endl;
290 // back to normal one ddl connects one 1/2 chamber
293 iDDL = ((idDE-1)/100)*2;
297 if (idDE % 100 == 0) {
302 begin[cursor] = AliMpBusPatch::GetGlobalBusID(0, iDDL-1);
303 cout << "# Chamber " << idDE/100 << endl;
304 out << "# Chamber " << idDE/100 << endl;
307 nbBusSt45Tot += nbBusPatch;
309 if (idDE == 700+idSt45swp1 || idDE == 800+idSt45swp1 || idDE == 900+idSt45swp1 || idDE == 1000+idSt45swp1 ) {
311 begin[cursor] = AliMpBusPatch::GetGlobalBusID(0, iDDL-1);
312 nbBusSt45Swap = nbBusSt45Tot - nbBusPatch;
315 if (idDE == 700+idSt45swp2 || idDE == 800+idSt45swp2 || idDE == 900+idSt45swp2 || idDE == 1000+idSt45swp2 ) {
317 begin[cursor] = AliMpBusPatch::GetGlobalBusID(nbBusSt45Swap, iDDL-1);
320 end[cursor] = begin[cursor] + nbBusPatch - 1;
322 begin[cursor] = end[cursor-1] + 1;
324 cout << idDE << " " << begin[cursor-1]<<"-"<<end[cursor-1] << " " << iDDL-1 << " " <<nameSlat <<endl;
325 out << idDE << " " << begin[cursor-1]<<"-"<<end[cursor-1] <<" " << iDDL-1 <<endl;
329 printf(" Slat: number of TB %d and BB %d\n", nbTB, nbBB);