ROOT logo
//_HADES_CLASS_DESCRIPTION
/////////////////////////////////////////////////////////////
//
//  HEmcCellGeomPar
//
//  Class for EMC cell geometry parameters
//
/////////////////////////////////////////////////////////////

using namespace std;
#include "hemccellgeompar.h"
#include "hades.h"
#include "hruntimedb.h"
#include "hspectrometer.h"
#include "hemcdetector.h"
#include "hemcgeompar.h"
#include "hgeomvolume.h"
#include "hgeomcompositevolume.h"
#include "hgeomvector.h"
#include <iostream>

ClassImp(HEmcCellGeomPar)

HEmcCellGeomPar::HEmcCellGeomPar(const Char_t* name,const Char_t* title,
                                 const Char_t* context)
               : HParSet(name,title,context) {
  // constructor
  labPos = NULL;
  pDet=(HEmcDetector*)(gHades->getSetup()->getDetector("Emc"));
  if (pDet) {
    nMaxCells = pDet->getMaxComponents();
    labPos = new TObjArray(pDet->getMaxSectors() * nMaxCells);
  } else {
    Error("HEmcCellGeomPar","No Emc detector");
  }
  pGeomPar=(HEmcGeomPar*)(gHades->getRuntimeDb()->getContainer("EmcGeomPar"));
  if (!pGeomPar){
    Error("initParContainer","No EmcGeomPar parameter container");
  }
}

HEmcCellGeomPar::~HEmcCellGeomPar(void) {
  // destructor deletes the array
  if (labPos) {
    labPos->Delete();
    delete labPos;
    labPos=0;
  }
}

void HEmcCellGeomPar::clear() {
  // clears the lab positions
  if (labPos) labPos->Delete();
}

Bool_t HEmcCellGeomPar::init(HParIo*,Int_t*) {
  // intitializes the container from geometry container
  if (!pGeomPar || !labPos) return kFALSE;
  if (pGeomPar->hasChanged()) {
    HGeomCompositeVolume* refMod=pGeomPar->getRefVolume(0);
    if (refMod) {
      for(Int_t m=0;m<pGeomPar->getNumModules();m++) {
        HModGeomPar* module=pGeomPar->getModule(m);
        if (module) {
          trMod2Lab[m]=module->getLabTransform();
          for(Int_t c=0;c<pGeomPar->getNumComponents();c++) {
            HGeomVolume* cell=refMod->getComponent(c);
            if (cell && strlen(cell->GetName())>0) {
              HGeomVector* lpos=new HGeomVector;
              HGeomVector cPos=cell->getTransform().getTransVector();
              (*lpos)=trMod2Lab[m].transFrom(cPos);
              labPos->AddAt(lpos,m*nMaxCells+c);
            }
          }
        }
      }      
    }
  }   
  return kTRUE;
}

void HEmcCellGeomPar::printParam(void) {
  // prints the parameters
  if (!labPos || !pDet) return;
  Int_t sec=-1, cell=0;
  Char_t row=-1, col=-1;
  printf("Cell geometry parameters for the EMC detector\n");
  printf("sector cell row column xLab yLab zLab\n");
  for(Int_t i=0;i<=labPos->GetLast();i++) {
    sec  = (Int_t)(i/nMaxCells);
    cell = i - sec*nMaxCells;  
    HGeomVector* v=(HGeomVector*)(labPos->At(i));
    if (v) {
      pDet->getRowCol(cell,row,col);
      printf("%i  %3i  %2i  %2i  %9.3f %9.3f %9.3f \n",sec,cell,row,col,v->getX(),v->getY(),v->getZ());
    }
  }
}

const HGeomVector* HEmcCellGeomPar::getLabPos(Int_t sec, Int_t cell) const {
  if (sec>=0 && sec<6 && cell>=0 && cell<nMaxCells) return (HGeomVector*)(labPos->At(sec*nMaxCells + cell));
  else return NULL;
}
  
const HGeomVector*  HEmcCellGeomPar::getLabPos(Int_t sec, Int_t row ,Int_t col) const {
  if (!pDet) return 0;
  Int_t cell=pDet->getCell(row,col);
  return getLabPos(sec,cell);
}

 










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