StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StFmsDbMaker.h
1 /***************************************************************************
2  * $Id: StFmsDbMaker.h,v 1.23 2018/03/09 21:36:18 smirnovd Exp $
3  * \author: akio ogawa
4  ***************************************************************************
5  *
6  * Description: FMS DB access Maker
7  * Please visit http://drupal.star.bnl.gov/STAR/subsys/fms/database/stfmsdbmaker for more information
8  *
9  ***************************************************************************
10  *
11  * $Log: StFmsDbMaker.h,v $
12  * Revision 1.23 2018/03/09 21:36:18 smirnovd
13  * Remove declared but undefined function
14  *
15  * Revision 1.22 2018/02/07 14:45:15 akio
16  * Update for faster DB tables
17  *
18  * Revision 1.21 2017/11/02 13:09:25 akio
19  * Adding getCorrectedAdc and fix a memory leak
20  *
21  * Revision 1.20 2017/09/28 17:00:48 akio
22  * adding BitShiftGain
23  *
24  * Revision 1.19 2017/09/15 15:43:54 akio
25  * Adding readGainCorrFromText()
26  *
27  * Revision 1.18 2017/08/14 16:08:55 smirnovd
28  * StFmsDbMaker: Declare member functions const
29  *
30  * These methods don't change the object by design
31  *
32  * Revision 1.17 2017/08/14 16:08:43 smirnovd
33  * [Cosmetic] Remove StRoot/ from include path
34  *
35  * $STAR/StRoot is already in the default path search
36  *
37  * Revision 1.16 2017/05/03 17:14:01 akio
38  * Adding Sigma and Valley for Fps/Fpost
39  *
40  * Revision 1.15 2017/01/30 17:50:16 akio
41  * adding Fpost
42  *
43  * Revision 1.14 2016/11/22 18:23:32 akio
44  * added getLorentzVector to take into account beamline angles/offsets for pt calc
45  *
46  * Revision 1.13 2016/06/08 19:58:03 akio
47  * Applying Coverity report
48  *
49  * Revision 1.12 2015/11/10 19:06:02 akio
50  * Adding TimeDepCorr for LED gain correction based on event#
51  *
52  * Revision 1.11 2015/10/20 19:49:28 akio
53  * Fixing distanceFromEdge()
54  * Adding readRecParamFromFile()
55  *
56  * Revision 1.10 2015/09/23 17:34:01 akio
57  * Adding distanceFromEdge() for fiducial volume cut
58  *
59  * Revision 1.9 2015/09/18 18:34:35 akio
60  * Adding getStarXYZfromColumnRow() to convert from local grid space [cell width unit, not cm]
61  * Adding protection for fmsGain and fmsGainCorrection when table length get shorter and can
62  * overwritten by old values.
63  * Removing some error log
64  *
65  * Revision 1.8 2015/09/02 14:45:14 akio
66  * Adding new functions for un-uniform grid cell positions, switched based on DB fmsPositionModel
67  *
68  * Revision 1.4 2014/08/06 11:43:15 jeromel
69  * Suffix on literals need to be space (later gcc compiler makes it an error) - first wave of fixes
70  *
71  * Revision 1.3 2014/04/24 21:15:04 tpb
72  * Change default name to fmsDb to match BFC
73  *
74  * Revision 1.2 2010/01/11 20:35:30 jgma
75  * Added reversed map and some other minor updates
76  *
77  * Revision 1.1 2009/10/28 16:11:15 jgma
78  * This is the first check in of the code.
79  *
80  **************************************************************************/
81 
82 #ifndef STFMSDBMAKER_H
83 #define STFMSDBMAKER_H
84 
85 #ifndef StMaker_H
86 #include "StMaker.h"
87 #endif
88 #include "StThreeVectorF.hh"
89 #include "StLorentzVectorF.hh"
90 #include "StFmsUtil/StFmsDbConfig.h"
91 
92 struct fmsDetectorPosition_st;
93 struct fmsChannelGeometry_st;
94 struct fmsMap_st;
95 struct fmsPatchPanelMap_st;
96 struct fmsQTMap_st;
97 struct fmsGain_st;
98 struct fmsGainCorrection_st;
99 struct fmsBitShiftGain_st;
100 struct fmsGainB_st;
101 struct fmsGainCorrectionB_st;
102 struct fmsBitShiftGainB_st;
103 struct fmsTimeDepCorr_st;
104 struct fmsRec_st;
105 
106 struct fpsConstant_st;
107 struct fpsChannelGeometry_st;
108 struct fpsSlatId_st;
109 struct fpsPosition_st;
110 struct fpsMap_st;
111 struct fpsGain_st;
112 struct fpsStatus_st;
113 
114 struct fpostConstant_st;
115 struct fpostChannelGeometry_st;
116 struct fpostSlatId_st;
117 struct fpostPosition_st;
118 struct fpostMap_st;
119 struct fpostGain_st;
120 struct fpostStatus_st;
121 
122 class StFmsHit;
123 class StFmsPoint;
124 
125 class StFmsDbMaker : public StMaker {
126  public:
127  StFmsDbMaker(const Char_t *name="fmsDb");
128  virtual ~StFmsDbMaker();
129  virtual Int_t Init();
130  virtual Int_t InitRun(Int_t runNumber);
131  virtual Int_t Make();
132  virtual Int_t Finish();
133  virtual void Clear(const Char_t *opt);
134 
135  void setDebug(Int_t debug);
136 
138  fmsChannelGeometry_st* ChannelGeometry();
139  fmsDetectorPosition_st* DetectorPosition();
140  fmsMap_st* Map();
141  fmsPatchPanelMap_st* PatchPanelMap();
142  fmsQTMap_st* QTMap();
143  fmsGain_st* Gain();
144  fmsGainCorrection_st* GainCorrection();
145  fmsRec_st* RecPar(); //reconstruction related parameters
146  fpsConstant_st* FpsConstant();
147  fpsChannelGeometry_st** FpsChannelGeometry();
148  fpsSlatId_st* FpsSlatId();
149  fpsPosition_st* FpsPosition();
150  fpsMap_st* FpsMap();
151  fpsGain_st* FpsGain();
152  fpostConstant_st* FpostConstant();
153  fpostChannelGeometry_st** FpostChannelGeometry();
154  fpostSlatId_st* FpostSlatId();
155  fpostPosition_st* FpostPosition();
156  fpostMap_st* FpostMap();
157  fpostGain_st* FpostGain();
158 
160  UShort_t maxDetectorId();
161  Int_t detectorId(Int_t ew, Int_t ns, Int_t type);
162  Int_t eastWest(Int_t detectorId);
163  Int_t northSouth(Int_t detectorId);
164  Int_t largeSmall(Int_t detectorId);
165  Int_t type(Int_t detectorId);
166  Int_t nRow(Int_t detectorId);
167  Int_t nColumn(Int_t detectorId);
168  UShort_t maxChannel(Int_t detectorId) const;
169  Int_t getRowNumber(Int_t detectorId, Int_t ch);
170  Int_t getColumnNumber(Int_t detectorId, Int_t ch);
171  Int_t getChannelNumber(Int_t detectorId, Int_t row, Int_t column);
172 
174  StThreeVectorF getDetectorOffset(Int_t detectorId);
175  Float_t getXWidth(Int_t detectorId);
176  Float_t getYWidth(Int_t detectorId);
177  StThreeVectorF getStarXYZ(Int_t detectorId,Float_t FmsX, Float_t FmsY);
178  StThreeVectorF getStarXYZ(Int_t detectorId,Double_t FmsX, Double_t FmsY);
179  StThreeVectorF getStarXYZ(Int_t detectorId,Int_t column, int row);
180  StThreeVectorF getStarXYZfromColumnRow(Int_t detectorId,Float_t column, Float_t row);
183  StThreeVectorF getStarXYZ(Int_t detectorId,Int_t ch);
184  Float_t getPhi(Int_t detectorId,Float_t FmsX, Float_t FmsY);
185  Float_t getEta(Int_t detectorId,Float_t FmsX, Float_t FmsY, Float_t Vertex);
186  StLorentzVectorF getLorentzVector(const StThreeVectorF& xyz, Float_t energy);
187 
188  // Distance(unit is incell space) from edge for given local X/Y [cm] for fiducial volume cut
189  // return negative distance if inside, positive outside
190  // edge: 0=well inside (more than 1 cell)
191  // 1=inner edge
192  // 2=outer edge
193  // 3=between north and south
194  // 4=between small and large
195  // 4=large cell corner
196  Float_t distanceFromEdge(Int_t det,Float_t x, Float_t y, int& edge);
197  Float_t distanceFromEdge(StFmsPoint* point, int& edge);
198  Int_t nCellHole(Int_t det);
199  Int_t nCellCorner(Int_t det);
200 
202  Int_t maxMap();
203  void getMap(Int_t detectorId, Int_t ch, Int_t* qtCrate, Int_t* qtSlot, Int_t* qtChannel);
204  void getReverseMap(Int_t qtCrate, Int_t qtSlot, Int_t qtChannel, Int_t* detectorId, Int_t* ch) const;
205 
207  Int_t maxModule();
208 
210  Int_t maxNS();
211 
213  Int_t maxGain();
214  Int_t maxGainCorrection();
215  Int_t maxBitShiftGain();
216  Float_t getGain(Int_t detectorId, Int_t ch) const;
217  Float_t getGainCorrection(Int_t detectorId, Int_t ch) const;
218  Short_t getBitShiftGain(Int_t detectorId, Int_t ch) const;
219  unsigned short getCorrectedAdc(unsigned short detectorId, unsigned short ch, unsigned short adc) const;
220  unsigned short getCorrectedAdc(StFmsHit* hit) const;
221 
222  void forceUniformGain(float v) {mForceUniformGain=v; }
223  void forceUniformGainCorrection(float v) {mForceUniformGainCorrection=v;}
224  void forceUniformBitShiftGain(short v) {mForceUniformBitShiftGain=v;}
225  void readGainFromText(int v=1) {mReadGainFile=v;}
226  void readGainCorrFromText(int v=1) {mReadGainCorrFile=v;}
227  void readBitShiftGainFromText(int v=1) {mReadBitShiftGainFile=v;}
228 
230  float getTimeDepCorr(int event, int det, int ch); //det = detectorId - 8 (0=largeNoth, 1=largeSouth, 2=smallNorth, 3=smallSouth)
231  //ch=1 to 578
232 
233  //reference to StFmsDbConfig
234  StFmsDbConfig& getRecConfig();
235  void readRecParamFromFile(int v=1){mReadRecParam=v;} // Read fmsrecpar.txt for reconstuction parameters
236 
238  Int_t fpsNQuad();
239  Int_t fpsNLayer();
240  Int_t fpsMaxSlat();
241  Int_t fpsMaxQTaddr();
242  Int_t fpsMaxQTch();
243  Int_t fpsMaxSlatId();
244  Int_t fpsNSlat(int quad, int layer);
245  Int_t fpsSlatId(int quad, int layer, int slat);
246  void fpsQLSfromSlatId(int slatid, int* quad, int* layer, int* slat);
247  void fpsPosition(int slatid, float xyz[3], float dxyz[3]);
248  void fpsPosition(int quad, int layer, int slat, float xyz[3], float dxyz[3]);
249  void fpsQTMap(int slatid, int* QTaddr, int* QTch);
250  Int_t fpsSlatidFromQT(int QTaddr, int QTch);
251  void fpsQLSFromQT(int QTaddr, int QTch, int* quad, int* layer, int* slat);
252  Float_t fpsGain(int slatid);
253  Float_t fpsGain(int quad, int layer, int slat);
254  Float_t fpsMipSigma(int slatid);
255  Float_t fpsMipSigma(int quad, int layer, int slat);
256  Float_t fpsValley(int slatid);
257  Float_t fpsValley(int quad, int layer, int slat);
258  UShort_t fpsStatus(int slatid);
259  UShort_t fpsStatus(int quad, int layer, int slat);
260  Int_t fpsSlatIdFromG2t(int g2tvolid);
261 
263  Int_t fpostNQuad();
264  Int_t fpostNLayer();
265  Int_t fpostMaxSlat();
266  Int_t fpostMaxQTaddr();
267  Int_t fpostMaxQTch();
268  Int_t fpostMaxSlatId();
269  Int_t fpostNSlat(int quad, int layer);
270  Int_t fpostSlatId(int quad, int layer, int slat);
271  void fpostQLSfromSlatId(int slatid, int* quad, int* layer, int* slat);
272  void fpostPosition(int slatid, float xyz[3], float dxyz[3], float * angle);
273  void fpostPosition(int quad, int layer, int slat, float xyz[3], float dxyz[3], float* angle);
274  void fpostQTMap(int slatid, int* QTaddr, int* QTch);
275  Int_t fpostSlatidFromQT(int QTaddr, int QTch);
276  void fpostQLSFromQT(int QTaddr, int QTch, int* quad, int* layer, int* slat);
277  Float_t fpostGain(int slatid);
278  Float_t fpostGain(int quad, int layer, int slat);
279  Float_t fpostMipSigma(int slatid);
280  Float_t fpostMipSigma(int quad, int layer, int slat);
281  Float_t fpostValley(int slatid);
282  Float_t fpostValley(int quad, int layer, int slat);
283  UShort_t fpostStatus(int slatid);
284  UShort_t fpostStatus(int quad, int layer, int slat);
285  Int_t fpostSlatIdFromG2t(int g2tvolid);
286 
288  void dumpFmsChannelGeometry (const Char_t* filename="dumpFmsChannelGeometry.txt");
289  void dumpFmsDetectorPosition(const Char_t* filename="dumpFmsDetectorPosition.txt");
290  void dumpFmsMap (const Char_t* filename="dumpFmsMap.txt");
291  void dumpFmsPatchPanelMap (const Char_t* filename="dumpFmsPatchPanelMap.txt");
292  void dumpFmsQTMap (const Char_t* filename="dumpFmsQTMap.txt");
293  void dumpFmsGain (const Char_t* filename="dumpFmsGain.txt");
294  void dumpFmsGainCorrection (const Char_t* filename="dumpFmsGainCorrection.txt");
295  void dumpFmsBitShiftGain (const Char_t* filename="dumpFmsBitShiftGain.txt");
296  void dumpFmsTimeDepCorr (const Char_t* filename="dumpFmsTimeDepCorr.txt");
297  void dumpFmsRec (const Char_t* filename="dumpFmsRec.txt");
298  void dumpFpsConstant (const Char_t* filename="dumpFpsConstant.txt");
299  void dumpFpsChannelGeometry (const Char_t* filename="dumpFpsChannelGeometry.txt");
300  void dumpFpsSlatId (const Char_t* filename="dumpSlatId.txt");
301  void dumpFpsPosition (const Char_t* filename="dumpFpsPosition.txt");
302  void dumpFpsMap (const Char_t* filename="dumpFpsMap.txt");
303  void dumpFpsGain (const Char_t* filename="dumpFpsGain.txt");
304  void dumpFpsStatus (const Char_t* filename="dumpFpsStatus.txt");
305  void dumpFpostConstant (const Char_t* filename="dumpFpostConstant.txt");
306  void dumpFpostChannelGeometry (const Char_t* filename="dumpFpostChannelGeometry.txt");
307  void dumpFpostSlatId (const Char_t* filename="dumpSlatId.txt");
308  void dumpFpostPosition (const Char_t* filename="dumpFpostPosition.txt");
309  void dumpFpostMap (const Char_t* filename="dumpFpostMap.txt");
310  void dumpFpostGain (const Char_t* filename="dumpFpostGain.txt");
311  void dumpFpostStatus (const Char_t* filename="dumpFpostStatus.txt");
312 
313  private:
314  void deleteArrays();
315  Int_t mDebug=0;
316 
317  fmsChannelGeometry_st *mChannelGeometry=0;
318  UShort_t mMaxDetectorId=0;
319 
320  fmsDetectorPosition_st *mDetectorPosition=0;
321 
322  unsigned int mPositionModel=0;
323 
324  fmsMap_st *mMap=0;
325  fmsMap_st **mmMap=0;
326  Int_t mMaxMap=0;
327  enum {mMaxCrate=8, mMaxSlot=17, mMaxCh=32};
328  Int_t mReverseMapDetectorId[mMaxCrate][mMaxSlot][mMaxCh];
329  Int_t mReverseMapChannel[mMaxCrate][mMaxSlot][mMaxCh];
330 
331  fmsPatchPanelMap_st *mPatchPanelMap=0;
332  Int_t mMaxModule=0;
333 
334  fmsQTMap_st *mQTMap=0;
335  Int_t mMaxNS=0;
336 
337  fmsGain_st *mGain=0;
338  fmsGainB_st *mGainB=0;
339  fmsGain_st **mmGain=0;
340  Int_t mMaxGain=0;
341 
342  fmsGainCorrection_st *mGainCorrection=0;
343  fmsGainCorrectionB_st *mGainCorrectionB=0;
344  fmsGainCorrection_st **mmGainCorrection=0;
345  Int_t mMaxGainCorrection=0;
346 
347  fmsBitShiftGain_st *mBitShiftGain=0;
348  fmsBitShiftGainB_st *mBitShiftGainB=0;
349  fmsBitShiftGain_st **mmBitShiftGain=0;
350  Int_t mMaxBitShiftGain=0;
351 
352  enum {mFmsTimeDepMaxData=20000,mFmsTimeDepMaxTimeSlice=200,mFmsTimeDepMaxDet=4,mFmsTimeDepMaxCh=578};
353  fmsTimeDepCorr_st *mTimeDepCorr=0;
354  int mMaxTimeSlice=0;
355  int mTimeDepEvt[mFmsTimeDepMaxTimeSlice];
356  float mTimeDep[mFmsTimeDepMaxTimeSlice][mFmsTimeDepMaxDet][mFmsTimeDepMaxCh];
357 
358  fmsRec_st *mRecPar=0;
359  Int_t mMaxRecPar=0;
360  StFmsDbConfig& mRecConfig; //reference to StFmsDbConfig singleton, for accessing rec. parameter values by name
361 
362  Float_t mForceUniformGain=0.0;
363  Float_t mForceUniformGainCorrection=0.0;
364  Short_t mForceUniformBitShiftGain=0;
365  Int_t mReadGainFile=0;
366  Int_t mReadGainCorrFile=0;
367  Int_t mReadBitShiftGainFile=0;
368 
369  Int_t mReadRecParam=0;
370 
371  fpsConstant_st* mFpsConstant=0;
372  Int_t mFpsMaxSlatId=0;
373  fpsChannelGeometry_st** mFpsChannelGeometry=0;
374  fpsSlatId_st* mFpsSlatId=0;
375  Int_t*** mFpsReverseSlatId=0;
376  fpsPosition_st* mFpsPosition=0;
377  fpsMap_st* mFpsMap=0;
378  Int_t** mFpsReverseMap=0;
379  fpsGain_st* mFpsGain=0;
380  fpsStatus_st* mFpsStatus=0;
381 
382  fpostConstant_st* mFpostConstant=0;
383  Int_t mFpostMaxSlatId=0;
384  fpostChannelGeometry_st** mFpostChannelGeometry=0;
385  fpostSlatId_st* mFpostSlatId=0;
386  Int_t*** mFpostReverseSlatId=0;
387  fpostPosition_st* mFpostPosition=0;
388  fpostMap_st* mFpostMap=0;
389  Int_t** mFpostReverseMap=0;
390  fpostGain_st* mFpostGain=0;
391  fpostStatus_st* mFpostStatus=0;
392 
393  virtual const Char_t *GetCVS() const {static const Char_t cvs[]="Tag " __DATE__ " " __TIME__ ; return cvs;}
394  ClassDef(StFmsDbMaker,3) //StAF chain virtual base class for Makers
395 };
396 
397 #endif
398 
399 
Int_t detectorId(Int_t ew, Int_t ns, Int_t type)
maximum value of detector Id
Float_t getGainCorrection(Int_t detectorId, Int_t ch) const
get the gain for the channel
Int_t maxMap()
fmsMap related
void readGainCorrFromText(int v=1)
force gain to be read from FmsGain.txt
Definition: StFmsDbMaker.h:226
UShort_t maxDetectorId()
Utility functions related to FMS ChannelGeometry.
virtual Int_t Make()
Float_t getXWidth(Int_t detectorId)
get the offset of the detector
Int_t getChannelNumber(Int_t detectorId, Int_t row, Int_t column)
get the column number for the channel
Int_t maxNS()
fmsQTMap related
virtual Int_t Finish()
void setDebug(Int_t debug)
debug mode, 0 for minimal message, >0 for more debug messages
StThreeVectorF getStarXYZfromColumnRow(Int_t detectorId, Float_t column, Float_t row)
get the STAR frame coordinates from column/row
float getTimeDepCorr(int event, int det, int ch)
force bit shift to be read from FmsBitShiftGain.txt
StThreeVectorF getDetectorOffset(Int_t detectorId)
get the channel number
fmsDetectorPosition_st * DetectorPosition()
getting the whole table
Int_t type(Int_t detectorId)
large or small cells for FMS
StLorentzVectorF getLorentzVector(const StThreeVectorF &xyz, Float_t energy)
get the STAR frame pseudo rapidity from the vertex from local X/Y [cm]
void readBitShiftGainFromText(int v=1)
force gain corr to be read from FmsGainCorr.txt
Definition: StFmsDbMaker.h:227
void forceUniformBitShiftGain(short v)
force gaincorr to be specified value
Definition: StFmsDbMaker.h:224
Int_t largeSmall(Int_t detectorId)
north or south side
Int_t getRowNumber(Int_t detectorId, Int_t ch)
maximum number of channels
Int_t nRow(Int_t detectorId)
type of the detector
StThreeVectorF getStarXYZ(Int_t detectorId, Float_t FmsX, Float_t FmsY)
get the Y width of the cell
Int_t getColumnNumber(Int_t detectorId, Int_t ch)
get the row number for the channel
void dumpFmsChannelGeometry(const Char_t *filename="dumpFmsChannelGeometry.txt")
text dump for debugging
Float_t distanceFromEdge(Int_t det, Float_t x, Float_t y, int &edge)
get 4 vector assuing m=0 and taking beamline from DB
Int_t northSouth(Int_t detectorId)
east or west to the STAR IP
Int_t fpsNQuad()
FPS related.
Short_t getBitShiftGain(Int_t detectorId, Int_t ch) const
get the gain correction for the channel
unsigned short getCorrectedAdc(unsigned short detectorId, unsigned short ch, unsigned short adc) const
get the bit shift gain for the channel
UShort_t maxChannel(Int_t detectorId) const
number of column
Float_t getYWidth(Int_t detectorId)
get the X width of the cell
Int_t fpostNQuad()
FPost related.
Float_t getEta(Int_t detectorId, Float_t FmsX, Float_t FmsY, Float_t Vertex)
get the STAR frame phi angle from from local X/Y [cm]
Int_t eastWest(Int_t detectorId)
convert to detector Id
Int_t maxGain()
fmsGain/GainCorrection/Bitshift related
Float_t getPhi(Int_t detectorId, Float_t FmsX, Float_t FmsY)
get the STAR frame cooridnates for center of the cell
virtual Int_t InitRun(Int_t runNumber)
Int_t nColumn(Int_t detectorId)
number of rows
Int_t maxModule()
fmsPatchPanelMap related
void readGainFromText(int v=1)
force bits hift gain to be specified value
Definition: StFmsDbMaker.h:225
void forceUniformGainCorrection(float v)
force gain to be specified value
Definition: StFmsDbMaker.h:223
fmsChannelGeometry_st * ChannelGeometry()
getting the whole table