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"
31 /// \file MUONGenerateBusPatch.C
32 /// \brief Generates buspatch id and DDL id for given detection element id
34 /// - station 1 & 2 assuming 24 buspatches per quadrant
35 /// - station345, reading from DetElemIdToSlatType.dat file and calculates
36 /// the number of bus patches per slat (and also number of Translator and Bridge Boards).
37 /// Generates an output file DetElemIdToBusPatch.dat.out, preserve from overwriting
40 /// - July 05, first version
41 /// - Nov. 05, added DDL
42 /// - June 06, correction for St123
43 /// - Feb. 07, add 1st manu list for St12 (starting on NB !) and new ddl sharing for station 3)
44 /// - June. 07, new numbering of station 345, and buspatch starts at 1)
46 /// \author Ch. Finck, July 05
49 void MUONGenerateBusPatch()
52 TString dirPath2 = gSystem->Getenv("ALICE_ROOT");
53 dirPath2 += "/MUON/mapping/data/";
55 TString dirPath1 = dirPath2 + "station345/";
57 TString infile = dirPath1 + "DetElemIdToSlatType.dat";
58 TString outfile = dirPath2 + "DetElemIdToBusPatch.dat.out";
60 ifstream in(infile, ios::in);
61 ofstream out(outfile, ios::out);
72 Int_t idSt12[] = {100, 101, 102, 103,
78 = " 1,27,53,79,105,131,157,183,201,214,224,232,1025,1051,1077,1103,1129,1155,1181,1207,1225,1238,1249,1257";
81 = " 1,27,53,79,105,131,157,183,201,214,226,246,1025,1051,1077,1103,1129,1155,1181,1207,1225,1238,1251,1269";
88 Int_t nbHalfBusPatch = nbBusPatch/2;
89 cout << "#DE BusPatch DDL SlatName" << endl;
90 out << "#DE BusPatch DDL 1st manu in buspatch" << endl;
92 for (Int_t j = 0; j < 16; j++) {
95 if (idDE % 100 == 0) {
97 begin[cursor] = AliMpBusPatch::GetGlobalBusID(1, iDDL-1);
98 cout << "# Chamber " << idDE/100 << endl;
99 out << "# Chamber " << idDE/100 << endl;
101 if (idDE % 100 == 1) {
103 begin[cursor] = AliMpBusPatch::GetGlobalBusID(1, iDDL-1);
106 if (idDE % 100 == 3) {
108 begin[cursor] = AliMpBusPatch::GetGlobalBusID(1, iDDL-1) + nbBusPatch;
111 end[cursor] = begin[cursor] + nbBusPatch - 1;
112 ++cursor; // it seems that vec[++i] does not work in Cint
113 begin[cursor] = end[cursor-1] + 1;
115 cout << idDE << " " << begin[cursor-1] + nbHalfBusPatch << "-" <<end[cursor-1] << ";" <<
116 begin[cursor-1] << "-" << end[cursor-1] - nbHalfBusPatch << " " << iDDL-1 << endl;
119 out << idDE << " " << begin[cursor-1] + nbHalfBusPatch << "-" <<end[cursor-1] << ";" <<
120 begin[cursor-1] << "-" << end[cursor-1] - nbHalfBusPatch << " " << iDDL-1 <<
123 out << idDE << " " << begin[cursor-1] + nbHalfBusPatch << "-" <<end[cursor-1] << ";" <<
124 begin[cursor-1] << "-" << end[cursor-1] - nbHalfBusPatch << " " << iDDL-1 <<
126 if (idDE % 100 == 3) iDDL++;
132 Int_t idCh5swp1 = 501; // 1/4 chamber for DDL on horizontal
133 Int_t idCh5swp2 = 505; // 1/4 chamber for DDL on horizontal
134 Int_t idCh5swp3 = 510; // 1/4 chamber for DDL on horizontal
135 Int_t idCh5swp4 = 514; // 1/4 chamber for DDL on horizontal
137 Int_t idCh6swp1 = 600; // 1/4 chamber for DDL on horizontal
138 Int_t idCh6swp2 = 605; // 1/4 chamber for DDL on horizontal
139 Int_t idCh6swp3 = 609; // 1/4 chamber for DDL on horizontal
140 Int_t idCh6swp4 = 614; // 1/4 chamber for DDL on horizontal
142 Int_t idSt45swp1 = 7; // half chamber for DDL in vertical cutting twice the official numbering
143 Int_t idSt45swp2 = 20;
145 Int_t offsetBusCh5swp1 = 13; // number of buspatches between DE 501-504
146 Int_t offsetBusCh5swp2 = 17; // number of buspatches before DE 510
148 Int_t offsetBusCh6swp1 = 17; // number of buspatches before DE 600-604
149 Int_t offsetBusCh6swp2 = 13; // number of buspatches between DE 614-617
151 Int_t offsetBusSt4 = 25; // number of buspatches before DE 700-800
152 Int_t offsetBusSt4swp = 46; // number of buspatches between 801-806 (701-706)
154 Int_t offsetBusSt5 = 27; // number of buspatches before DE 900-1000
155 Int_t offsetBusSt5swp = 50; // number of buspatches between 901-906 (1001-1006)
158 while ( in.getline(line,80) ) {
160 if ( line[0] == '#' || line[0] == '\0' ) continue;
162 sscanf(line, "%d %s", &idDE, nameSlat);
165 while(nameSlat[i] < '4' && nameSlat[i] !='0') i++;
166 Int_t len = strlen(nameSlat);
168 // number of buspatch
169 if (i == 2 || i == 3)
174 // calculate the number of TB & BB
175 // R1: 2 bridges more per PCB
176 // R2 & R3: 1 translator more per PCB
177 if (i == 2) nbBB += 2;
178 if (i == 3) nbBB += 4;
179 if (i == 4) nbBB += 4;
180 if (i == 5) nbBB += 6;
181 if (i == 6) nbBB += 8;
184 if (nameSlat[len-1] == '1') {
188 if (nameSlat[len-1] == '2' || nameSlat[len-1] == '3') {
194 // for buspatch length reasons, one ddl connects one 1/4 of two chambers
195 // really messy isn't it ?
196 // much more with the new DDL sharing for station 3
200 if (idDE % 100 == 0) {
201 cout << "# Chamber " << idDE/100 << endl;
202 out << "# Chamber " << idDE/100 << endl;
207 iDDL = (idDE/100)*2+2;
208 begin[cursor] = AliMpBusPatch::GetGlobalBusID(1, iDDL-1);
210 end[cursor] = begin[cursor] + nbBusPatch - 1;
212 begin[cursor] = end[cursor-1] + 1;
214 cout << idDE << " " << begin[cursor-1]<<"-"<<end[cursor-1] << " " << iDDL-1 << " " <<nameSlat <<endl;
215 out << idDE << " " << begin[cursor-1]<<"-"<<end[cursor-1] <<" " << iDDL-1 <<endl;
218 if (idDE >= idCh5swp1 && idDE < idCh5swp2) {
220 if ( idDE == idCh5swp1) {
221 iDDL = (idDE/100)*2 ;
222 begin[cursor] = AliMpBusPatch::GetGlobalBusID(offsetBusCh5swp1, iDDL-1);
225 end[cursor] = begin[cursor] - nbBusPatch + 1;
227 begin[cursor] = end[cursor-1] - 1;
229 cout << idDE << " " << end[cursor-1]<<"-"<<begin[cursor-1] << " " << iDDL-1 << " " <<nameSlat <<endl;
230 out << idDE << " " << end[cursor-1]<<"-"<<begin[cursor-1] <<" " << iDDL-1 <<endl;
233 if (idDE >= idCh5swp2 && idDE < idCh5swp3) {
235 if (idDE == idCh5swp2) {
236 iDDL = (idDE/100)*2-1;
237 begin[cursor] = AliMpBusPatch::GetGlobalBusID(1, iDDL-1);
240 end[cursor] = begin[cursor] + nbBusPatch - 1;
242 begin[cursor] = end[cursor-1] + 1;
244 cout << idDE << " " << begin[cursor-1]<<"-"<<end[cursor-1] << " " << iDDL-1 << " " <<nameSlat <<endl;
245 out << idDE << " " << begin[cursor-1]<<"-"<<end[cursor-1] <<" " << iDDL-1 <<endl;
248 if (idDE >= idCh5swp3 && idDE < idCh5swp4) {
250 if (idDE == idCh5swp3) {
251 iDDL = (idDE/100)*2+1;
252 begin[cursor] = AliMpBusPatch::GetGlobalBusID(1, iDDL-1);
255 end[cursor] = begin[cursor] + nbBusPatch - 1;
257 begin[cursor] = end[cursor-1] + 1;
259 cout << idDE << " " << begin[cursor-1]<<"-"<<end[cursor-1] << " " << iDDL-1 << " " <<nameSlat <<endl;
260 out << idDE << " " << begin[cursor-1]<<"-"<<end[cursor-1] <<" " << iDDL-1 <<endl;
263 if (idDE >= idCh5swp4 && idDE < 600) {
265 if ( idDE == idCh5swp4) {
266 iDDL = (idDE/100)*2+2 ;
267 begin[cursor] = AliMpBusPatch::GetGlobalBusID(offsetBusCh5swp2, iDDL-1);
270 end[cursor] = begin[cursor] - nbBusPatch + 1;
272 begin[cursor] = end[cursor-1] - 1;
274 cout << idDE << " " << end[cursor-1]<<"-"<<begin[cursor-1] << " " << iDDL-1 << " " <<nameSlat <<endl;
275 out << idDE << " " << end[cursor-1]<<"-"<<begin[cursor-1] <<" " << iDDL-1 <<endl;
279 if (idDE >= idCh6swp1 && idDE < idCh6swp2) {
281 if ( idDE == idCh6swp1) {
282 iDDL = (idDE/100)*2-2 ;
283 begin[cursor] = AliMpBusPatch::GetGlobalBusID(offsetBusCh5swp1+offsetBusCh6swp1, iDDL-1);
286 end[cursor] = begin[cursor] - nbBusPatch + 1;
288 begin[cursor] = end[cursor-1] - 1;
290 cout << idDE << " " << end[cursor-1]<<"-"<<begin[cursor-1] << " " << iDDL-1 << " " <<nameSlat <<endl;
291 out << idDE << " " << end[cursor-1]<<"-"<<begin[cursor-1] <<" " << iDDL-1 <<endl;
294 if (idDE >= idCh6swp2 && idDE < idCh6swp3) {
296 if (idDE == idCh6swp2) {
297 iDDL = (idDE/100)*2-3;
298 begin[cursor] = AliMpBusPatch::GetGlobalBusID(offsetBusCh5swp2+1, iDDL-1);
301 end[cursor] = begin[cursor] + nbBusPatch - 1;
303 begin[cursor] = end[cursor-1] + 1;
305 cout << idDE << " " << begin[cursor-1]<<"-"<<end[cursor-1] << " " << iDDL-1 << " " <<nameSlat <<endl;
306 out << idDE << " " << begin[cursor-1]<<"-"<<end[cursor-1] <<" " << iDDL-1 <<endl;
309 if (idDE >= idCh6swp3 && idDE < idCh6swp4) {
311 if (idDE == idCh6swp3) {
312 iDDL = (idDE/100)*2-1;
313 begin[cursor] = AliMpBusPatch::GetGlobalBusID(offsetBusCh5swp1+1, iDDL-1);
316 end[cursor] = begin[cursor] + nbBusPatch - 1;
318 begin[cursor] = end[cursor-1] + 1;
320 cout << idDE << " " << begin[cursor-1]<<"-"<<end[cursor-1] << " " << iDDL-1 << " " <<nameSlat <<endl;
321 out << idDE << " " << begin[cursor-1]<<"-"<<end[cursor-1] <<" " << iDDL-1 <<endl;
324 if (idDE >= idCh6swp4 && idDE < 700) {
326 if ( idDE == idCh6swp4) {
327 iDDL = (idDE/100)*2 ;
328 begin[cursor] = AliMpBusPatch::GetGlobalBusID(offsetBusCh5swp2+offsetBusCh6swp2, iDDL-1);
331 end[cursor] = begin[cursor] - nbBusPatch + 1;
333 begin[cursor] = end[cursor-1] - 1;
335 cout << idDE << " " << end[cursor-1]<<"-"<<begin[cursor-1] << " " << iDDL-1 << " " <<nameSlat <<endl;
336 out << idDE << " " << end[cursor-1]<<"-"<<begin[cursor-1] <<" " << iDDL-1 <<endl;
342 // back to normal one ddl connects one 1/2 chamber
347 if (idDE % 100 == 0) {
348 cout << "# Chamber " << idDE/100 << endl;
349 out << "# Chamber " << idDE/100 << endl;
352 if ((idDE % 100) >= idSt45swp1 && (idDE % 100) < idSt45swp2) {
353 if ((idDE % 100) == idSt45swp1) {
354 iDDL = (idDE/100)*2-1;
355 begin[cursor] = AliMpBusPatch::GetGlobalBusID(1, iDDL-1);
357 end[cursor] = begin[cursor] + nbBusPatch - 1;
359 begin[cursor] = end[cursor-1] + 1;
361 cout << idDE << " " << begin[cursor-1]<<"-"<<end[cursor-1] << " " << iDDL-1 << " " <<nameSlat <<endl;
362 out << idDE << " " << begin[cursor-1]<<"-"<<end[cursor-1] <<" " << iDDL-1 <<endl;
365 if (idDE % 100 >= idSt45swp2) {
367 if ((idDE % 100) == idSt45swp2 ) {
368 iDDL = (idDE/100)*2 ;
369 if (idDE/100 == 7 || idDE/100 == 8)
370 begin[cursor] = AliMpBusPatch::GetGlobalBusID(offsetBusSt4swp, iDDL-1);
372 begin[cursor] = AliMpBusPatch::GetGlobalBusID(offsetBusSt5swp, iDDL-1);
375 end[cursor] = begin[cursor] - nbBusPatch + 1;
377 begin[cursor] = end[cursor-1] - 1;
379 cout << idDE << " " << end[cursor-1]<<"-"<<begin[cursor-1] << " " << iDDL-1 << " " <<nameSlat <<endl;
380 out << idDE << " " << end[cursor-1]<<"-"<<begin[cursor-1] <<" " << iDDL-1 <<endl;
383 if ((idDE % 100) >= 0 && (idDE % 100) < idSt45swp1) {
385 if ((idDE % 100) == 0 ) {
387 if (idDE/100 == 7 || idDE/100 == 8)
388 begin[cursor] = AliMpBusPatch::GetGlobalBusID(offsetBusSt4, iDDL-1);
390 begin[cursor] = AliMpBusPatch::GetGlobalBusID(offsetBusSt5, iDDL-1);
393 end[cursor] = begin[cursor] - nbBusPatch + 1;
395 begin[cursor] = end[cursor-1] - 1;
397 cout << idDE << " " << end[cursor-1]<<"-"<<begin[cursor-1] << " " << iDDL-1 << " " <<nameSlat <<endl;
398 out << idDE << " " << end[cursor-1]<<"-"<<begin[cursor-1] <<" " << iDDL-1 <<endl;
404 printf(" Slat: number of TB %d and BB %d\n", nbTB, nbBB);