StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StBTofTables.cxx
1 /*******************************************************************
2  *
3  * $Id: StBTofTables.cxx,v 1.4 2017/10/20 17:50:33 smirnovd Exp $
4  *
5  *****************************************************************
6  *
7  * $Log: StBTofTables.cxx,v $
8  * Revision 1.4 2017/10/20 17:50:33 smirnovd
9  * Squashed commit of the following:
10  *
11  * StBTof: Remove outdated ClassImp macro
12  *
13  * Prefer explicit namespace for std:: names in header files
14  *
15  * Removed unnecessary specification of default std::allocator
16  *
17  * Frank signed-off
18  *
19  * Revision 1.3 2017/10/03 22:54:45 geurts
20  * restore access to TOF status table (Calibrations/tof/tofStatus)
21  *
22  * Revision 1.2 2012/12/14 06:35:41 geurts
23  * Changed global database calls to direct table access and/or removed deprecated database access code.
24  *
25  * Revision 1.1 2009/08/28 17:22:11 dongx
26  * first release
27  *
28  *
29  *******************************************************************/
30 #include "StBTofTables.h"
31 #include "StMaker.h"
32 
33 
34 //____________________________________________________________________
36  Reset();
37 }
38 
39 //____________________________________________________________________
40 StBTofTables::~StBTofTables() {
41  Reset();
42 }
43 
44 //____________________________________________________________________
45 void StBTofTables::Reset() {
46  memset(mBTofTrayConfig, 0, sizeof(mBTofTrayConfig));
47  memset(mBTofStatus, 0, sizeof(mBTofStatus));
48 }
49 
50 //____________________________________________________________________
52 
53  LOG_INFO << "StBTofTables -- loading the BTOF tray/channel status tables ..." << endm;
54 
55  TDataSet *mDbTOFDataSet = maker->GetDataBase("Calibrations/tof/tofTrayConfig");
56  if(!mDbTOFDataSet) {
57  LOG_ERROR << "unable to access Calibrations TOF parameters for config" << endm;
58  // assert(mDbTOFDataSet);
59  return; // kStErr;
60  }
61 
62  St_tofTrayConfig* trayConfig = static_cast<St_tofTrayConfig*>(mDbTOFDataSet->Find("tofTrayConfig"));
63  if(!trayConfig) {
64  LOG_ERROR << "unable to get tof tray configuration" << endm;
65  return; // kStErr;
66  }
67  tofTrayConfig_st* trayconf = static_cast<tofTrayConfig_st*>(trayConfig->GetArray());
68  if(maker->Debug()) { LOG_INFO << " Valid Trays: " << endm; }
69 
70  Int_t nValidTrays = (Int_t)(trayconf[0].entries);
71  for (Int_t i=0;i<nValidTrays;i++) {
72  int trayId = (Int_t)(trayconf[0].iTray[i]);
73  mBTofTrayConfig[trayId-1] = 1;
74  if(maker->Debug()) {
75  LOG_INFO << " " << trayId;
76  }
77  }
78  if(maker->Debug()) { LOG_INFO << endm; }
79 
80  mDbTOFDataSet = maker->GetDataBase("Calibrations/tof/tofStatus");
81  if(!mDbTOFDataSet) {
82  LOG_ERROR << "unable to access Calibrations TOF parameters for status" << endm;
83  // assert(mDbTOFDataSet);
84  return; // kStErr;
85  }
86  St_tofStatus* tofStatus = static_cast<St_tofStatus*>(mDbTOFDataSet->Find("tofStatus"));
87  if(!tofStatus) {
88  LOG_ERROR << "unable to get tof status table" << endm;
89  return; // kStErr;
90  }
91 
92  tofStatus_st* status = static_cast<tofStatus_st*>(tofStatus->GetArray());
93  for(int i=0;i<mNChanMax;i++) {
94  int trayId = i/(mNModule*mNCell) + 1;
95  int moduleId = (i%(mNModule*mNCell))/mNCell + 1;
96  int cellId = i%mNCell + 1;
97  if(trayId<=0||trayId>mNTray||moduleId<=0||moduleId>mNModule||cellId<=0||cellId>mNCell) continue;
98  mBTofStatus[trayId-1][moduleId-1][cellId-1] = (UShort_t)status[0].status[i];
99  }
100 
101  return;
102 }
103 
104 //____________________________________________________________________
105 bool StBTofTables::trayValid(int trayId) const {
106  return mBTofTrayConfig[trayId-1];
107 }
108 
109 //____________________________________________________________________
110 int StBTofTables::status(int trayId, int moduleId, int cellId) const {
111  return mBTofStatus[trayId-1][moduleId-1][cellId-1];
112 }
UShort_t mBTofTrayConfig[mNTray]
A large number for total channels.
Definition: StBTofTables.h:36
int status(int trayId, int moduleId, int cellId) const
function to return the channel status
StBTofTables()
Default constructor.
bool trayValid(int trayId) const
function to return the tray status
void loadTables(StMaker *anyMaker)
load status tables from data base
virtual TDataSet * Find(const char *path) const
Definition: TDataSet.cxx:362