using namespace std;
#include "htofunpacker99.h"
#include "htofraw.h"
#include "hdebug.h"
#include "hades.h"
#include "hevent.h"
#include "hspectrometer.h"
#include "hdetector.h"
#include "hcategory.h"
#include "hldsubevt.h"
#include <iostream>
#include <iomanip>
HTofUnpacker99::HTofUnpacker99(void) {
pRawCat=NULL;
pTofData = NULL;
}
HTofUnpacker99::~HTofUnpacker99(void) {
}
Bool_t HTofUnpacker99::init(void) {
pRawCat=gHades->getCurrentEvent()->getCategory(catTofRaw);
if (!pRawCat) {
pRawCat=gHades->getSetup()->getDetector("Tof")->buildCategory(catTofRaw);
if (!pRawCat) {
return kFALSE;
} else {
gHades->getCurrentEvent()->addCategory(catTofRaw,pRawCat,"Tof");
}
}
return kTRUE;
}
Int_t HTofUnpacker99::execute() {
Int_t i = fill();
return i;
}
Int_t HTofUnpacker99::fill() {
if(pTofData) {
delete [] pTofData;
pTofData = NULL;
}
if(pSubEvt) {
UInt_t channels,geo;
UInt_t tdcCh,time;
Int_t cursor;
Int_t j;
UInt_t tdcCounter;
HLocation loc;
loc.set(3,0,0,0);
Int_t length = pSubEvt->getEnd() - pSubEvt->getData();
pTofData = new UInt_t[length];
UInt_t *pointer = pSubEvt->getData();
for(j=0;j<length;j++) pTofData[j] = pointer[j];
cursor = 0;
tdcCounter = 0;
while(cursor<length) {
geo = (UInt_t) byte(1,pTofData[cursor]) >> 3;
channels = (UInt_t) byte(3,pTofData[cursor++]);
tdcCh = 0;
time = 0;
for(j=cursor; j < (Int_t)(cursor+channels); j++) {
tdcCh = (tdcCh | (pTofData[j] & 0x001f0000)) >> 16;
time = (pTofData[j] & 0xfff ) % 0xfff;
if(geo==3||geo==4||geo==5||geo==6) loc[0] = 2;
if(geo==8||geo==9||geo==10||geo==11) loc[0] = 5;
if(geo==3||geo==5||geo==8||geo==10) loc[1] = tdcCh/8;
if(geo==4||geo==6||geo==9||geo==11) loc[1] = tdcCh/8 + 4;
loc[2] = tdcCh%8;
HTofRaw *pCell = (HTofRaw*) pRawCat->getObject(loc);
if (pCell == NULL) {
pCell = (HTofRaw*) pRawCat->getSlot(loc);
if (pCell != NULL) {
pCell = new(pCell) HTofRaw;
pCell->setRightTime(0.0);
pCell->setLeftTime(0.0);
pCell->setRightCharge(0.0);
pCell->setLeftCharge(0.0);
pCell->setSector((Char_t) loc[0]);
pCell->setModule((Char_t)loc[1]);
pCell->setCell((Char_t)loc[2]);
} else return kFALSE;
}
if(pCell != NULL) {
if(geo==3||geo==4||geo==8||geo==9) {
pCell->setRightTime((Float_t) time);
pCell->setSector((Char_t) loc[0]);
pCell->setModule((Char_t) loc[1]);
pCell->setCell((Char_t) loc[2]);
}
if(geo==5||geo==6||geo==10||geo==11) {
pCell->setLeftTime((Float_t) time);
pCell->setSector((Char_t) loc[0]);
pCell->setModule((Char_t) loc[1]);
pCell->setCell((Char_t) loc[2]);
}
}
}
cursor += channels + 1;
tdcCounter++;
}
}
return kTRUE;
}
ClassImp(HTofUnpacker99)
Last change: Sat May 22 13:16:32 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.