# include "hades.h" # include "hdetpario.h" # include "hmdcdetector.h" # include "hspectrometer.h" # include "hmdctargetgeometry.h" ClassImp(HMdcTargetGeometry) //*-- Author : Beatriz Fuentes Arenaz //*-- Last updated : 17/01/2002 by I. Koenig //*-- Last updated : 16/3/2000 by Beatriz Fuentes(functions read and writeFile) //*-- Modified : 31/05/99 //*-- Copyright : GENP (Univ. Santiago de Compostela) //_HADES_CLASS_DESCRIPTION ////////////////////////////////////////////////////////// // HMdcTargetGeometry stores the geometry of the target. // // It will change soon, since the general geometry // // structure has not been completely designed. // ////////////////////////////////////////////////////////// HMdcTargetGeometry :: HMdcTargetGeometry(const char* name,const char* title, const char* context) : HParSet(name,title,context) { fNSectors = gHades->getSetup()->getDetector("Mdc")->getMaxSectors(); fNModules = gHades->getSetup()->getDetector("Mdc")->getMaxModules(); fXDim = fYDim = 0; fZPos = new TArrayF(fNSectors*fNModules); strcpy(detName, "Mdc"); } HMdcTargetGeometry :: ~HMdcTargetGeometry(void){ if (fZPos) delete fZPos; } Bool_t HMdcTargetGeometry :: init(HParIo* inp, Int_t* set){ // initializes the container from an input HDetParIo* input=inp->getDetParIo("HMdcParIo"); if (input) return (input->init(this,set)); return kFALSE; } Int_t HMdcTargetGeometry :: write(HParIo* output){ // writes the container to an output HDetParIo* out=output->getDetParIo("HMdcParIo"); if (out) return out->write(this); return -1; } Int_t HMdcTargetGeometry::writeFile(fstream *pFile) { if (pFile) { Text_t buf[155]; Text_t com[]="##############################################################################\n" "# Target geometrical parameters for Santiago tracking of the MDC\n" "# Format:\n" "# xdim ydim sector module zpos\n" "# (mm) (mm) (mm)\n" "################################################################################\n"; pFile->write(com,strlen(com)); sprintf(buf,"[%s]\n",GetName()); pFile->write(buf,strlen(buf)); sprintf(buf,"%7.2f%7.2f\n", fXDim, fYDim); pFile->write(buf,strlen(buf)); Int_t index; for(Int_t s=0;sAt(index)); pFile->write(buf,strlen(buf)); } } sprintf(buf,"###########################################################\n"); pFile->write(buf,strlen(buf)); setChanged(kFALSE); return 1; } cerr<<"Output is not writable"<eof()) { pFile->getline(buf,maxbuf); if (buf[0]=='[') { sscanf(buf,"%s",key); if (strstr(buf,GetName())!=0) { pFile->getline(buf,maxbuf); sscanf(buf,"%lf%lf",&fXDim,&fYDim); while (!all && !pFile->eof()) { c=pFile->get(); if (c=='#' || c=='/') all=kTRUE; else { pFile->putback(c); pFile->getline(buf,maxbuf); sscanf(buf,"%i%i%f",§or,&module,&zpos); pos=sector*4+module; if (set[pos]){ index = getIndex(sector,module); fZPos->AddAt(zpos,index); } } } } } } if (all) { setInputVersion(1,inputNumber); setChanged(); printf("TargetGeometry initialized from Ascii file\n"); return kTRUE; } } return kFALSE; } Bool_t HMdcTargetGeometry :: setZPos(Int_t nSect, Int_t nMod, Double_t z){ if ((nSect<0) || (nSect>=fNSectors)) return kFALSE; if ((nMod<0) || (nMod>=fNModules )) return kFALSE; Int_t pos = nSect*fNModules + nMod ; fZPos->AddAt(z, pos); return kTRUE; }