StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StEpdDbMaker.cxx
1 
2 #include "StEpdDbMaker.h"
3 //#include "StMessMgr.h"
4 #include "St_db_Maker/St_db_Maker.h"
5 #include "tables/St_epdQTMap_Table.h"
6 #include "tables/St_epdFEEMap_Table.h"
7 #include "tables/St_epdStatus_Table.h"
8 #include "tables/St_epdGain_Table.h"
9 
10 
11 ClassImp(StEpdDbMaker)
12 
13 StEpdDbMaker::StEpdDbMaker(const Char_t *name) : StMaker(name){
14  ResetArrays();
15 };
16 
17 StEpdDbMaker::~StEpdDbMaker(){
18  ResetArrays();
19 }
20 
21 // JL -> there seem to be no reason to define those methods (base
22 // class would do the job just fine)
23 //Int_t StEpdDbMaker::Init(){
24 // LOG_DEBUG<<"StEpdDbMaker Init Start"<<endm;
25 // return StMaker::Init();
26 //}
27 
28 //Int_t StEpdDbMaker::Make(){
29 // LOG_DEBUG<<"StEpdDbMaker Make"<<endm;
30 // return kStOK;
31 //}
32 
33 //void StEpdDbMaker::Clear(const Char_t*){
34 // LOG_DEBUG<<"StEpdDbMaker Clear"<<endm;
35 // StMaker::Clear();
36 //}
37 
38 //Int_t StEpdDbMaker::Finish(){
39 // LOG_DEBUG<<"StEpdDbMaker Finish"<<endm;
40 // return kStOK;
41 //}
42 
43 
44 Int_t StEpdDbMaker::InitRun( Int_t runNumber ){
45  LOG_DEBUG << "StEpdDbMaker::InitRun " << endm;
46  ResetArrays();
47 
49  if(mDebug>=0) {
50  St_db_Maker* dbmaker = (St_db_Maker*)GetMaker("db");
51  LOG_INFO << "StEpdDbMaker::InitRun - Date&time from St_db_Maker="
52  << dbmaker->GetDate() << "," << dbmaker->GetTime() << endm;
53  }
54 
55  // Note: the calls below are requesting all epd tables in Geometry
56  // calibration branches. If only a sub-set of tables is needed,
57  // you may instead access them one by one.
58  TDataSet *DbGeometry = GetInputDB("Geometry/epd");
59  TDataSet *DbCalibrations = GetInputDB("Calibrations/epd");
60 
61  if(!DbGeometry){
62  LOG_ERROR << "StEpdDbMaker::InitRun - No Geometry/epd"<<endm;
63  return kStFatal;
64  }
65  if(!DbCalibrations){
66  LOG_ERROR << "StEpdDbMaker::InitRun - No Calibrations/epd"<<endm;
67  return kStFatal;
68  }
69 
71  St_epdQTMap *dbQTMap = (St_epdQTMap*) DbGeometry->Find("epdQTMap");
72  St_epdFEEMap *dbFeeMap = (St_epdFEEMap*)DbGeometry->Find("epdFEEMap");
73  St_epdStatus *dbStatus = (St_epdStatus*)DbCalibrations->Find("epdStatus");
74  St_epdGain *dbGain = (St_epdGain*) DbCalibrations->Find("epdGain");
75 
76 
77  if(!dbQTMap){
78  LOG_ERROR << "StEpdDbMaker::InitRun - No Geometry/epd/epdQTMap "<<endm;
79  return kStFatal;
80  }
81  if(!dbFeeMap){
82  LOG_ERROR << "StEpdDbMaker::InitRun - No Geometry/epd/epdFEEMap "<<endm;
83  return kStFatal;
84  }
85  if(!dbStatus){
86  LOG_ERROR << "StEpdDbMaker::InitRun - No Calibrations/epd/epdStatus "<<endm;
87  return kStFatal;
88  }
89  if(!dbGain){
90  LOG_ERROR << "StEpdDbMaker::InitRun - No Calibrations/epd/epdGain "<<endm;
91  return kStFatal;
92  }
93 
94  // EPD QT map
95  epdQTMap_st* mEpdQtMapTable = (epdQTMap_st*)dbQTMap->GetTable();
96  epdFEEMap_st* mEpdFeeMapTable = (epdFEEMap_st*)dbFeeMap->GetTable();
97  epdStatus_st* mEpdStatusTable = (epdStatus_st*)dbStatus->GetTable();
98  epdGain_st* mEpdGainTable = (epdGain_st*)dbGain->GetTable();
99 
100 
101  int wire1n=0;
102  for (Int_t i = 0; i < 768; i++) {
103  //Fetch from epdQTMap_st table
104  short ew = mEpdQtMapTable->ew[i];
105  short pp = mEpdQtMapTable->pp[i] -1; // In DB PP starts from 1
106  short tile = mEpdQtMapTable->tile[i];
107 
108  mCrateAdc[ew][pp][tile] = mEpdQtMapTable->qt_crate_adc[i];
109  mBoardAdc[ew][pp][tile] = mEpdQtMapTable->qt_board_adc[i];
110  mChannelAdc[ew][pp][tile] = mEpdQtMapTable->qt_channel_adc[i];
111  mCrateTac[ew][pp][tile] = mEpdQtMapTable->qt_crate_tac[i];
112  mBoardTac[ew][pp][tile] = mEpdQtMapTable->qt_board_tac[i];
113  mChannelTac[ew][pp][tile] = mEpdQtMapTable->qt_channel_tac[i];
114 
115  // Fetch from epdFEEMap_st table
116  mTuffId[ew][pp][tile] = mEpdFeeMapTable->tuff_id[i];
117  mTuffGroup[ew][pp][tile] = mEpdFeeMapTable->tuff_group[i];
118  mTuffChannel[ew][pp][tile] = mEpdFeeMapTable->tuff_channel[i];
119  mReceiverBoard[ew][pp][tile] = mEpdFeeMapTable->receiver_board[i];
120  mReceiverBoardChannel[ew][pp][tile] = mEpdFeeMapTable->receiver_board_channel[i];
121  mCamacCrateAddress[ew][pp][tile] = mEpdFeeMapTable->camac_crate_address[i];
122  mWireOneId[ew][pp][tile][0] = mEpdFeeMapTable->wire_1_id[wire1n];
123  wire1n++;
124  mWireOneId[ew][pp][tile][1] = mEpdFeeMapTable->wire_1_id[wire1n];
125  wire1n++;
126 
127  // Fetch from epdStatus_st table
128  mStatus[ew][pp][tile]= mEpdStatusTable->status[i];
129 
130  // Fetch from epdGain_st table
131  mVPed[ew][pp][tile] = mEpdGainTable->vped[i];
132  mMip[ew][pp][tile] = mEpdGainTable->mip[i];
133  mQtPedestals[ew][pp][tile] = mEpdGainTable->qt_pedestals[i];
134  mDarkCurrent[ew][pp][tile] = mEpdGainTable->dark_current[i];
135  mQtPedestalsSigma[ew][pp][tile] = mEpdGainTable->qt_pedestals_sigma[i];
136  mOffset[ew][pp][tile] = mEpdGainTable->offset[i];
137 
138  }
139 
140  return kStOK;
141 
142 }
143 
144 // default values -1
145 void StEpdDbMaker::ResetArrays(){
146  for(int ew=0; ew<2 ; ew++){
147  for(int pp=0; pp < 12;pp++){
148  for(int tile=0; tile<32 ; tile++){
149 
150  mCrateAdc[ew][pp][tile] = -1;
151  mBoardAdc[ew][pp][tile] = -1;
152  mChannelAdc[ew][pp][tile] = -1;
153  mCrateTac[ew][pp][tile] = -1;
154  mBoardTac[ew][pp][tile] = -1;
155  mChannelTac[ew][pp][tile] = -1;
156 
157  // Fetch from epdFEEMap_st table
158  mTuffId[ew][pp][tile] = -1;
159  mTuffGroup[ew][pp][tile] = -1;
160  mTuffChannel[ew][pp][tile] = -1;
161  mReceiverBoard[ew][pp][tile] = -1;
162  mReceiverBoardChannel[ew][pp][tile] = -1;
163  mCamacCrateAddress[ew][pp][tile] = -1;
164  mWireOneId[ew][pp][tile][0] = 0x0;
165  mWireOneId[ew][pp][tile][1] = 0x0;
166 
167  // Fetch from epdStatus_st table
168  mStatus[ew][pp][tile]= -1;
169 
170  // Fetch from epdGain_st table
171  mVPed[ew][pp][tile] = -1;
172  mMip[ew][pp][tile] = -1;
173  mQtPedestals[ew][pp][tile] = -1;
174  mDarkCurrent[ew][pp][tile] = -1;
175  mQtPedestalsSigma[ew][pp][tile] = -1;
176  mOffset[ew][pp][tile] = -1;
177 
178  }
179  }
180  }
181 
182 }
183 
184 
virtual Int_t InitRun(Int_t runNumber)
Definition: Stypes.h:40
virtual TDataSet * Find(const char *path) const
Definition: TDataSet.cxx:362