//_HADES_CLASS_DESCRIPTION ///////////////////////////////////////////////////////////// // // HStsCalPar // // Container class for Sts calibration parameters // ///////////////////////////////////////////////////////////// #include "hstscalpar.h" #include "hades.h" #include "hdetpario.h" #include "hpario.h" #include "hspectrometer.h" #include "hstsdetector.h" #include "stsdef.h" #include #include #include const Int_t DATA_NUM = 11; ClassImp(HStsCalPar) ClassImp(HStsCalParMod) ClassImp(HStsCalParSec) ClassImp(HStsCalParCell) void HStsCalParCellKind::clear() { timeOffset = 0.F; timeMax = 0.F; timeSlope = 0.F; tofReference = 0.F; isoPar0 = 0.F; isoPar1 = 0.F; isoPar2 = 0.F; isoPar3 = 0.F; isoPar4 = 0.F; totPar0 = 0.F; totPar1 = 0.F; } void HStsCalParCellKind::fill(Float_t to, Float_t tm, Float_t ts, Float_t tr, Float_t i0, Float_t i1, Float_t i2, Float_t i3, Float_t i4, Float_t t0, Float_t t1) { timeOffset = to; timeMax = tm; timeSlope = ts; tofReference = tr; isoPar0 = i0; isoPar1 = i1; isoPar2 = i2; isoPar3 = i3; isoPar4 = i4; totPar0 = t0; totPar1 = t1; } void HStsCalParCellKind::fill(Float_t *data) { timeOffset = data[0]; timeMax = data[1]; timeSlope = data[2]; tofReference = data[3]; isoPar0 = data[4]; isoPar1 = data[5]; isoPar2 = data[6]; isoPar3 = data[7]; isoPar4 = data[8]; totPar0 = data[9]; totPar1 = data[10]; } void HStsCalParCellKind::fill(HStsCalParCellKind &r) { *this = r; } HStsCalParCell::HStsCalParCell(Int_t n) { // constructor creates an array of pointers of type HStsCalParCellKind array = new TObjArray(n); for (Int_t i = 0; i < n; i++) { array->AddAt(new HStsCalParCellKind(), i); } } HStsCalParCell::~HStsCalParCell() { // destructor array->Delete(); delete array; } HStsCalParSec::HStsCalParSec(Int_t n) { // constructor creates an array of pointers of type HStsCalParCellKind array = new TObjArray(n); for (Int_t i = 0; i < n; i++) { array->AddAt(new HStsCalParCell(STS_MAX_UDCONF), i); } } HStsCalParSec::~HStsCalParSec() { // destructor array->Delete(); delete array; } HStsCalParMod::HStsCalParMod(Int_t n) { // constructor creates an array of pointers of type HStsCalParCellKind array = new TObjArray(n); for (Int_t i = 0; i < n; i++) { array->AddAt(new HStsCalParSec(STS_MAX_CELLS), i); } } HStsCalParMod::~HStsCalParMod() { // destructor array->Delete(); delete array; } HStsCalPar::HStsCalPar(const Char_t *name, const Char_t *title, const Char_t *context) : HParSet(name, title, context) { // constructor creates an array of pointers of type HStsCalParSec strcpy(detName, "Sts"); HStsDetector *det = (HStsDetector *)(gHades->getSetup()->getDetector("Sts")); array = new TObjArray(STS_MAX_MODULES); for (Int_t i = 0; i < STS_MAX_MODULES; i++) { if (det->getModule(i, 0) > 0) { array->AddAt(new HStsCalParMod(STS_MAX_LAYERS), i); } else { array->AddAt(new HStsCalParMod(0), i); } } } HStsCalPar::~HStsCalPar() { // destructor if (array) { array->Delete(); delete array; } } Bool_t HStsCalPar::init(HParIo *inp, Int_t *set) { // intitializes the container from an input HDetParIo *input = inp->getDetParIo("HStsParIo"); if (input) return (input->init(this, set)); return kFALSE; } Int_t HStsCalPar::write(HParIo *output) { // writes the container to an output HDetParIo *out = output->getDetParIo("HStsParIo"); if (out) return out->write(this); return -1; } void HStsCalPar::clear() { // clears the container for (Int_t i = 0; i < getSize(); i++) { HStsCalParMod &mod = (*this)[i]; for (Int_t j = 0; j < mod.getSize(); j++) { HStsCalParSec &sec = mod[j]; for (Int_t k = 0; k < sec.getSize(); k++) { HStsCalParCell &cell = sec[k]; for (Int_t l = 0; l < cell.getSize(); l++) cell[l].clear(); } } } status = kFALSE; resetInputVersions(); } void HStsCalPar::printParams() { // prints the calibration parameters printf("Calibration parameters for the Sts\n"); printf(" mod(0...1) layer(0...3) straw(0...255) timeOffset timeMax timeSlope tofRef" " isoPar0 isoPar1 isoPar2 isoPar3 isoPar4" " totPar0 totPar1\n"); Float_t data[DATA_NUM]; for (Int_t i = 0; i < getSize(); i++) { HStsCalParMod &mod = (*this)[i]; for (Int_t j = 0; j < mod.getSize(); j++) { HStsCalParSec §or = mod[j]; for (Int_t k = 0; k < sector.getSize(); k++) { HStsCalParCell &cell = sector[k]; for (Int_t l = 0; l < cell.getSize(); l++) { HStsCalParCellKind &kind = cell[l]; kind.getData(data); if (data[0] == 0.f) continue; printf("%4i %4i %4i %4i %10.5f %10.5f %10.5f %10.5f" " %10.5f %10.5f %.5g %.5g %.5g %10.5f %10.5f\n", i, j, k, l, data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7], data[8], data[9], data[10]); } } } } } void HStsCalPar::readline(const Char_t *buf, Int_t *set) { // decodes one line read from ASCII file I/O Int_t mod, sector, cell, kind; Float_t data[DATA_NUM] = {0.F}; Int_t n = sscanf(buf, "%i%i%i%i%f%f%f%f%f%f%g%g%g%f%f", &mod, §or, &cell, &kind, &data[0], &data[1], &data[2], &data[3], &data[4], &data[5], &data[6], &data[7], &data[8], &data[9], &data[10]); if (n < DATA_NUM + 4) { Error("readline", "Not enough values in line %s\n", buf); } else if (n > DATA_NUM + 4) { Error("readline", "Too many values in line %s\n", buf); } else { if (sector < 0 || sector > 3) return; if (!set[sector]) return; if (cell < 0) { Error("readline", "STS strip %d not defined\n", cell); return; } if (kind < 1 || kind > 3) { Error("readline", "STS strip %d kind %d not defined\n", cell, kind); return; } (*this)[mod][sector][cell][kind].fill(data); set[sector] = 999; } } void HStsCalPar::putAsciiHeader(TString &header) { // puts the ascii header to the string used in HStsParAsciiFileIo header = "# Calibration parameters for the Sts\n" "# Format:\n" "# mod(0...1) layer(0...3) straw(0...255) kind(1,2,3) timeOffset timeMax timeSlope tofRef" " isoPar0 isoPar1 isoPar2 isoPar3 isoPar4" " totPar0 totPar1\n"; } void HStsCalPar::write(fstream &fout) { Text_t buf[255]; Float_t data[DATA_NUM]; for (Int_t i = 0; i < getSize(); i++) { HStsCalParMod &mod = (*this)[i]; for (Int_t j = 0; j < mod.getSize(); j++) { HStsCalParSec §or = mod[j]; for (Int_t k = 0; k < sector.getSize(); k++) { HStsCalParCell &cell = sector[k]; for (Int_t l = 0; l < cell.getSize(); l++) { HStsCalParCellKind &kind = cell[l]; kind.getData(data); if (data[0] == 0.f) continue; sprintf(buf, "%4i %4i %4i %4i %10.5f %10.5f %10.5f %10.5f" " %10.5f %10.5f %10.5g %10.5g %10.5g %10.5f %10.5f", i, j, k, l, data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7], data[8], data[9], data[10]); fout << buf <