StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StFttRawHitMaker.cxx
1 /***************************************************************************
2  *
3  * StFttRawHitMaker.cxx
4  *
5  * Author: jdb 2021
6  ***************************************************************************
7  *
8  * Description: StFttRawHitMaker - class to fill the StEvent from DAQ reader
9  *
10  ***************************************************************************/
11 #include <vector>
12 #include <map>
13 #include <array>
14 #include <algorithm>
15 
16 #include "StRTSBaseMaker.h"
17 #include "StDAQMaker/StDAQReader.h"
18 #include "StRtsTable.h"
19 
20 #include "StEvent.h"
21 
22 #include "StFttRawHitMaker.h"
23 
24 
25 #include "StEvent/StFttRawHit.h"
26 #include "StEvent/StEvent.h"
27 #include "StEvent/StFttCollection.h"
28 
29 #include "StMuDSTMaker/COMMON/StMuTypes.hh"
30 #include "StMuDSTMaker/COMMON/StMuFttUtil.h"
31 
32 
33 //_____________________________________________________________
34 StFttRawHitMaker::StFttRawHitMaker( const char* name )
35 : StRTSBaseMaker( "stgc", name ),
36  mEvent( 0 ),
37  mFttCollection( 0 ), // StFttCollection
38  mRunYear( 0 ),
39  mDebug( false ),
40  mReadMuDst(0)
41 { /* no op */ }
42 
43 
44 //_____________________________________________________________
45 Int_t
46 StFttRawHitMaker::Init()
47 {
48  return kStOk;
49 }
50 
51 //_____________________________________________________________
52 Int_t
53 StFttRawHitMaker::InitRun( Int_t runnumber )
54 {
55  mRunYear = ( runnumber + 727000 ) / 1000000 + 1999;
56  return kStOk;
57 }
58 
59 //_____________________________________________________________
60 Int_t
61 StFttRawHitMaker::FinishRun( Int_t runnumber )
62 {
63  return kStOk;
64 }
65 
66 //_____________________________________________________________
67 Int_t
69 {
70  return kStOk;
71 }
72 
73 
74 //_____________________________________________________________
75 Int_t
77 {
78  LOG_DEBUG << "StFttRawHitMaker::Make()" << endm;
79 
80  mEvent = (StEvent*)GetInputDS("StEvent");
81  if(mEvent) {
82  LOG_DEBUG<<"Found StEvent"<<endm;
83  } else {
84  mEvent = new StEvent();
85  AddData(mEvent);
86  LOG_DEBUG <<"Added StEvent"<<endm;
87  }
88 
89  if ( mReadMuDst > 0 )
90  return readMuDst();
91 
92  mFttCollection=mEvent->fttCollection();
93  if(!mFttCollection) {
94  mFttCollection = new StFttCollection();
95  mEvent->setFttCollection(mFttCollection);
96  LOG_DEBUG <<"Added StFttCollection"<<endm;
97  } else {
98  mFttCollection = mEvent->fttCollection();
99  LOG_DEBUG <<"Found StFttCollection"<<endm;
100  }
101 
102  StRtsTable* daqdta = nullptr;
103 
104  // Loop on all available daq dta vmm blocks
105  while ( (daqdta = GetNext( "vmm" )) ) {
106 
107  if ( daqdta == nullptr ) {
108  LOG_WARN << "StFttRawHitMaker::Make() - NO STGC DATA found in event" << endm;
109  return kStOk;
110  }
111 
112  // do unpacking of the raw data
113  int inputSizeBytes = daqdta->GetSize();
114 
115  int rdo = daqdta->Rdo();
116  int sec = daqdta->Sector();
117 
118  if( mDebug ) {
119  LOG_INFO << "InputSize (bytes): " << inputSizeBytes << endm;
120  LOG_INFO << "Sector: " << daqdta->Sector() << endm;
121  LOG_INFO << "Pad: " << daqdta->Pad() << endm;
122  LOG_INFO << "Row: " << daqdta->Row() << endm;
123  LOG_INFO << "Rdo: " << daqdta->Rdo() << endm;
124  LOG_INFO << "InputSize (bytes): " << inputSizeBytes << endm;
125  LOG_INFO << "ROWS: " << daqdta->GetNRows() << endm;
126  }
127 
128  for (auto it = daqdta->begin(); it != daqdta->end(); ++it) {
129 
130  struct stgc_vmm_t *vmm = (stgc_vmm_t *) ( *it );
131  u_char feb = vmm[0].feb_vmm >> 2 ; // feb [0..5]
132  u_char vm = vmm[0].feb_vmm & 3 ; // VMM [0..3]
133 
134  // create the StFttRawHit object
135  StFttRawHit *hit = new StFttRawHit( sec, rdo, feb, vm, vmm[0].ch, vmm[0].adc, vmm[0].bcid, vmm[0].tb, vmm[0].bcid_delta );
136  // add it to the collection in StEvent
137  mFttCollection->addRawHit( hit );
138  if ( mDebug ){
139  PrintTheVMM( vmm );
140  }
141  } // loop it
142  } // while daqdta
143 
144  return kStOk;
145 }
146 
147 int StFttRawHitMaker::readMuDst() {
148  StMuDst* mudst = (StMuDst*)GetInputDS("MuDst");
149  if(!mudst){LOG_ERROR<<"StFttRawHitMaker::readMuDst() found no MuDst"<<endm; return kStErr;}
150  StMuFttCollection* mufttColl= mudst->muFttCollection();
151  if(!mufttColl){LOG_ERROR<<"StFttRawHitMaker::readMuDst found no MuFttCollection"<<endm; return kStErr;}
152  StMuFttUtil util;
153  mFttCollection = util.getFtt(mufttColl);
154  mEvent->setFttCollection(mFttCollection);
155 }
static StMuFttCollection * muFttCollection()
returns pointer to current StMuFttCollection
Definition: StMuDst.h:397
Class StRTSBaseMaker - is an abstract StMaker to define the interface to access the DAQ data from the...
virtual void AddData(TDataSet *data, const char *dir=".data")
User methods.
Definition: StMaker.cxx:332
virtual Long_t GetNRows() const
Returns the number of the used rows for the wrapped table.
Definition: TTable.cxx:1388
StRtsTable * GetNext(const char *bank)
This is an overloaded member function, provided for convenience.
Definition: Stypes.h:44
Definition: Stypes.h:41