StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StarChairDefs.h
1 #ifndef __StarChairDefs_h
2 #define __StarChairDefs_h
3 #include <assert.h>
4 #include "TDatime.h"
5 #include "tables/St_tpcCorrection_Table.h"
6 #define DEBUGTABLE(STRUCT) \
7  TDatime t[2]; \
8  if (St_db_Maker::GetValidity(table,t) > 0) { \
9  Int_t Nrows = table->GetNRows(); \
10  if (table->InheritsFrom("St_tpcCorrection")) { \
11  St_tpcCorrection *t = (St_tpcCorrection *) table; \
12  tpcCorrection_st *s = t->GetTable(); Nrows = s->nrows;} \
13  LOG_WARN << "St_" << # STRUCT << "C::instance found table " << table->GetName() \
14  << " with NRows = " << Nrows << " in db" << endm; \
15  LOG_WARN << "Validity:" << t[0].GetDate() << "/" << t[0].GetTime() \
16  << " ----- " << t[1].GetDate() << "/" << t[1].GetTime() << endm; \
17  if (Nrows > 10) Nrows = 10; \
18  if (table->GetRowSize() < 512) table->Print(0,Nrows); \
19  }
20 #define MakeString(PATH) # PATH
21 #define MakeChairInstance(STRUCT,PATH) \
22 ClassImp(St_ ## STRUCT ## C); \
23 St_ ## STRUCT ## C *St_ ## STRUCT ## C::fgInstance = 0; \
24 St_ ## STRUCT ## C *St_ ## STRUCT ## C::instance() { \
25  if (fgInstance) return fgInstance; \
26  St_ ## STRUCT *table = (St_ ## STRUCT *) StMaker::GetChain()->GetDataBase(MakeString(PATH)); \
27  if (! table) { \
28  LOG_WARN << "St_" << # STRUCT << "C::instance " << MakeString(PATH) << "\twas not found" << endm; \
29  assert(table); \
30  } \
31  DEBUGTABLE(STRUCT); \
32  fgInstance = new St_ ## STRUCT ## C(table); \
33  return fgInstance; \
34  }
35 #define MakeChairOptionalInstance(STRUCT,PATH) \
36  ClassImp(St_ ## STRUCT ## C); \
37  St_ ## STRUCT ## C *St_ ## STRUCT ## C::fgInstance = 0; \
38  St_ ## STRUCT ## C *St_ ## STRUCT ## C::instance() { \
39  if (fgInstance) return fgInstance; \
40  St_ ## STRUCT *table = (St_ ## STRUCT *) StMaker::GetChain()->GetDataBase(MakeString(PATH)); \
41  if (! table) { \
42  table = new St_ ## STRUCT(# STRUCT ,0); \
43  table->Mark(); \
44  LOG_WARN << "St_" << # STRUCT << "C::instance create optional " << # STRUCT << " table" << endm; \
45  } \
46  assert(table); DEBUGTABLE(STRUCT); \
47  fgInstance = new St_ ## STRUCT ## C(table); \
48  return fgInstance; \
49  }
50 #define MakeChairInstance2(STRUCT,CLASS,PATH) \
51  ClassImp(CLASS); \
52  CLASS *CLASS::fgInstance = 0; \
53  CLASS *CLASS::instance() { \
54  if (fgInstance) return fgInstance; \
55  St_ ## STRUCT *table = (St_ ## STRUCT *) StMaker::GetChain()->GetDataBase(MakeString(PATH)); \
56  assert(table); DEBUGTABLE(STRUCT); \
57  fgInstance = new CLASS(table); \
58  return fgInstance; \
59  }
60 #define MakeChairOptionalInstance2(STRUCT,CLASS,PATH) \
61  ClassImp(CLASS); \
62  CLASS *CLASS::fgInstance = 0; \
63  CLASS *CLASS::instance() { \
64  if (fgInstance) return fgInstance; \
65  St_ ## STRUCT *table = (St_ ## STRUCT *) StMaker::GetChain()->GetDataBase(MakeString(PATH)); \
66  if (! table) { \
67  table = new St_ ## STRUCT(# STRUCT ,0); \
68  table->Mark(); \
69  LOG_WARN << "St_" << # STRUCT << "C::instance create optional " << # CLASS << " table" << endm; \
70  } \
71  assert(table); DEBUGTABLE(STRUCT); \
72  fgInstance = new CLASS(table); \
73  return fgInstance; \
74  }
75 #define PATHAorPATHB(STRUCT,PATHA,PATHB,AorB) \
76  St_ ## STRUCT *table = (St_ ## STRUCT *) \
77  ((AorB == 0) ? StMaker::GetChain()->GetDataBase(MakeString(PATHA)): \
78  StMaker::GetChain()->GetDataBase(MakeString(PATHB)))
79 #define MakeChairAltInstance(STRUCT,PATHA,PATHB,AorB) \
80  ClassImp(St_ ## STRUCT ## C); \
81  St_ ## STRUCT ## C *St_ ## STRUCT ## C::fgInstance = 0; \
82  St_ ## STRUCT ## C *St_ ## STRUCT ## C::instance() { \
83  if (fgInstance) return fgInstance; \
84  PATHAorPATHB(STRUCT,PATHA,PATHB,AorB); \
85  if (! table) { \
86  LOG_WARN << "St_" << # STRUCT << "C::instance " \
87  << ((AorB) ? MakeString(PATHA) : MakeString(PATHB)) \
88  << "\twas not found" << endm; \
89  assert(table); \
90  } \
91  DEBUGTABLE(STRUCT); \
92  fgInstance = new St_ ## STRUCT ## C(table); \
93  return fgInstance; \
94  }
95 #define MakeChairAltOptionalInstance(STRUCT,PATHA,PATHB,AorB) \
96  ClassImp(St_ ## STRUCT ## C); \
97  St_ ## STRUCT ## C *St_ ## STRUCT ## C::fgInstance = 0; \
98  St_ ## STRUCT ## C *St_ ## STRUCT ## C::instance() { \
99  if (fgInstance) return fgInstance; \
100  PATHAorPATHB(STRUCT,PATHA,PATHB,AorB); \
101  if (! table) { \
102  table = new St_ ## STRUCT(# STRUCT ,0); \
103  table->Mark(); \
104  LOG_WARN << "St_" << # STRUCT << "C::instance create optional " << # STRUCT << " table" << endm; \
105  } \
106  assert(table); DEBUGTABLE(STRUCT); \
107  fgInstance = new St_ ## STRUCT ## C(table); \
108  return fgInstance; \
109  }
110 #define MakeChairAltInstance2(STRUCT,CLASS,PATHA,PATHB,AorB) \
111  ClassImp(CLASS); \
112  CLASS *CLASS::fgInstance = 0; \
113  CLASS *CLASS::instance() { \
114  if (fgInstance) return fgInstance; \
115  PATHAorPATHB(STRUCT,PATHA,PATHB,AorB); \
116  assert(table); DEBUGTABLE(STRUCT); \
117  fgInstance = new CLASS(table); \
118  return fgInstance; \
119  }
120 #define MakeChairAltOptionalInstance2(STRUCT,CLASS,PATHA,PATHB,AorB) \
121  ClassImp(CLASS); \
122  CLASS *CLASS::fgInstance = 0; \
123  CLASS *CLASS::instance() { \
124  if (fgInstance) return fgInstance; \
125  PATHAorPATHB(STRUCT,PATHA,PATHB,AorB); \
126  if (! table) { \
127  table = new St_ ## STRUCT(# STRUCT ,0); \
128  table->Mark(); \
129  LOG_WARN << "St_" << # STRUCT << "C::instance create optional " << # CLASS << " table" << endm; \
130  } \
131  assert(table); DEBUGTABLE(STRUCT); \
132  fgInstance = new CLASS(table); \
133  return fgInstance; \
134  }
135 #endif /* __StarChairDefs_h */
136