7 #include "StFpsRawDaqReader.h"
8 #include "StRoot/StEvent/StEvent.h"
10 #include "StRoot/St_base/StMessMgr.h"
11 #include "RTS/src/DAQ_FPS/daq_fps.h"
12 #include "RTS/src/DAQ_READER/daq_dta.h"
13 #include "StRoot/StEvent/StTriggerData.h"
14 #include "StRoot/StEvent/StTriggerData2017.h"
15 #include "StRoot/StEvent/StFmsCollection.h"
16 #include "StRoot/StEvent/StFmsHit.h"
17 #include "RTS/src/DAQ_READER/daqReader.h"
18 #include "StRoot/StFmsDbMaker/StFmsDbMaker.h"
23 StFpsRawDaqReader::StFpsRawDaqReader(
const Char_t* name,
const Char_t *daqFileName) :
24 StMaker(name),mEvent(0),mFmsCollectionPtr(0),mDaqFileName(daqFileName),mRdr(0),mFmsDbMkr(0){
25 std::string daqFileNameS( daqFileName );
28 StFpsRawDaqReader::~StFpsRawDaqReader(){
32 Int_t StFpsRawDaqReader::prepareEnvironment(){
35 mFmsCollectionPtr=mEvent->fmsCollection();
36 LOG_DEBUG <<
"::prepareEnvironment() found StEvent"<<endm;
40 LOG_DEBUG <<
"::prepareEnvironment() has added StEvent"<<endm;
42 if(!mFmsCollectionPtr) {
44 mEvent->setFmsCollection(mFmsCollectionPtr);
45 LOG_DEBUG <<
"::prepareEnvironment() has added StFpsCollection"<<endm;
47 LOG_DEBUG <<
"::prepareEnvironment() found FmsCollection"<<endm;
52 Int_t StFpsRawDaqReader::Init(){
53 GetEvtHddr()->SetEventNumber(1);
54 LOG_INFO <<
"Opening "<< mDaqFileName.data() <<endm;
55 mRdr =
new daqReader( const_cast< Char_t* >( mDaqFileName.data() ) );
57 LOG_FATAL <<
"Error constructing daqReader" << endm;
60 mRdr->get(0,EVP_TYPE_ANY);
61 int unixtime=mRdr->evt_time;
62 struct tm* local = localtime((
const time_t*)&unixtime);
63 int date=(local->tm_year+1900)*10000 + (local->tm_mon+1)*100 + local->tm_mday;
64 int time=local->tm_hour*10000 + local->tm_min*100 + local->tm_sec;
65 printf(
"Event Unix Time = %d %0d %06d\n",mRdr->evt_time,date,time);
66 mFmsDbMkr =
static_cast< StFmsDbMaker*
>(GetMaker(
"fmsDb"));
68 LOG_FATAL <<
"Error finding StFmsDbMaker"<< endm;
71 mFmsDbMkr->SetDateTime(date,time);
72 LOG_INFO <<
"Using date and time " << mFmsDbMkr->GetDateTime().GetDate() <<
", "
73 << mFmsDbMkr->GetDateTime().GetTime() << endm;
78 enum {kFpsQtCrate=8, kFpostQtCrate=9};
83 mRdr->get(0,EVP_TYPE_ANY);
84 if(mRdr->status == EVP_STAT_EOR) {
85 LOG_DEBUG <<
"End of File reached..."<<endm;
89 mTrgMask = mRdr->daqbits64;
92 for(
int i=63; i>=0; i--){
93 if(i%10==9) printf(
" ");
94 printf(
"%1x",(mTrgMask>>i)&0x1);
100 dd = mRdr->det(
"trg")->get(
"raw");
102 printf(
"trg/raw not found\n");
104 while(dd->iterate()) {
105 uint8_t *trg_raw = dd->Byte;
111 desc = (simple_desc *) trg_raw ;
117 if(Debug()) printf(
"Creating StTriggerData for ver=0x44 (2017) with run=%d\n",mRun);
121 printf(
"Unknown StTriggerData version = %x\n",desc->ver);
127 mRccFps=0; mRccFpost=0;
128 for(
int fpsfpost=1;fpsfpost<=2;fpsfpost++) {
129 dd = mRdr->det(
"fps")->get(
"adc",fpsfpost) ;
137 while(dd && dd->iterate()) {
147 int xing=(char)dd->pad;
148 if(xing>=128) xing-=256;
150 uint32_t n=dd->ncontent;
152 if(Debug()) printf(
"FPS: fpsfpost %1d xing %2d, QT %d, chs %d\n",fpsfpost,xing,qt,n) ;
154 for(uint32_t i=0;i<n;i++) {
160 if(fpsfpost==1) printf(
"FPS : xing %2d, QT %4d, ch %2d: ADC %4d, TDC %2d\n",xing,qt,ch,adc,tdc);
161 if(fpsfpost==2) printf(
"FPOST: xing %2d, QT %4d, ch %2d: ADC %4d, TDC %2d\n",xing,qt,ch,adc,tdc);
163 int slatid,q,l,s,flag=0,det,crate;
165 slatid = mFmsDbMkr->fpsSlatidFromQT(qt,ch);
166 mFmsDbMkr->fpsQLSfromSlatId(slatid,&q,&l,&s);
167 if(slatid<0) { flag=1; }
168 if(q<0 || l<1 || s<1) { flag=1; }
171 }
else if(fpsfpost==2){
172 slatid = mFmsDbMkr->fpostSlatidFromQT(qt,ch);
173 mFmsDbMkr->fpostQLSfromSlatId(slatid,&q,&l,&s);
174 if(slatid<0) { flag=1; }
175 if(q<0 || l<1 || s<1) { flag=1; }
181 hit->setDetectorId(det);
182 hit->setChannel(slatid);
183 hit->setQtCrate(crate);
185 hit->setQtChannel(ch);
187 hit->setTdc((
char)xing);
190 printf(
"Nhit=%d : ",mFmsCollectionPtr->numberOfHits());
193 mFmsCollectionPtr->addHit(hit);
198 LOG_DEBUG <<Form(
"Found %d data lines",ndata)<<endm;
205 if(mFmsCollectionPtr) mFmsCollectionPtr->hits().clear();
virtual void AddData(TDataSet *data, const char *dir=".data")
User methods.
virtual void Clear(Option_t *opts="")
User defined functions.