# include "hades.h"
# include "hdetpario.h"
# include "hmdcdetector.h"
# include "hspectrometer.h"
# include "hmdctargetgeometry.h"
ClassImp(HMdcTargetGeometry)
HMdcTargetGeometry :: HMdcTargetGeometry(const Char_t* name,const Char_t* title,
const Char_t* 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){
HDetParIo* input=inp->getDetParIo("HMdcParIo");
if (input) return (input->init(this,set));
return kFALSE;
}
Int_t HMdcTargetGeometry :: write(HParIo* 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;s<fNSectors;s++) {
for(Int_t m=0;m<fNModules;m++) {
index = getIndex(s,m);
sprintf(buf,"\t\t\t%4i%8i%15.8f\n",s,m,fZPos->At(index));
pFile->write(buf,strlen(buf));
}
}
sprintf(buf,"###########################################################\n");
pFile->write(buf,strlen(buf));
setChanged(kFALSE);
return 1;
}
cerr<<"Output is not writable"<<endl;
return -1;
}
Bool_t HMdcTargetGeometry::read(fstream* pFile,Int_t* set, Int_t inputNumber) {
if (pFile) {
const Int_t maxbuf=1550;
Text_t buf[maxbuf], key[20];
Char_t c;
Int_t sector, module, pos, index;
Float_t zpos;
Bool_t all=kFALSE;
while (!all && !pFile->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;
}
Last change: Sat May 22 13:03:40 2010
Last generated: 2010-05-22 13:03
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.