//*-- AUTHOR Ilse Koenig //*-- created : 12/03/2014 by Ilse Koenig //_HADES_CLASS_DESCRIPTION /////////////////////////////////////////////////////////////////////// // // HTrb3Calpar // // Calibration parameters of TRB3 TDC // /////////////////////////////////////////////////////////////////////// using namespace std; #include "htrb3calpar.h" #include "htrb3tdcmessage.h" #include "TBuffer.h" #include #include #include #include #include #include ClassImp(HTrb3CalparTdc) ClassImp(HTrb3Calpar) HTrb3CalparTdc::HTrb3CalparTdc(void) { // constructor clear(); } void HTrb3CalparTdc::clear(void) { // clears the data subEvtId = 0; nEdgesMask = 1; nChannels = 0; nBinsPerChannel = 0; binsPar.Set(0); } Int_t HTrb3CalparTdc::makeArray(Int_t subevtid, Int_t edges, Int_t nChan, Int_t nBin) { // creates the array for nChan channels with nBin bins each subEvtId = subevtid; nEdgesMask = edges; nChannels = nChan; nBinsPerChannel = nBin; Int_t nData = nChannels * nBinsPerChannel; if (nEdgesMask == 3) nData*=2; binsPar.Set(nData); binsPar.Reset(); return nData; } Bool_t HTrb3CalparTdc::fillArray(Float_t* data,Int_t nData) { // copies the data into the arrays Int_t nd = binsPar.GetSize(); if (nd == nData) { memcpy(binsPar.GetArray(),&data[0],nd*sizeof(Float_t)); return kTRUE; } else { Error("fillArrays(Float_t*,Int_t)", "Invalid number of data (nData: %i, binsPar: %i)",nData,nd); return kFALSE; } } void HTrb3CalparTdc::print(void) { // prints the array cout<<" subEvtId: "<<"0x"<0) cout<0) fout<Delete(); delete array; } void HTrb3Calpar::clear() { // deletes all HTrb2Correction objects from the array and resets the input versions array->Delete(); status=kFALSE; resetInputVersions(); } HTrb3CalparTdc* HTrb3Calpar::addTdc(Int_t address) { // adds a new HTrb3CalparTdc objects in the array at position (address-arrayOffset) HTrb3CalparTdc* p = getTdc(address); if (p != NULL) { Error("addTdc","TDC exists already for trbnet-address 0x%04x",address); } else { p = new HTrb3CalparTdc(); array->AddAt(p,address-arrayOffset); } return p; } void HTrb3Calpar::printParam() { // prints the calibration parameters cout<<"Trb3 TDC calibration parameters\n"; cout<<"-------------------------------------------------------------------------------------\n"; for(Int_t i=0;i<=array->GetLast();i++) { HTrb3CalparTdc* tdc=(*this)[i]; if (tdc) { cout<<"trbnet-address: "<<"0x"<print(); } } } void HTrb3Calpar::putAsciiHeader(TString& header) { // header in ASCII file header= "# TRB3 TDC calibration parameters\n" "# Format: trbnetAddress subEvtId mask for number of edges number of channels number of bins per channel \n" "# rising calpar and/or falling calpar \n"; } void HTrb3Calpar::write(fstream& fout) { // writes the information of all non-zero HTrb3CalparTdc objects to the ASCII file for(Int_t i=0;i<=array->GetLast();i++) { HTrb3CalparTdc* tdc=(*this)[i]; if (tdc) { fout<<"trbnet-address: "<<"0x"<write(fout); } } } Bool_t HTrb3Calpar::loadFromBinaryFiles(const char* basefname, Int_t subevtid, Int_t numBins, Int_t nEdgesMask) { // reads the parameters from binary file // here directory and base file name must be specified resetInputVersions(); TString filename; Bool_t res = kTRUE; for(Int_t i=0;i<=array->GetLast();i++) { HTrb3CalparTdc* tdc=(*this)[i]; if (tdc==0) continue; filename.Form("%s%04x.cal", basefname, (unsigned) (arrayOffset+i)); if (!tdc->loadFromBinaryFile(filename.Data(),subevtid,numBins,nEdgesMask)) res = kFALSE; } if (res) { setChanged(); setInputVersion(1, 1); setStatic(); } return res; }