//*-- AUTHOR : Jerzy Pietraszko, Ilse Koenig
//*-- Created : 03/02/2006
//_HADES_CLASS_DESCRIPTION
/////////////////////////////////////////////////////////////
//
// HWallTrbUnpacker
//
// Class for unpacking TRB data and filling
// the Forward Wall Raw category
// Base subevent decoding is performed by decode function
// see: htrbbaseunpacker.h
//
/////////////////////////////////////////////////////////////
using namespace std;
#include "hwalltrbunpacker.h"
#include "walldef.h"
#include "htrblookup.h"
#include "hwallraw.h"
#include "hdebug.h"
#include "hades.h"
#include "hevent.h"
#include "hspectrometer.h"
#include "hdetector.h"
#include "hruntimedb.h"
#include "hcategory.h"
#include "hldsubevt.h"
#include "heventheader.h"
#include <iostream>
#include <iomanip>
#include <stdlib.h>
ClassImp (HWallTrbUnpacker)
HWallTrbUnpacker::HWallTrbUnpacker (UInt_t id):HTrbBaseUnpacker (id) {
// constructor
pRawCat = NULL;
debugWallFlag=0;
}
Bool_t
HWallTrbUnpacker::init (void) {
// creates the raw category and gets the pointer to the lookup table
pRawCat = gHades->getCurrentEvent ()->getCategory (catWallRaw);
if (!pRawCat) {
pRawCat = gHades->getSetup ()->getDetector ("Wall")->buildCategory (catWallRaw);
if (!pRawCat)
return kFALSE;
gHades->getCurrentEvent ()->addCategory (catWallRaw, pRawCat, "Wall");
}
loc.set (1, 0);
lookup = (HTrbLookup *) (gHades->getRuntimeDb ()->getContainer ("TrbLookup"));
return kTRUE;
}
Int_t HWallTrbUnpacker::execute (void) {
HWallRaw *pRaw = 0; // pointer to Raw category
Int_t nEvt = 0; // Evt Seq. Nb.
nEvt = gHades->getCurrentEvent ()->getHeader ()->getEventSeqNumber ();
if (gHades->isCalibration ()) {
//calibration event
//cout << " --calibration event nothing to do for forward wall " << endl;
return 1;
}
// decode subevent data
if (pSubEvt) { // pSubEvt - make sure that there is something for decoding
decode (); // decode the subevent and fill arrays, see: htrbbaseunpacker.h
// get the part of the lookup table which belongs to the subevent ID
// in order to check which TRBchannel belongs to the WallDetector
///////////////////////////////
//
// Be Carefull !! I am changing SubEvent ID
// Should not be a case !! Only for tests
// My test HLD data are with SubEventId = 545
// In Hydra Allowed SubEvents Ids for TRB starts from 800...
//
//////////////////////////////
if(debugWallFlag==802){
subEvtId = 802; // this line changes SubEventID
}
HTrbLookupBoard *board = lookup->getBoard (subEvtId);
if (!board) {
// Problem: unpacker for specific SubId was called but for this SubId
// no channel in lookup table axist.
//
Warning ("execute", "SubEvent: %i unpacked but channel in Lookup table does not exist", subEvtId);
}
//fill RAW category for Forward Wall detector
for (Int_t i = 0; i < 128; i++) {
if (trbLeadingMult[i] < 1) continue; //Leading Time data for this channel exist
// fill wall raw category
HTrbLookupChan *chan = board->getChannel (i);
if (chan && 'W' == (Char_t) (chan->getDetector ())) { //Channel belongs to Wall det
//cout << "--Evnt Nb " << nEvt << "t --Channel= " << i << " belongs to Wall n";
loc[0] = i;
pRaw = (HWallRaw *) pRawCat->getObject (loc);
if (!pRaw) {
pRaw = (HWallRaw *) pRawCat->getSlot (loc);
if (pRaw) {
pRaw = new (pRaw) HWallRaw;
pRaw->setCell ((Int_t) chan->getCell ());
pRaw->setTime (trbLeadingTime[i][0]);
pRaw->setCharge (trbADC[i][0]);
}
else {
Error ("execute()", "Can't get slotn");
return -1;
}
}
else {
//
// here you can fill more than one hit for one
// detector channel
// Row category has to be prepared for this
//
#if DEBUG_LEVEL>4
Info ("execute()", "Slot already exists!\n");
#endif
}
}
}// for(Int_t i=0; i<128; i++)
} //if(pSubEvt)
return 1;
}
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.