1 #ifndef __StarChairDefs_h
2 #define __StarChairDefs_h
5 #include "tables/St_tpcCorrection_Table.h"
6 #define DEBUGTABLE(STRUCT) \
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); \
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)); \
28 LOG_WARN << "St_" << # STRUCT << "C::instance " << MakeString(PATH) << "\twas not found" << endm; \
32 fgInstance = new St_ ## STRUCT ## C(table); \
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)); \
42 table = new St_ ## STRUCT(# STRUCT ,0); \
44 LOG_WARN << "St_" << # STRUCT << "C::instance create optional " << # STRUCT << " table" << endm; \
46 assert(table); DEBUGTABLE(STRUCT); \
47 fgInstance = new St_ ## STRUCT ## C(table); \
50 #define MakeChairInstance2(STRUCT,CLASS,PATH) \
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); \
60 #define MakeChairOptionalInstance2(STRUCT,CLASS,PATH) \
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)); \
67 table = new St_ ## STRUCT(# STRUCT ,0); \
69 LOG_WARN << "St_" << # STRUCT << "C::instance create optional " << # CLASS << " table" << endm; \
71 assert(table); DEBUGTABLE(STRUCT); \
72 fgInstance = new CLASS(table); \
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); \
86 LOG_WARN << "St_" << # STRUCT << "C::instance " \
87 << ((AorB) ? MakeString(PATHA) : MakeString(PATHB)) \
88 << "\twas not found" << endm; \
92 fgInstance = new St_ ## STRUCT ## C(table); \
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); \
102 table = new St_ ## STRUCT(# STRUCT ,0); \
104 LOG_WARN << "St_" << # STRUCT << "C::instance create optional " << # STRUCT << " table" << endm; \
106 assert(table); DEBUGTABLE(STRUCT); \
107 fgInstance = new St_ ## STRUCT ## C(table); \
110 #define MakeChairAltInstance2(STRUCT,CLASS,PATHA,PATHB,AorB) \
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); \
120 #define MakeChairAltOptionalInstance2(STRUCT,CLASS,PATHA,PATHB,AorB) \
122 CLASS *CLASS::fgInstance = 0; \
123 CLASS *CLASS::instance() { \
124 if (fgInstance) return fgInstance; \
125 PATHAorPATHB(STRUCT,PATHA,PATHB,AorB); \
127 table = new St_ ## STRUCT(# STRUCT ,0); \
129 LOG_WARN << "St_" << # STRUCT << "C::instance create optional " << # CLASS << " table" << endm; \
131 assert(table); DEBUGTABLE(STRUCT); \
132 fgInstance = new CLASS(table); \