//*-- AUTHOR Ilse Koenig //*-- created : 25/06/2009 by Ilse Koenig //_HADES_CLASS_DESCRIPTION /////////////////////////////////////////////////////////////////////// // // HTrbnetAddressMapping // /////////////////////////////////////////////////////////////////////// using namespace std; #include "htrbnetaddressmapping.h" #include "htrb2correction.h" #include "hpario.h" #include "hdetpario.h" #include #include #include #include ClassImp(HTrbnetAddressMapping) HTrbnetAddressMapping::HTrbnetAddressMapping(const Char_t* name, const Char_t* title, const Char_t* context, Int_t minTrbnetAddress, Int_t maxTrbnetAddress) : HParSet(name,title,context) { // constructor creates an empty array of size nBoards arrayOffset=minTrbnetAddress; array = new TObjArray(maxTrbnetAddress-minTrbnetAddress+1); } HTrbnetAddressMapping::~HTrbnetAddressMapping() { // destructor array->Delete(); delete array; } Bool_t HTrbnetAddressMapping::init(HParIo* inp,Int_t* set) { // initializes the container from an input Bool_t rc=kFALSE; HDetParIo* input=inp->getDetParIo("HSpecParIo"); if (input) rc=(input->init(this,set)); if (rc) { Int_t n=0; for(Int_t i=0;i<=array->GetLast();i++) { HTrb2Correction* b=(*this)[i]; if (b&&strcmp(b->getBoardType(),"TRB")==0&&b->getNChannels()==0) { if (n==0) cout<<" WARNING:\n"; cout<<" No TDC corrections for trbnet-address 0x"<getDetParIo("HSpecParIo"); if (out) return out->write(this); return -1; } void HTrbnetAddressMapping::clear() { // deletes all HTrb2Correction objects from the array and resets the input versions array->Delete(); status=kFALSE; resetInputVersions(); } void HTrbnetAddressMapping::printParam() { // prints the mapping table printf("Mapping of trbnet-addresses to readout boards\n"); printf("Format: trbnet-address temperatureSensor boardType nChannelsWithCorrections\n"); for(Int_t i=0;i<=array->GetLast();i++) { HTrb2Correction* b=(*this)[i]; if (b) { cout<<" 0x"<GetName() <<" "<getBoardType()<getNChannels()<setBoardType(boardtype); p->setSubeventId(subEventId); p->setHighResolutionFlag(tdcResolMode); array->AddAt(p,address-arrayOffset); } else if (strcmp(p->GetName(),temperatureSensor)!=0) { Error("addBoard","Board exists already for trbnet-address 0x%x:\n" " old temperature sensor: %s new: %s\n", address,p->GetName(),temperatureSensor); } return p; } Bool_t HTrbnetAddressMapping::readline(const Char_t *buf) { // decodes one line read from ASCII file I/O and adds a trb board Bool_t rc=kFALSE; Int_t address=-1, subevtId=-1, tdcResolMode=-1; Char_t tempSensor[30], boardType[30]; boardType[0]=tempSensor[0]='\0'; Int_t n=sscanf(buf," 0x%x %s %s %i %i", &address,tempSensor,boardType,&subevtId,&tdcResolMode); if (n==5) { if (addBoard(address,tempSensor,boardType,subevtId,tdcResolMode)) rc=kTRUE; } else { Error("readline","Not enough or too many values in %s\n",buf); } return rc; } void HTrbnetAddressMapping::putAsciiHeader(TString& header) { // puts the ASCII header to the string used in HSpecParAsciiFileIo header= "# Mapping of trbnet-address to TRB boards\n" "# Format: trbnetAddress temperatureSensor boardType subeventId tdc resolution mode \n"; } void HTrbnetAddressMapping::write(fstream& fout) { // writes the information of all non-zero HTrb2Correction objects to the ASCII file for(Int_t i=0;i<=array->GetLast();i++) { HTrb2Correction* b=(*this)[i]; if (b) { fout<<" 0x"<GetName() <<" "<getBoardType(); if (b->getSubeventId()>=0) { fout<<" 0x"<getSubeventId(); } else { fout<getSubeventId(); } fout<<" "<getHighResolutionFlag()<GetLast();i++) { HTrb2Correction* b=(*this)[i]; if (b) { b->write(fout); } } }