#pragma implementation
using namespace std;
#include <iostream>
#include <iomanip>
#include "hades.h"
#include "hparhadasciifileio.h"
#include "hspectrometer.h"
#include "htofinoparset.h"
#include "htofinodetector.h"
#include "htofinoshowermap.h"
#include "htofinoshowermapcell.h"
ClassImp(HTofinoShowerMap)
HTofinoShowerMap::HTofinoShowerMap(const Char_t* name,const Char_t* title,
const Char_t* context)
: HTofinoParSet(name,title,context) {
setSetup(32, 32);
setCellClassName("HTofinoShowerMapCell");
defaultInit();
fLoc.set(2, 0, 0);
}
HTofinoShowerMap::~HTofinoShowerMap()
{
m_ParamsTable.deleteTab();
}
void HTofinoShowerMap::setSetup(Int_t nRows, Int_t nColumns)
{
m_nRows = nRows;
m_nColumns = nColumns;
}
void HTofinoShowerMap::setCellClassName(const Char_t* pszName)
{
strncpy(m_szClassName, pszName, sizeof(m_szClassName));
}
Char_t* HTofinoShowerMap::getCellClassName()
{
return m_szClassName;
}
HTofinoShowerMapCell*& HTofinoShowerMap::getSlot(HLocation &loc)
{
return (HTofinoShowerMapCell*&) m_ParamsTable.getSlot(loc);
}
HTofinoShowerMapCell* HTofinoShowerMap::getObject(HLocation &loc)
{
return (HTofinoShowerMapCell*) m_ParamsTable.getObject(loc);
}
Int_t HTofinoShowerMap::getCellNumber(Int_t nRow, Int_t nColumn) {
fLoc[0] = nRow;
fLoc[1] = nColumn;
return getCellNumber(fLoc);
}
Int_t HTofinoShowerMap::getCellNumber(HLocation &loc)
{
return getObject(loc)->getCellNumber();
}
void HTofinoShowerMap::setCellNumber(HLocation &loc, Int_t nCell)
{
getObject(loc)->setCellNumber(nCell);
}
Bool_t HTofinoShowerMap::initAscii(HParHadAsciiFileIo* pHadAsciiFile) {
Bool_t status = kTRUE;
if (!pHadAsciiFile) return kFALSE;
Char_t keyname[60];
Int_t row, col, cell[32], cell1;
HLocation loc;
HTofinoShowerMapCell *pCell;
loc.setNIndex(2);
try {
HAsciiKey* pHAscii = pHadAsciiFile->GetKeyAscii();
HAsciiKey &mydata = *pHAscii;
setSetup(32, 32);
m_ParamsTable.set(2, m_nRows, m_nColumns);
m_ParamsTable.setCellClassName(getCellClassName());
m_ParamsTable.makeObjTable();
mydata.SetActiveSection("Tofino-Shower Map");
for(row = 0; row < m_nRows; row++) {
sprintf(keyname, "row%02d", row);
mydata.ReadInt(cell, keyname);
loc[0] = row;
for(col = 0; col < 32; col++) {
loc[1] = col;
pCell = (HTofinoShowerMapCell*) getSlot(loc);
if (pCell) {
pCell = new(pCell) HTofinoShowerMapCell;
cell1 = cell[col];
pCell->setCellNumber(cell1);
}
}
}
}
catch (Bool_t ret) {
status = ret;
}
return status;
}
Bool_t HTofinoShowerMap::writeAscii(HParHadAsciiFileIo* pHadAsciiFile) {
Bool_t status = kTRUE;
if (!pHadAsciiFile) return kFALSE;
Char_t keyname[60];
Int_t row, col;
Int_t cell[m_nColumns];
HLocation loc;
loc.setNIndex(2);
try {
HAsciiKey* pHAscii = pHadAsciiFile->GetKeyAscii();
HAsciiKey &mydata = *pHAscii;
mydata.WriteSection("Tofino-Shower Map");
mydata.SetSeparator(' ');
mydata.SetNumInLine(32);
for(row = 0; row < m_nRows; row++) {
loc[0] = row;
for(col = 0; col < 32; col++) {
loc[1] = col;
cell[col] = getCellNumber(loc);
}
sprintf(keyname, "row%02d", row);
mydata.WriteInt(keyname, 32, cell);
}
}
catch (Bool_t ret) {
status = ret;
}
return status;
}
Bool_t HTofinoShowerMap::defaultInit()
{
printf("initialization of TofinoShowerMap\n");
Int_t row, col;
Int_t tofcell;
HTofinoDetector *pTofinoDet = (HTofinoDetector*)gHades->getSetup()
->getDetector("Tofino");
if (!pTofinoDet) return kFALSE;
m_nRows = 32;
m_nColumns = 32;
printf("%d - %d\n", m_nRows, m_nColumns);
m_ParamsTable.set(2, m_nRows, m_nColumns);
m_ParamsTable.setCellClassName(getCellClassName());
m_ParamsTable.makeObjTable();
HLocation loc;
HTofinoShowerMapCell *pCell;
loc.setNIndex(2);
for(row = 0; row < m_nRows; row++)
for(col = 0; col < m_nColumns; col++) {
loc[0] = row;
loc[1] = col;
pCell = (HTofinoShowerMapCell*) getSlot(loc);
if (pCell) {
pCell = new(pCell) HTofinoShowerMapCell;
tofcell = (col < 8) ? 9 : 3 - col/8;
pCell->setCellNumber(tofcell);
}
}
printf("Tofino/Shower MapPar container default initialization\n");
return kTRUE;
}
void HTofinoShowerMap::Print() {
Int_t i, j;
Int_t cell;
HLocation loc;
loc.setNIndex(2);
for (i = 0; i < m_nRows; i++)
for (j = 0; j < m_nColumns; j++) {
loc[0] = i;
loc[1] = j;
cell = getCellNumber(loc);
printf("%d:%d %d\n", i, j, cell);
}
}
Last change: Sat May 22 13:16:54 2010
Last generated: 2010-05-22 13:16
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.