using namespace std;
#include "htoflookup.h"
#include "hpario.h"
#include "hdetpario.h"
#include <iostream>
#include <iomanip>
ClassImp(HTofLookupChan)
ClassImp(HTofLookupSlot)
ClassImp(HTofLookupCrate)
ClassImp(HTofLookup)
HTofLookupSlot::HTofLookupSlot(Int_t nChan) {
array = new TObjArray(nChan);
for(Int_t i=0;i<nChan;i++) array->AddAt(new HTofLookupChan(),i);
nChannels=32;
maxChannel=nChan-1;
clear();
}
HTofLookupSlot::~HTofLookupSlot() {
array->Delete();
delete array;
}
void HTofLookupSlot::clear() {
modType='U';
for(Int_t i=0;i<=maxChannel;i++) (*this)[i].clear();
}
void HTofLookupSlot::fill(Char_t dcType, Int_t channel,
Int_t sector, Int_t module, Int_t cell, Char_t side) {
modType=dcType;
if (channel>maxChannel) {
array->Expand(nChannels);
for(Int_t i=maxChannel+1;i<nChannels;i++) array->AddAt(new HTofLookupChan(),i);
maxChannel=nChannels-1;
}
(*this)[channel].fill(sector,module,cell,side);
}
HTofLookupCrate::HTofLookupCrate(Int_t numSlots) {
nSlots=21;
maxSlot=numSlots-1;
array = new TObjArray(numSlots);
for(Int_t i=0;i<numSlots;i++) array->AddAt(new HTofLookupSlot(),i);
}
HTofLookupCrate::~HTofLookupCrate() {
array->Delete();
delete array;
}
void HTofLookupCrate::fill(Int_t slot, Char_t modType,
Int_t channel, Int_t sector, Int_t module, Int_t cell, Char_t side) {
if (slot>maxSlot) {
array->Expand(slot+1);
for(Int_t i=maxSlot+1;i<=slot;i++) array->AddAt(new HTofLookupSlot(),i);
maxSlot=slot;
}
(*this)[slot].fill(modType,channel,sector,module,cell,side);
}
HTofLookup::HTofLookup(const Char_t* name,const Char_t* title,
const Char_t* context,
Int_t nCrates, Int_t nSlots)
: HParSet(name,title,context) {
strcpy(detName,"Tof");
maxCrate=nCrates-1;
array = new TObjArray(nCrates);
for (Int_t i=0;i<nCrates;i++) array->AddAt(new HTofLookupCrate(nSlots),i);
}
HTofLookup::~HTofLookup() {
array->Delete();
delete array;
}
Bool_t HTofLookup::init(HParIo* inp,Int_t* set) {
HDetParIo* input=inp->getDetParIo("HTofParIo");
if (input) return (input->init(this,set));
return kFALSE;
}
Int_t HTofLookup::write(HParIo* output) {
HDetParIo* out=output->getDetParIo("HTofParIo");
if (out) return out->write(this);
return -1;
}
void HTofLookup::clear() {
for(Int_t c=0;c<=maxCrate;c++) {
for(Int_t s=0;s<(*this)[c].getSize();s++) (*this)[c][s].clear();
}
status=kFALSE;
resetInputVersions();
}
void HTofLookup::printParam() {
printf("Lookup table for the TOF unpacker\n");
printf("crate slot type channel sector module cell side\n");
for(Int_t c=0;c<getSize();c++) {
for(Int_t s=0;s<(*this)[c].getSize();s++) {
HTofLookupSlot& slot=(*this)[c][s];
for(Int_t r=0;r<slot.getSize();r++) {
HTofLookupChan& chan=slot[r];
if (chan.getSector()>=0) printf("%4i%4i %c%4i%4i%4i%4i %c\n",
c,s,slot.getType(),r,chan.getSector(),chan.getModule(),
chan.getCell(),chan.getSide());
}
}
}
}
void HTofLookup::fill(Int_t crate, Int_t slot, Char_t modType,
Int_t channel, Int_t sector, Int_t module, Int_t cell, Char_t side) {
if (crate>maxCrate) {
array->Expand(crate+1);
for(Int_t i=maxCrate+1;i<=crate;i++) array->AddAt(new HTofLookupCrate(),i);
maxCrate=crate;
}
(*this)[crate].fill(slot,modType,channel,sector,module,cell,side);
}
void HTofLookup::readline(const Char_t *buf, Int_t *set) {
Int_t crate, slot, chan, sec, mod, cell;
Char_t dcType[2], side[2];
sscanf(buf,"%i%i%s%i%i%i%i%s",&crate,&slot,dcType,&chan,&sec,&mod,&cell,side);
Int_t pos=sec*22+mod;
if (set[pos]) {
fill(crate,slot,dcType[0],chan,sec,mod,cell,side[0]);
set[pos]=999;
}
}
void HTofLookup::putAsciiHeader(TString& header) {
header=
"# Lookup table for the TOF unpacker\n"
"# Format:\n"
"# crate slot type channel sector module rod side\n";
}
Bool_t HTofLookup::writeline(Char_t *buf, Int_t crate, Int_t slot, Int_t chan) {
HTofLookupSlot& s=(*this)[crate][slot];
HTofLookupChan& c=s[chan];
if (c.getSector()>=0) {
sprintf(buf,"%4i%4i %c%4i%4i%4i%4i %c\n",
crate,slot,s.getType(),chan,c.getSector(),c.getModule(),c.getCell(),
c.getSide());
return kTRUE;
}
return kFALSE;
}
Last change: Sat May 22 13:16:20 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.