]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - MUON/MUONGenerateBusPatch.C
Generates the number of buspatches and DDL's per detection element (Christian)
[u/mrichter/AliRoot.git] / MUON / MUONGenerateBusPatch.C
... / ...
CommitLineData
1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16
17void MUONGenerateBusPatch()
18{
19 // Generates buspatch id and DDL id for given detection element id
20 // station 1 & 2 assuming 25 bus patch 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
27 TString dirPath2 = gSystem->Getenv("ALICE_ROOT");
28 dirPath2 += "/MUON/mapping/data/";
29
30 TString dirPath1 = dirPath2 + "station345/";
31
32 TString infile = dirPath1 + "DetElemIdToSlatType.dat";
33 TString outfile = dirPath2 + "DetElemIdToBusPatch.dat.out";
34
35 ifstream in(infile, ios::in);
36 ofstream out(outfile, ios::out);
37 char line[80];
38 char nameSlat[82];
39 Int_t idDE;
40 Int_t i;
41 Int_t cursor = 0;
42 Int_t begin[800];
43 Int_t end[800];
44 Int_t nbBusPatch;
45 Int_t listDE[800];
46 Int_t nbTB = 0;
47 Int_t nbBB = 0;
48 Int_t idSt12[] = {100, 101, 102, 103,
49 200, 201, 202, 203,
50 300, 301, 302, 303,
51 400, 401, 402, 403};
52
53 Int_t idSt3swp = 9; // half chamber for DDL on horizontal
54 Int_t idSt45swp1 = 7; // half chamber for DDL in vertical cutting twice the official numbering
55 Int_t idSt45swp2 = 20;
56
57 Int_t iDDL = 0;
58 // station 1 & 2
59 nbBusPatch = 25;
60 cout << "#DE BusPatch DDL SlatName" << endl;
61 out << "#DE BusPatch DDL " << endl;
62
63 for (Int_t j = 0; j < 16; j++) {
64
65 idDE = idSt12[j];
66 if (idDE % 100 == 0) {
67 begin[cursor] = idDE;
68 cout << "# Chamber " << idDE/100 << endl;
69 out << "# Chamber " << idDE/100 << endl;
70 }
71 if (idDE % 2 == 0) iDDL++;
72 end[cursor] = begin[cursor] + nbBusPatch - 1;
73 begin[++cursor] = end[cursor] + 1;
74
75 cout << idDE << " " << begin[cursor-1]<<"-"<<end[cursor-1] <<" " << iDDL << endl;
76 out << idDE << " " << begin[cursor-1]<<"-"<<end[cursor-1] <<" " << iDDL <<endl;
77 }
78
79 // station 345
80 nbBusPatch = 0;
81 while ( in.getline(line,80) ) {
82
83 if ( line[0] == '#' || line[0] == '\0' ) continue;
84 i = 0;
85 sscanf(line, "%d %s", &idDE, nameSlat);
86
87 // number of PCB's
88 while(nameSlat[i] < '4' && nameSlat[i] !='0') i++;
89 Int_t len = strlen(nameSlat);
90
91 // number of buspatch
92 if (i == 2 || i == 3)
93 nbBusPatch = 2;
94 else
95 nbBusPatch = 4;
96
97 // calculate the number of TB & BB
98 // R1: 2 bridges more per PCB
99 // R2 & R3: 1 translator more per PCB
100 if (i == 2) nbBB += 2;
101 if (i == 3) nbBB += 4;
102 if (i == 4) nbBB += 4;
103 if (i == 5) nbBB += 6;
104 if (i == 6) nbBB += 8;
105
106 nbTB += nbBusPatch;
107 if (nameSlat[len-1] == '1')
108 nbBB += 4;
109 if (nameSlat[len-1] == '2' || nameSlat[len-1] == '3')
110 nbTB += 1;
111
112 listDE[cursor] = idDE;
113 if (idDE % 100 == 0) {
114 iDDL++;
115 if (idDE >=800)
116 iDDL++;
117 begin[cursor] = idDE;
118 cout << "# Chamber " << idDE/100 << endl;
119 out << "# Chamber " << idDE/100 << endl;
120 }
121 if (idDE == 500+idSt3swp || idDE == 600+idSt3swp )
122 iDDL++;
123
124 if (idDE == 700+idSt45swp1 || idDE == 800+idSt45swp1 || idDE == 900+idSt45swp1 || idDE == 1000+idSt45swp1 )
125 iDDL++;
126
127 if (idDE == 700+idSt45swp2 || idDE == 800+idSt45swp2 || idDE == 900+idSt45swp2 || idDE == 1000+idSt45swp2 )
128 iDDL--;
129
130 end[cursor] = begin[cursor] + nbBusPatch - 1;
131 begin[++cursor] = end[cursor] + 1;
132
133 cout << idDE << " " << begin[cursor-1]<<"-"<<end[cursor-1] << " " << iDDL << " " <<nameSlat <<endl;
134 out << idDE << " " << begin[cursor-1]<<"-"<<end[cursor-1] <<" " << iDDL <<endl;
135 }
136 printf(" Slat: number of TB %d and BB %d\n", nbTB, nbBB);
137 in.close();
138 out.close();
139}