StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StTpcDb.h
1 /***************************************************************************
2  *
3  * $Id: StTpcDb.h,v 1.46 2021/03/26 20:26:48 fisyak Exp $
4  *
5  * Author: David Hardtke
6  ***************************************************************************
7  *
8  * Description: This is the interface between the database and the offline
9  * TPC software. This classes takes care of the annoying
10  * calls to the root infrastucture, packages and manipulates
11  * the data, and returns the data to the user via simple
12  * interface classes.
13  *
14  ***************************************************************************
15  *
16  * $Log: StTpcDb.h,v $
17  * Revision 1.46 2021/03/26 20:26:48 fisyak
18  * Synchronize with TFG version, new schema for Inner Sector alignment (thank to Hongwei)
19  *
20  * Revision 1.44 2018/06/21 01:47:16 perev
21  * iTPCheckIn
22  *
23  * Revision 1.41.10.1 2018/02/16 22:14:59 perev
24  * iTPC
25  * Revision 1.43 2018/06/07 04:30:35 genevb
26  * Remove unnecessary dependence on StMagUtilities.h
27  *
28  * Revision 1.42 2018/04/11 02:43:22 smirnovd
29  * Enable TPC/iTPC switch via St_tpcPadConfig
30  *
31  * This is accomplished by substituting St_tpcPadPlanes with St_tpcPadConfig.
32  * A sector ID is passed to St_tpcPadConfig in order to extract parameters for
33  * either TPC or iTPC
34  *
35  * Revision 1.41 2014/06/27 14:04:25 fisyak
36  * Add env. NewTpcAlignment to switch between new and old scheme
37  *
38  * Revision 1.40 2014/06/26 21:32:57 fisyak
39  * New Tpc Alignment, v632
40  *
41  * Revision 1.39 2012/09/17 19:39:44 fisyak
42  * Add rotation for Half Tpc's
43  *
44  * Revision 1.38 2012/05/03 23:56:48 fisyak
45  * Set interpolation for one week only, fix sign of interpolation (thanks Gene), add TriggerId
46  *
47  * Revision 1.37 2011/07/21 16:48:53 fisyak
48  * New schema for Sub Sector Alginement: SuperSectror position (defined by inner sub sector) and Outer sector position wrt SuperSectror position
49  *
50  * Revision 1.36 2011/01/18 14:39:43 fisyak
51  * Clean up TpcDb interfaces and Tpc coordinate transformation
52  *
53  * Revision 1.35 2010/05/27 19:14:26 fisyak
54  * Take out flavoring by 'sim' for tpcGlobalPosition,tpcSectorPosition and starClockOnl tables. remove usage tpcISTimeOffsets and tpcOSTimeOffsets tables
55  *
56  * Revision 1.34 2009/12/07 23:44:58 fisyak
57  * Drop coordinate transformation for fortran, remove TpcHitErr
58  *
59  * Revision 1.33 2009/11/02 17:31:41 fisyak
60  * use directly field from StarMagField, replace St_tpcGainC and St_tpcT0C by St_tpcPadGainT0C, add remove defaults in coordinate transformations
61  *
62  * Revision 1.32 2009/03/16 14:13:31 fisyak
63  * Use StDetectorDb chairs for TpcGlobalPosition and TpcSectorPosition
64  *
65  * Revision 1.31 2008/09/10 15:46:36 fisyak
66  * Recalculate Tpc drift velocity once per event, avoid expensive conversion to unix time
67  *
68  * Revision 1.30 2008/08/01 14:28:25 fisyak
69  * Add new getT0, clean up
70  *
71  * Revision 1.29 2007/08/12 15:06:30 fisyak
72  * Use separated East/West drift velocities only >= 2007, for back compartibility
73  *
74  * Revision 1.28 2007/07/12 20:21:09 fisyak
75  * Drift velocity depends on TPC half, use online RHIC clock
76  *
77  * Revision 1.27 2007/03/21 17:27:01 fisyak
78  * use TGeoHMatrix, change mode for switching drift velocities
79  *
80  * Revision 1.26 2004/10/27 21:44:28 fisyak
81  * Add debug print for tables Validities, add access to ExB correction
82  *
83  * Revision 1.25 2004/02/23 00:35:00 fisyak
84  * Add access to tpcPadResponse
85  *
86  * Revision 1.24 2004/01/14 22:54:30 fisyak
87  * Add hooks for Pedestal and tpcGain
88  *
89  * Revision 1.23 2002/04/02 00:16:31 hardtke
90  * New class that gets hit errors from database
91  *
92  * Revision 1.22 2002/02/06 18:39:13 hardtke
93  * Add tpc Field Cage structure
94  *
95  * Revision 1.21 2001/08/14 18:18:03 hardtke
96  * Add sector position structures
97  *
98  * Revision 1.20 2001/05/21 23:25:34 hardtke
99  * Add tpcGlobalPosition to StTpcDb. This includes the global position offset and the rotation w.r.t. the magnet
100  *
101  * Revision 1.19 2000/08/10 18:41:34 hardtke
102  * only look for L0_trigger table once per event -- improves timing
103  *
104  * Revision 1.18 2000/08/09 14:54:54 hardtke
105  * Add Clear option, set trigger table pointer to 0 after each event
106  *
107  * Revision 1.17 2000/08/08 19:15:23 hardtke
108  * use correct trigger time offset in case of laser
109  *
110  * Revision 1.16 2000/05/11 17:17:27 hardtke
111  * make trigger time offset available -- currently NOT different for beam and laser events
112  *
113  * Revision 1.15 2000/03/27 21:21:22 fine
114  * Adjusted to ROOT 2.24
115  *
116  * Revision 1.14 2000/02/10 00:29:09 hardtke
117  * Add tpg functions to StTpcDbMaker, fix a few bugs
118  *
119  * Revision 1.13 2000/01/25 16:01:10 fisyak
120  * Devorce with StAF
121  *
122  * Revision 1.12 2000/01/11 15:49:52 hardtke
123  * get Electronics table from Calibrations database, Fix error messages
124  *
125  * Revision 1.11 1999/12/16 22:00:53 hardtke
126  * add CVS tags
127  *
128  **************************************************************************/
129 #ifndef ClassStTpcDb
130 #define ClassStTpcDb
131 
133 // //
134 // StTpcDb //
135 // //
136 // This class implements to offline interface to the STAR database //
137 // //
139 
140 #include "StMessMgr.h"
141 #include "StEnumerations.h"
142 #include "StDetectorDbMaker/St_tpcPadConfigC.h"
143 #include "StDetectorDbMaker/St_tpcWirePlanesC.h"
144 #include "StDetectorDbMaker/St_tpcDimensionsC.h"
145 #include "StDetectorDbMaker/St_tpcElectronicsC.h"
146 #include "StDetectorDbMaker/St_tpcSlowControlSimC.h"
147 #include "StDetectorDbMaker/St_tpcGlobalPositionC.h"
148 #include "StDetectorDbMaker/St_tpcSectorPositionC.h"
149 #include "StDetectorDbMaker/St_tpcFieldCageC.h"
150 #include "StDetectorDbMaker/St_tpcPedestalC.h"
151 #include "StDetectorDbMaker/St_tpcPadResponseC.h"
152 #include "StDetectorDbMaker/St_tpcPadGainT0BC.h"
153 #include "StDbUtilities/StMagUtilities.h"
154 #include "StDetectorDbMaker/St_trgTimeOffsetC.h"
155 #include "TGeoMatrix.h"
156 #include "TString.h"
157 class StTpcDb;
158 // Global pointers:
159 R__EXTERN StTpcDb* gStTpcDb;
160 class StTpcDb {
161  public:
162  static StTpcDb* instance() {if (! gStTpcDb) new StTpcDb(); return gStTpcDb;}
163  // Glob = Global coordinate
164  // Tpc = Tpc -"- survey
165  // Half = Tpc Half west / east -"- survey
166  // SupS = super sector misalignment(?)
167  // SubS[io] = SubSector[io] misalignment
168  // SecL = sector -"- coordinate (y_p, x_p, DriftDistance - z_p);
169  // Pad = Pad -"- (x_p,y_p,z_p) (Sector12 coordinate system)
170  // Tpc => Global is mTpc2GlobMatrix
171  // Pad => SecL is internal Flip matrix
172  enum ETpcSectorRotationType {kUndefSector =-2,
173  kFlip =-1, // Flip * Subs[io] => SupS
174  kSupS2Tpc = 0, // SupS => Tpc
175  kSupS2Glob = 1, // SupS => Tpc => Glob;
176  kSubSInner2SupS = 2, // Subs[io] => SupS
177  kSubSOuter2SupS = 3, // -"-
178  kSubSInner2Tpc = 4, // (Subs[io] => SupS) => Tpc
179  kSubSOuter2Tpc = 5, // -"-
180  kSubSInner2Glob = 6, // (Subs[io] => SupS => Tpc) => Glob
181  kSubSOuter2Glob = 7, // -"-
182  kPadInner2SupS = 8, // (Pad => SecL) => (SubS[io] => SupS)
183  kPadOuter2SupS = 9, // -"-
184  kPadInner2Tpc =10, // (Pad => SecL) => (SubS[io] => SupS => Tpc)
185  kPadOuter2Tpc =11, // -"-
186  kPadInner2Glob =12, // (Pad => SecL) => (SubS[io] => SupS => Tpc => Glob)
187  kPadOuter2Glob =13, // -"-
188  kTotalTpcSectorRotaions =14};
189  private:
190  Char_t mBeg[1];
191  Int_t m_Debug;
192  TGeoTranslation *mShift[2];
193  TGeoHMatrix *mFlip;
194  TGeoHMatrix *mTpc2GlobMatrix;
195  TGeoHMatrix *mHalf[2];
196  TGeoHMatrix *mTpcSectorRotations[24][kTotalTpcSectorRotaions];
197  Float_t mDriftVel[2];
198  UInt_t mUc;
199  Int_t mTriggerId;
200  Double_t mzGG;
201  Char_t mEnd[1];
202  static Bool_t mOldScheme;
203  private:
204  StTpcDb();
205  public:
206  virtual ~StTpcDb();
207  St_tpcWirePlanesC *WirePlaneGeometry() {return St_tpcWirePlanesC::instance();}
208  St_tpcDimensionsC *Dimensions() {return St_tpcDimensionsC::instance();}
209  St_tpcSlowControlSimC *SlowControlSim() {return St_tpcSlowControlSimC::instance();}
210  St_tpcElectronicsC *Electronics() {return St_tpcElectronicsC::instance();}
211  St_tpcGlobalPositionC *GlobalPosition() {return St_tpcGlobalPositionC::instance();}
212  St_tpcFieldCageC *FieldCage() {return St_tpcFieldCageC::instance();}
213  St_tpcSectorPositionC *SectorPosition() {return St_tpcSectorPositionC::instance();}
214  St_tpcPedestalC *Pedestal() {return St_tpcPedestalC::instance();}
215  St_tpcPadGainT0BC *tpcGain() {return St_tpcPadGainT0BC::instance();}
216  St_tpcPadGainT0BC *tpcT0() {return St_tpcPadGainT0BC::instance();}
217  St_tpcPadResponseC *PadResponse() {return St_tpcPadResponseC::instance();}
218  Float_t triggerTimeOffset() {return 1e-6*(IsLaser() ? St_trgTimeOffsetC::instance()->laserOffset() : St_trgTimeOffsetC::instance()->offset());} // usec
219  Float_t triggerTimeOffsetWest() {return 1e-6*(IsLaser() ? St_trgTimeOffsetC::instance()->laserOffsetW(): 0);} // usec
220  Bool_t IsLaser() {return mTriggerId != 0;}
221  static Bool_t IsOldScheme() {return mOldScheme;}
222  Double_t zGG() {return mzGG;}
223  //small pieces of data:
224  void SetDriftVelocity();
225  Float_t DriftVelocity(Int_t sector=24) {return DriftVelocity(sector, 0);}
226  Float_t DriftVelocity(Int_t sector, Int_t row);
227  void SetTpcRotations();
228  void SetTpc2GlobalMatrix(TGeoHMatrix *m) {SetTpcRotationMatrix(m);}
229  void SetTpcRotationMatrix(TGeoHMatrix *m, Int_t sector = 0, Int_t k = kSupS2Tpc) {
230  if (sector == 0) {if (m) *mTpc2GlobMatrix = *m;}
231  else {if (m) *mTpcSectorRotations[sector-1][k] = *m;}
232  }
233  void SetDebug(Int_t m) {m_Debug = m;}
234  Int_t Debug() {return m_Debug;}
235  void SetTriggerId(Int_t m) {mTriggerId = m;} // Laser Trigger
236  Int_t TriggerId() {return mTriggerId;}
237  const TGeoHMatrix &Flip() const {return *mFlip;}
238  const TGeoHMatrix &TpcHalf(StBeamDirection part) const {return *mHalf[part];}
239  const TGeoTranslation &Shift(StBeamDirection part) const {return *mShift[part];}
240  const TGeoHMatrix &Tpc2GlobalMatrix() const {return *mTpc2GlobMatrix;}
241  const TGeoHMatrix &TpcRot(Int_t sector, Int_t k) const {return *mTpcSectorRotations[sector-1][k];}
242  const TGeoHMatrix &SupS2Tpc(Int_t sector = 1) const {return TpcRot(sector,kSupS2Tpc);}
243  const TGeoHMatrix &SupS2Glob(Int_t sector = 1) const {return TpcRot(sector,kSupS2Glob);}
244  const TGeoHMatrix &SubSInner2SupS(Int_t sector = 1) const {return TpcRot(sector,kSubSInner2SupS);}
245  const TGeoHMatrix &SubSOuter2SupS(Int_t sector = 1) const {return TpcRot(sector,kSubSOuter2SupS);}
246  const TGeoHMatrix &SubSInner2Tpc(Int_t sector = 1) const {return TpcRot(sector,kSubSInner2Tpc);}
247  const TGeoHMatrix &SubSOuter2Tpc(Int_t sector = 1) const {return TpcRot(sector,kSubSOuter2Tpc);}
248  const TGeoHMatrix &SubSInner2Glob(Int_t sector = 1) const {return TpcRot(sector,kSubSInner2Glob);}
249  const TGeoHMatrix &SubSOuter2Glob(Int_t sector = 1) const {return TpcRot(sector,kSubSOuter2Glob);}
250 
251  const TGeoHMatrix &PadInner2SupS(Int_t sector = 1) const {return TpcRot(sector,kPadInner2SupS);}
252  const TGeoHMatrix &PadOuter2SupS(Int_t sector = 1) const {return TpcRot(sector,kPadOuter2SupS);}
253  const TGeoHMatrix &PadInner2Tpc(Int_t sector = 1) const {return TpcRot(sector,kPadInner2Tpc);}
254  const TGeoHMatrix &PadOuter2Tpc(Int_t sector = 1) const {return TpcRot(sector,kPadOuter2Tpc);}
255  const TGeoHMatrix &PadInner2Glob(Int_t sector = 1) const {return TpcRot(sector,kPadInner2Glob);}
256  const TGeoHMatrix &PadOuter2Glob(Int_t sector = 1) const {return TpcRot(sector,kPadOuter2Glob);}
257 
258  const TGeoHMatrix &SubS2SupS(Int_t sector = 1, Int_t row = 1) const {Int_t k = (row <= St_tpcPadConfigC::instance()->innerPadRows(sector)) ? kSubSInner2SupS : kSubSOuter2SupS; return TpcRot(sector,k);}
259  const TGeoHMatrix &SubS2Tpc(Int_t sector = 1, Int_t row = 1) const {Int_t k = (row <= St_tpcPadConfigC::instance()->innerPadRows(sector)) ? kSubSInner2Tpc : kSubSOuter2Tpc; return TpcRot(sector,k);}
260  const TGeoHMatrix &SubS2Glob(Int_t sector = 1, Int_t row = 1) const {Int_t k = (row <= St_tpcPadConfigC::instance()->innerPadRows(sector)) ? kSubSInner2Glob: kSubSOuter2Glob; return TpcRot(sector,k);}
261 
262  const TGeoHMatrix &Pad2SupS(Int_t sector = 1, Int_t row = 1) const {Int_t k = (row <= St_tpcPadConfigC::instance()->innerPadRows(sector)) ? kPadInner2SupS: kPadOuter2SupS; return TpcRot(sector,k);}
263  const TGeoHMatrix &Pad2Tpc(Int_t sector = 1, Int_t row = 1) const {Int_t k = (row <= St_tpcPadConfigC::instance()->innerPadRows(sector)) ? kPadInner2Tpc: kPadOuter2Tpc; return TpcRot(sector,k);}
264  const TGeoHMatrix &Pad2Glob(Int_t sector = 1, Int_t row = 1) const {Int_t k = (row <= St_tpcPadConfigC::instance()->innerPadRows(sector)) ? kPadInner2Glob: kPadOuter2Glob; return TpcRot(sector,k);}
265  ClassDef(StTpcDb,0)
266 };
267 #endif