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

//*-- Author : I. Koenig, D. Bertini, M. Sanchez
//*-- Modified : 6/11/1998 by Manuel Sanchez 
//*-- Modified : 17/02/2000 by Ilse Koenig

//_HADES_CLASS_DESCRIPTION 
////////////////////////////////////////////////////////////////////////////////
//  HDetector
//
//  class to store the actual setup of a detector
//
//  The setup is defined in the macro via the memberfuntion
//  setModules(Int_t sector,Int_t* modules). The array must
//  have the size of the maximum mumber of modules in a
//  sector for this detector. If the module if not active the
//  according number is 0.
//  e.g. for Mdc:   Int_t mod[4]={1,2,0,0};
//                  mdc.setModules(0,mod);
//       This activates the modules 1 and 2 in sector 0
//  Detectors without a sector wise segmentation as e.g. the Start detector
//  use sector = -1.
//
//  It also holds the intelligence to build tasks related to this particular
//  detector as well as to create data structures for it.
//
//  This intelligence is stored in the functions: buildTask() and 
//  buildCategory() and has the form of compiled C++ code.
//
//  The function HTask *HDetector::buildTask(Text_t *task, Option_t *opt) 
//  builds a task object corresponding to the task identified by the string
//  "task". This can be an atomic task (a HReconstructor) or a set of them, in
//  this case the tasks will be packed in a HTaskSet so that buildTask() returns
//  a pointer to that HTaskSet. "opt" is a string where extra options can be 
//  given; the available options differ from detector to detector.
//
//  The function HCategory* HDetector::buildCategory(Cat_t cat) uses the
//  setup information in the HDetector to build a category object. The category
//  class and it's setup will be defined by "cat"; i.e. the HDetector has built
//  in the information of which category subclass is recommended for each kind
//  of data.
////////////////////////////////////////////////////////////////////////////////


HDetector::HDetector(void) {
  //Constructor
  maxSectors=6;
  maxModules=0;
  maxComponents=0;
  modules=0;
}

HDetector::HDetector(const Text_t* name,const Text_t* title) : TNamed(name,title) {
  //Constructor with name
  maxSectors=6;
  maxModules=0;
  maxComponents=0;
  modules=0;
}

HDetector::~HDetector(void) {
  //Destructor
  if (modules) delete modules;
}
  
void HDetector::setModules(Int_t s,Int_t* m){
  // stores the modules givven in 'm' as active modules in sector 's'
  // may be called with s=-1 for detectors not belonging to a sector
  if (!modules) return;
  if (s<0) s=0;
  for(Int_t i=0;i<maxModules;i++) {
    modules->AddAt(m[i],(s*maxModules+i));
  }
}

Int_t* HDetector::getModules(){
  // returns a linear array of all modules
  if (modules) return modules->GetArray();
  return 0;
}

Int_t HDetector::getModule(Int_t s,Int_t m){
  // returns the number of the module in a sector
  // may be called with s=-1 for detectors not belonging to a sector
  // returns 0 if this module is not active
  if (m>=maxModules) return 0;
  if (s<0) return (*modules)[m];
  if (modules && s<maxSectors) return (*modules)[(s*maxModules+m)];
  return 0;
}

Bool_t HDetector::isSectorActive(Int_t sector) {
  // Returns true if any module in the sector "sector" is set active.
  Int_t begin = sector * maxModules;
  Int_t end = begin + maxModules;
  for (Int_t i=begin; i<end; i++) 
    if ( modules->At(i) > 0 ) return kTRUE;
  return kFALSE;
}

void HDetector::print() {
  // prints the detector setup
  if (!modules) return;
  cout<<fName<<'\n';
  Int_t s=(maxSectors<0) ? 1 : maxSectors;
  for(Int_t i=0;i<s;i++) {
    cout<<"      ";
    for(Int_t j=0;j<maxModules;j++) {
      Int_t k=i*maxModules+j;
      cout<<(*modules)[k]<<" ";
    }
    cout<<'\n';
  }
}

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