164 #include "StRtsReaderMaker.h"
165 #include "StRtsTable.h"
167 #include "StDAQMaker/StDAQReader.h"
169 #include "TDataSetIter.h"
171 # include "RTS/src/DAQ_READER/daq_det.h"
172 # include "RTS/src/DAQ_READER/daq_dta.h"
173 # include "RTS/src/DAQ_READER/daq_dta_structs.h"
174 typedef unsigned int UINT32;
175 # include "RTS/include/evp.h"
176 # include "RTS/src/DAQ_READER/cfgutil.h"
177 # include "RTS/src/DAQ_READER/daqReader.h"
179 #include "StStreamFile.h"
185 StRtsReaderMaker::StRtsReaderMaker(
const char *name):
StMaker(name)
186 ,fRtsReader(0),fDatReader(0),fRtsTable(0),fBank(0)
192 StRtsReaderMaker::~StRtsReaderMaker()
200 Int_t StRtsReaderMaker::Init() {
201 return StMaker::Init();
205 daqReader *StRtsReaderMaker::InitReader()
208 if (!fRtsReader && !fDatReader) {
211 TDataSet *dr = GetDataSet(
"StDAQReader");
214 if(daqReader == NULL) {
215 LOG_INFO <<
"StRtsReaderMaker::InitReader No daqReader available..." << endm;
217 evpReader *daqEvp = daqReader->getFileReader();
219 LOG_INFO <<
"StRtsReaderMaker::InitReader No evpReader available..." << endm;
221 LOG_INFO <<
"StRtsReaderMaker::InitReader: evpReader was found: " << daqEvp << endm;
222 fRtsReader = daqEvp->rts();
224 LOG_ERROR <<
"StRtsReaderMaker::InitReader: no daqReader was found!" << endm;
242 void StRtsReaderMaker::SetDaqReader(daqReader *reader)
245 assert(reader && !fDatReader &&
"Can not use two readers simultaneously");
250 void StRtsReaderMaker::SetDatReader(
StStreamFile *reader)
253 assert(reader && !fRtsReader &&
"Can not use two readers simultaneously");
260 static const char*RtsDataTypeByBankName(
const char *bankName)
272 TString bn = bankName;
273 if (bn ==
"cld" )
return "daq_cld";
275 static const char *str = 0;
277 gROOT->ProcessLine(
"struct intstruct { int a;}");
286 StRtsTable *StRtsReaderMaker::InitTable(
const char *detName,
const char *bankName)
291 if (fBank && !fBank->is_empty())
294 LOG_DEBUG <<
" You are going to use \"" << detName <<
"/" << bankName <<
"\" RTS bank" << endm;
295 LOG_DEBUG <<
" even though you did not use all information from the previous RTS bank: \""
296 << fLastQuery <<
"\" yet" << endm;
302 size_t dtBankSize = 0;
303 if (fBank) { dtBankSize = fBank->get_size_t(); }
304 else if (fDatReader) { dtBankSize = fDatReader->Length() ; }
308 if (Debug() > 3 ) fRtsTable->
Print();
314 void StRtsReaderMaker::FillDaqHeader()
317 fRtsTable->SetToken (fRtsReader->token );
318 fRtsTable->SetTrgcmd (fRtsReader->trgcmd );
319 fRtsTable->SetDaqcmd (fRtsReader->daqcmd );
320 fRtsTable->SetTrgword (fRtsReader->trgword);
321 fRtsTable->SetPhyword (fRtsReader->phyword);
322 fRtsTable->SetDaqbits (fRtsReader->daqbits);
323 fRtsTable->SetDaqbits_l1 (fRtsReader->daqbits_l1);
324 fRtsTable->SetDaqbits_l2 (fRtsReader->daqbits_l2);
325 fRtsTable->SetEvpgroups (fRtsReader->evpgroups);
326 fRtsTable->SetDetectors (fRtsReader->detectors);
331 TDataSet *StRtsReaderMaker::FillTable()
334 if (fBank && fBank->iterate()) {
335 fRtsTable->SetAll( fBank->sec
339 fRtsTable->SetMeta(fBank->meta);
341 fRtsTable->SetNRows(0);
343 LOG_DEBUG <<
" StRtsReaderMaker::FillTable(): the bank size is "
344 << fBank->ncontent <<
" row" << ((fBank->ncontent>1)?
"s ":
" ")
345 << fRtsTable->
GetRowSize() <<
" bytes each" << endm;
347 fRtsTable->
AppendRows(fBank->Byte,fBank->ncontent);
348 fRtsTable->SetNRows(fBank->ncontent);
349 }
else if (fDatReader) {
350 fRtsTable->SetAll(0,0,0,0);
351 fRtsTable->SetNRows(0);
352 fRtsTable->
AppendRows(fDatReader->Record(),1);
353 fRtsTable->SetNRows(1);
356 if (!fLastQuery.IsNull() && Debug()) {
357 LOG_DEBUG <<
" StRtsReaderMaker::FillTable(): No data has been found for \""
358 << fLastQuery <<
"\" to fill the table"
362 if (fRtsTable && Debug() > 3 ) fRtsTable->
Print(0,5);
371 TDataSet *StRtsReaderMaker::FindDataSet (
const char* logInput,
const StMaker *uppMk,
385 if ( !(logInput && logInput[0]) )
386 return StMaker::FindDataSet(logInput,uppMk,dowMk);
388 TString rtsRequest = logInput;
389 Bool_t rtsSystem =
false;
393 if (fLastQuery == rtsRequest) {
395 }
else if (fRtsReader || fDatReader) {
396 TObjArray *tokens = rtsRequest.Tokenize(
"/[],");
397 Int_t nItems = tokens->GetEntries();
398 if ( !strcmp(tokens->At(0)->GetName(),
"RTS") ) {
400 TString detName = tokens->At(1)->GetName();
402 char *detNameBuf =
new char[detName.Length()+1];
403 strncpy(detNameBuf,detName.Data(),detName.Length());
404 detNameBuf[detName.Length()]=0;
405 daq_det *rts_det = fRtsReader ? fRtsReader->det(detNameBuf) : 0;
406 delete [] detNameBuf;
412 thisMaker->fBank = rts_det->get( tokens->At(2)->GetName() );
415 thisMaker->fBank = rts_det->get( tokens->At(2)->GetName()
416 ,atoi(tokens->At(3)->GetName()));
418 LOG_DEBUG <<
" StRtsReaderMaker::FindDataSet det(\"" <<
419 detName <<
"\")->get(\""<<tokens->At(2)->GetName()
420 <<
"\"," << atoi(tokens->At(3)->GetName())
422 <<
"fBank = "<< thisMaker->fBank << endm;
426 thisMaker->fBank = rts_det->get( tokens->At(2)->GetName()
427 ,atoi(tokens->At(3)->GetName())
428 ,atoi(tokens->At(4)->GetName()));
431 thisMaker->fBank = rts_det->get( tokens->At(2)->GetName()
432 ,atoi(tokens->At(3)->GetName())
433 ,atoi(tokens->At(4)->GetName())
434 ,atoi(tokens->At(5)->GetName()));
436 default: thisMaker->fBank = 0;
break;
439 thisMaker->InitTable(detName,tokens->At(2)->GetName());
441 thisMaker->fLastQuery = rtsRequest;
443 thisMaker->fLastQuery =
"";
445 }
else if (fDatReader && detName==
"trg" && TString(
"raw") == tokens->At(2)->GetName()) {
446 thisMaker->InitTable(detName,tokens->At(2)->GetName());
447 thisMaker->fLastQuery = rtsRequest;
448 rtsSystem = fDatReader->Record();
450 LOG_DEBUG <<
" StRtsReaderMaker::FindDataSet: DAT request was found: "
451 << fDatReader->Length() << (
void *)fDatReader->Record() << endm;
459 thisMaker->FillDaqHeader();
460 ds = thisMaker->FillTable();
462 ds = StMaker::FindDataSet(logInput,uppMk,dowMk);
468 Int_t StRtsReaderMaker::InitRun(
int run)
470 return StMaker::InitRun(run);
virtual Long_t GetRowSize() const
Returns the size (in bytes) of one table row.
virtual void AddData(TDataSet *data, const char *dir=".data")
User methods.
virtual void Clear(Option_t *option="")
User defined functions.
virtual Long_t AppendRows(const void *row, UInt_t nRows)
virtual TObject * GetObject() const
The depricated method (left here for the sake of the backward compatibility)
virtual void Clear(Option_t *option="")
User defined functions.
virtual Char_t * Print(Char_t *buf, Int_t n) const
Create IDL table defintion (to be used for XDF I/O)