57 #include "StSvtConfig.hh"
58 #include "StMessMgr.h"
65 StSvtConfig::~StSvtConfig()
76 void StSvtConfig::setConfiguration()
78 if (mTotalNumberOfHybrids == 18 )
79 mConfig = TString(
"SYST");
80 else if ((mTotalNumberOfHybrids == 14) && (mNumberOfBarrels == 3))
81 mConfig = TString(
"Y1L");
82 else if (mTotalNumberOfHybrids == 432 )
83 mConfig = TString(
"FULL");
84 else if ((mTotalNumberOfHybrids == 14) && (mNumberOfBarrels == 1))
85 mConfig = TString(
"LADDER");
86 else if (mTotalNumberOfHybrids == 36 )
87 mConfig = TString(
"BARREL");
88 else if (mTotalNumberOfHybrids == 3 )
89 mConfig = TString(
"SVT");
91 mConfig = TString(
"NULL");
94 void StSvtConfig::setConfiguration(
const char* config)
98 mConfig = TString(config);
99 setNumberOfAnodes(240);
100 setNumberOfTimeBins(128);
101 if ( !strncmp(config,
"ASCII", strlen(
"ASCII")) ) {
102 setNumberOfBarrels(1);
103 setNumberOfLadders(1,1);
104 setNumberOfWafers(1,1);
105 setNumberOfHybrids(2);
106 setTotalNumberOfHybrids(2);
109 else if ( !strncmp(config,
"SYST", strlen(
"SYST")) ) {
110 setNumberOfBarrels(3);
111 setNumberOfLadders(1,8);
112 setNumberOfLadders(2,12);
113 setNumberOfLadders(3,16);
114 setNumberOfWafers(1,4);
115 setNumberOfWafers(2,6);
116 setNumberOfWafers(3,7);
117 setNumberOfHybrids(2);
118 setTotalNumberOfHybrids(18);
121 else if ( !strncmp(config,
"Y1L", strlen(
"Y1L")) ) {
122 setNumberOfBarrels(3);
123 setNumberOfLadders(1,0);
124 setNumberOfLadders(2,0);
125 setNumberOfLadders(3,2);
126 setNumberOfWafers(1,0);
127 setNumberOfWafers(2,0);
128 setNumberOfWafers(3,7);
129 setNumberOfHybrids(2);
130 setTotalNumberOfHybrids(14);
133 else if ( !strncmp(config,
"LADDER", strlen(
"LADDER")) ) {
134 setNumberOfBarrels(1);
135 setNumberOfLadders(1,1);
136 setNumberOfWafers(1,7);
137 setNumberOfHybrids(2);
138 setTotalNumberOfHybrids(14);
141 else if ( !strncmp(config,
"BARREL", strlen(
"BARREL")) ) {
142 setNumberOfBarrels(3);
143 setNumberOfLadders(1,8);
144 setNumberOfLadders(2,12);
145 setNumberOfLadders(3,16);
146 setNumberOfWafers(1,1);
147 setNumberOfWafers(2,1);
148 setNumberOfWafers(3,1);
149 setNumberOfHybrids(1);
150 setTotalNumberOfHybrids(36);
153 else if ( !strncmp(config,
"SVT", strlen(
"SVT")) ) {
154 setNumberOfBarrels(3);
155 setNumberOfLadders(1,1);
156 setNumberOfLadders(2,1);
157 setNumberOfLadders(3,1);
158 setNumberOfWafers(1,1);
159 setNumberOfWafers(2,1);
160 setNumberOfWafers(3,1);
161 setNumberOfHybrids(1);
162 setTotalNumberOfHybrids(3);
165 else if ( !strncmp(config,
"FULL", strlen(
"FULL")) ) {
166 setNumberOfBarrels(3);
167 setNumberOfLadders(1,8);
168 setNumberOfLadders(2,12);
169 setNumberOfLadders(3,16);
170 setNumberOfWafers(1,4);
171 setNumberOfWafers(2,6);
172 setNumberOfWafers(3,7);
173 setNumberOfHybrids(2);
174 setTotalNumberOfHybrids(432);
177 LOG_ERROR <<
"Configuration of SVT not defined! It must be SYST, Y1L or FULL"<< endm;
181 const char* StSvtConfig::getConfiguration()
183 return mConfig.Data();
186 int StSvtConfig::getHybridIndex(
int barrelID,
int ladderID,
int waferID,
int hybridID)
193 int mNumberOfBarrels;
194 int mNumberOfLadders[MAX_NUMBER_OF_BARRELS];
195 int mNumberOfWafers[MAX_NUMBER_OF_BARRELS];
196 int mNumberOfHybrids;
198 mNumberOfBarrels = getNumberOfBarrels();
200 for (
int i = 0;i < mNumberOfBarrels;i++) {
201 mNumberOfLadders[i] = getNumberOfLadders(i+1);
202 mNumberOfWafers[i] = getNumberOfWafers(i+1);
204 mNumberOfHybrids = getNumberOfHybrids();
210 index = (ladderID-1)*mNumberOfWafers[barrelID-1]*mNumberOfHybrids + (waferID-1)*mNumberOfHybrids + (hybridID-1);
214 index = mNumberOfLadders[barrelID-2]*mNumberOfWafers[barrelID-2]*mNumberOfHybrids +
215 (ladderID-1)*mNumberOfWafers[barrelID-1]*mNumberOfHybrids + (waferID-1)*mNumberOfHybrids + (hybridID-1);
219 index = mNumberOfLadders[barrelID-2]*mNumberOfWafers[barrelID-2]*mNumberOfHybrids +
220 mNumberOfLadders[barrelID-3]*mNumberOfWafers[barrelID-3]*mNumberOfHybrids +
221 (ladderID-1)*mNumberOfWafers[barrelID-1]*mNumberOfHybrids + (waferID-1)*mNumberOfHybrids + (hybridID-1);
225 LOG_ERROR <<
"There is NO barrel number " << barrelID <<
" !!!" << endm;
231 if ( !strncmp(mConfig,
"SYST", strlen(
"SYST")) ) {
232 if ((barrelID == 3) && (ladderID == 1) && (waferID == 7) && (hybridID == 1)) index = 0;
233 else if ((barrelID == 3) && (ladderID == 1) && (waferID == 7) && (hybridID == 2)) index = 1;
234 else if ((barrelID == 3) && (ladderID == 1) && (waferID == 6) && (hybridID == 1)) index = 2;
235 else if ((barrelID == 3) && (ladderID == 1) && (waferID == 6) && (hybridID == 2)) index = 3;
236 else if ((barrelID == 3) && (ladderID == 1) && (waferID == 5) && (hybridID == 1)) index = 4;
237 else if ((barrelID == 3) && (ladderID == 1) && (waferID == 5) && (hybridID == 2)) index = 5;
238 else if ((barrelID == 3) && (ladderID == 1) && (waferID == 4) && (hybridID == 1)) index = 6;
239 else if ((barrelID == 3) && (ladderID == 1) && (waferID == 4) && (hybridID == 2)) index = 7;
240 else if ((barrelID == 1) && (ladderID == 1) && (waferID == 4) && (hybridID == 1)) index = 4;
241 else if ((barrelID == 1) && (ladderID == 1) && (waferID == 4) && (hybridID == 2)) index = 5;
242 else if ((barrelID == 1) && (ladderID == 1) && (waferID == 3) && (hybridID == 1)) index = 6;
243 else if ((barrelID == 1) && (ladderID == 1) && (waferID == 3) && (hybridID == 2)) index = 7;
244 else if ((barrelID == 3) && (ladderID == 2) && (waferID == 7) && (hybridID == 1)) index = 8;
245 else if ((barrelID == 3) && (ladderID == 2) && (waferID == 7) && (hybridID == 2)) index = 9;
246 else if ((barrelID == 3) && (ladderID == 2) && (waferID == 6) && (hybridID == 1)) index = 10;
247 else if ((barrelID == 3) && (ladderID == 2) && (waferID == 6) && (hybridID == 2)) index = 11;
248 else if ((barrelID == 3) && (ladderID == 2) && (waferID == 5) && (hybridID == 1)) index = 16;
249 else if ((barrelID == 3) && (ladderID == 2) && (waferID == 5) && (hybridID == 2)) index = 17;
253 else if ( !strncmp(mConfig,
"Y1L", strlen(
"Y1L")) ) {
254 if ((barrelID == 3) && (ladderID == 2) && (waferID == 1) && (hybridID == 1)) index = 0;
255 else if ((barrelID == 3) && (ladderID == 2) && (waferID == 1) && (hybridID == 2)) index = 1;
256 else if ((barrelID == 3) && (ladderID == 2) && (waferID == 2) && (hybridID == 1)) index = 2;
257 else if ((barrelID == 3) && (ladderID == 2) && (waferID == 2) && (hybridID == 2)) index = 3;
258 else if ((barrelID == 3) && (ladderID == 2) && (waferID == 3) && (hybridID == 1)) index = 4;
259 else if ((barrelID == 3) && (ladderID == 2) && (waferID == 3) && (hybridID == 2)) index = 5;
260 else if ((barrelID == 3) && (ladderID == 1) && (waferID == 4) && (hybridID == 1)) index = 6;
261 else if ((barrelID == 3) && (ladderID == 1) && (waferID == 4) && (hybridID == 2)) index = 7;
262 else if ((barrelID == 3) && (ladderID == 1) && (waferID == 5) && (hybridID == 1)) index = 8;
263 else if ((barrelID == 3) && (ladderID == 1) && (waferID == 5) && (hybridID == 2)) index = 9;
264 else if ((barrelID == 3) && (ladderID == 1) && (waferID == 6) && (hybridID == 1)) index = 10;
265 else if ((barrelID == 3) && (ladderID == 1) && (waferID == 6) && (hybridID == 2)) index = 11;
266 else if ((barrelID == 3) && (ladderID == 1) && (waferID == 7) && (hybridID == 1)) index = 12;
267 else if ((barrelID == 3) && (ladderID == 1) && (waferID == 7) && (hybridID == 2)) index = 13;
272 else if ( !strncmp(mConfig,
"LADDER", strlen(
"LADDER")) ) {
273 if ((waferID == 1) && (hybridID == 1)) index = 0;
274 else if ((waferID == 1) && (hybridID == 2)) index = 1;
275 else if ((waferID == 2) && (hybridID == 1)) index = 2;
276 else if ((waferID == 2) && (hybridID == 2)) index = 3;
277 else if ((waferID == 3) && (hybridID == 1)) index = 4;
278 else if ((waferID == 3) && (hybridID == 2)) index = 5;
279 else if ((waferID == 4) && (hybridID == 1)) index = 6;
280 else if ((waferID == 4) && (hybridID == 2)) index = 7;
281 else if ((waferID == 5) && (hybridID == 1)) index = 8;
282 else if ((waferID == 5) && (hybridID == 2)) index = 9;
283 else if ((waferID == 6) && (hybridID == 1)) index = 10;
284 else if ((waferID == 6) && (hybridID == 2)) index = 11;
285 else if ((waferID == 7) && (hybridID == 1)) index = 12;
286 else if ((waferID == 7) && (hybridID == 2)) index = 13;
291 else if ( !strncmp(mConfig,
"BARREL", strlen(
"BARREL")) ) {
292 if ((barrelID == 1) && (ladderID == 1)) index = 0;
293 else if ((barrelID == 1) && (ladderID == 2)) index = 1;
294 else if ((barrelID == 1) && (ladderID == 3)) index = 2;
295 else if ((barrelID == 1) && (ladderID == 4)) index = 3;
296 else if ((barrelID == 1) && (ladderID == 5)) index = 4;
297 else if ((barrelID == 1) && (ladderID == 6)) index = 5;
298 else if ((barrelID == 1) && (ladderID == 7)) index = 6;
299 else if ((barrelID == 1) && (ladderID == 8)) index = 7;
300 else if ((barrelID == 2) && (ladderID == 1)) index = 8;
301 else if ((barrelID == 2) && (ladderID == 2)) index = 9;
302 else if ((barrelID == 2) && (ladderID == 3)) index = 10;
303 else if ((barrelID == 2) && (ladderID == 4)) index = 11;
304 else if ((barrelID == 2) && (ladderID == 5)) index = 12;
305 else if ((barrelID == 2) && (ladderID == 6)) index = 13;
306 else if ((barrelID == 2) && (ladderID == 7)) index = 14;
307 else if ((barrelID == 2) && (ladderID == 8)) index = 15;
308 else if ((barrelID == 2) && (ladderID == 9)) index = 16;
309 else if ((barrelID == 2) && (ladderID == 10)) index = 17;
310 else if ((barrelID == 2) && (ladderID == 11)) index = 18;
311 else if ((barrelID == 2) && (ladderID == 12)) index = 19;
312 else if ((barrelID == 3) && (ladderID == 1)) index = 20;
313 else if ((barrelID == 3) && (ladderID == 2)) index = 21;
314 else if ((barrelID == 3) && (ladderID == 3)) index = 22;
315 else if ((barrelID == 3) && (ladderID == 4)) index = 23;
316 else if ((barrelID == 3) && (ladderID == 5)) index = 24;
317 else if ((barrelID == 3) && (ladderID == 6)) index = 25;
318 else if ((barrelID == 3) && (ladderID == 7)) index = 26;
319 else if ((barrelID == 3) && (ladderID == 8)) index = 27;
320 else if ((barrelID == 3) && (ladderID == 9)) index = 28;
321 else if ((barrelID == 3) && (ladderID == 10)) index = 29;
322 else if ((barrelID == 3) && (ladderID == 11)) index = 30;
323 else if ((barrelID == 3) && (ladderID == 12)) index = 31;
324 else if ((barrelID == 3) && (ladderID == 13)) index = 32;
325 else if ((barrelID == 3) && (ladderID == 14)) index = 33;
326 else if ((barrelID == 3) && (ladderID == 15)) index = 34;
327 else if ((barrelID == 3) && (ladderID == 16)) index = 35;
332 else if ( !strncmp(mConfig,
"SVT", strlen(
"SVT")) ) {
333 if ((barrelID == 1)) index = 0;
334 else if ((barrelID == 2)) index = 1;
335 else if ((barrelID == 3)) index = 2;
343 int StSvtConfig::getProperHybridIndex(
int barrelID,
int ladderID,
int waferID,
int hybridID)
348 int index = getHybridIndex( barrelID, ladderID, waferID, hybridID);
353 int StSvtConfig::getBarrel(
int index){
356 for(
int i=0; i< mNumberOfBarrels;i++) {
358 MaxIndex += getNumberOfLadders(i+1)*getNumberOfWafers(i+1)*
359 getNumberOfHybrids();
360 if( MaxIndex > index)
return i+1;
366 int StSvtConfig::getLayer(
int index)
369 int Barrel = getBarrel(index);
370 int Ladder = getLadder(index);
402 int StSvtConfig::getLadder(
int index){
404 int i, indexsav, CurrentIndex=0;
406 int Barrel = getBarrel(index);
412 for( i=0; i< Barrel-1; i++){
413 CurrentIndex += getNumberOfLadders(i+1)*getNumberOfWafers(i+1)*
414 getNumberOfHybrids();
417 for( i=0; i< getNumberOfLadders(Barrel); i++){
418 CurrentIndex += getNumberOfWafers(Barrel)*getNumberOfHybrids();
419 if( CurrentIndex > indexsav)
return i+1;
425 int StSvtConfig::getWafer(
int index){
427 int i, indexsav=0,CurrentIndex=0;
429 int Barrel = getBarrel(index);
430 int Ladder = getLadder(index);
435 for( i=0; i< Barrel-1; i++){
436 CurrentIndex += getNumberOfLadders(i+1)*getNumberOfWafers(i+1)*
437 getNumberOfHybrids();
440 for( i=0; i< Ladder-1; i++){
441 CurrentIndex += getNumberOfWafers(Barrel)*getNumberOfHybrids();
444 for(i=0; i<getNumberOfWafers(Barrel); i++){
445 CurrentIndex += getNumberOfHybrids();
446 if( CurrentIndex > indexsav)
return i+1;
452 int StSvtConfig::getHybrid(
int index){
454 int i, indexsav, CurrentIndex=0;
456 int Barrel = getBarrel(index);
457 int Ladder = getLadder(index);
458 int Wafer = getWafer(index);
463 for( i=0; i< Barrel-1; i++){
464 CurrentIndex += getNumberOfLadders(i+1)*getNumberOfWafers(i+1)*
465 getNumberOfHybrids();
468 for( i=0; i< Ladder-1; i++){
469 CurrentIndex += getNumberOfWafers(Barrel)*getNumberOfHybrids();
472 for(i=0; i<Wafer-1; i++){
473 CurrentIndex += getNumberOfHybrids();
476 if( indexsav == CurrentIndex++)
return 1;
477 else if ( indexsav == CurrentIndex)
return 2;