StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StBemcTables.cxx
1 /***************************************************************************
2  *
3  * $Id: StBemcTables.cxx,v 1.14 2015/03/02 20:25:51 jkadkins Exp $
4  * Author: Alexandre A. P. Suaide
5  * Maintainer: Adam Kocoloski, MIT, kocolosk@mit.edu
6  *
7  ***************************************************************************/
8 
9 #include "StBemcTables.h"
10 #include "Stiostream.h"
11 #include "StEmcUtil/others/emcDetectorName.h"
12 #include "StDaqLib/EMC/StEmcDecoder.h"
13 #include "StMaker.h"
14 #include "St_db_Maker/St_db_Maker.h"
15 #include "StEmcRawMaker/defines.h"
16 
17 ClassImp(StBemcTables)
18 
19 StBemcTables::StBemcTables(Bool_t btowMapFix, Bool_t bprsMapFix):TObject() {
20  mBtowP = NULL;
21  mBprsP = NULL;
22  mSmdeP = NULL;
23  mSmdpP = NULL;
24  mBtowS = NULL;
25  mBprsS = NULL;
26  mSmdeS = NULL;
27  mSmdpS = NULL;
28  mBtowC = NULL;
29  mBprsC = NULL;
30  mSmdeC = NULL;
31  mSmdpC = NULL;
32  mBtowG = NULL;
33  mBprsG = NULL;
34  mSmdeG = NULL;
35  mSmdpG = NULL;
36  mTrigS = NULL;
37  mTrigP = NULL;
38  mTrigL = NULL;
39  mTrigP4 = NULL;
40 
41  mBtowMapFix = btowMapFix;
42  mBprsMapFix = bprsMapFix;
43  mDecoder = new StEmcDecoder();
44 }
45 
47  delete mBtowP;
48  delete mBprsP;
49  delete mSmdeP;
50  delete mSmdpP;
51  delete mBtowS;
52  delete mBprsS;
53  delete mSmdeS;
54  delete mSmdpS;
55  delete mBtowC;
56  delete mBprsC;
57  delete mSmdeC;
58  delete mSmdpC;
59  delete mBtowG;
60  delete mBprsG;
61  delete mSmdeG;
62  delete mSmdpG;
63  delete mTrigS;
64  delete mTrigP;
65  delete mTrigL;
66  delete mTrigP4;
67 
68  if(mDecoder) delete mDecoder;
69 }
70 
71 //-----------------------------------------------------------------------------
72 
74  if(mBtowP) mBtowP = NULL;
75  if(mBtowS) mBtowS = NULL;
76  if(mBtowC) mBtowC = NULL;
77  if(mBtowG) mBtowG = NULL;
78 
79  if(mBprsP) mBprsP = NULL;
80  if(mBprsS) mBprsS = NULL;
81  if(mBprsC) mBprsC = NULL;
82  if(mBprsG) mBprsG = NULL;
83 
84  if(mSmdeP) mSmdeP = NULL;
85  if(mSmdeS) mSmdeS = NULL;
86  if(mSmdeC) mSmdeC = NULL;
87  if(mSmdeG) mSmdeG = NULL;
88 
89  if(mSmdpP) mSmdpP = NULL;
90  if(mSmdpS) mSmdpS = NULL;
91  if(mSmdpC) mSmdpC = NULL;
92  if(mSmdpG) mSmdpG = NULL;
93 
94  int date = (maker->GetDBTime()).GetDate();
95  int time = (maker->GetDBTime()).GetTime();
96  mDecoder->SetDateTime(date, time);
97 
98  // the BTOW map fix should be used *ONLY* for runs before 2006
99  // For runs after 2006-01-01 the database is supposed to be fixed
100  if(date >= 20060101) mBtowMapFix = kFALSE;
101 
102  // same comment for BPRS in Run 8
103  if(date >= 20080101) mBprsMapFix = kFALSE;
104 
105  TDataSet * DB = NULL;
106 
107  DB = maker->GetInputDB("Calibrations/emc/y3bemc");
108  if(DB) {
109  St_emcPed* bemcPed = (St_emcPed*)DB->Find("bemcPed");
110  if(bemcPed) {
111  mBtowP = bemcPed->GetTable();
112  updateValidity(maker, bemcPed);
113  }
114 
115  St_emcStatus* bemcStatus = (St_emcStatus*)DB->Find("bemcStatus");
116  if(bemcStatus) {
117  mBtowS = bemcStatus->GetTable();
118  updateValidity(maker, bemcStatus);
119  }
120 
121  St_emcCalib* bemcCalib = (St_emcCalib*)DB->Find("bemcCalib");
122  if(bemcCalib) {
123  mBtowC = bemcCalib->GetTable();
124  updateValidity(maker, bemcCalib);
125  }
126 
127  St_emcGain* bemcGain = (St_emcGain*)DB->Find("bemcGain");
128  if(bemcGain) {
129  mBtowG = bemcGain->GetTable();
130  updateValidity(maker, bemcGain);
131  }
132  }
133 
134  DB = maker->GetInputDB("Calibrations/emc/y3bprs");
135  if(DB) {
136  St_emcPed* bprsPed = (St_emcPed*)DB->Find("bprsPed");
137  if(bprsPed) {
138  mBprsP = bprsPed->GetTable();
139  updateValidity(maker, bprsPed);
140  }
141 
142  St_emcStatus* bprsStatus = (St_emcStatus*)DB->Find("bprsStatus");
143  if(bprsStatus) {
144  mBprsS = bprsStatus->GetTable();
145  updateValidity(maker, bprsStatus);
146  }
147 
148  St_emcCalib* bprsCalib = (St_emcCalib*)DB->Find("bprsCalib");
149  if(bprsCalib) {
150  mBprsC = bprsCalib->GetTable();
151  updateValidity(maker, bprsCalib);
152  }
153 
154  St_emcGain* bprsGain = (St_emcGain*)DB->Find("bprsGain");
155  if(bprsGain) {
156  mBprsG = bprsGain->GetTable();
157  updateValidity(maker, bprsGain);
158  }
159  }
160 
161  DB = maker->GetInputDB("Calibrations/emc/y3bsmde");
162  if(DB) {
163  St_smdPed* bsmdePed = (St_smdPed*)DB->Find("bsmdePed");
164  if(bsmdePed) {
165  mSmdeP = bsmdePed->GetTable();
166  updateValidity(maker, bsmdePed);
167  }
168 
169  St_smdStatus* bsmdeStatus = (St_smdStatus*)DB->Find("bsmdeStatus");
170  if(bsmdeStatus) {
171  mSmdeS = bsmdeStatus->GetTable();
172  updateValidity(maker, bsmdeStatus);
173  }
174 
175  St_smdCalib* bsmdeCalib = (St_smdCalib*)DB->Find("bsmdeCalib");
176  if(bsmdeCalib) {
177  mSmdeC = bsmdeCalib->GetTable();
178  updateValidity(maker, bsmdeCalib);
179  }
180 
181  St_smdGain* bsmdeGain = (St_smdGain*)DB->Find("bsmdeGain");
182  if(bsmdeGain) {
183  mSmdeG = bsmdeGain->GetTable();
184  updateValidity(maker, bsmdeGain);
185  }
186  }
187 
188  DB = maker->GetInputDB("Calibrations/emc/y3bsmdp");
189  if(DB) {
190  St_smdPed* bsmdpPed = (St_smdPed*)DB->Find("bsmdpPed");
191  if(bsmdpPed) {
192  mSmdpP = bsmdpPed->GetTable();
193  updateValidity(maker, bsmdpPed);
194  }
195 
196  St_smdStatus* bsmdpStatus = (St_smdStatus*)DB->Find("bsmdpStatus");
197  if(bsmdpStatus) {
198  mSmdpS = bsmdpStatus->GetTable();
199  updateValidity(maker, bsmdpStatus);
200  }
201 
202  St_smdCalib* bsmdpCalib = (St_smdCalib*)DB->Find("bsmdpCalib");
203  if(bsmdpCalib) {
204  mSmdpC = bsmdpCalib->GetTable();
205  updateValidity(maker, bsmdpCalib);
206  }
207 
208  St_smdGain* bsmdpGain = (St_smdGain*)DB->Find("bsmdpGain");
209  if(bsmdpGain) {
210  mSmdpG = bsmdpGain->GetTable();
211  updateValidity(maker, bsmdpGain);
212  }
213  }
214 
215  DB = maker->GetInputDB("Calibrations/emc/trigger");
216  if(DB) {
217  St_emcTriggerStatus* bemcTriggerStatus = (St_emcTriggerStatus*)DB->Find("bemcTriggerStatus");
218  if(bemcTriggerStatus) {
219  mTrigS = bemcTriggerStatus->GetTable();
220  updateValidity(maker, bemcTriggerStatus);
221  }
222 
223  St_emcTriggerPed* bemcTriggerPed = (St_emcTriggerPed*)DB->Find("bemcTriggerPed");
224  if(bemcTriggerPed) {
225  mTrigP = bemcTriggerPed->GetTable();
226  updateValidity(maker, bemcTriggerPed);
227  }
228 
229  St_bemcTriggerPed4* bemcTriggerPed4 = (St_bemcTriggerPed4*)DB->Find("bemcTriggerPed4");
230  if(bemcTriggerPed4) {
231  mTrigP4 = bemcTriggerPed4->GetTable();
232  updateValidity(maker, bemcTriggerPed4);
233  }
234 
235  St_emcTriggerLUT* bemcTriggerLUT = (St_emcTriggerLUT*)DB->Find("bemcTriggerLUT");
236  if(bemcTriggerLUT) {
237  mTrigL = bemcTriggerLUT->GetTable();
238  updateValidity(maker, bemcTriggerLUT);
239  }
240  }
241 }
242 
243 void StBemcTables::updateValidity(StMaker* maker, TTable* table) {
244  TDatime datime[2];
245  St_db_Maker::GetValidity(table,datime);
246  string tableName = table->GetName();
247  string beginTime = datime[0].AsSQLString();
248  string endTime = datime[1].AsSQLString();
249 
250  map<string, pair<string, string> >::iterator iter = mValidRanges.find(tableName);
251  if(iter == mValidRanges.end()) {
252  mValidRanges[tableName] = make_pair(beginTime, endTime);
253  LOG_INFO << Form("loaded a new %20s table with beginTime %s and endTime %s", tableName.c_str(), beginTime.c_str(), endTime.c_str()) << endm;
254  }
255  else if( beginTime != (iter->second).first ) {
256  (iter->second).first = beginTime;
257  (iter->second).second = endTime;
258  LOG_INFO << Form("loaded a new %20s table with beginTime %s and endTime %s", tableName.c_str(), beginTime.c_str(), endTime.c_str()) << endm;
259  }
260 }
261 
262 const char* StBemcTables::beginTime(const char * tableName) const {
263  string t = tableName;
264  map<string, pair<string, string> >::const_iterator iter = mValidRanges.find(t);
265  if(iter == mValidRanges.end()) {
266  LOG_WARN << "Couldn't find a table named " << tableName << endm;
267  return NULL;
268  }
269  else {
270  return (iter->second).first.c_str();
271  }
272 }
273 
274 const char* StBemcTables::endTime(const char * tableName) const {
275  string t = tableName;
276  map<string, pair<string, string> >::const_iterator iter = mValidRanges.find(t);
277  if(iter == mValidRanges.end()) {
278  LOG_WARN << "Couldn't find a table named " << tableName << endm;
279  return NULL;
280  }
281  else {
282  return (iter->second).second.c_str();
283  }
284 }
285 
286 //-----------------------------------------------------------------------------
287 
288 Int_t StBemcTables::getOldId(int det, Int_t newId) const {
289  Int_t shift = 0;
290  if(det == BTOW) {
291  mDecoder->GetTowerBugCorrectionShift(newId, shift);
292  }
293  if(det == BPRS) {
294  mDecoder->GetPreshowerBugCorrectionShift(newId, shift);
295  }
296  return newId + shift;
297 }
298 
299 //-----------------------------------------------------------------------------
300 
301 void StBemcTables::getPedestal(Int_t det, Int_t id, Int_t CAP,Float_t& P, Float_t& R) const {
302  P = 0;
303  R = 0;
304  if(det==BTOW && mBtowP)
305  {
306  Int_t id1 = id;
307  if(mBtowMapFix) id1 = getOldId(BTOW, id);
308  P = ((Float_t)mBtowP[0].AdcPedestal[id1-1])/100;
309  R = ((Float_t)mBtowP[0].AdcPedestalRMS[id1-1])/100;
310  return;
311  }
312  if(det==BPRS && mBprsP)
313  {
314  Int_t id1 = id;
315  if(mBprsMapFix) id1 = getOldId(BPRS, id);
316  P = ((Float_t)mBprsP[0].AdcPedestal[id1-1])/100;
317  R = ((Float_t)mBprsP[0].AdcPedestalRMS[id1-1])/100;
318  return;
319  }
320  if(det==BSMDE && mSmdeP)
321  {
322  Int_t C = 0;
323  if(CAP==CAP1) C = 1;
324  if(CAP==CAP2) C = 2;
325  P = ((Float_t)mSmdeP[0].AdcPedestal[id-1][C])/100;
326  R = ((Float_t)mSmdeP[0].AdcPedestalRMS[id-1][C])/100;
327  return;
328  }
329  if(det==BSMDP && mSmdpP)
330  {
331  Int_t C = 0;
332  if(CAP==CAP1) C = 1;
333  if(CAP==CAP2) C = 2;
334  P = ((Float_t)mSmdpP[0].AdcPedestal[id-1][C])/100;
335  R = ((Float_t)mSmdpP[0].AdcPedestalRMS[id-1][C])/100;
336  return;
337  }
338  return;
339 }
340 
341 void StBemcTables::getStatus(Int_t det, Int_t id, Int_t& S, const char *option) const {
342  S = STATUS_OK;
343  if(det==BTOW && mBtowS)
344  {
345  Int_t id1 = id;
346  if(mBtowMapFix) id1 = getOldId(BTOW, id);
347  if(!strcmp(option, "calib")) { S = (Int_t)mBtowC[0].Status[id1-1]; return; }
348  if(!strcmp(option, "pedestal")) { S = (Int_t)mBtowP[0].Status[id1-1]; return; }
349  if(!strcmp(option, "gain")) { S = (Int_t)mBtowG[0].Status[id1-1]; return; }
350  S = (Int_t)mBtowS[0].Status[id1-1];
351  return;
352  }
353  if(det==BPRS && mBprsS) {
354  Int_t id1 = id;
355  if(mBprsMapFix) id1 = getOldId(BPRS, id);
356  if(!strcmp(option, "calib")) { S = (Int_t)mBprsC[0].Status[id1-1]; return; }
357  if(!strcmp(option, "pedestal")) { S = (Int_t)mBprsP[0].Status[id1-1]; return; }
358  if(!strcmp(option, "gain")) { S = (Int_t)mBprsG[0].Status[id1-1]; return; }
359  S = (Int_t)mBprsS[0].Status[id1-1];return;
360  }
361  if(det==BSMDE && mSmdeS) {
362  if(!strcmp(option, "calib")) { S = (Int_t)mSmdeC[0].Status[id-1]; return; }
363  if(!strcmp(option, "pedestal")) { S = (Int_t)mSmdeP[0].Status[id-1]; return; }
364  if(!strcmp(option, "gain")) { S = (Int_t)mSmdeG[0].Status[id-1]; return; }
365  S = (Int_t)mSmdeS[0].Status[id-1];return;
366  }
367  if(det==BSMDP && mSmdpS) {
368  if(!strcmp(option, "calib")) { S = (Int_t)mSmdpC[0].Status[id-1]; return; }
369  if(!strcmp(option, "pedestal")) { S = (Int_t)mSmdpP[0].Status[id-1]; return; }
370  if(!strcmp(option, "gain")) { S = (Int_t)mSmdpG[0].Status[id-1]; return; }
371  S = (Int_t)mSmdpS[0].Status[id-1];return;
372  }
373  return;
374 }
375 
376 void StBemcTables::getGain(Int_t det, Int_t id, Float_t& G) const {
377  G = 1;
378  if(det==BTOW && mBtowG)
379  {
380  Int_t id1 = id;
381  if(mBtowMapFix) id1 = getOldId(BTOW, id);
382  G = (Float_t)mBtowG[0].Gain[id1-1];
383  return;
384  }
385  if(det==BPRS && mBprsG) {
386  Int_t id1 = id;
387  if(mBprsMapFix) id1 = getOldId(BPRS, id);
388  G = (Float_t)mBprsG[0].Gain[id1-1];return;
389  }
390  if(det==BSMDE && mSmdeG) { G = (Float_t)mSmdeG[0].Gain[id-1];return;}
391  if(det==BSMDP && mSmdpG) { G = (Float_t)mSmdpG[0].Gain[id-1];return;}
392  return;
393 }
394 
395 void StBemcTables::getCalib(Int_t det, Int_t id, Int_t power, Float_t& C) const {
396  C = 0;
397  if(det==BTOW && mBtowC)
398  {
399  Int_t id1 = id;
400  if(mBtowMapFix) id1 = getOldId(BTOW, id);
401  C = (Float_t)mBtowC[0].AdcToE[id1-1][power];
402  return;
403  }
404  if(det==BPRS && mBprsC) {
405  Int_t id1 = id;
406  if(mBprsMapFix) id1 = getOldId(BPRS, id);
407  C = (Float_t)mBprsC[0].AdcToE[id1-1][power];return;
408  }
409  if(det==BSMDE && mSmdeC) { C = (Float_t)mSmdeC[0].AdcToE[id-1][power];return;}
410  if(det==BSMDP && mSmdpC) { C = (Float_t)mSmdpC[0].AdcToE[id-1][power];return;}
411  return;
412 }
413 
414 //-----------------------------------------------------------------------------
415 
416 void StBemcTables::getTriggerPatchStatus(Int_t patch, Int_t& STATUS) const {
417  STATUS = 0;
418  if(mTrigS && patch>=0 && patch<NBEMCTRIGGERTOWER)
419  STATUS = (Int_t)mTrigS[0].PatchStatus[patch];
420 }
421 
422 void StBemcTables::getTriggerHighTowerStatus(Int_t hightower, Int_t& STATUS) const {
423  STATUS = 0;
424  if(mTrigS && hightower>=0 && hightower<NBEMCTRIGGERTOWER)
425  STATUS = (Int_t)mTrigS[0].HighTowerStatus[hightower];
426 }
427 
428 void StBemcTables::getTriggerTowerStatus(Int_t crate,Int_t index, Int_t& STATUS) const {
429  STATUS = 0;
430  if(mTrigS && crate>0 && crate<=MAXCRATES && index>=0 && index<NTOWERSPERCRATE)
431  STATUS = (Int_t)mTrigS[0].TowerStatus[crate-1][index];
432 }
433 
434 void StBemcTables::getTriggerPedestal(Int_t crate,Int_t index, Float_t& PEDESTAL) const {
435  PEDESTAL = 0;
436  if(mTrigP && crate>0 && crate<=MAXCRATES && index>=0 && index<NTOWERSPERCRATE)
437  PEDESTAL = ((Float_t)mTrigP[0].Ped[crate-1][index])/100.0;
438 }
439 
440 void StBemcTables::getTriggerBitConv(Int_t crate,Int_t patch, Int_t& BIT) const {
441  BIT = 0;
442  if(mTrigP && crate>0 && crate<=MAXCRATES && patch>=0 && patch<NPATCHESPERCRATE) {
443  BIT = (Int_t)mTrigP[0].BitConversionMode[crate-1][patch];
444  }
445 }
446 
447 void StBemcTables::getTriggerPedestalShift(Int_t& pedestalShift) const {
448  if (mTrigP) pedestalShift = (Int_t)mTrigP->PedShift / 100;
449 }
450 
451 void StBemcTables::getTriggerPed4(Int_t softId, Short_t& PED4) const {
452  PED4 = 0;
453  if (mTrigP4 && softId>0 && softId<=4800)
454  PED4 = (Short_t)mTrigP4->Ped4[softId];
455 }
456 
457 void StBemcTables::getTriggerFormulaTag(Int_t crate, Int_t index, Int_t& formula) const {
458  if (mTrigL) formula = (Int_t)mTrigL->FormulaTag[crate-1][index];
459 }
460 
461 void StBemcTables::getTriggerFormulaParameters(Int_t crate, Int_t index, Int_t* parameters) const {
462  if (mTrigL) {
463  parameters[0] = (Int_t)mTrigL->FormulaParameter0[crate-1][index];
464  parameters[1] = (Int_t)mTrigL->FormulaParameter1[crate-1][index];
465  parameters[2] = (Int_t)mTrigL->FormulaParameter2[crate-1][index];
466  parameters[3] = (Int_t)mTrigL->FormulaParameter3[crate-1][index];
467  parameters[4] = (Int_t)mTrigL->FormulaParameter4[crate-1][index];
468  parameters[5] = (Int_t)mTrigL->FormulaParameter5[crate-1][index];
469  }
470 }
471 
472 //-----------------------------------------------------------------------------
473 
474 float StBemcTables::calib(int det, int softId, int power) const {
475  float val;
476  getCalib(det, softId, power, val);
477  return val;
478 }
479 
480 float StBemcTables::pedestal(int det, int softId, int cap) const {
481  float val, junk;
482  getPedestal(det, softId, cap, val, junk);
483  return val;
484 }
485 
486 float StBemcTables::pedestalRMS(int det, int softId, int cap) const {
487  float val, junk;
488  getPedestal(det, softId, cap, junk, val);
489  return val;
490 }
491 
492 float StBemcTables::gain(int det, int softId) const {
493  float val;
494  getGain(det, softId, val);
495  return val;
496 }
497 
498 int StBemcTables::status(int det, int softId, const char *option) const {
499  int val;
500  getStatus(det, softId, val, option);
501  return val;
502 }
503 
504 //-----------------------------------------------------------------------------
505 
506 int StBemcTables::triggerPatchStatus(int triggerPatchId) const {
507  int val;
508  getTriggerPatchStatus(triggerPatchId,val);
509  return val;
510 }
511 
512 int StBemcTables::triggerHighTowerStatus(int triggerPatchId) const {
513  int val;
514  getTriggerHighTowerStatus(triggerPatchId,val);
515  return val;
516 }
517 
518 int StBemcTables::triggerTowerStatus(int crate, int sequence) const {
519  int val;
520  getTriggerTowerStatus(crate,sequence,val);
521  return val;
522 }
523 
524 float StBemcTables::triggerPedestal(int crate, int sequence) const {
525  float val;
526  getTriggerPedestal(crate,sequence,val);
527  return val;
528 }
529 
530 int StBemcTables::triggerBitConversion(int crate, int patchSequence) const {
531  int val;
532  getTriggerBitConv(crate,patchSequence,val);
533  return val;
534 }
535 
536 int StBemcTables::triggerPedestalShift() const {
537  int val;
539  return val;
540 }
541 
542 short StBemcTables::triggerPed4(int softId) const {
543  short val;
544  getTriggerPed4(softId,val);
545  return val;
546 }
547 
548 int StBemcTables::triggerFormulaTag(int crate, int patchSequence) const {
549  int val;
550  getTriggerFormulaTag(crate,patchSequence,val);
551  return val;
552 }
553 
554 int* StBemcTables::triggerFormulaParameters(int crate, int patchSequence) const {
555  int * params = new int[6];
556  getTriggerFormulaParameters(crate,patchSequence,params);
557  return params;
558 }
559 
560 //-----------------------------------------------------------------------------
561 
562 int StBemcTables::triggerPatchStatusByID(int softId) const {
563  int patchId;
564  if(mDecoder->GetTriggerPatchFromTowerId(softId, patchId)) {
565  return this->triggerPatchStatus(patchId);
566  }
567  LOG_ERROR << "Problem with StEmcDecoder::GetTriggerPatchFromTowerId for softId " << softId << endm;
568  return -999;
569 }
570 
571 int StBemcTables::triggerHighTowerStatusByID(int softId) const {
572  int patchId;
573  if(mDecoder->GetTriggerPatchFromTowerId(softId, patchId)) {
574  return this->triggerHighTowerStatus(patchId);
575  }
576  LOG_ERROR << "Problem with StEmcDecoder::GetTriggerPatchFromTowerId for softId " << softId << endm;
577  return -999;
578 }
579 
580 int StBemcTables::triggerTowerStatusByID(int softId) const {
581  int crate, sequence;
582  if(mDecoder->GetCrateFromTowerId(softId, crate, sequence)) {
583  return this->triggerTowerStatus(crate, sequence);
584  }
585  LOG_ERROR << "Problem with StEmcDecoder::GetCrateFromTowerId for softId " << softId << endm;
586  return -999;
587 }
588 
589 float StBemcTables::triggerPedestalByID(int softId) const {
590  int crate, sequence;
591  if(mDecoder->GetCrateFromTowerId(softId, crate, sequence)) {
592  return this->triggerPedestal(crate, sequence);
593  }
594  LOG_ERROR << "Problem with StEmcDecoder::GetCrateFromTowerId for softId " << softId << endm;
595  return -999;
596 }
597 
598 int StBemcTables::triggerBitConversionByID(int softId) const {
599  int patchId, crate, patchSequence;
600  if(mDecoder->GetTriggerPatchFromTowerId(softId, patchId)) {
601  if(mDecoder->GetCrateAndSequenceFromTriggerPatch(patchId, crate, patchSequence)) {
602  if( (patchSequence%16 != 0) || (patchId%10 != patchSequence/16) ) {
603  LOG_ERROR << "Please ask Adam what the heck is going on" << endm;
604  }
605  return this->triggerBitConversion(crate, patchSequence/16);
606  }
607  LOG_ERROR << "Problem with StEmcDecoder::GetCrateAndSequenceFromTriggerPatch for patchId " << patchId << endm;
608  }
609  LOG_ERROR << "Problem with StEmcDecoder::GetTriggerPatchFromTowerId for softId " << softId << endm;
610  return -999;
611 }
612 
613 int StBemcTables::triggerFormulaTagByID(int softId) const {
614  int patchId, crate, patchSequence;
615  if(mDecoder->GetTriggerPatchFromTowerId(softId, patchId)) {
616  if(mDecoder->GetCrateAndSequenceFromTriggerPatch(patchId, crate, patchSequence)) {
617  if( (patchSequence%16 != 0) || (patchId%10 != patchSequence/16) ) {
618  LOG_ERROR << "Please ask Adam what the heck is going on" << endm;
619  }
620  return this->triggerFormulaTag(crate, patchSequence/16);
621  }
622  LOG_ERROR << "Problem with StEmcDecoder::GetCrateAndSequenceFromTriggerPatch for patchId " << patchId << endm;
623  }
624  LOG_ERROR << "Problem with StEmcDecoder::GetTriggerPatchFromTowerId for softId " << softId << endm;
625  return -999;
626 }
627 
628 int* StBemcTables::triggerFormulaParametersByID(int softId) const {
629  int patchId, crate, patchSequence;
630  if(mDecoder->GetTriggerPatchFromTowerId(softId, patchId)) {
631  if(mDecoder->GetCrateAndSequenceFromTriggerPatch(patchId, crate, patchSequence)) {
632  if( (patchSequence%16 != 0) || (patchId%10 != patchSequence/16) ) {
633  LOG_ERROR << "Please ask Adam what the heck is going on" << endm;
634  }
635  return this->triggerFormulaParameters(crate, patchSequence/16);
636  }
637  LOG_ERROR << "Problem with StEmcDecoder::GetCrateAndSequenceFromTriggerPatch for patchId " << patchId << endm;
638  }
639  LOG_ERROR << "Problem with StEmcDecoder::GetTriggerPatchFromTowerId for softId " << softId << endm;
640  return NULL;
641 }
642 
643 /***************************************************************************
644  *
645  * $Log: StBemcTables.cxx,v $
646  * Revision 1.14 2015/03/02 20:25:51 jkadkins
647  * Updates to include "bemcTriggerPed4" for BEMC online trigger monitoring
648  *
649  * Revision 1.13 2010/01/27 21:39:51 perev
650  * GetValidity now is static
651  *
652  * Revision 1.12 2009/01/02 02:56:18 kocolosk
653  * use StMaker::GetDBTime() instead of GetDateTime()
654  *
655  * Revision 1.11 2007/11/08 11:12:39 kocolosk
656  * remove debugging statements
657  *
658  * Revision 1.10 2007/10/01 19:53:43 kocolosk
659  * another bugfix from Renee: patchSequence is 0-9, not 0-159
660  *
661  * Revision 1.9 2007/10/01 15:03:35 kocolosk
662  * bugfix in trigger DB methods that used StEmcDecoder, thanks to R. Fatemi
663  *
664  * Revision 1.8 2007/09/18 19:41:46 kocolosk
665  * added an optional argument to status methods to get status for calib, pedestal, and gain tables
666  *
667  * Revision 1.7 2007/09/10 21:23:22 kocolosk
668  * specify kTRUE as 2nd ctor argument to implement swapping corrections for 06/07 BPRS DB
669  *
670  * Revision 1.6 2007/08/21 18:39:22 kocolosk
671  * added methods to get beginTime / endTime of a given DB table
672  *
673  *
674  **************************************************************************/
void getTriggerFormulaParameters(Int_t crate, Int_t index, Int_t *parameters) const
Return LUT formula parameters.
int status(int det, int softId, const char *option="") const
void getTriggerBitConv(Int_t crate, Int_t patch, Int_t &bit) const
Return 6 bits conversion mode.
void getGain(Int_t det, Int_t softId, Float_t &gain) const
Return gain correction factor.
void getTriggerTowerStatus(Int_t crate, Int_t index, Int_t &status) const
Return trigger single tower status.
virtual ~StBemcTables()
StBemcTables destructor.
void getPedestal(Int_t det, Int_t softId, Int_t cap, Float_t &ped, Float_t &rms) const
Return pedestal mean and rms.
void getTriggerPatchStatus(Int_t patch, Int_t &status) const
Return trigger patch status.
int GetPreshowerBugCorrectionShift(int id_original, int &shift) const
Returns the index shift for the preshower in original map.
void loadTables(StMaker *anyMaker)
load tables.
int GetCrateAndSequenceFromTriggerPatch(int patchId, int &crate, int &sequence) const
returns the crate number and start point for a given trigger patch
void getTriggerFormulaTag(Int_t crate, Int_t index, Int_t &formula) const
Return LUT formula.
int GetCrateFromTowerId(int softId, int &crate, int &sequence) const
Get crate number and position in crate for Software Id.
void getCalib(Int_t det, Int_t softId, Int_t power, Float_t &calib) const
Return calibration constant.
void getTriggerHighTowerStatus(Int_t hightower, Int_t &status) const
Return trigger highTower status.
void getTriggerPedestal(Int_t crate, Int_t index, Float_t &pedestal) const
Return tower pedestal loaded in trigger.
void getTriggerPedestalShift(Int_t &pedestalShift) const
Return target pedestal shift.
Definition: TTable.h:48
int GetTriggerPatchFromTowerId(int softId, int &patchId) const
Get trigger patch that contains software Id.
int GetTowerBugCorrectionShift(int id_original, int &shift) const
Returns the index shift for the tower in original map.
void getStatus(Int_t det, Int_t softId, Int_t &status, const char *option="") const
Return status.
virtual TDataSet * Find(const char *path) const
Definition: TDataSet.cxx:362