#include "TResponseTable.h"
ClassImp(TResponseTable)
TableClassStreamerImp(TResponseTable)
TResponseTable::TResponseTable():TGenericTable(), fResponseLocation(-1)
{
}
TResponseTable::TResponseTable(const char *name,const char *volumePath, const char *responseDefinition, Int_t )
: TGenericTable(), fResponseLocation(-1)
{
SetDescriptorPointer(new TTableDescriptor(name));
AddElement("TRACK",kInt);
AddVolumePath(volumePath);
AddResponse(responseDefinition);
fSize = GetDescriptorPointer()->Sizeof();
fResponseLocation = FindResponseLocation(*GetDescriptorPointer());
SetType("DetectorResponse");
}
void TResponseTable::AddVolumePath(const char *path)
{
Int_t counter = 0;
const Int_t maxResponseCounter = 15;
const char *next = &path[0];
while( ( *next && *next != ' ') && counter < maxResponseCounter ) {
TString elName;
for (int j=0; j<4 && (next[j] != ' ');j++) elName += next[j];
AddElement(elName,kInt);
next += 4;
counter++;
}
}
void TResponseTable::AddResponse(const char *chit)
{
Int_t counter = 0;
const Int_t maxResponseCounter = 15;
const char *next = &chit[0];
while( ( *next != ' ' ) && counter < maxResponseCounter ) {
TString elName;
for (int j=0; j<4 && (next[j] != ' ');j++) elName += next[j];
AddElement(elName,kFloat);
next += 4;
counter++;
}
}
void TResponseTable::AddElement(const char *path,EColumnType type)
{
assert( (type == kInt || type == kFloat ) );
TTableDescriptor &dsc = *GetTableDescriptors();
Int_t nRow = dsc.GetNRows();
tableDescriptor_st row;
memset(&row,0,sizeof(row));
strncpy(row.fColumnName,path,sizeof(row.fColumnName));
if (nRow) row.fOffset = dsc[nRow-1].fOffset + dsc[nRow-1].fSize;
row.fType = type;
if (type == kInt)
row.fTypeSize = sizeof(Int_t);
else
row.fTypeSize = sizeof(Float_t);
row.fSize = row.fTypeSize;
dsc.AddAt(&row);
}
void TResponseTable::SetResponse(int track, int *nvl, float *response)
{
char *charBuffer = new char[GetRowSize()];
Int_t *nvlBuffer = (Int_t *)charBuffer;
Float_t *responseBuffer = (Float_t *)charBuffer;
Int_t jResponse = 0;
Int_t jNvl = 0;
TTableDescriptor &dsc = *GetTableDescriptors();
Int_t nRow = dsc.GetNRows();
tableDescriptor_st *row = dsc.GetTable();
nvlBuffer[0] = track; row++;
for (int i=1;i<nRow;i++,row++) {
if (row->fType == kFloat) {
responseBuffer[i] = response[jResponse++];
} else {
nvlBuffer[i] = nvl[jNvl++];
}
}
AddAt(charBuffer);
delete [] charBuffer;
}
Int_t TResponseTable::FindResponseLocation(TTableDescriptor &dsc)
{
Int_t responseLocation = -1;
Int_t nRow = dsc.GetNRows();
tableDescriptor_st *row = dsc.GetTable();
for (int i=0;i<nRow;i++,row++) {
if (row->fType == kFloat) {
responseLocation = i;
break;
}
}
return responseLocation;
}
ROOT page - Class index - Class Hierarchy - Top of the page
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.