StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StSvtConfig.cc
1 /***************************************************************************
2  *
3  * $Id: StSvtConfig.cc,v 1.12 2008/06/12 14:22:11 fisyak Exp $
4  *
5  * Author: Marcelo Munhoz
6  ***************************************************************************
7  *
8  * Description: SVT Config
9  *
10  ***************************************************************************
11  *
12  * $Log: StSvtConfig.cc,v $
13  * Revision 1.12 2008/06/12 14:22:11 fisyak
14  * Add default no. of anodes and timeBins
15  *
16  * Revision 1.11 2008/05/21 19:09:30 fine
17  * fix the STAR messager interface # 1190
18  *
19  * Revision 1.10 2002/05/06 00:36:12 munhoz
20  * correct hybrid swapping
21  *
22  * Revision 1.9 2002/02/22 20:12:10 caines
23  * Add getLayer() call
24  *
25  * Revision 1.8 2001/10/04 02:56:26 caines
26  * Fix some of the hybrid swapping indexing
27  *
28  * Revision 1.7 2001/10/02 22:57:49 caines
29  * Wafer 3 is also swapped on getHybrid()B2L8
30  *
31  * Revision 1.6 2001/09/06 22:11:30 caines
32  * Still fixing swapped hybrids
33  *
34  * Revision 1.5 2001/09/06 15:46:13 caines
35  * Swapped to many hybrids on Barrel2 ladder 8 - fixed
36  *
37  * Revision 1.4 2001/08/24 21:02:58 caines
38  * Do index swapping for year2001 data
39  *
40  * Revision 1.3 2001/08/16 21:02:03 munhoz
41  * changing StObjArray to StStrArray. StSvtConfig reestructured. New classes for geometry DB
42  *
43  * Revision 1.2 2001/02/18 00:10:28 caines
44  * Improve and use StSvtConifg
45  *
46  * Revision 1.1 2000/11/30 20:38:50 caines
47  * Svt configuration files
48  *
49  **************************************************************************/
51 // //
52 // This class represents the SVT Config object. //
53 // //
55 
56 
57 #include "StSvtConfig.hh"
58 #include "StMessMgr.h"
59 
60 ClassImp(StSvtConfig)
61 
63 {}
64 
65 StSvtConfig::~StSvtConfig()
66 {}
67 
68 StSvtConfig::StSvtConfig(const StSvtConfig& geom)
69 {}
70 
71 StSvtConfig& StSvtConfig::operator = (const StSvtConfig& geom)
72 {
73  return *this;
74 }
75 
76 void StSvtConfig::setConfiguration()
77 {
78  if (mTotalNumberOfHybrids == 18 ) // SYSTEM TEST
79  mConfig = TString("SYST");
80  else if ((mTotalNumberOfHybrids == 14) && (mNumberOfBarrels == 3)) // YEAR 1 LADDER
81  mConfig = TString("Y1L");
82  else if (mTotalNumberOfHybrids == 432 ) // FULL SVT
83  mConfig = TString("FULL");
84  else if ((mTotalNumberOfHybrids == 14) && (mNumberOfBarrels == 1)) // YEAR 1 LADDER
85  mConfig = TString("LADDER");
86  else if (mTotalNumberOfHybrids == 36 ) // FULL SVT
87  mConfig = TString("BARREL");
88  else if (mTotalNumberOfHybrids == 3 ) // FULL SVT
89  mConfig = TString("SVT");
90  else
91  mConfig = TString("NULL");
92 }
93 
94 void StSvtConfig::setConfiguration(const char* config)
95 {
96  // set the Collection configuration
97 
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);
107  }
108 
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);
119  }
120 
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);
131  }
132 
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);
139  }
140 
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);
151  }
152 
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);
163  }
164 
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);
175  }
176  else {
177  LOG_ERROR << "Configuration of SVT not defined! It must be SYST, Y1L or FULL"<< endm;
178  }
179 }
180 
181 const char* StSvtConfig::getConfiguration()
182 {
183  return mConfig.Data();
184 }
185 
186 int StSvtConfig::getHybridIndex(int barrelID, int ladderID, int waferID, int hybridID)
187 {
188  // returns an internal index for the specified hybrid.
189  // This index should be used to store/retrieve a specific hybrid in/from the collection.
190  // Or one can use the getObject method which parameters are the barrel, ladder, wafer and hybrid numbers.
191 
192  int index;
193  int mNumberOfBarrels; // Number of Barrels
194  int mNumberOfLadders[MAX_NUMBER_OF_BARRELS]; // Number of Ladders of each Barrel
195  int mNumberOfWafers[MAX_NUMBER_OF_BARRELS]; // Number of Wafers of each Ladder (Barrel dependent)
196  int mNumberOfHybrids; // Number of Hybrids of each Wafer ( = 2)
197 
198  mNumberOfBarrels = getNumberOfBarrels();
199 
200  for (int i = 0;i < mNumberOfBarrels;i++) {
201  mNumberOfLadders[i] = getNumberOfLadders(i+1);
202  mNumberOfWafers[i] = getNumberOfWafers(i+1);
203  }
204  mNumberOfHybrids = getNumberOfHybrids();
205 
206 
207  switch (barrelID) {
208 
209  case 1:
210  index = (ladderID-1)*mNumberOfWafers[barrelID-1]*mNumberOfHybrids + (waferID-1)*mNumberOfHybrids + (hybridID-1);
211  break;
212 
213  case 2:
214  index = mNumberOfLadders[barrelID-2]*mNumberOfWafers[barrelID-2]*mNumberOfHybrids +
215  (ladderID-1)*mNumberOfWafers[barrelID-1]*mNumberOfHybrids + (waferID-1)*mNumberOfHybrids + (hybridID-1);
216  break;
217 
218  case 3:
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);
222  break;
223 
224  default:
225  LOG_ERROR << "There is NO barrel number " << barrelID << " !!!" << endm;
226  // gMessMgr->Print();
227  index = -1;
228  break;
229  }
230 
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;
250 
251  else index = -1;
252  }
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;
268 
269  else index = -1;
270  }
271 
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;
287 
288  else index = -1;
289  }
290 
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;
328 
329  else index = -1;
330  }
331 
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;
336 
337  else index = -1;
338  }
339 
340  return index;
341 }
342 
343 int StSvtConfig::getProperHybridIndex(int barrelID, int ladderID, int waferID, int hybridID)
344 {
345 
346  //Returns the index that the barrel,ladder,wafer and hybrid should be if
347  // things werent swapped around
348  int index = getHybridIndex( barrelID, ladderID, waferID, hybridID);
349 
350  return index;
351 }
352 
353 int StSvtConfig::getBarrel(int index){
354 
355  int MaxIndex=0;
356  for( int i=0; i< mNumberOfBarrels;i++) {
357 
358  MaxIndex += getNumberOfLadders(i+1)*getNumberOfWafers(i+1)*
359  getNumberOfHybrids();
360  if( MaxIndex > index) return i+1;
361  }
362 
363  return -1;
364 }
365 
366 int StSvtConfig::getLayer(int index)
367 {
368  int Layer;
369  int Barrel = getBarrel(index);
370  int Ladder = getLadder(index);
371  switch (Barrel) {
372 
373  case 1:
374  if (Ladder%2)
375  Layer = 2;
376  else
377  Layer = 1;
378 
379  break;
380 
381  case 2:
382  if (Ladder%2)
383  Layer = 4; //
384  else // switched due to different geometry (07/12/2001)
385  Layer = 3; //
386 
387  break;
388 
389  case 3:
390  if (Ladder%2)
391  Layer = 6;
392  else
393  Layer = 5;
394 
395  break;
396  }
397 
398  return Layer;
399 }
400 
401 
402 int StSvtConfig::getLadder(int index){
403 
404  int i, indexsav, CurrentIndex=0;
405 
406  int Barrel = getBarrel(index);
407 
408  // Cope with switch readout in real data
409 
410  indexsav = index;
411 
412  for( i=0; i< Barrel-1; i++){
413  CurrentIndex += getNumberOfLadders(i+1)*getNumberOfWafers(i+1)*
414  getNumberOfHybrids();
415  }
416 
417  for( i=0; i< getNumberOfLadders(Barrel); i++){
418  CurrentIndex += getNumberOfWafers(Barrel)*getNumberOfHybrids();
419  if( CurrentIndex > indexsav) return i+1;
420  }
421 
422  return -1;
423 }
424 
425 int StSvtConfig::getWafer(int index){
426 
427  int i, indexsav=0,CurrentIndex=0;
428 
429  int Barrel = getBarrel(index);
430  int Ladder = getLadder(index);
431 
432 
433  indexsav = index;
434 
435  for( i=0; i< Barrel-1; i++){
436  CurrentIndex += getNumberOfLadders(i+1)*getNumberOfWafers(i+1)*
437  getNumberOfHybrids();
438  }
439 
440  for( i=0; i< Ladder-1; i++){
441  CurrentIndex += getNumberOfWafers(Barrel)*getNumberOfHybrids();
442  }
443 
444  for(i=0; i<getNumberOfWafers(Barrel); i++){
445  CurrentIndex += getNumberOfHybrids();
446  if( CurrentIndex > indexsav) return i+1;
447  }
448 
449  return -1;
450 }
451 
452 int StSvtConfig::getHybrid(int index){
453 
454  int i, indexsav, CurrentIndex=0;
455 
456  int Barrel = getBarrel(index);
457  int Ladder = getLadder(index);
458  int Wafer = getWafer(index);
459 
460 
461  indexsav = index;
462 
463  for( i=0; i< Barrel-1; i++){
464  CurrentIndex += getNumberOfLadders(i+1)*getNumberOfWafers(i+1)*
465  getNumberOfHybrids();
466  }
467 
468  for( i=0; i< Ladder-1; i++){
469  CurrentIndex += getNumberOfWafers(Barrel)*getNumberOfHybrids();
470  }
471 
472  for(i=0; i<Wafer-1; i++){
473  CurrentIndex += getNumberOfHybrids();
474  }
475 
476  if( indexsav == CurrentIndex++) return 1;
477  else if ( indexsav == CurrentIndex) return 2;
478 
479  return -1;
480 }