ROOT logo
using namespace std;
#include "hlocation.h"
#include <iostream> 
#include <iomanip>

//*-- Author : Manuel Sanchez 
//*-- Modified : 20/08/99 by R. Holzmann
//*-- Modified : 27/05/98 by Manuel Sanchez
//*-- Copyright : GENP (Univ. Santiago de Compostela)

//_HADES_CLASS_DESCRIPTION 
////////////////////////////////////
//HLocation
//
//  ATENCION! Se ha eliminado el index check en operator[]
// 
//  A location is a set of indexes defining the location of a particular 
//data object within the HEvent structure; so within a loop is recommended to 
//directly use one HLocation instead of a set of indexes (i,j,k,l...) (and
//better an HIterator instead of HLocation).
//
//  An HEvent holds the data corresponding to an event, those data are arranged
// in categories (mdc raw data, mdc cal data, rich rings,...) which are objects
// instantianting one HCategory, to access one of these categories the user
// can call HEvent::getCategory(). Within the categories, each data object has
// a location (given by an object instantiating HLocation) which identifies 
// that object in the category (in some sense, the location is a generalized
// index).
//
////////////////////////////////

ClassImp(HLocation) 

Int_t HLocation::getLinearIndex(Int_t *sizes,Int_t n) {
  Int_t r=1,i;
  r=fIndexes.fArray[0];
  for (i=1;i<fIndexes.fN;i++) 
    r=r*(sizes[i])+fIndexes.fArray[i];
  for(;i<n;i++) {
    r*=sizes[i];
  }
  return (r);
}





Int_t HLocation::getLinearIndex(TArrayI *sizes) {
  Int_t r=1,i;
  r=fIndexes.fArray[0];
  for (i=1;i<fIndexes.fN;i++) 
    r=r*(sizes->fArray[i])+fIndexes.fArray[i];
  for(;i<sizes->fN;i++) {
    r*=sizes->fArray[i];
  }
  return (r);
}

void  HLocation::set(Int_t nIndex, Int_t i1, Int_t i2, Int_t i3, Int_t i4, Int_t i5) {  // this handles up to 5 indexes, but can easily be extended
   fIndexes.Set(nIndex);
   switch(nIndex) {
   case 5:
     fIndexes[4] = i5;
   case 4:
     fIndexes[3] = i4;
   case 3:
     fIndexes[2] = i3;
   case 2:
     fIndexes[1] = i2;
   case 1:
     fIndexes[0] = i1;
   default: ;
   }
}


void HLocation::incIndex(Int_t nIndex) {
  //Increments the index nIndex and sets all the following indexes to 0
  Int_t i;
  fIndexes[nIndex]++;
  for (i=nIndex+1;i<fIndexes.fN;i++) fIndexes[i]=0;
}


void HLocation::readIndexes(HLocation &loc) {
  //Sets the loc.getNIndex() first indexes to the value given in loc
  //and the others are set to 0
  Int_t n=0,i=0;
  Int_t nInd=loc.getNIndex();
  n=((fIndexes.fN>nInd)? nInd : fIndexes.fN);
  for (i=0;i<n;i++) {
    fIndexes.fArray[i]=loc.fIndexes.fArray[i];
  }
  for (;i<fIndexes.fN;i++) fIndexes[i]=0;
}

void HLocation::Dump(void) {
  //Dumps the object to cout in the format:
  //
  //index1:index2:....:offset
  Int_t i;
  
  cout << "fIndexes.fN|";
  for (i=0;i<fIndexes.fN;i++) {
    if (i==fIndexes.fN-1) cout << fIndexes[i] << endl;
    else cout << fIndexes[i] << ":" ;
  }
} 



 hlocation.cc:1
 hlocation.cc:2
 hlocation.cc:3
 hlocation.cc:4
 hlocation.cc:5
 hlocation.cc:6
 hlocation.cc:7
 hlocation.cc:8
 hlocation.cc:9
 hlocation.cc:10
 hlocation.cc:11
 hlocation.cc:12
 hlocation.cc:13
 hlocation.cc:14
 hlocation.cc:15
 hlocation.cc:16
 hlocation.cc:17
 hlocation.cc:18
 hlocation.cc:19
 hlocation.cc:20
 hlocation.cc:21
 hlocation.cc:22
 hlocation.cc:23
 hlocation.cc:24
 hlocation.cc:25
 hlocation.cc:26
 hlocation.cc:27
 hlocation.cc:28
 hlocation.cc:29
 hlocation.cc:30
 hlocation.cc:31
 hlocation.cc:32
 hlocation.cc:33
 hlocation.cc:34
 hlocation.cc:35
 hlocation.cc:36
 hlocation.cc:37
 hlocation.cc:38
 hlocation.cc:39
 hlocation.cc:40
 hlocation.cc:41
 hlocation.cc:42
 hlocation.cc:43
 hlocation.cc:44
 hlocation.cc:45
 hlocation.cc:46
 hlocation.cc:47
 hlocation.cc:48
 hlocation.cc:49
 hlocation.cc:50
 hlocation.cc:51
 hlocation.cc:52
 hlocation.cc:53
 hlocation.cc:54
 hlocation.cc:55
 hlocation.cc:56
 hlocation.cc:57
 hlocation.cc:58
 hlocation.cc:59
 hlocation.cc:60
 hlocation.cc:61
 hlocation.cc:62
 hlocation.cc:63
 hlocation.cc:64
 hlocation.cc:65
 hlocation.cc:66
 hlocation.cc:67
 hlocation.cc:68
 hlocation.cc:69
 hlocation.cc:70
 hlocation.cc:71
 hlocation.cc:72
 hlocation.cc:73
 hlocation.cc:74
 hlocation.cc:75
 hlocation.cc:76
 hlocation.cc:77
 hlocation.cc:78
 hlocation.cc:79
 hlocation.cc:80
 hlocation.cc:81
 hlocation.cc:82
 hlocation.cc:83
 hlocation.cc:84
 hlocation.cc:85
 hlocation.cc:86
 hlocation.cc:87
 hlocation.cc:88
 hlocation.cc:89
 hlocation.cc:90
 hlocation.cc:91
 hlocation.cc:92
 hlocation.cc:93
 hlocation.cc:94
 hlocation.cc:95
 hlocation.cc:96
 hlocation.cc:97
 hlocation.cc:98
 hlocation.cc:99
 hlocation.cc:100
 hlocation.cc:101
 hlocation.cc:102
 hlocation.cc:103
 hlocation.cc:104
 hlocation.cc:105
 hlocation.cc:106
 hlocation.cc:107
 hlocation.cc:108
 hlocation.cc:109
 hlocation.cc:110
 hlocation.cc:111
 hlocation.cc:112