//_HADES_CLASS_DESCRIPTION ///////////////////////////////////////////////////////////// // // HFRpcCalPar // // Container class for FRpc calibration parameters // ///////////////////////////////////////////////////////////// #include "hfrpccalpar.h" #include "frpcdef.h" #include "hades.h" #include "hdetpario.h" #include "hfrpcdetector.h" #include "hpario.h" #include "hspectrometer.h" #include #include #include using namespace std; const Int_t DATA_NUM = 8; void HFRpcCalParCell::clear() { qThresholdN = 0.F; qThresholdF = 0.F; timeOffset = 0.F; posOffset = 0.F; propCorr = 1.F; twcPar0 = 0.F; twcPar1 = 0.F; } void HFRpcCalParCell::fill(Float_t qtn, Float_t qtf, Float_t to, Float_t po, Float_t pc, Float_t twc0, Float_t twc1, Float_t twc2) { qThresholdN = qtn; qThresholdF = qtf; timeOffset = to; posOffset = po; propCorr = pc; twcPar0 = twc0; twcPar1 = twc1; twcPar2 = twc2; } void HFRpcCalParCell::fill(Float_t *data) { qThresholdN = data[0]; qThresholdF = data[1]; timeOffset = data[2]; posOffset = data[3]; propCorr = data[4]; twcPar0 = data[5]; twcPar1 = data[6]; twcPar2 = data[7]; } HFRpcCalParSec::HFRpcCalParSec(Int_t n) { // constructor creates an array of pointers of type HFRpcCalParCell array = new TObjArray(n); for (Int_t i = 0; i < n; i++) { array->AddAt(new HFRpcCalParCell(), i); } } HFRpcCalParSec::~HFRpcCalParSec() { // destructor array->Delete(); delete array; } HFRpcCalPar::HFRpcCalPar(const Char_t *name, const Char_t *title, const Char_t *context) : HParSet(name, title, context) { // constructor creates an array of pointers of type HFRpcCalParSec // constructor creates an array of pointers of type HEmcCalParSec strcpy(detName, "FRpc"); HFRpcDetector *det = (HFRpcDetector *)(gHades->getSetup()->getDetector("FRpc")); if (!det) { Error("HFRpcCalPar", "FRpc detector doesn't exists\n"); abort(); } array = new TObjArray(FRPC_MAX_SECTORS); for (Int_t i = 0; i < FRPC_MAX_SECTORS; i++) { if (det->getModule(i, 0) > 0) { array->AddAt(new HFRpcCalParSec(FRPC_MAX_STRIPS), i); } else { array->AddAt(new HFRpcCalParSec(0), i); } } } HFRpcCalPar::~HFRpcCalPar() { // destructor if (array) { array->Delete(); delete array; } } Bool_t HFRpcCalPar::init(HParIo *inp, Int_t *set) { // intitializes the container from an input HDetParIo *input = inp->getDetParIo("HFRpcParIo"); if (input) return (input->init(this, set)); return kFALSE; } Int_t HFRpcCalPar::write(HParIo *output) { // writes the container to an output HDetParIo *out = output->getDetParIo("HFRpcParIo"); if (out) return out->write(this); return -1; } void HFRpcCalPar::clear() { // clears the container for (Int_t i = 0; i < getSize(); i++) { HFRpcCalParSec &sec = (*this)[i]; for (Int_t j = 0; j < sec.getSize(); j++) sec[j].clear(); } status = kFALSE; resetInputVersions(); } void HFRpcCalPar::printParams() { // prints the calibration parameters printf("Calibration parameters for the FRpc\n"); printf(" sector(0...3) strip(0...31) QThreshN QThreshF TimeOffset PosOffset PropCorr" " twcPar0 twcPar1 twcPar2\n"); Float_t data[DATA_NUM]; for (Int_t i = 0; i < getSize(); i++) { HFRpcCalParSec &sec = (*this)[i]; for (Int_t j = 0; j < sec.getSize(); j++) { HFRpcCalParCell &cell = sec[j]; cell.getData(data); printf("%4i %4i %10.5f %10.5f %10.5f %10.3f %10.3f %10.5f %10.5f %10.5f\n", i, j, data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7]); } } } void HFRpcCalPar::readline(const Char_t *buf, Int_t *set) { // decodes one line read from ASCII file I/O Int_t sector, strip; Float_t data[DATA_NUM] = {0.F}; Int_t n = sscanf(buf, "%i%i%f%f%f%f%f%f%f%f", §or, &strip, &data[0], &data[1], &data[2], &data[3], &data[4], &data[5], &data[6], &data[7]); if (n < (DATA_NUM + 2)) { Error("readline", "Not enough values in line %s\n", buf); } else if (n > (DATA_NUM + 2)) { Error("readline", "Too many values in line %s\n", buf); } else { if (sector < 0 || sector > 3) return; if (!set[sector]) return; if (strip < 0) { Error("readline", "FRPC strip %d not defined\n", strip); return; } (*this)[sector][strip].fill(data); set[sector] = 999; } } void HFRpcCalPar::putAsciiHeader(TString &header) { // puts the ascii header to the string used in HFRpcParAsciiFileIo header = "# Calibration parameters for the FRpc\n" "# Format:\n" "# sector(0...3) strip(0...31) QThreshN QThreshF TimeOffset PosOffset PropCorr" " twcPar0 twcPar1 twcPar2\n"; } void HFRpcCalPar::write(fstream &fout) { Text_t buf[155]; Float_t data[DATA_NUM]; for (Int_t i = 0; i < getSize(); i++) { HFRpcCalParSec §or = (*this)[i]; for (Int_t j = 0; j < sector.getSize(); j++) { HFRpcCalParCell &cell = sector[j]; cell.getData(data); sprintf(buf, "%4i %4i %10.5f %10.5f %10.5f %10.3f %10.3f %10.5f %10.5f %10.5f\n", i, j, data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7]); fout << buf; } } }