6 #include "StFgtDbMaker.h"
7 #include "TDataSetIter.h"
9 #include "tables/St_fgtElosCutoff_Table.h"
10 #include "tables/St_fgtSimuParams_Table.h"
11 #include "tables/St_fgtPedestal_Table.h"
12 #include "tables/St_fgtMapping_Table.h"
13 #include "tables/St_fgtGain_Table.h"
14 #include "tables/St_fgtStatus_Table.h"
15 #include "tables/St_fgtAlignment_Table.h"
16 #include "St_db_Maker/St_db_Maker.h"
31 StFgtDbMaker::~StFgtDbMaker()
38 void StFgtDbMaker::setFlavor(
const char * flav,
const char * tabname )
40 StMaker::SetFlavor( flav, tabname );
44 Int_t StFgtDbMaker::Init()
46 LOG_DEBUG <<
"StFgtDbMaker::Init()" <<endm;
48 return StMaker::Init();
54 LOG_INFO << Form(
"StFgtDbMaker::InitRun(), run=%d",runNumber)<<endm;
55 LOG_INFO << Form(
"StFgtDbMaker::InitRun(), Event DateTime=%s",GetDateTime().AsString())<<endm;
56 LOG_INFO << Form(
"StFgtDbMaker::InitRun(), Database Time=%s",GetDBTime().AsString())<<endm;
63 St_fgtElosCutoff *eLossDataset=0;
64 St_fgtSimuParams *simuParamsDataset=0;
65 St_fgtMapping * mapDataset = 0;
66 St_fgtGain * gainDataset = 0;
67 St_fgtPedestal * pedDataset = 0;
68 St_fgtStatus * statusDataset = 0;
69 St_fgtAlignment *alignmentDataset = 0;
72 LOG_INFO <<
"::RequestDataBase() for Elos cut off ..."<< endl;
73 TDataSet *ELossDB = GetDataBase(
"Calibrations/fgt/fgtElosCutoff");
77 <<
"ERROR: no table found in db for eloss, or malformed local db config"
82 LOG_INFO <<
"::RequestDataBase() for slow-simu params ..."<< endl;
83 TDataSet *SimuParamsDB = GetDataBase(
"Calibrations/fgt/fgtSimuParams");
87 <<
"ERROR: no table found in db for slow-simu params , or malformed local db config"
91 LOG_INFO <<
"::RequestDataBase() for calibration tables..."<< endl;
92 TDataSet *MapDB = GetDataBase(
"Calibrations/fgt/fgtMapping");
96 <<
"ERROR: no table found in db for map, or malformed local db config"
99 TDataSet *PedDB = GetDataBase(
"Calibrations/fgt/fgtPedestal");
103 <<
"ERROR: no table found in db for pedestals, or malformed local db config"
106 TDataSet *StatusDB = GetDataBase(
"Calibrations/fgt/fgtStatus");
110 <<
"ERROR: no table found in db for pedestals, or malformed local db config"
113 TDataSet *GainDB = GetDataBase(
"Calibrations/fgt/fgtGain");
117 <<
"ERROR: no table found in db for pedestals, or malformed local db config"
120 TDataSet *AlignmentDB = GetDataBase(
"Calibrations/fgt/fgtAlignment");
124 <<
"ERROR: no table found in db for pedestals, or malformed local db config"
129 eLossDataset=(St_fgtElosCutoff*)ELossDB->
Find(
"fgtElosCutoff");
130 Int_t rows = eLossDataset->GetNRows();
133 LOG_FATAL <<
" found INDEXED fgtElosCutoff table with " << rows
134 <<
" rows, this is fatal, fix DB content" << endm;
138 simuParamsDataset=(St_fgtSimuParams*)SimuParamsDB->
Find(
"fgtSimuParams");
139 rows =simuParamsDataset->GetNRows();
142 LOG_FATAL <<
" found INDEXED fgtSimuParams table with " << rows
143 <<
" rows, this is fatal, fix DB content" << endm;
147 mapDataset = (St_fgtMapping *)
148 MapDB->
Find(
"fgtMapping");
149 rows = mapDataset->GetNRows();
152 LOG_FATAL <<
" found INDEXED table for mapping with " << rows
153 <<
" rows, this is fatal, fix DB content" << endm;
156 gainDataset = (St_fgtGain*)
157 GainDB->
Find(
"fgtGain");
158 rows = gainDataset->GetNRows();
161 LOG_FATAL <<
" found INDEXED table for gains with " << rows
162 <<
" rows, this is fatal, fix DB content" << endm;
165 pedDataset = (St_fgtPedestal*)
166 PedDB->
Find(
"fgtPedestal");
167 rows = pedDataset->GetNRows();
170 LOG_FATAL <<
" found INDEXED table for pedestals with " << rows
171 <<
" rows, this is fatal, fix DB content" << endm;
173 statusDataset = (St_fgtStatus*)
174 StatusDB->
Find(
"fgtStatus");
175 rows = statusDataset->GetNRows();
178 LOG_FATAL <<
" found INDEXED table for status with " << rows
179 <<
" rows, this is fatal, fix DB content" << endm;
182 alignmentDataset = (St_fgtAlignment*) AlignmentDB->
Find(
"fgtAlignment");
183 rows = alignmentDataset->GetNRows();
186 LOG_FATAL <<
" found INDEXED table for alignment with " << rows
187 <<
" rows, this is fatal, fix DB content" << endm;
191 if (pedDataset && statusDataset && mapDataset && gainDataset && eLossDataset && simuParamsDataset && alignmentDataset)
195 m_rmap =
new fgtMapping_st();
197 fgtMapping_st * map = mapDataset->GetTable();
199 for (
int ii = 0; ii < 51200; ++ii )
201 if (map->Mapping[ii]>=0)
202 m_rmap->Mapping[ map->Mapping[ii] ] = ii;
206 dynamic_cast< StFgtDb*
>(m_tables)->updateTables(
208 statusDataset->GetTable(),
209 pedDataset->GetTable(),
210 gainDataset->GetTable(),
211 eLossDataset->GetTable(),
212 simuParamsDataset->GetTable(),
213 alignmentDataset->GetTable()
219 "%s :: map, gain, pedestal and status tables received, comments",
224 displayBeginEndTime(mapDataset);
225 displayBeginEndTime(statusDataset);
226 displayBeginEndTime(pedDataset);
227 displayBeginEndTime(gainDataset);
228 displayBeginEndTime(alignmentDataset);
229 displayBeginEndTime(eLossDataset); LOG_INFO <<eLossDataset->GetTable()->comment<<endl;
230 displayBeginEndTime(simuParamsDataset); LOG_INFO <<simuParamsDataset->GetTable()->comment<<endl;
237 LOG_FATAL << Form(
"%s :: pedestal table failed,",
GetName())
242 LOG_FATAL << Form(
"%s :: map table failed,",
GetName())
247 LOG_FATAL << Form(
"%s :: gain table failed,",
GetName())
250 if ( !statusDataset )
252 LOG_FATAL << Form(
"%s :: status table failed,",
GetName())
257 LOG_FATAL << Form(
"%s :: eLoss table failed,",
GetName())
260 if ( !simuParamsDataset )
262 LOG_FATAL << Form(
"%s :: SimuParams table failed,",
GetName())
265 if ( !alignmentDataset )
267 LOG_FATAL << Form(
"%s :: Alignment table failed,",
GetName())
276 void StFgtDbMaker::displayBeginEndTime(
TTable* table) {
278 St_db_Maker::GetValidity(table,datime);
279 string tableName = table->GetName();
280 string beginTime = datime[0].AsSQLString();
281 string endTime = datime[1].AsSQLString();
283 map<string, pair<string, string> >::iterator iter = mValidRanges.find(tableName);
284 if(iter == mValidRanges.end()) {
285 mValidRanges[tableName] = make_pair(beginTime, endTime);
286 LOG_INFO << Form(
"loaded a new %20s table with beginTime %s and endTime %s", tableName.c_str(), beginTime.c_str(), endTime.c_str()) << endm;
287 cout << Form(
"loaded a new %20s table with beginTime %s and endTime %s", tableName.c_str(), beginTime.c_str(), endTime.c_str()) << endl;
289 else if( beginTime != (iter->second).first ) {
290 (iter->second).first = beginTime;
291 (iter->second).second = endTime;
292 LOG_INFO << Form(
"loaded a new %20s table with beginTime %s and endTime %s", tableName.c_str(), beginTime.c_str(), endTime.c_str()) << endm;
293 cout << Form(
"loaded a new %20s table with beginTime %s and endTime %s", tableName.c_str(), beginTime.c_str(), endTime.c_str()) << endl;
300 LOG_DEBUG <<
"Make" << endm;
306 void StFgtDbMaker::Clear(
const char*)
308 LOG_DEBUG <<
"Clear" << endm;
315 LOG_DEBUG <<
"Finish" << endm;
virtual void Clear(Option_t *option="")
User defined functions.
Int_t InitRun(Int_t runNumber)
virtual const char * GetName() const
special overload
virtual TDataSet * Find(const char *path) const