/***************************************************************************
 *
 * $Id$
 *
 * Author: Marcelo Munhoz
 ***************************************************************************
 *
 * Description: SVT Hybrid System Test Array BASE class
 *
 ***************************************************************************
 *
 * $Log$
 **************************************************************************/
///////////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                                       //
// This class corresponds to a collection of hybrid objects(for instance, StSvtHybrid).                  // 
// Basically, it represents the entire SVT, since the detector is a "collection" of hybrids (basic unit).// 
// This should be the base class for any "SVT object".                                                   //
// For instance, the SVT pedestals (that inherits from StSvtHybridCollection)                            //
// is a collection of hybrid pedestals (that inherits from StSvtHybrid).                                 //
//                                                                                                       //
///////////////////////////////////////////////////////////////////////////////////////////////////////////


#include <iostream.h>
#include "StSvtHybridCollection.hh"

ClassImp(StSvtHybridCollection)

 StSvtHybridCollection::StSvtHybridCollection(char* config, int size) : 
  StObjArray(size)
{
  // As the SVT can present various configurations, 
  // the constructor of this class has one parameter that corresponds to the configuration name.
  // So far, there are three configurations defined:
  //   "FULL": corresponds to the full detector (216 wafers or 432 hybrids);
  //   "Y1L": corresponds to the year 1 ladder (7 wafers or 14 hybrids);
  //   "SYST": corresponds to the system test configuration. 
  //           The configuration of the system test correspond to 9 wafers (or 18 hybrids) 
  //           that corresponds to the maximum number of detectors that a Receiver board can read. 
  //           There is no meaningful barrel, ladder, wafer or hybrid number information. 
  //           The hybrid index depends on the order of the read out in the RB.

  if (config)  
    setConfiguration(config);
  else {
    mNumberOfBarrels = 0;
    for (int barrel = 0;barrel<MAX_NUMBER_OF_BARRELS;barrel++) {
      mNumberOfLadders[barrel] = 0;
      mNumberOfWafers[barrel] = 0;
    }
    mNumberOfHybrids = 0;

    mTotalNumberOfHybrids = 0;
  }

  count = 0;
}

 StSvtHybridCollection::~StSvtHybridCollection()
{}


 void StSvtHybridCollection::setConfiguration(char* config)
{
  // set the Collection configuration

  fConfig = config;
 
  if ( !strncmp(config, "SYST", strlen("SYST")) ) {
    mNumberOfBarrels = 3;
    mNumberOfLadders[0] = 8;
    mNumberOfLadders[1] = 12;
    mNumberOfLadders[2] = 16;
    mNumberOfWafers[0] = 4;
    mNumberOfWafers[1] = 6;
    mNumberOfWafers[2] = 7;
    mNumberOfHybrids = 2;
    mTotalNumberOfHybrids = 18;
  }
  else if ( !strncmp(config, "Y1L", strlen("Y1L")) ) {
    mNumberOfBarrels = 1;
    mNumberOfLadders[0] = 1;
    mNumberOfWafers[0] = 7;
    mNumberOfHybrids = 2;
    mTotalNumberOfHybrids = 14;
  }
  else if ( !strncmp(config, "FULL", strlen("FULL")) ) {
    mNumberOfBarrels = 3;
    mNumberOfLadders[0] = 8;
    mNumberOfLadders[1] = 12;
    mNumberOfLadders[2] = 16;
    mNumberOfWafers[0] = 4;
    mNumberOfWafers[1] = 6;
    mNumberOfWafers[2] = 7;
    mNumberOfHybrids = 2;
    mTotalNumberOfHybrids = 432;
  }
  else
    cout << "Configuration of SVT not defined! It must be SYST, Y1L or FULL" << endl;

  Expand(mTotalNumberOfHybrids);

  count = 0;
}

 int StSvtHybridCollection::getHybridIndex(int barrelID, int ladderID, int waferID, int hybridID)
{
  // returns an internal index for the specified hybrid. 
  // This index should be used to store/retrieve a specific hybrid in/from the collection.

  int index;


  switch  (barrelID) {
    
  case 1:
    index = (ladderID-1)*mNumberOfWafers[barrelID-1]*mNumberOfHybrids + (waferID-1)*mNumberOfHybrids + (hybridID-1);
    break;
    
  case 2:
    index = mNumberOfLadders[barrelID-2]*mNumberOfWafers[barrelID-2]*mNumberOfHybrids +
      (ladderID-1)*mNumberOfWafers[barrelID-1]*mNumberOfHybrids + (waferID-1)*mNumberOfHybrids + (hybridID-1);
    break;
    
  case 3:
    index = mNumberOfLadders[barrelID-2]*mNumberOfWafers[barrelID-2]*mNumberOfHybrids + 
      mNumberOfLadders[barrelID-3]*mNumberOfWafers[barrelID-3]*mNumberOfHybrids +
      (ladderID-1)*mNumberOfWafers[barrelID-1]*mNumberOfHybrids + (waferID-1)*mNumberOfHybrids + (hybridID-1);
    break;
    
  default:
    cout << "There is NO barrel number " << barrelID << " !!!" << endl;
    index = -1;
    break;
  }

  if (( !strncmp(fConfig, "SYST", strlen("SYST")) ) || ( !strncmp(fConfig, "Y1L", strlen("Y1L")) )) {
    if ((barrelID == 3) && (ladderID == 1) && (waferID == 7) && (hybridID == 1)) index = 0;
    else if ((barrelID == 3) && (ladderID == 1) && (waferID == 7) && (hybridID == 2)) index = 1;
    else if ((barrelID == 3) && (ladderID == 1) && (waferID == 6) && (hybridID == 1)) index = 2;
    else if ((barrelID == 3) && (ladderID == 1) && (waferID == 6) && (hybridID == 2)) index = 3;
    else if ((barrelID == 1) && (ladderID == 1) && (waferID == 4) && (hybridID == 1)) index = 4;
    else if ((barrelID == 1) && (ladderID == 1) && (waferID == 4) && (hybridID == 2)) index = 5;
    else if ((barrelID == 1) && (ladderID == 1) && (waferID == 3) && (hybridID == 1)) index = 6;
    else if ((barrelID == 1) && (ladderID == 1) && (waferID == 3) && (hybridID == 2)) index = 7;
    else if ((barrelID == 3) && (ladderID == 2) && (waferID == 7) && (hybridID == 1)) index = 8;
    else if ((barrelID == 3) && (ladderID == 2) && (waferID == 7) && (hybridID == 2)) index = 9;
    else if ((barrelID == 3) && (ladderID == 2) && (waferID == 6) && (hybridID == 1)) index = 10;
    else if ((barrelID == 3) && (ladderID == 2) && (waferID == 6) && (hybridID == 2)) index = 11;
    else if ((barrelID == 3) && (ladderID == 1) && (waferID == 5) && (hybridID == 1)) index = 12;
    else if ((barrelID == 3) && (ladderID == 1) && (waferID == 5) && (hybridID == 2)) index = 13;
    else if ((barrelID == 3) && (ladderID == 1) && (waferID == 4) && (hybridID == 1)) index = 14;
    else if ((barrelID == 3) && (ladderID == 1) && (waferID == 4) && (hybridID == 2)) index = 15;
    else if ((barrelID == 3) && (ladderID == 2) && (waferID == 5) && (hybridID == 1)) index = 16;
    else if ((barrelID == 3) && (ladderID == 2) && (waferID == 5) && (hybridID == 2)) index = 17;
    else index = -1;

    //int indexP = getSytHybridIndex(index);
    //if (indexP < 0) 
    //  indexP = setSytHybridIndex(index); 
    //return indexP;
  }
  //else 
  return index;
}

 int StSvtHybridCollection::getSytHybridIndex(int index)
{  
  for (int i = 0;i < 18;i++) {
    if (indexSyt[i] == index)
      return i;
  }

  return -1;
}

 int StSvtHybridCollection::setSytHybridIndex(int index)
{  
  if (count > 17)
    return -1;

  indexSyt[count] = index;
  count++;
  return (count-1);
}


ROOT page - Class index - Top of the page

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.