StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StETofDigiMaker.cxx
1 /***************************************************************************
2  *
3  * $Id: StETofDigiMaker.cxx,v 1.6 2021/05/12 16:31:47 weidenkaff Exp $
4  *
5  * Author: Florian Seck, April 2018
6  ***************************************************************************
7  *
8  * Description: StETofDigiMaker - class to fill the StEvent from DAQ reader:
9  * unpack raw data & save StETofHeader & StETofDigis in StETofCollection
10  *
11  ***************************************************************************
12  *
13  * $Log: StETofDigiMaker.cxx,v $
14  * Revision 1.6 2021/05/12 16:31:47 weidenkaff
15  * removed some clutter messages from text output
16  *
17  * Revision 1.5 2021/05/10 10:45:30 weidenkaff
18  * Added unpacking of status pattern to be written to Event header. PW.StETofDigiMaker.cxx
19  *
20  * Revision 1.4 2019/03/08 18:45:40 fseck
21  * save middle value of tot bin as raw tot of the digi
22  *
23  * Revision 1.3 2019/02/19 20:32:09 fseck
24  * update for unpacking year 2019+ daq files
25  *
26  * Revision 1.2 2018/07/27 13:58:12 fseck
27  * small change to compile also in 64bit mode
28  *
29  * Revision 1.1 2018/07/25 14:39:40 jeromel
30  * Peer reviewed Raghav+Jerome - code from Florian Seck
31  *
32  *
33  ***************************************************************************/
34 #include <map>
35 #include <array>
36 #include <algorithm> // std::is_sorted
37 
38 #include "StDAQMaker/StDAQReader.h"
39 #include "StRtsTable.h"
40 
41 #include "StEvent.h"
42 #include "StETofCollection.h"
43 #include "StETofHeader.h"
44 #include "StETofDigi.h"
45 #include "StETofHit.h"
46 
47 #include "StETofDigiMaker.h"
48 #include "StETofUtil/StETofConstants.h"
49 #include "StETofUtil/StETofHardwareMap.h"
50 #include "StETofUtil/StETofMessageFormat.h"
51 
52 #include "tables/St_etofElectronicsMap_Table.h"
53 
54 
55 //_____________________________________________________________
57 : StRTSBaseMaker( "etof", name ),
58  mEvent( 0 ),
59  mETofCollection( 0 ),
60  mRunYear( 0 ),
61  mHwMap( nullptr ),
62  mFileNameElectronicsMap( "" ),
63  mDebug( false )
64 {
65  LOG_DEBUG << "StETofDigiMaker::ctor" << endm;
66  const size_t kNbGet4sInSystem = 1728;
67  mMissMatchFlagVec = vector< bool >( kNbGet4sInSystem, false );
68  mGet4ActiveMap.clear();
69 }
70 
71 //_____________________________________________________________
72 StETofDigiMaker::~StETofDigiMaker()
73 { /* no op */
74 
75 }
76 
77 //_____________________________________________________________
78 Int_t
79 StETofDigiMaker::Init()
80 {
81  LOG_INFO << "StETofDigiMaker::Init" << endm;
82 
83  return kStOk;
84 }
85 
86 //_____________________________________________________________
87 Int_t
88 StETofDigiMaker::InitRun( Int_t runnumber )
89 {
90  mRunYear = ( runnumber + 727000 ) / 1000000 + 1999;
91 
92  LOG_INFO << "runnumber: " << runnumber << " --> year: " << mRunYear << endm;
93 
94  mGet4ActiveMap.clear();
95  TDataSet* dbDataSet = nullptr;
96 
97  //load electronics-to-hardware map for missmatch pattern. PW
98  if( mFileNameElectronicsMap.empty() ) {
99  LOG_INFO << "StETofDigiMaker::InitRun: no electronics map filename provided --> load database table" << endm;
100 
101  dbDataSet = GetDataBase( "Geometry/etof/etofElectronicsMap" );
102 
103  St_etofElectronicsMap* etofElectronicsMap = static_cast< St_etofElectronicsMap* > ( dbDataSet->Find( "etofElectronicsMap" ) );
104  if( !etofElectronicsMap ) {
105  LOG_ERROR << "unable to get the electronics map from the database" << endm;
106  return kStFatal;
107  }
108 
109  mHwMap = new StETofHardwareMap( etofElectronicsMap, mRunYear );
110  //debug PW
111  etofElectronicsMap_st* table = etofElectronicsMap->GetTable();
112  LOG_INFO << "StETofDigiMaker::InitRun: PRINTING CHANNEL MAP: " << endm;
113  for( size_t i=0; i<576; i++ ) {
114  //LOG_INFO << "Ch " <<table->channelNumber[ i ] <<" Geo "<< table->geometryId[ i ] << endm;
115  mGet4ActiveMap[ table->channelNumber[ i ] ] = true;
116  }
117  }
118  else {
119  LOG_INFO << "StETofDigiMaker::InitRun: etofElectronicsMap: filename provided --> use parameter file: " << mFileNameElectronicsMap.c_str() << endm;
120 
121  mHwMap = new StETofHardwareMap( mFileNameElectronicsMap, mRunYear );
122 
123  // get local parameter file
124  std::ifstream paramFile;
125 
126  paramFile.open( mFileNameElectronicsMap.c_str() );
127 
128  if( !paramFile.is_open() ) {
129  LOG_ERROR << "StETofHardwareMap -- unable to get the parameters from local file --> file does not exist" << endm;
130  return kStFatal;
131  }
132 
133  unsigned int temp;
134 
135  for( int i=0; i<576; i++ ) {
136  if( !paramFile.eof() ) {
137  paramFile >> std::dec >> temp;
138  mGet4ActiveMap[ temp ] = true;
139  }
140  }
141  }
142 
143  return kStOk;
144 }
145 
146 //_____________________________________________________________
147 Int_t
148 StETofDigiMaker::FinishRun( Int_t runnumber )
149 {
150  return kStOk;
151 }
152 
153 //_____________________________________________________________
154 Int_t
156 {
157  return kStOk;
158 }
159 
160 //_____________________________________________________________
168 {
170  StETofCollection* etofCollection = 0;
171  mEvent = dynamic_cast< StEvent* >( GetInputDS( "StEvent" ) );
172 
173  if ( mEvent ) {
174  etofCollection = mEvent->etofCollection();
175 
177  if ( !etofCollection ) {
179  LOG_INFO << "StETofDigiMaker::getETofCollection - making new StETofCollection and giving it to StEvent" << endm;
180  etofCollection = new StETofCollection();
181  mEvent->setETofCollection( etofCollection );
182  }
183  else {
184  LOG_INFO << "StETofDigiMaker::getETofCollection - StEvent already has a StETofCollection - not making a new one" << endm;
185  }
186  }
187  else {
188  LOG_WARN << "No StEvent found by StETofDigiMaker::getETofCollection" << endm;
189  }
190 
191  return etofCollection;
192 }
193 
194 //_____________________________________________________________
195 Int_t
197 {
198  LOG_INFO << "StETofDigiMaker::Make()" << endm;
199 
200  //---------------------------------
201  mETofCollection = getETofCollection();
202  if( mDebug ) {
203  LOG_DEBUG << "StETofDigiMaker::Make() - getting the etof collection " << mETofCollection << endm;
204  }
205 
206  if ( mETofCollection == nullptr ) {
207  LOG_WARN << "No StEvent --> no ETofCollection --> nothing to do" << endm;
208  return kStWarn;
209  }
210 
211  if( mETofCollection->digisPresent() ) {
212  LOG_WARN << "StETofDigiMaker::Make() - there are already ETOF DIGIS ... nothing to do." << endm;
213  return kStWarn;
214  }
215  //---------------------------------
216 
217 
218 
219  StRtsTable* daqdta = GetNextRaw();
220 
221  if ( daqdta == nullptr ) {
222  LOG_WARN << "StETofDigiMaker::Make() - NO ETOF DATA found in event" << endm;
223  return kStOk;
224  }
225 
226  // do unpacking of the raw data
227  int inputSizeBytes = daqdta->GetSize();
228 
229  if( mDebug ) {
230  LOG_DEBUG << "StETofDigiMaker::Make() - InputSize (bytes): " << inputSizeBytes << endm;
231  }
232 
233  uint64_t* messageBuffer = ( uint64_t* ) ( *daqdta->begin() );
234 
235  // ------------------------------------------------------------------------------------------------------
236  // determine number of full messages to read:
237  // the packed version sent to the STAR DAQ systems is made of a 256 bit header (4 long unsigned integers)
238  // followed by a buffer of gdpb::FullMessage (128 bit each).
239  //
240  // gdbp(v100)::Message = 64 bit message as received from the eTOF gDPB boards
241  // gdpb(v100)::FullMessage = 128 bit message, obtained by combining a
242  // 64 bit extended epoch (bits 127-64) with a gdpb::Message (bits 63-0)
243  // -------------------------------------------------------------------------------------------------------
244  size_t nFullMessagesToRead = ( ( inputSizeBytes / eTofConst::daqMessageSize ) - 4 ) / 2;
245  LOG_INFO << "StETofDigiMaker::Make() - # full messages to read: " << nFullMessagesToRead << endm;
246 
247  if( mRunYear == 2018 ) {
248  if( mDebug ) {
249  LOG_DEBUG << "processing event from 2018" << endm;
250  }
251  processEvent2018( messageBuffer, nFullMessagesToRead );
252  }
253  else{
254  if( mDebug ) {
255  LOG_DEBUG << "processing event from 2019+" << endm;
256  }
257  processEvent( messageBuffer, nFullMessagesToRead );
258  }
259 
260  return kStOk;
261 }
262 
263 
264 //_____________________________________________________________
268 void
269 StETofDigiMaker::processEvent( uint64_t* messageBuffer, size_t nFullMessagesToRead )
270 {
271  // create vector to store the trigger messages
272  vector< gdpbv100::FullMessage > triggerMessages;
273  const size_t kNbGet4sInSystem = 1728;
274  mMissMatchFlagVec.clear();
275  mMissMatchFlagVec.resize( kNbGet4sInSystem, 0 );
276 
277  // loop over gdpb messages
278  for( size_t msgIndex = 0; msgIndex < nFullMessagesToRead; msgIndex++ ) {
279  // convert to 'full messages'
280  gdpbv100::FullMessage mess( messageBuffer[ 4 + 2 * msgIndex ], messageBuffer[ 4 + 2 * msgIndex + 1 ] );
281 
282  // print message for debugging
283  if( mDebug ) {
284  LOG_DEBUG << std::hex << messageBuffer[ 4 + 2 * msgIndex ] << " " << messageBuffer[ 4 + 2 * msgIndex + 1 ] << std::dec << endm;
285  mess.PrintMessage( gdpb::msg_print_Prefix | gdpb::msg_print_Data );
286  }
287 
288  // fill structural pointer vector with eTOF digis if the message is a 'hit' message
289  if( mess.isHitMsg() ) {
290  fillETofDigi( mess );
291  }
292 
293  // deal with STAR trigger messages A,B,C,D
294  if( mess.isStarTrigger() ) {
295  triggerMessages.push_back( mess );
296  }
297 
298  if( mess.isSysMsg() ) {
299  // only care about pattern messages
300  if( mess.getGdpbSysSubType() != 3 ) continue;
301 
302  int patternType = mess.getGdpbSysPattType();
303  int patternIndex = mess.getGdpbSysPattIndex();
304  int pattern = mess.getGdpbSysPattPattern();
305 
306  int rocId = mess.getGdpbGenGdpbId();
307  unsigned int sector;
308  mHwMap->mapToSector( rocId, sector );
309 
310  // only care about the status bits
311  if( patternType != 3 ) continue;
312 
313  int nBits = ( 7 == patternIndex ? 16 : 32 );
314 
315  // LOG_INFO << "Found Pattern Message: "<< sector << endm;
316 
317  for( int bit = 0; bit < nBits; ++bit ) {
318  if( ( pattern >> bit ) & 0x1 ) {
319 
320  int get4Id = 32 * patternIndex + bit;
321  if ( mGet4ActiveMap.count( 10*get4Id ) ){
322  std::vector< unsigned int > geomVec;
323  mHwMap->mapToGeom( rocId, get4Id, 0, geomVec );
324 
325  LOG_INFO << " "<< sector << endm;
326  LOG_INFO << "-----------------------------"<< sector << endm;
327  LOG_INFO << "FOUND ACTIVE PATTERN! Sector: "<< sector << endm;
328  LOG_INFO << "-----------------------------"<< sector << endm;
329  LOG_INFO << " "<< sector << endm;
330 
331  if( geomVec.size() < 5 ) {
332  LOG_WARN << "geometry vector has wrong size !!! --> skip message. size: "<< geomVec.size() << endm;
333  continue;
334  }
335  //unsigned int sector = geomVec.at( 0 );
336  unsigned int zplane = geomVec.at( 1 );
337  unsigned int counter = geomVec.at( 2 );
338  unsigned int strip = geomVec.at( 3 );
339  unsigned int side = geomVec.at( 4 );
340 
341  mMissMatchFlagVec.at( 144 * ( sector - 13 ) + 48 * ( zplane -1 ) + 16 * ( counter - 1 ) + 8 * ( side - 1 ) + ( ( strip - 1 ) / 4 ) ) = true;
342  }else{
343  LOG_DEBUG << "Wrongly mapped get4 chip in message pattern --> skip message. ID: "<< get4Id << endm;
344  }
345  }
346  }
347  }
348  } // end message loop
349 
350  // fill eTOF collection with eTOF header
351  fillETofHeader( messageBuffer, triggerMessages );
352 
353  // check eTOF information in StEvent
354  checkEvent();
355 }
356 
357 //_____________________________________________________________
362 void
363 StETofDigiMaker::convertTriggerMessages( vector< gdpbv100::FullMessage >& triggerMessages,
364  map< unsigned int, uint64_t >& gdpbTsMap,
365  map< unsigned int, uint64_t >& starTsMap )
366 {
367  if( mDebug ) {
368  LOG_DEBUG << "StETofDigiMaker::convertTriggerMessages() - do the conversion... " << endm;
369  }
370  size_t nTriggerMessages = triggerMessages.size();
371 
372  LOG_INFO << "StETofDigiMaker::convertTriggerMessages() - size of triggerMessage vector: " << nTriggerMessages << endm;
373 
374  // there should be 4 StarTriggerMessages (A, B, C, D) for each Roc
375  if( nTriggerMessages % 4 != 0 ) {
376  LOG_WARN << "number of trigger messages does not match expectations --> skip conversion " << endm;
377  return;
378  }
379 
380  array< int, 4 > messageTypesTemplate = { 0, 1, 2, 3 };
381 
382  for( unsigned int i=0; i<nTriggerMessages; i+=4 ) {
383 
384  array< int, 4 > messageTypes;
385  messageTypes.at( 0 ) = triggerMessages.at( i ).getStarTrigMsgIndex();
386  messageTypes.at( 1 ) = triggerMessages.at( i+1 ).getStarTrigMsgIndex();
387  messageTypes.at( 2 ) = triggerMessages.at( i+2 ).getStarTrigMsgIndex();
388  messageTypes.at( 3 ) = triggerMessages.at( i+3 ).getStarTrigMsgIndex();
389 
390  array< int, 4 > rocIds;
391  rocIds.at( 0 ) = triggerMessages.at( i ).getGdpbGenGdpbId();
392  rocIds.at( 1 ) = triggerMessages.at( i+1 ).getGdpbGenGdpbId();
393  rocIds.at( 2 ) = triggerMessages.at( i+2 ).getGdpbGenGdpbId();
394  rocIds.at( 3 ) = triggerMessages.at( i+3 ).getGdpbGenGdpbId();
395 
396  if( !std::all_of( rocIds.begin(), rocIds.end(), [ rocIds ]( int i ) { return i == rocIds[ 0 ]; } ) ||
397  messageTypes != messageTypesTemplate )
398  {
399  LOG_WARN << "Roc Id miss match --> skip conversion " << endm;
400  gdpbTsMap.clear();
401  starTsMap.clear();
402  return;
403  }
404 
405  uint64_t gdpbTsMsb = triggerMessages.at( i ).getGdpbTsMsbStarA();
406  uint64_t gdpbTsLsb = triggerMessages.at( i+1 ).getGdpbTsLsbStarB();
407  uint64_t starTsMsb = triggerMessages.at( i+1 ).getStarTsMsbStarB();
408  uint64_t starTsMid = triggerMessages.at( i+2 ).getStarTsMidStarC();
409 
410  uint64_t rocGdpbTs = ( gdpbTsMsb << 24 )
411  + ( gdpbTsLsb );
412 
413  uint64_t rocStarTs = ( starTsMsb << 48 )
414  + ( starTsMid << 8 )
415  + triggerMessages.at( i+3 ).getStarTsLsbStarD();
416 
417  //unsigned int rocToken = triggerMessages.at( i+3 ).getStarTokenStarD();
418  //unsigned int rocDaqCmd = triggerMessages.at( i+3 ).getStarDaqCmdStarD();
419  //unsigned int rocTrigCmd = triggerMessages.at( i+3 ).getStarTrigCmdStarD();
420 
421  gdpbTsMap[ rocIds.at( 0 ) ] = rocGdpbTs;
422  starTsMap[ rocIds.at( 0 ) ] = rocStarTs;
423  }
424 }
425 
426 //_____________________________________________________________
427 void
428 StETofDigiMaker::fillETofHeader( uint64_t* messageBuffer, vector< gdpbv100::FullMessage >& triggerMessages )
429 {
430  uint64_t trgGdpbFullTs = messageBuffer[ 0 ]; // time since last eTOF clock reset in ns
431  uint64_t trgStarFullTs = messageBuffer[ 1 ]; // time since last bTOF clock reset in ns
432  unsigned int starToken = ( messageBuffer[ 2 ] >> 32 ) & 0xFFF;
433  unsigned int starDaqCmdIn = ( messageBuffer[ 2 ] >> 16 ) & 0x00F;
434  unsigned int starTrigCmdIn = ( messageBuffer[ 2 ] ) & 0x00F;
435  uint64_t eventStatusFlag = messageBuffer[ 3 ];
436 
437  if( mDebug ) {
438  LOG_INFO << "StETofDigiMaker::fillETofHeader(): " << " ";
439  LOG_INFO << "trgGdpbFullTs=" << trgGdpbFullTs << " ";
440  LOG_INFO << "trgStarFullTs=" << trgStarFullTs << endm;
441  LOG_DEBUG << "starToken=" << starToken << " ";
442  LOG_DEBUG << "starDaqCmdIn=" << starDaqCmdIn << " ";
443  LOG_DEBUG << "starTrigCmdIn=" << starTrigCmdIn << endm;
444  LOG_DEBUG << "eventStatusFlag=" << eventStatusFlag << endm;
445  }
446 
447  map< unsigned int, uint64_t > gdpbTsMap;
448  map< unsigned int, uint64_t > starTsMap;
449 
450  convertTriggerMessages( triggerMessages, gdpbTsMap, starTsMap );
451 
452  if( mDebug ) {
453  for( const auto& kv : gdpbTsMap ) {
454  LOG_DEBUG << "GdpbTs( 0x" << std::hex << kv.first << std::dec << " ): " << kv.second << endm;
455  }
456  for( const auto& kv : starTsMap ) {
457  LOG_DEBUG << "StarTs( 0x" << std::hex << kv.first << std::dec << " ): " << kv.second << endm;
458  }
459  }
460 
461  // fill eTOF header with trigger & star time as doubles
462  StETofHeader *etofHeader = new StETofHeader( trgGdpbFullTs * gdpbv100::kdClockCycleSizeNs,
463  trgStarFullTs * gdpbv100::kdClockCycleSizeNs,
464  gdpbTsMap,
465  starTsMap,
466  starToken,
467  starDaqCmdIn,
468  starTrigCmdIn,
469  eventStatusFlag,
470  mMissMatchFlagVec
471  );
472 
473  mETofCollection->setHeader( etofHeader );
474 }
475 
476 //_____________________________________________________________
477 void
478 StETofDigiMaker::fillETofDigi( gdpbv100::FullMessage& mess )
479 {
480  // fill eTOF digis
481  mETofCollection->addDigi( new StETofDigi( mess.getGdpbGenGdpbId(),
482  mess.getGdpbGenChipId(),
483  mess.getGdpbHitChanId(),
484  mess.GetFullTimeNs(),
485  ( double ) mess.getGdpbHit32Tot() + 0.5 ) );
486 }
487 
488 
489 
490 //_____________________________________________________________
494 void
496  LOG_DEBUG << "StETofDigiMaker::fillEvent() starting..." << endm;
497 
499  if( !mETofCollection ) {
500  LOG_WARN << "StETofDigiMaker::fillEvent() - no ETofCollection ... creating one in StEvent" << endm;
501  mETofCollection = new StETofCollection();
502  mEvent->setETofCollection( mETofCollection );
503  }
504 
506  StETofCollection* etofCollection = mEvent->etofCollection();
507  if( etofCollection ) {
508  if( etofCollection->digisPresent() ) {
509  StSPtrVecETofDigi& eTofDigiVec = etofCollection->etofDigis();
510  LOG_INFO << "StETofDigiMaker::fillEvent() - StETofCollection has " << eTofDigiVec.size() << " digis" << endm;
511  if( mDebug ) {
512  for( size_t i=0; i<eTofDigiVec.size(); i++ ) {
513  LOG_INFO << ( *eTofDigiVec[ i ] ) << endm;
514  }
515  }
516  }
517  else {
518  LOG_INFO << "StETofDigiMaker::fillEvent() - no digis in the StETofCollection" << endm;
519  }
520  }
521  else {
522  LOG_WARN << "StETofDigiMaker::fillEvent() - no StETofCollection" << endm;
523  }
524 }
525 //_____________________________________________________________
526 
527 
528 
529 //**** methods for year 2018 data format ***
530 
531 //_____________________________________________________________
535 void
536 StETofDigiMaker::processEvent2018( uint64_t* messageBuffer, size_t nFullMessagesToRead )
537 {
538  // create vector to store the trigger messages
539  vector< gdpb::FullMessage > triggerMessages;
540 
541  // loop over gdpb messages
542  for( size_t msgIndex = 0; msgIndex < nFullMessagesToRead; msgIndex++ ) {
543  // convert to 'full messages'
544  gdpb::FullMessage mess( messageBuffer[ 4 + 2 * msgIndex ], messageBuffer[ 4 + 2 * msgIndex + 1 ] );
545 
546  // print message for debugging
547  if( mDebug ) {
548  LOG_DEBUG << std::hex << messageBuffer[ 4 + 2 * msgIndex ] << " " << messageBuffer[ 4 + 2 * msgIndex + 1 ] << std::dec << endm;
549  mess.PrintMessage( gdpb::msg_print_Prefix | gdpb::msg_print_Data );
550  }
551 
552  // fill structural pointer vector with eTOF digis if the message is a 'hit' message
553  if( mess.isGet4Hit32Msg() ) {
554  fillETofDigi( mess );
555  }
556 
557  // deal with STAR trigger messages A,B,C,D
558  if( mess.isStarTrigger() ) {
559  triggerMessages.push_back( mess );
560  }
561 
562  } // end message loop
563 
564  // fill eTOF collection with eTOF header
565  fillETofHeader( messageBuffer, triggerMessages );
566 
567  // check eTOF information in StEvent
568  checkEvent();
569 }
570 
571 //_____________________________________________________________
576 void
577 StETofDigiMaker::convertTriggerMessages( vector< gdpb::FullMessage >& triggerMessages,
578  map< unsigned int, uint64_t >& gdpbTsMap,
579  map< unsigned int, uint64_t >& starTsMap )
580 {
581  if( mDebug ) {
582  LOG_DEBUG << "StETofDigiMaker::convertTriggerMessages() - do the conversion... " << endm;
583  }
584  size_t nTriggerMessages = triggerMessages.size();
585 
586  LOG_INFO << "StETofDigiMaker::convertTriggerMessages() - size of triggerMessage vector: " << nTriggerMessages << endm;
587 
588  // there should be 4 StarTriggerMessages (A, B, C, D) for each Roc
589  if( nTriggerMessages % 4 != 0 ) {
590  LOG_WARN << "number of trigger messages does not match expectations --> skip conversion " << endm;
591  return;
592  }
593 
594  for( unsigned int i=0; i<nTriggerMessages; i+=4 ) {
595  array< int, 4 > rocIds;
596  rocIds.at( 0 ) = triggerMessages.at( i ).getRocNumber();
597  rocIds.at( 1 ) = triggerMessages.at( i+1 ).getRocNumber();
598  rocIds.at( 2 ) = triggerMessages.at( i+2 ).getRocNumber();
599  rocIds.at( 3 ) = triggerMessages.at( i+3 ).getRocNumber();
600 
601  // check that all trigger messages come from the same AFCK
602  if( !std::all_of( rocIds.begin(), rocIds.end(), [ rocIds ]( int i ) { return i == rocIds[ 0 ]; } ) ) {
603  LOG_WARN << "Roc Id miss match --> skip conversion " << endm;
604  gdpbTsMap.clear();
605  starTsMap.clear();
606  return;
607  }
608 
609  uint64_t gdpbTsMsb = triggerMessages.at( i ).getGdpbTsMsbStarA();
610  uint64_t gdpbTsLsb = triggerMessages.at( i+1 ).getGdpbTsLsbStarB();
611  uint64_t starTsMsb = triggerMessages.at( i+1 ).getStarTsMsbStarB();
612  uint64_t starTsMid = triggerMessages.at( i+2 ).getStarTsMidStarC();
613 
614  uint64_t rocGdpbTs = ( gdpbTsMsb << 24 )
615  + ( gdpbTsLsb );
616 
617  uint64_t rocStarTs = ( starTsMsb << 48 )
618  + ( starTsMid << 8 )
619  + triggerMessages.at( i+3 ).getStarTsLsbStarD();
620 
621  //unsigned int rocToken = triggerMessages.at( i+3 ).getStarTokenStarD();
622  //unsigned int rocDaqCmd = triggerMessages.at( i+3 ).getStarDaqCmdStarD();
623  //unsigned int rocTrigCmd = triggerMessages.at( i+3 ).getStarTrigCmdStarD();
624 
625  gdpbTsMap[ rocIds.at( 0 ) ] = rocGdpbTs;
626  starTsMap[ rocIds.at( 0 ) ] = rocStarTs;
627  }
628 }
629 
630 //_____________________________________________________________
631 void
632 StETofDigiMaker::fillETofHeader( uint64_t* messageBuffer, vector< gdpb::FullMessage >& triggerMessages )
633 {
634  uint64_t trgGdpbFullTs = messageBuffer[ 0 ]; // time since last eTOF clock reset in ns
635  uint64_t trgStarFullTs = messageBuffer[ 1 ]; // time since last bTOF clock reset in ns
636  unsigned int starToken = ( messageBuffer[ 2 ] >> 32 ) & 0xFFF;
637  unsigned int starDaqCmdIn = ( messageBuffer[ 2 ] >> 16 ) & 0x00F;
638  unsigned int starTrigCmdIn = ( messageBuffer[ 2 ] ) & 0x00F;
639  uint64_t eventStatusFlag = messageBuffer[ 3 ]; // filled from Apr 24th 2018 on
640 
641  if( mDebug ) {
642  LOG_DEBUG << "StETofDigiMaker::fillETofHeader()" << endm;
643  LOG_DEBUG << "trgGdpbFullTs=" << trgGdpbFullTs << endm;
644  LOG_DEBUG << "trgStarFullTs=" << trgStarFullTs << endm;
645  LOG_DEBUG << "starToken=" << starToken << endm;
646  LOG_DEBUG << "starDaqCmdIn=" << starDaqCmdIn << endm;
647  LOG_DEBUG << "starTrigCmdIn=" << starTrigCmdIn << endm;
648  LOG_DEBUG << "eventStatusFlag=" << eventStatusFlag << endm;
649  }
650  map< unsigned int, uint64_t > gdpbTsMap;
651  map< unsigned int, uint64_t > starTsMap;
652 
653  convertTriggerMessages( triggerMessages, gdpbTsMap, starTsMap );
654 
655  if( mDebug ) {
656  for( const auto& kv : gdpbTsMap ) {
657  LOG_DEBUG << "GdpbTs( 0x" << std::hex << kv.first << std::dec << " ): " << kv.second << endm;
658  }
659  for( const auto& kv : starTsMap ) {
660  LOG_DEBUG << "StarTs( 0x" << std::hex << kv.first << std::dec << " ): " << kv.second << endm;
661  }
662  }
663 
664  // fill eTOF header with trigger & star time as doubles
665  StETofHeader *etofHeader = new StETofHeader( static_cast< double > ( trgGdpbFullTs ),
666  static_cast< double > ( trgStarFullTs ),
667  gdpbTsMap,
668  starTsMap,
669  starToken,
670  starDaqCmdIn,
671  starTrigCmdIn,
672  eventStatusFlag
673  );
674 
675  mETofCollection->setHeader( etofHeader );
676 }
677 
678 //_____________________________________________________________
679 void
680 StETofDigiMaker::fillETofDigi( gdpb::FullMessage& mess )
681 {
682  // fill eTOF digis
683  mETofCollection->addDigi( new StETofDigi( mess.getRocNumber(),
684  mess.getGdpbGenChipId(),
685  mess.getGdpbHitChanId(),
686  mess.GetFullTimeNs(),
687  ( double ) mess.getGdpbHit32Tot() + 0.5 ) );
688 }
bool isSysMsg() const
Returns true is message type is #MSG_SYST (system message)
bool isStarTrigger() const
Returns true is message type is #MSG_STAR_TRI_A, _B, _C, _D (STAR Trigger message) ...
Class StRTSBaseMaker - is an abstract StMaker to define the interface to access the DAQ data from the...
uint16_t getRocNumber() const
Returns the number of the sending ROC. Valid for all message types.
void processEvent(uint64_t *messageBuffer, size_t nFullMessagesToRead)
bool isGet4Hit32Msg() const
Returns true is message type is #MSG_GET4_32B (GET4 Hit Data in 32b mode)
virtual StRtsTable * GetNextRaw()
This is an overloaded member function, provided for convenience.
void convertTriggerMessages(vector< gdpbv100::FullMessage > &triggerMessages, map< unsigned int, uint64_t > &gdpbTs, map< unsigned int, uint64_t > &starTs)
StETofDigiMaker(const char *name="etofDigi")
Default constructor.
Definition: Stypes.h:42
bool isStarTrigger() const
Returns true is message type is #MSG_STAR_TRI (STAR Trigger message)
StETofCollection * getETofCollection()
void processEvent2018(uint64_t *messageBuffer, size_t nFullMessagesToRead)
bool isHitMsg() const
Returns true is message type is #MSG_HIT (Get4 hit data)
Definition: Stypes.h:41
virtual TDataSet * Find(const char *path) const
Definition: TDataSet.cxx:362