ROOT logo
//*-- AUTHOR : Ilse Koenig
//*-- Modified : 17/01/2002 by I. Koenig

//_HADES_CLASS_DESCRIPTION 
//////////////////////////////////////////////////////////////////////////////
// HMdcGeomPar
//
// Container class for the basic MDC geometry parameters
//
//////////////////////////////////////////////////////////////////////////////

#include "hmdcgeompar.h"
#include "hades.h"
#include "hruntimedb.h"
#include "hpario.h"
#include "hdetpario.h"
#include "hgeomcompositevolume.h"

ClassImp(HMdcGeomPar)

HMdcGeomPar::HMdcGeomPar(const Char_t* name,const Char_t* title,
                               const Char_t* context)
            : HDetGeomPar(name,title,context,"Mdc") {
  // constructor calling the base class constructor with the detector name
}

Bool_t HMdcGeomPar::init(HParIo* inp,Int_t* set) {
  // intitializes the container from an input
  Bool_t rc=kFALSE;
  HDetParIo* input=inp->getDetParIo("HMdcParIo");
  if (input) {
    rc= (input->init(this,set));
    if (rc&&changed) {
      shiftLayerTransToCenter();
    }
  }
  return rc;
}

void HMdcGeomPar::shiftLayerTransToCenter() {
  // Shifts the points to be symmetric in z.
  // The translation vector is changed accordingly to place the intrisic coodinate
  // system in the center of the volume
  for (Int_t m=0;m<refVolumes->GetSize();m++) {
    HGeomCompositeVolume* refMod=(HGeomCompositeVolume*)(refVolumes->At(m));
    if (refMod) {
      for(Int_t c=0;c<refMod->getNumComponents();c++) {
        HGeomVolume* vol=refMod->getComponent(c);
        if (vol) {
          Double_t zShift=(vol->getPoint(4)->getZ()+vol->getPoint(0)->getZ())/2.;
          zShift=round(zShift*1000.)/1000.;
          if (fabs(zShift)>=0.001) {
            for(Int_t k=0;k<vol->getNumPoints();k++) {
              HGeomVector* point=vol->getPoint(k);
              point->setZ(point->getZ()-zShift);
            }
            HGeomTransform& trans=vol->getTransform();
            HGeomVector pos=trans.getTransVector();
            pos.setZ(pos.getZ()+zShift);
            trans.setTransVector(pos);
          }
        }
      } 
    }
  }
}

Int_t HMdcGeomPar::write(HParIo* output) {
  // writes the container to an output
  HDetParIo* out=output->getDetParIo("HMdcParIo");
  if (out) return out->write(this);
  return -1;
}
 hmdcgeompar.cc:1
 hmdcgeompar.cc:2
 hmdcgeompar.cc:3
 hmdcgeompar.cc:4
 hmdcgeompar.cc:5
 hmdcgeompar.cc:6
 hmdcgeompar.cc:7
 hmdcgeompar.cc:8
 hmdcgeompar.cc:9
 hmdcgeompar.cc:10
 hmdcgeompar.cc:11
 hmdcgeompar.cc:12
 hmdcgeompar.cc:13
 hmdcgeompar.cc:14
 hmdcgeompar.cc:15
 hmdcgeompar.cc:16
 hmdcgeompar.cc:17
 hmdcgeompar.cc:18
 hmdcgeompar.cc:19
 hmdcgeompar.cc:20
 hmdcgeompar.cc:21
 hmdcgeompar.cc:22
 hmdcgeompar.cc:23
 hmdcgeompar.cc:24
 hmdcgeompar.cc:25
 hmdcgeompar.cc:26
 hmdcgeompar.cc:27
 hmdcgeompar.cc:28
 hmdcgeompar.cc:29
 hmdcgeompar.cc:30
 hmdcgeompar.cc:31
 hmdcgeompar.cc:32
 hmdcgeompar.cc:33
 hmdcgeompar.cc:34
 hmdcgeompar.cc:35
 hmdcgeompar.cc:36
 hmdcgeompar.cc:37
 hmdcgeompar.cc:38
 hmdcgeompar.cc:39
 hmdcgeompar.cc:40
 hmdcgeompar.cc:41
 hmdcgeompar.cc:42
 hmdcgeompar.cc:43
 hmdcgeompar.cc:44
 hmdcgeompar.cc:45
 hmdcgeompar.cc:46
 hmdcgeompar.cc:47
 hmdcgeompar.cc:48
 hmdcgeompar.cc:49
 hmdcgeompar.cc:50
 hmdcgeompar.cc:51
 hmdcgeompar.cc:52
 hmdcgeompar.cc:53
 hmdcgeompar.cc:54
 hmdcgeompar.cc:55
 hmdcgeompar.cc:56
 hmdcgeompar.cc:57
 hmdcgeompar.cc:58
 hmdcgeompar.cc:59
 hmdcgeompar.cc:60
 hmdcgeompar.cc:61
 hmdcgeompar.cc:62
 hmdcgeompar.cc:63
 hmdcgeompar.cc:64
 hmdcgeompar.cc:65
 hmdcgeompar.cc:66
 hmdcgeompar.cc:67
 hmdcgeompar.cc:68
 hmdcgeompar.cc:69
 hmdcgeompar.cc:70
 hmdcgeompar.cc:71
 hmdcgeompar.cc:72
 hmdcgeompar.cc:73