using namespace std;
#include <iostream>
#include <iomanip>
#include <stdlib.h>
#include <math.h>
#include "hshowerwire.h"
#include "hshowergeantwire.h"
ClassImp(HShowerWire)
ClassImp(HShowerWireTab)
HShowerWire::HShowerWire() {
nWireNr = 0;
fYwir = 0.;
}
HShowerWire::~HShowerWire() {
}
HShowerWireTab::HShowerWireTab()
{
reset();
}
HShowerWireTab::~HShowerWireTab()
{
reset();
}
Bool_t HShowerWireTab::initAscii(HParHadAsciiFileIo* pHadAsciiFile) {
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; i<nrWires; i++) {
pWire = new HShowerWire;
pWire->setNrWire(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) {
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; i<getWireNr(); i++) {
HShowerWire* pWire = getWire(i);
temp[i] = pWire->getYWire();
}
mydata.WriteFloat("Wires Coordinates*",&temp);
}
catch (Bool_t ret) {
status = ret;
}
return status;
}
void HShowerWireTab::reset()
{
fDistWire = 0.0;
nWires = 0;
m_nModuleID = -1;
m_WiresArr.Delete();
}
HShowerWire* HShowerWireTab::getWire(Int_t n) {
if ((n < 0) || (n >= nWires))
return NULL;
return (HShowerWire*)m_WiresArr.At(n);
}
Int_t HShowerWireTab::addWire(HShowerWire* pWire) {
m_WiresArr.Add(pWire);
return nWires++;
}
Int_t HShowerWireTab::setWire(HShowerWire* pWire, Int_t n) {
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)
{
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;
}
Last change: Sat May 22 13:14:18 2010
Last generated: 2010-05-22 13:14
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.