StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StRHICfRawHitMaker.cxx
1 /***************************************************************************
2  * Author: Akio Ogawa, Minho Kim, Seunghwan Lee
3  ***************************************************************************
4  *
5  * Description: This is the Hit maker for the RHICf data.
6  *
7  ***************************************************************************
8  * $Id: StRHICfRawHitMaker.cxx,v 1.4 2017/01/30 18:10:16 akio Exp $
9  * $Log: StRHICfRawHitMaker.cxx,v $
10  ***************************************************************************/
11 
12 #include "StRHICfRawHitMaker.h"
13 
14 #include "StEvent/StEventTypes.h"
15 #include "St_base/StMessMgr.h"
16 #include "St_base/Stypes.h"
17 #include "RTS/src/DAQ_RHICF/daq_rhicf.h"
18 #include "RTS/src/DAQ_READER/daq_dta.h"
19 #include "StChain/StRtsTable.h"
20 #include "StEvent/StEvent.h"
21 
22 #include "StRHICfDbMaker/StRHICfDbMaker.h"
23 #include "StEvent/StRHICfCollection.h"
24 #include "StEvent/StRHICfRawHit.h"
25 
26 StRHICfRawHitMaker::StRHICfRawHitMaker(const Char_t* name) : StRTSBaseMaker( "rhicf", name )
27 {
28 }
29 
30 StRHICfRawHitMaker::~StRHICfRawHitMaker()
31 {
32 }
33 
34 Int_t StRHICfRawHitMaker::InitRun(Int_t runNumber)
35 {
36  LOG_INFO << "StRHICfRawHitMaker::InitRun with run = " << runNumber << endm;
37  checkRunTypeForRHICf2017(runNumber);
38 
39  mRHICfDbMaker = static_cast<StRHICfDbMaker*>(GetMaker("rhicfDb"));
40  if(!mRHICfDbMaker){
41  LOG_ERROR << "StRHICfRawHitMaker::InitRun Failed to get StRHICfDbMaker" << endm;
42  return kStFatal;
43  }
44 
45  return kStOK;
46 }
47 
49 {
50  LOG_INFO <<"StRHICfRawHitMaker::Make()" <<endm;
51 
52  StEvent* eventPtr=0;
53  eventPtr= (StEvent*)StRTSBaseMaker::GetInputDS("StEvent");
54 
55  if(!eventPtr) return kStFatal;
56  mRHICfCollection = new StRHICfCollection;
57  if(!mRHICfCollection){return kStFatal;}
58 
59  mRHICfRawHitColl=mRHICfCollection->rawHitCollection();
60  if(!mRHICfRawHitColl){return kStFatal;}
61 
62  eventPtr->setRHICfCollection(mRHICfCollection);
63 
64  StRtsTable *daqData = GetNextRaw();
65  if(daqData){
66  unsigned int* gendata = (unsigned int*) daqData->GetTable();
67  unsigned short* rawdata = (unsigned short*) daqData->GetTable();
68 
69  // Insert general data
70  unsigned int rhicfRunIdx = mRHICfDbMaker->getRHICfRunNumberAddress();
71  unsigned int rhicfEventIdx = mRHICfDbMaker->getRHICfEventNumberAddress();
72  mRHICfCollection -> setRHICfRunNumber(gendata[rhicfRunIdx]);
73  mRHICfCollection -> setRHICfEventNumber(gendata[rhicfEventIdx]);
74  mRHICfCollection -> setRunType(getRunType());
75 
76  unsigned int bunchIdx = mRHICfDbMaker->getBunchNumberAddress();
77  unsigned int triggerIdx = mRHICfDbMaker->getTriggerAddress();
78  unsigned int runTRGMIdx = mRHICfDbMaker->getRunTRGMAddress();
79 
80  mRHICfCollection -> setBunchNumber(gendata[bunchIdx]);
81  mRHICfCollection -> setTriggerNumber(gendata[triggerIdx]);
82  mRHICfCollection -> setRunTRGM(gendata[runTRGMIdx]);
83 
84  for(int i=0; i<2; i++){
85  unsigned int runTimeIdx = mRHICfDbMaker->getRunTimeAddress(i);
86  mRHICfCollection -> setRunTime(i, gendata[runTimeIdx]);
87  }
88 
89  // Insert raw data for Plate, GSOBar
90  for(int it=0; it<kRHICfNtower; it++){
91  for(int ip=0; ip<kRHICfNplate; ip++){
92  for(int ir=0; ir<kRHICfNrange; ir++){
93  unsigned int plateADCIdx = mRHICfDbMaker -> getAdcAddress(it, ip, ir);
94  unsigned int plateADCDIdx = mRHICfDbMaker -> getAdcDAddress(it, ip, ir);
95  mRHICfRawHitColl -> setPlateADC(it, ip, ir, rawdata[plateADCIdx]);
96  mRHICfRawHitColl -> setPlateADCDelay(it, ip, ir, rawdata[plateADCDIdx]);
97  }
98  }
99 
100  for(int il=0; il<kRHICfNlayer; il++){
101  for(int ixy=0; ixy<kRHICfNxy; ixy++){
102  Int_t gsobarSize = checkGSOBarSize(it);
103  for(int ich=0; ich<gsobarSize; ich++){
104  unsigned int gsobarADCIdx = mRHICfDbMaker -> getScifiAddress(it, il, ixy, ich);
105  mRHICfRawHitColl -> setGSOBarADC(it, il, ixy, ich, rawdata[gsobarADCIdx]);
106  }
107  }
108  }
109  }
110 
111  // Insert raw data
112  for(Int_t idx=0; idx<kRHICfNtdc; idx++){
113  if(idx<kRHICfNcad0){
114  // for CAD0
115  unsigned int cad0Idx = mRHICfDbMaker->getCAD0Address(idx);
116  mRHICfRawHitColl -> setCAD0(idx, gendata[cad0Idx]);
117  }
118  if(idx<kRHICfNgpi0){
119  // for GPI0
120  unsigned int gpi0Idx = mRHICfDbMaker->getGPI0Address(idx);
121  mRHICfRawHitColl -> setGPI0(idx, gendata[gpi0Idx]);
122  }
123  if(idx<kRHICfNgpi1){
124  // for GPI1
125  unsigned int gpi1Idx = mRHICfDbMaker->getGPI1Address(idx);
126  mRHICfRawHitColl -> setGPI1(idx, gendata[gpi1Idx]);
127  }
128  // for TDC
129  unsigned int tdcIdx = mRHICfDbMaker->getTDCAddress(idx);
130  mRHICfRawHitColl -> setTDC(idx, gendata[tdcIdx]);
131  }
132  }
133  else{LOG_ERROR <<"No RHICf data found" <<endm;}
134 
135  return kStOK;
136 }
137 
139 {
140  return kStOk;
141 }
142 
143 ClassImp(StRHICfRawHitMaker)
Class StRTSBaseMaker - is an abstract StMaker to define the interface to access the DAQ data from the...
virtual StRtsTable * GetNextRaw()
This is an overloaded member function, provided for convenience.
Definition: Stypes.h:40
Definition: Stypes.h:41