using namespace std; #include #include #include #include #include "hshowerwire.h" #include "hshowergeantwire.h" ClassImp(HShowerWire) ClassImp(HShowerWireTab) //_HADES_CLASS_DESCRIPTION ///////////////////////////////////////////////////////////// // HShowerWire // Class describe coordinates one wire // // HShowerWireTab // Table of local coordinates of wires // ///////////////////////////////////////////////////////////// HShowerWire::HShowerWire() { nWireNr = 0; fYwir = 0.; } // eof constructor HShowerWire::~HShowerWire() { } // eof destructor HShowerWireTab::HShowerWireTab() { //creating empty table reset(); } HShowerWireTab::~HShowerWireTab() { reset(); } Bool_t HShowerWireTab::initAscii(HParHadAsciiFileIo* pHadAsciiFile) { //reading and initializing wires table from ascii file (HAsciiKey format) Bool_t status = kTRUE; if (!pHadAsciiFile) return kFALSE; Char_t buf[80]; try { sprintf(buf, "Shower Module %d - Wires Coordinates", m_nModuleID); printf("%s initializating ...", buf); HAsciiKey* pHAscii = pHadAsciiFile->GetKeyAscii(); HAsciiKey &mydata = *pHAscii; if(!mydata.SetActiveSection(buf)) return kFALSE; Int_t nrWires = mydata.ReadInt("Wires"); HShowerWire* pWire; setDistWire(mydata.ReadFloat("Distance")); for (Int_t i=0; isetNrWire(i); pWire->setYWire(mydata.ReadFloat("Wires Coordinates",i)); addWire(pWire); } printf("\tdone\n"); } catch (Bool_t ret) { status = ret; } return status; } Bool_t HShowerWireTab::writeAscii(HParHadAsciiFileIo* pHadAsciiFile) { //writing wires table into ascii file (HAsciiKey format) Bool_t status = kTRUE; if (!pHadAsciiFile) return kFALSE; Char_t buf[80]; try { sprintf(buf, "Shower Module %d - Wires Coordinates", m_nModuleID); HAsciiKey* pHAscii = pHadAsciiFile->GetKeyAscii(); HAsciiKey &mydata = *pHAscii; mydata.WriteSection(buf); mydata.WriteInt("Wires",getWireNr()); mydata.WriteFloat("Distance",getDistWire()); TArrayF temp(getWireNr()); mydata.SetNumInLine(8); for (Int_t i=0; igetYWire(); } mydata.WriteFloat("Wires Coordinates*",&temp); } catch (Bool_t ret) { status = ret; } return status; } void HShowerWireTab::reset() { //clearing data fDistWire = 0.0; nWires = 0; m_nModuleID = -1; m_WiresArr.Delete(); } HShowerWire* HShowerWireTab::getWire(Int_t n) { //return information about one wire if ((n < 0) || (n >= nWires)) return NULL; return (HShowerWire*)m_WiresArr.At(n); } Int_t HShowerWireTab::addWire(HShowerWire* pWire) { //add new wire information m_WiresArr.Add(pWire); return nWires++; } Int_t HShowerWireTab::setWire(HShowerWire* pWire, Int_t n) { //set wire information at n pos if ((n < 0) || (n >= nWires)) return 0; delete m_WiresArr.At(n); m_WiresArr.AddAt(pWire, n); return 1; } Int_t HShowerWireTab::lookupWire(Float_t y) { //return number of wire at position y // Int_t nWireNr = -1;; Float_t Ywir; for(Int_t j = 0; j < nWires; j++) { Ywir = getWire(j)->getYWire(); if ((y >= Ywir - fDistWire) && (y < Ywir + fDistWire)) { nWireNr = j; break; } } return nWireNr; }