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)
39 // (June. 07, new numbering of station 345, and buspatch starts at 1)
42 void MUONGenerateBusPatch()
45 TString dirPath2 = gSystem->Getenv("ALICE_ROOT");
46 dirPath2 += "/MUON/mapping/data/";
48 TString dirPath1 = dirPath2 + "station345/";
50 TString infile = dirPath1 + "DetElemIdToSlatType.dat";
51 TString outfile = dirPath2 + "DetElemIdToBusPatch.dat.out";
53 ifstream in(infile, ios::in);
54 ofstream out(outfile, ios::out);
65 Int_t idSt12[] = {100, 101, 102, 103,
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";
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";
81 Int_t nbHalfBusPatch = nbBusPatch/2;
82 cout << "#DE BusPatch DDL SlatName" << endl;
83 out << "#DE BusPatch DDL 1st manu in buspatch" << endl;
85 for (Int_t j = 0; j < 16; j++) {
88 if (idDE % 100 == 0) {
90 begin[cursor] = AliMpBusPatch::GetGlobalBusID(1, iDDL-1);
91 cout << "# Chamber " << idDE/100 << endl;
92 out << "# Chamber " << idDE/100 << endl;
94 if (idDE % 100 == 1) {
96 begin[cursor] = AliMpBusPatch::GetGlobalBusID(1, iDDL-1);
99 if (idDE % 100 == 3) {
101 begin[cursor] = AliMpBusPatch::GetGlobalBusID(1, iDDL-1) + nbBusPatch;
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;
108 cout << idDE << " " << begin[cursor-1] + nbHalfBusPatch << "-" <<end[cursor-1] << ";" <<
109 begin[cursor-1] << "-" << end[cursor-1] - nbHalfBusPatch << " " << iDDL-1 << endl;
112 out << idDE << " " << begin[cursor-1] + nbHalfBusPatch << "-" <<end[cursor-1] << ";" <<
113 begin[cursor-1] << "-" << end[cursor-1] - nbHalfBusPatch << " " << iDDL-1 <<
116 out << idDE << " " << begin[cursor-1] + nbHalfBusPatch << "-" <<end[cursor-1] << ";" <<
117 begin[cursor-1] << "-" << end[cursor-1] - nbHalfBusPatch << " " << iDDL-1 <<
119 if (idDE % 100 == 3) iDDL++;
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
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
135 Int_t idSt45swp1 = 7; // half chamber for DDL in vertical cutting twice the official numbering
136 Int_t idSt45swp2 = 20;
138 Int_t offsetBusCh5swp1 = 13; // number of buspatches between DE 501-504
139 Int_t offsetBusCh5swp2 = 17; // number of buspatches before DE 510
141 Int_t offsetBusCh6swp1 = 17; // number of buspatches before DE 600-604
142 Int_t offsetBusCh6swp2 = 13; // number of buspatches between DE 614-617
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)
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)
151 while ( in.getline(line,80) ) {
153 if ( line[0] == '#' || line[0] == '\0' ) continue;
155 sscanf(line, "%d %s", &idDE, nameSlat);
158 while(nameSlat[i] < '4' && nameSlat[i] !='0') i++;
159 Int_t len = strlen(nameSlat);
161 // number of buspatch
162 if (i == 2 || i == 3)
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;
177 if (nameSlat[len-1] == '1') {
181 if (nameSlat[len-1] == '2' || nameSlat[len-1] == '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
193 if (idDE % 100 == 0) {
194 cout << "# Chamber " << idDE/100 << endl;
195 out << "# Chamber " << idDE/100 << endl;
200 iDDL = (idDE/100)*2+2;
201 begin[cursor] = AliMpBusPatch::GetGlobalBusID(1, iDDL-1);
203 end[cursor] = begin[cursor] + nbBusPatch - 1;
205 begin[cursor] = end[cursor-1] + 1;
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;
211 if (idDE >= idCh5swp1 && idDE < idCh5swp2) {
213 if ( idDE == idCh5swp1) {
214 iDDL = (idDE/100)*2 ;
215 begin[cursor] = AliMpBusPatch::GetGlobalBusID(offsetBusCh5swp1, iDDL-1);
218 end[cursor] = begin[cursor] - nbBusPatch + 1;
220 begin[cursor] = end[cursor-1] - 1;
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;
226 if (idDE >= idCh5swp2 && idDE < idCh5swp3) {
228 if (idDE == idCh5swp2) {
229 iDDL = (idDE/100)*2-1;
230 begin[cursor] = AliMpBusPatch::GetGlobalBusID(1, iDDL-1);
233 end[cursor] = begin[cursor] + nbBusPatch - 1;
235 begin[cursor] = end[cursor-1] + 1;
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;
241 if (idDE >= idCh5swp3 && idDE < idCh5swp4) {
243 if (idDE == idCh5swp3) {
244 iDDL = (idDE/100)*2+1;
245 begin[cursor] = AliMpBusPatch::GetGlobalBusID(1, iDDL-1);
248 end[cursor] = begin[cursor] + nbBusPatch - 1;
250 begin[cursor] = end[cursor-1] + 1;
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;
256 if (idDE >= idCh5swp4 && idDE < 600) {
258 if ( idDE == idCh5swp4) {
259 iDDL = (idDE/100)*2+2 ;
260 begin[cursor] = AliMpBusPatch::GetGlobalBusID(offsetBusCh5swp2, iDDL-1);
263 end[cursor] = begin[cursor] - nbBusPatch + 1;
265 begin[cursor] = end[cursor-1] - 1;
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;
272 if (idDE >= idCh6swp1 && idDE < idCh6swp2) {
274 if ( idDE == idCh6swp1) {
275 iDDL = (idDE/100)*2-2 ;
276 begin[cursor] = AliMpBusPatch::GetGlobalBusID(offsetBusCh5swp1+offsetBusCh6swp1, iDDL-1);
279 end[cursor] = begin[cursor] - nbBusPatch + 1;
281 begin[cursor] = end[cursor-1] - 1;
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;
287 if (idDE >= idCh6swp2 && idDE < idCh6swp3) {
289 if (idDE == idCh6swp2) {
290 iDDL = (idDE/100)*2-3;
291 begin[cursor] = AliMpBusPatch::GetGlobalBusID(offsetBusCh5swp2+1, iDDL-1);
294 end[cursor] = begin[cursor] + nbBusPatch - 1;
296 begin[cursor] = end[cursor-1] + 1;
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;
302 if (idDE >= idCh6swp3 && idDE < idCh6swp4) {
304 if (idDE == idCh6swp3) {
305 iDDL = (idDE/100)*2-1;
306 begin[cursor] = AliMpBusPatch::GetGlobalBusID(offsetBusCh5swp1+1, iDDL-1);
309 end[cursor] = begin[cursor] + nbBusPatch - 1;
311 begin[cursor] = end[cursor-1] + 1;
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;
317 if (idDE >= idCh6swp4 && idDE < 700) {
319 if ( idDE == idCh6swp4) {
320 iDDL = (idDE/100)*2 ;
321 begin[cursor] = AliMpBusPatch::GetGlobalBusID(offsetBusCh5swp2+offsetBusCh6swp2, iDDL-1);
324 end[cursor] = begin[cursor] - nbBusPatch + 1;
326 begin[cursor] = end[cursor-1] - 1;
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;
335 // back to normal one ddl connects one 1/2 chamber
340 if (idDE % 100 == 0) {
341 cout << "# Chamber " << idDE/100 << endl;
342 out << "# Chamber " << idDE/100 << endl;
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);
350 end[cursor] = begin[cursor] + nbBusPatch - 1;
352 begin[cursor] = end[cursor-1] + 1;
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;
358 if (idDE % 100 >= idSt45swp2) {
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);
365 begin[cursor] = AliMpBusPatch::GetGlobalBusID(offsetBusSt5swp, iDDL-1);
368 end[cursor] = begin[cursor] - nbBusPatch + 1;
370 begin[cursor] = end[cursor-1] - 1;
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;
376 if ((idDE % 100) >= 0 && (idDE % 100) < idSt45swp1) {
378 if ((idDE % 100) == 0 ) {
380 if (idDE/100 == 7 || idDE/100 == 8)
381 begin[cursor] = AliMpBusPatch::GetGlobalBusID(offsetBusSt4, iDDL-1);
383 begin[cursor] = AliMpBusPatch::GetGlobalBusID(offsetBusSt5, iDDL-1);
386 end[cursor] = begin[cursor] - nbBusPatch + 1;
388 begin[cursor] = end[cursor-1] - 1;
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;
397 printf(" Slat: number of TB %d and BB %d\n", nbTB, nbBB);