StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StIstDbMaker.cxx
1 /* $Id: StIstDbMaker.cxx,v 1.31 2018/03/29 23:07:30 dongx Exp $ */
2 
3 #include "StIstDbMaker/StIstDbMaker.h"
4 #include "StIstDbMaker/StIstDb.h"
5 #include "St_base/StMessMgr.h"
6 #include "St_db_Maker/St_db_Maker.h"
7 
8 #include "tables/St_Survey_Table.h"
9 #include "tables/St_istPedNoise_Table.h"
10 #include "tables/St_istGain_Table.h"
11 #include "tables/St_istMapping_Table.h"
12 #include "tables/St_istControl_Table.h"
13 #include "tables/St_istChipConfig_Table.h"
14 #include "tables/St_istSimPar_Table.h"
15 
16 ClassImp(StIstDbMaker)
17 
18 
19 
23 StIstDbMaker::StIstDbMaker(const char *name) : StMaker(name), mIstDb(new StIstDb()), mReady(kStErr)
24 {
25 }
26 
27 
28 Int_t StIstDbMaker::Init()
29 {
30  ToWhiteConst("ist_db", mIstDb);
31 
32  return kStOk;
33 }
34 
35 
36 Int_t StIstDbMaker::InitRun(Int_t runNumber)
37 {
38  mReady = kStFatal;
39 
40  LOG_DEBUG << "StIstDbMaker::InitRun() - Access data from database" << endm;
41 
42  // Get IDS positionment relative to TPC
43  St_Survey *st_idsOnTpc = (St_Survey *) GetDataBase("Geometry/ist/idsOnTpc");
44 
45  if (!st_idsOnTpc) {
46  LOG_ERROR << "No relevant entry found in 'Geometry/ist/idsOnTpc' table."
47  " StIstDb object will not be created" << endm;
48  return kStErr;
49  }
50  st_idsOnTpc->Print(0,1);
51 
52  // Get PST positionment relative to IDS
53  St_Survey *st_pstOnIds = (St_Survey *) GetDataBase("Geometry/ist/pstOnIds");
54 
55  if (!st_pstOnIds) {
56  LOG_ERROR << "No relevant entry found in 'Geometry/ist/pstOnIds' table."
57  " StIstDb object will not be created" << endm;
58  return kStErr;
59  }
60  st_pstOnIds->Print(0,1);
61 
62  // Get IST positionment relative to PST
63  St_Survey *st_istOnPst = (St_Survey *) GetDataBase("Geometry/ist/istOnPst");
64 
65  if (!st_istOnPst) {
66  LOG_ERROR << "No relevant entry found in 'Geometry/ist/istOnPst' table."
67  " StIstDb object will not be created" << endm;
68  return kStErr;
69  }
70  st_istOnPst->Print(0,1);
71 
72  // Get ladder positionments relative to IST
73  St_Survey *st_istLadderOnIst = (St_Survey *) GetDataBase("Geometry/ist/istLadderOnIst");
74 
75  if (!st_istLadderOnIst) {
76  LOG_ERROR << "No relevant entry found in 'Geometry/ist/istLadderOnIst' table."
77  " StIstDb object will not be created" << endm;
78  return kStErr;
79  }
80  st_istLadderOnIst->Print(0,1);
81 
82  // Get sensor positionments relative to ladder
83  St_Survey *st_istSensorOnLadder = (St_Survey *) GetDataBase("Geometry/ist/istSensorOnLadder");
84 
85  if (!st_istSensorOnLadder) {
86  LOG_ERROR << "No relevant entry found in 'Geometry/ist/istSensorOnLadder' table."
87  " StIstDb object will not be created" << endm;
88  return kStErr;
89  }
90  st_istSensorOnLadder->Print(0,1);
91 
92  Survey_st *tables[5] = {st_idsOnTpc->GetTable(), st_pstOnIds->GetTable(), st_istOnPst->GetTable(),
93  st_istLadderOnIst->GetTable(), st_istSensorOnLadder->GetTable()
94  };
95  mIstDb->setGeoHMatrices(tables);
96 
97  // Now access IST pedestal and noise tables
98  St_istPedNoise *mPedNoise = (St_istPedNoise *) GetDataBase("Calibrations/ist/istPedNoise");
99 
100  if (!mPedNoise) {
101  LOG_ERROR << "No relevant entry found in 'Calibrations/ist/istPedNoise' table."
102  " StIstDb object will not be created" << endm;
103  return kStErr;
104  }
105 
106  mIstDb->setPedNoise(mPedNoise->GetTable());
107  if(Debug()) mPedNoise->Print(0,1);
108 
109  // Access IST gain table
110  St_istGain *mGain = (St_istGain *) GetDataBase("Calibrations/ist/istGain");
111 
112  if (!mGain) {
113  LOG_ERROR << "No relevant entry found in 'Calibrations/ist/istGain' table."
114  " StIstDb object will not be created" << endm;
115  return kStErr;
116  }
117 
118  mIstDb->setGain(mGain->GetTable());
119  if(Debug()) mGain->Print(0,1);
120 
121  St_istMapping *mMapping = (St_istMapping *) GetDataBase("Calibrations/ist/istMapping");
122 
123  if (!mMapping) {
124  LOG_ERROR << "No relevant entry found in 'Calibrations/ist/istMapping' table."
125  " StIstDb object will not be created" << endm;
126  return kStErr;
127  }
128 
129  mIstDb->setMapping(mMapping->GetTable());
130  if(Debug()) mMapping->Print(0,1);
131 
132  // Access IST control table
133  St_istControl *mControl = (St_istControl *) GetDataBase("Calibrations/ist/istControl");
134 
135  if (!mControl) {
136  LOG_ERROR << "No relevant entry found in 'Calibrations/ist/istControl' table."
137  " StIstDb object will not be created" << endm;
138  return kStErr;
139  }
140 
141  mIstDb->setControl(mControl->GetTable());
142  mControl->Print(0,1);
143 
144  // Access IST chip status table
145  St_istChipConfig *mChipConfig = (St_istChipConfig *) GetDataBase("Calibrations/ist/istChipConfig");
146 
147  if (!mChipConfig) {
148  LOG_ERROR << "No relevant entry found in 'Calibrations/ist/istChipConfig' table."
149  " StIstDb object will not be created" << endm;
150  return kStErr;
151  }
152 
153  mIstDb->setChipStatus(mChipConfig->GetTable());
154  mChipConfig->Print(0,1);
155 
156  // set istSimPar
157  St_istSimPar *istSimPar = (St_istSimPar *)GetDataBase("Calibrations/ist/istSimPar");
158  if (istSimPar) {
159  mIstDb->setIstSimPar(istSimPar->GetTable());
160  }
161  else {
162  LOG_WARN << "InitRun : No access to istSimPar table, abort IST reconstruction" << endm;
163  return kStErr;
164  }
165  istSimPar->Print(0,1);
166 
167  if ( GetDebug() >= 2)
168  mIstDb->Print();
169 
170  mReady = kStOK;
171 
172  return kStOK;
173 }
174 
175 
177 {
178  return mReady;
179 }
180 
181 
182 /***************************************************************************
183 *
184 * $Log: StIstDbMaker.cxx,v $
185 * Revision 1.31 2018/03/29 23:07:30 dongx
186 * Added print-out information for loaded tables
187 *
188 * Revision 1.30 2018/03/15 21:35:48 dongx
189 *
190 * Added the access to new table istSimPar
191 *
192 * Revision 1.29 2015/02/04 07:56:31 smirnovd
193 * StIstDbMaker: Changed ToWhiteBoard() to ToWhiteConst() because we don't want to loose the StIstDb object at every call to StMaker::Clear()
194 *
195 * Revision 1.28 2015/02/04 07:56:19 smirnovd
196 * Create StIstDb object in constructor and pass it to the framework in Init()
197 *
198 * It makes perfect sense to do it this way because the StIstDb obect is created
199 * once by the maker and later reused/updated only at every new run.
200 *
201 * Revision 1.27 2015/02/04 07:56:05 smirnovd
202 * Revert "Move ToWhiteBoard() to Make". Will implement a different solution to avoid losing istDb from this maker's data container
203 *
204 * Revision 1.25 2014/11/19 18:29:47 genevb
205 * Use flags to indicate DbMaker readiness
206 *
207 * Revision 1.24 2014/11/19 04:17:31 genevb
208 * Return fatal if database tables are not found
209 *
210 * Revision 1.23 2014/11/18 23:11:44 smirnovd
211 * [Style] Changes in comments and user feedback only
212 *
213 * Revision 1.22 2014/11/18 23:11:35 smirnovd
214 * [Minor] Coding style clean-up. Removed unconstructive comments
215 *
216 * Revision 1.21 2014/11/18 23:10:27 smirnovd
217 * Do not destruct StIstDb object as the ownership is passed to the framework
218 *
219 * Revision 1.20 2014/11/18 23:10:20 smirnovd
220 * Renamed printGeoHMatrices to customary Print as that what users of ROOT framework normaly expect
221 *
222 * Revision 1.19 2014/11/18 23:08:37 smirnovd
223 * Moved CVS log to the end of file and updated doxygen-style comments
224 *
225 * Revision 1.18 2014/11/18 19:43:24 genevb
226 * STAR Logger messages need endm, not endl
227 *
228 * Revision 1.17 2014/08/06 18:44:21 ypwang
229 * replace assert statement for gStTpcDb with normal variable check and LOG_WARN printout; non-ROOT methods formatted with STAR coding style
230 *
231 * Revision 1.16 2014/08/05 17:48:58 ypwang
232 * update Print() function to PrintGeoHMatrices()
233 *
234 * Revision 1.15 2014/08/01 22:15:04 ypwang
235 * mIstDb geometry matrices print out when Debug2 enabled
236 *
237 * Revision 1.14 2014/07/31 21:00:36 ypwang
238 * c++ format style improvements; virtual keyword added for destructor
239 *
240 * Revision 1.13 2014/07/31 18:24:03 ypwang
241 * add destructor and deallocate the mIstDb; c++ formatting style improvements and formatted with astyle -s3 -p -H -A3 -k3 -O -o -y -Y -f
242 *
243 * Revision 1.12 2014/07/29 19:50:25 ypwang
244 * IST DB dataset in order to separate from IST Db maker
245 *
246 * Revision 1.11 2014/07/15 23:17:51 smirnovd
247 * Improved doxygen documentation
248 *
249 * Revision 1.10 2014/03/27 22:46:46 smirnovd
250 * Updated broken style with astyle -s3 -p -H -A3 -k3 -O -o -y -Y -f
251 *
252 * Revision 1.9 2014/03/27 22:46:38 smirnovd
253 * Renamed static data member according to mixed star/root convention
254 *
255 * Revision 1.8 2014/03/25 03:01:57 ypwang
256 * get rid of GetIstPedNoise(), GetIstGain(), GetIstMapping() and GetIstControl() functions; use TDataSet instead of Db table structure
257 *
258 * Revision 1.7 2014/03/24 15:49:48 ypwang
259 * checks added and const pointers returned for GetIstPedNoise, GetIstGain, GetIstMapping and GetIstControl functions
260 *
261 * Revision 1.6 2014/03/13 22:10:12 smirnovd
262 * Move some constants from StIstUtil/StIstConsts.h to StEvent/StEnumerations.h to avoid external dependance of StEvent on StIstUtil
263 *
264 * Revision 1.5 2014/02/08 03:34:16 ypwang
265 * updating scripts
266 *
267 *
268 ****************************************************************************
269 * StIstDbMaker.cxx,v 1.0
270 * Revision 1.0 2013/11/04 16:15:30 Yaping
271 * Initial version
272 ****************************************************************************/
Definition: Stypes.h:40
Definition: Stypes.h:44
Definition: Stypes.h:41