using namespace std;
#include "hspectrometer.h"
#include "hdetector.h"
#include "hades.h"
#include "hruntimedb.h"
#include "hpario.h"
#include "hparrootfileio.h"
#include "hdetpario.h"
#include "hcondparrootfileio.h"
#include "hspecparrootfileio.h"
#include "hparasciifileio.h"
#include "hcondparasciifileio.h"
#include "hspecparasciifileio.h"
#include "hgeomshapes.h"
#include "TClass.h"
#include <iostream>
#include <iomanip>
#include <stdlib.h>
ClassImp(HSpectrometer)
HSpectrometer::HSpectrometer(void) : TNamed("Hades","The Hades spectrometer") {
detectors=new TList();
changed=kFALSE;
shapes = 0;
}
HSpectrometer::~HSpectrometer(void) {
detectors->Delete();
delete detectors;
if (shapes) { delete shapes; shapes = 0; }
}
void HSpectrometer::addDetector(HDetector* det) {
detectors->Add(det);
changed=kTRUE;
}
HDetector* HSpectrometer::getDetector(const Char_t* name) {
return ((HDetector*)detectors->FindObject(name));
}
Bool_t HSpectrometer::init(void) {
TIter next(detectors);
HDetector *det=0;
while ((det=(HDetector *)next())) {
if (!det->init()) return kFALSE;
}
return kTRUE;
}
void HSpectrometer::activateParIo(HParIo* io) {
const Char_t* ioName=io->IsA()->GetName();
if (strcmp(ioName,"HParOraIo")==0) {
io->setDetParIo("HCondParIo");
io->setDetParIo("HSpecParIo");
} else {
if (strcmp(ioName,"HParRootFileIo")==0) {
HDetParRootFileIo* p=
new HCondParRootFileIo(((HParRootFileIo*)io)->getParRootFile());
io->setDetParIo(p);
p=new HSpecParRootFileIo(((HParRootFileIo*)io)->getParRootFile());
io->setDetParIo(p);
} else {
if (strcmp(ioName,"HParAsciiFileIo")==0) {
HDetParAsciiFileIo* p=
new HCondParAsciiFileIo(((HParAsciiFileIo*)io)->getFile());
io->setDetParIo(p);
p=new HSpecParAsciiFileIo(((HParAsciiFileIo*)io)->getFile());
io->setDetParIo(p);
}
}
}
TIter next(detectors);
HDetector* det;
while ((det=(HDetector*)next())) {
det->activateParIo(io);
}
}
Bool_t HSpectrometer::write() {
HParIo* io=gHades->getRuntimeDb()->getOutput();
if (io) return write(io);
cerr<<"actual setup couldn't be written to output"<<endl;
return kFALSE;
}
Bool_t HSpectrometer::write(HParIo* io) {
TIter next(detectors);
HDetector* det=0;
Bool_t rc=kTRUE;
while ((det=(HDetector*)next())) {
if (det->write(io)==kFALSE) rc=kFALSE;
}
if (rc==kTRUE) changed=kFALSE;
else cerr<<"actual setup couldn't be written to output"<<endl;
return rc;
}
HGeomShapes* HSpectrometer::getShapes() {
if (shapes==0) shapes=new HGeomShapes();
return shapes;
}
void HSpectrometer::print() {
cout<<"Actual setup for Hades Spectrometer:"<<"\n";
TIter next(detectors);
HDetector* det=0;
while ((det=(HDetector*)next())) {
det->print();
}
}
void HSpectrometer::Streamer(TBuffer &R__b)
{
if (R__b.IsReading()) {
Version_t R__v = R__b.ReadVersion(); if (R__v) { }
TObject::Streamer(R__b);
R__b >> detectors;
R__b >> shapes;
if (detectors->GetSize() == 0) {
printf(" detectors list empty ! \n");
exit(0);
}
} else {
R__b.WriteVersion(HSpectrometer::IsA());
TObject::Streamer(R__b);
R__b << detectors;
R__b << shapes;
}
}
Last change: Sat May 22 13:14:27 2010
Last generated: 2010-05-22 13:14
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.