StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StPxlDbMaker.cxx
1 
6 /***************************************************************************
7  *
8  * $Id: StPxlDbMaker.cxx,v 1.21 2018/03/29 23:07:10 dongx Exp $
9  *
10  * Author: J. Bouchet, M. Lomnitz, May 2013
11  ***************************************************************************
12  *
13  * Description:
14  * Read DB and prepare information on pxl geometry and sensor/row/column status
15  * More information at
16  * https://www.star.bnl.gov/protected/heavy/qiuh/HFT/software/PXL_software.pdf
17  *
18  ***************************************************************************
19  *
20  * $Log: StPxlDbMaker.cxx,v $
21  * Revision 1.21 2018/03/29 23:07:10 dongx
22  * Added print-out information to check loaded tables
23  *
24  * Revision 1.20 2018/03/15 21:33:07 dongx
25  * *** empty log message ***
26  *
27  * Revision 1.19 2017/09/01 03:10:49 dongx
28  * Added access functions for pxlDigmapsSim table
29  *
30  * Revision 1.18 2015/02/04 07:55:41 smirnovd
31  * Create StPxlDb object in constructor and pass it to the framework via ToWhiteConst() in Init()
32  *
33  * It makes perfect sense to do it this way because the StPxlDb obect is created
34  * once by the maker and later reused/updated only at every new run.
35  *
36  * Revision 1.17 2014/11/19 18:29:47 genevb
37  * Use flags to indicate DbMaker readiness
38  *
39  * Revision 1.16 2014/10/25 00:51:11 qiuh
40  * replace ToWhiteBoard with ToWhiteConst to fix a chain crush
41  *
42  * Revision 1.15 2014/10/07 19:25:28 smirnovd
43  * StPxlDbMaker/: Collected all debugging print statements into a single Print() which is called only when Debug2 option is specified
44  *
45  * Revision 1.14 2014/08/27 16:52:14 qiuh
46  * change pxlRowColumnStatus to pxlBadRowColumns to decrease DB szie
47  *
48  * Revision 1.13 2014/05/07 22:19:19 smirnovd
49  * Change the name of PXL DB dataset to avoid conflict with StPxlDbMaker's name
50  *
51  * Revision 1.12 2014/04/01 15:28:18 qiuh
52  * add single hot pixel masking
53  *
54  * Revision 1.11 2014/01/28 19:29:37 qiuh
55  * *** empty log message ***
56  *
57  *
58  **************************************************************************/
59 
60 #include "StPxlDbMaker.h"
61 #include "StPxlDb.h"
62 #include "StMessMgr.h"
63 #include "tables/St_Survey_Table.h"
64 #include "St_db_Maker/St_db_Maker.h"
65 #include "tables/St_pxlSensorStatus_Table.h"
66 #include "tables/St_pxlRowColumnStatus_Table.h"
67 #include "tables/St_pxlBadRowColumns_Table.h"
68 #include "tables/St_pxlHotPixels_Table.h"
69 #include "tables/St_pxlControl_Table.h"
70 #include "tables/St_pxlSensorTps_Table.h"
71 #include "tables/St_pxlDigmapsSim_Table.h"
72 #include "tables/St_pxlSimPar_Table.h"
73 
74 ClassImp(StPxlDbMaker)
75 //_____________________________________________________________________________
76 StPxlDbMaker::StPxlDbMaker(const char *name) :
77  StMaker(name), mPxlDb(new StPxlDb()), mReady(kStErr)
78 {
79  readAllRowColumnStatus = 0;
80 }
81 
82 
83 Int_t StPxlDbMaker::Init()
84 {
85  ToWhiteConst("pxl_db", mPxlDb);
86 
87  return kStOk;
88 }
89 
90 
91 //_____________________________________________________________________________
92 Int_t StPxlDbMaker::InitRun(Int_t runNumber)
93 {
94  mReady = kStFatal;
95 
96  // set geoHMatrices
97  St_Survey *idsOnTpc = (St_Survey *) GetDataBase("Geometry/pxl/idsOnTpc");
98  if (! idsOnTpc) {LOG_WARN << "idsOnTpc has not been found" << endm; return kStErr;}
99  idsOnTpc->Print(0,1);
100 
101  St_Survey *pstOnIds = (St_Survey *) GetDataBase("Geometry/pxl/pstOnIds");
102  if (! pstOnIds) {LOG_WARN << "pstOnIds has not been found" << endm; return kStErr;}
103  pstOnIds->Print(0,1);
104 
105  St_Survey *pxlOnPst = (St_Survey *) GetDataBase("Geometry/pxl/pxlOnPst");
106  if (! pxlOnPst) {LOG_WARN << "pxlOnPst has not been found" << endm; return kStErr;}
107  pxlOnPst->Print(0,1);
108 
109  St_Survey *pxlHalfOnPxl = (St_Survey *) GetDataBase("Geometry/pxl/pxlHalfOnPxl");
110  if (! pxlHalfOnPxl) {LOG_WARN << "pxlHalfOnPxl has not been found" << endm; return kStErr;}
111  pxlHalfOnPxl->Print(0,1);
112 
113  St_Survey *pxlSectorOnHalf = (St_Survey *) GetDataBase("Geometry/pxl/pxlSectorOnHalf");
114  if (! pxlSectorOnHalf) {LOG_WARN << "pxlSectorOnHalf has not been found" << endm; return kStErr;}
115  pxlSectorOnHalf->Print(0,1);
116 
117  St_Survey *pxlLadderOnSector = (St_Survey *) GetDataBase("Geometry/pxl/pxlLadderOnSector");
118  if (! pxlLadderOnSector) {LOG_WARN << "pxladderOnSector has not been found" << endm; return kStErr;}
119  pxlLadderOnSector->Print(0,1);
120 
121  St_Survey *pxlSensorOnLadder = (St_Survey *) GetDataBase("Geometry/pxl/pxlSensorOnLadder");
122  if (! pxlSensorOnLadder) {LOG_WARN << "pxlSensorOnLadder has not been found" << endm; return kStErr;}
123  pxlSensorOnLadder->Print(0,1);
124 
125  Survey_st *tables[7] = {idsOnTpc->GetTable(), pstOnIds->GetTable(), pxlOnPst->GetTable(), pxlHalfOnPxl->GetTable(),
126  pxlSectorOnHalf->GetTable(), pxlLadderOnSector->GetTable(), pxlSensorOnLadder->GetTable()
127  };
128 
129  mPxlDb->setGeoHMatrices(tables);
130 
131  // set status tables
132  St_pxlSensorStatus *sensorStatus = (St_pxlSensorStatus *)GetDataBase("Calibrations/pxl/pxlSensorStatus");
133  if (sensorStatus) mPxlDb->setSensorStatus(sensorStatus->GetTable());
134  else {LOG_WARN << " no pxl sensor status table " << endm; return kStErr;}
135  sensorStatus->Print(0,1);
136 
137  if(readAllRowColumnStatus) // old method
138  {
139  St_pxlRowColumnStatus *rowColumnStatus = (St_pxlRowColumnStatus *)GetDataBase("Calibrations/pxl/pxlRowColumnStatus");
140  if (rowColumnStatus) mPxlDb->setRowColumnStatus(rowColumnStatus->GetTable());
141  else {LOG_WARN << " no pxl row column status table " << endm; return kStErr;}
142  if(Debug()) rowColumnStatus->Print(0,1);
143  }
144  else
145  {
146  St_pxlBadRowColumns *badRowColumns = (St_pxlBadRowColumns *)GetDataBase("Calibrations/pxl/pxlBadRowColumns");
147  if (badRowColumns) mPxlDb->setBadRowColumns(badRowColumns->GetTable());
148  else {LOG_WARN << " no pxl bad row columns table " << endm; return kStErr;}
149  if(Debug()) badRowColumns->Print(0,1);
150  }
151 
152  St_pxlHotPixels *hotPixels = (St_pxlHotPixels *)GetDataBase("Calibrations/pxl/pxlHotPixels");
153  if (hotPixels) mPxlDb->setHotPixels(hotPixels->GetTable());
154  else {LOG_WARN << " no pxl hot pixels table " << endm; return kStErr;}
155  if(Debug()) hotPixels->Print(0,1);
156 
157  // set pxlControl
158  St_pxlControl *pxlControl = (St_pxlControl *)GetDataBase("Geometry/pxl/pxlControl");
159  if (pxlControl) {
160  mPxlDb->setPxlControl(pxlControl->GetTable());
161  pxlControl->Print(0,1);
162  }
163  else {
164  LOG_WARN << "InitRun : No access to pxlControl table, abort PXL reconstruction" << endm;
165  return kStErr;
166  }
167 
168  // set pxlDigmapsSim
169  St_pxlDigmapsSim *pxlDigmapsSim = (St_pxlDigmapsSim *)GetDataBase("Geometry/pxl/pxlDigmapsSim");
170  if (pxlDigmapsSim) {
171  mPxlDb->setPxlDigmapsSim(pxlDigmapsSim->GetTable());
172  pxlDigmapsSim->Print(0,1);
173  }
174  else {
175  LOG_WARN << "InitRun : No access to pxlDigmapsSim table, abort PXL reconstruction" << endm;
176  return kStErr;
177  }
178 
179  // set pxlSimPar
180  St_pxlSimPar *pxlSimPar = (St_pxlSimPar *)GetDataBase("Calibrations/pxl/pxlSimPar");
181  if (pxlSimPar) {
182  mPxlDb->setPxlSimPar(pxlSimPar->GetTable());
183  pxlSimPar->Print(0,1);
184  }
185  else {
186  LOG_WARN << "InitRun : No access to pxlSimPar table, abort PXL reconstruction" << endm;
187  return kStErr;
188  }
189 
190  // create and set thin plate functions
191  TDataSet *dbTps = 0;
192  dbTps = GetDataBase("Geometry/pxl/pxlSensorTps");
193  if (!dbTps) {
194  LOG_WARN << "no tps table found in db, or malformed local db config " << endm;
195  return kStErr;
196  }
197 
198  St_pxlSensorTps *datasetTps = 0;
199  datasetTps = (St_pxlSensorTps *) dbTps->Find("pxlSensorTps");
200  if (datasetTps) {
201  mPxlDb->setThinPlateSpline(datasetTps->GetTable());
202  if(Debug()) datasetTps->Print(0,1);
203  }
204  else {
205  LOG_WARN << "ERROR: dataset does not contain tps table" << endm;
206  return kStErr;
207  }
208 
209  if ( GetDebug() >= 2)
210  mPxlDb->Print();
211 
212  mReady = kStOK;
213 
214  return kStOK;
215 }
216 //_____________________________________________________________________________
218 {
219  return mReady;
220 }
void setThinPlateSpline(pxlSensorTps_st *pxlSensorTps)
create sensor thin plate spline functions and set their parameters
Definition: StPxlDb.cxx:193
void setGeoHMatrices(Survey_st **tables)
set geoHMatrix parameters with parameters from Survey_st tables
Definition: StPxlDb.cxx:87
Definition: Stypes.h:40
Definition: Stypes.h:44
Definition: Stypes.h:41
virtual TDataSet * Find(const char *path) const
Definition: TDataSet.cxx:362