StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StTpcDbMaker.cxx
1 /***************************************************************************
2  *
3  * $Id: StTpcDbMaker.cxx,v 1.78 2021/03/26 20:26:48 fisyak Exp $
4  *
5  * Author: David Hardtke
6  ***************************************************************************
7  *
8  * Description:
9  *This make initializes and controls the TPC interface to the database
10  *
11  ***************************************************************************
12  *
13  * $Log: StTpcDbMaker.cxx,v $
14  * Revision 1.78 2021/03/26 20:26:48 fisyak
15  * Synchronize with TFG version, new schema for Inner Sector alignment (thank to Hongwei)
16  *
17  * Revision 1.77 2019/04/22 20:47:15 genevb
18  * Introducing codes for AbortGapCleaning distortion corrections
19  *
20  * Revision 1.76 2018/12/06 19:30:59 genevb
21  * Check on StMagUtilities instance from StTpcDb instead of global
22  *
23  * Revision 1.75 2018/12/05 18:12:09 genevb
24  * Use NoReset attribute to prevent reinstantiation of StMagUtilities
25  *
26  * Revision 1.74 2018/07/06 22:13:16 smirnovd
27  * [Cosmetic] Remove unused variables and commented code
28  *
29  * Revision 1.71 2018/06/21 01:47:18 perev
30  * iTPCheckIn
31  *
32  * Revision 1.67.2.1 2018/02/16 22:14:59 perev
33  * iTPC
34  * Revision 1.70 2018/06/08 18:18:37 genevb
35  * Introduce padrow 40 correction for iTPC GridLeak Wall, reduce includes dependencies
36  *
37  * Revision 1.69 2018/04/30 23:18:11 smirnovd
38  * [Cosmetic] Minor changes in various files
39  *
40  * Revision 1.65 2017/01/30 17:54:18 fisyak
41  * Remove dependce on StEvent
42  *
43  * Revision 1.64 2017/01/06 22:30:45 genevb
44  * Introduce FullGridLeak distortion correction
45  *
46  * Revision 1.63 2015/05/21 21:48:22 fisyak
47  * Fix array out of bound, comment out tpcGlobalPosition field dependence
48  *
49  * Revision 1.62 2014/06/26 21:32:57 fisyak
50  * New Tpc Alignment, v632
51  *
52  * Revision 1.61 2012/09/17 19:39:44 fisyak
53  * Add rotation for Half Tpc's
54  *
55  * Revision 1.60 2011/08/23 22:14:24 genevb
56  * Introduce sector alignment distortion corrections
57  *
58  * Revision 1.59 2011/01/18 14:39:43 fisyak
59  * Clean up TpcDb interfaces and Tpc coordinate transformation
60  *
61  * Revision 1.58 2010/10/28 19:08:43 genevb
62  * Introduce GG Voltage Error switch
63  *
64  * Revision 1.57 2010/09/01 21:11:32 fisyak
65  * Use Mag.field flavor besides simu flag
66  *
67  * Revision 1.56 2010/05/27 20:46:25 genevb
68  * Allow discontinued use of FullMagF geometry flavors, now just use ofl with appropriate timestamp
69  *
70  * Revision 1.55 2010/05/27 19:14:26 fisyak
71  * Take out flavoring by 'sim' for tpcGlobalPosition,tpcSectorPosition and starClockOnl tables. remove usage tpcISTimeOffsets and tpcOSTimeOffsets tables
72  *
73  * Revision 1.54 2010/03/18 14:40:47 fisyak
74  * back to 3 parameter constration of StMagUtilities
75  *
76  * Revision 1.53 2010/03/17 15:53:15 fisyak
77  * Move StTpcdEdxCorrection to StdEdxY2Maker to avoid dependence of StTpcDb on StDetectorDbMaker
78  *
79  * Revision 1.52 2010/03/15 23:29:47 fisyak
80  * switch from St_tpcAnodeHVC => St_tpcAnodeHVavgC
81  *
82  * Revision 1.51 2010/01/26 21:04:42 fisyak
83  * Add new dE/dx calibration tables: TpcRowQ, tpcMethaneIn, tpcWaterOut, TpcZDC
84  *
85  * Revision 1.50 2009/12/07 23:44:58 fisyak
86  * Drop coordinate transformation for fortran, remove TpcHitErr
87  *
88  * Revision 1.49 2009/11/23 16:50:27 fisyak
89  * St_tpcAnodeHVavgC => St_tpcAnodeHVC, comment out exported for fortran coordinate transformations
90  *
91  * Revision 1.48 2009/11/06 13:41:31 fisyak
92  * Revert the change done 11/03/09
93  *
94  * Revision 1.47 2009/11/02 17:31:41 fisyak
95  * use directly field from StarMagField, replace St_tpcGainC and St_tpcT0C by St_tpcPadGainT0C, add remove defaults in coordinate transformations
96  *
97  * Revision 1.46 2009/08/11 20:38:04 genevb
98  * slightly more detailed message
99  *
100  * Revision 1.45 2009/05/01 19:09:23 fisyak
101  * StTpcDbMaker::Make is aware about TPC trips and generagte EoF when this happenss
102  *
103  * Revision 1.44 2008/09/10 15:46:37 fisyak
104  * Recalculate Tpc drift velocity once per event, avoid expensive conversion to unix time
105  *
106  * Revision 1.43 2008/08/01 14:28:34 fisyak
107  * Add new getT0, clean up
108  *
109  * Revision 1.42 2008/07/10 20:25:31 fisyak
110  * Warn of
111  *
112  * Revision 1.41 2007/12/28 00:30:06 fine
113  * Add a function to calculate the tpc coord transfoirmation in one step
114  *
115  * Revision 1.40 2007/08/04 00:38:04 jeromel
116  * SL4 issue: Removal of the inline func, moved to class implementation.
117  * Symbols may otherwise be hidden.
118  *
119  * Revision 1.39 2007/07/12 20:21:09 fisyak
120  * Drift velocity depends on TPC half, use online RHIC clock
121  *
122  * Revision 1.38 2007/04/28 17:57:19 perev
123  * Redundant StChain.h removed
124  *
125  * Revision 1.37 2007/03/21 17:27:02 fisyak
126  * use TGeoHMatrix, change mode for switching drift velocities
127  *
128  * Revision 1.36 2006/02/27 19:20:53 fisyak
129  * Set simu flag for tpcISTimeOffsets and tpcOSTimeOffsets tables
130  *
131  * Revision 1.35 2005/03/30 17:56:59 fisyak
132  * Fix a bug with flavor handling, StTpcDb has to be instantiated after setting flavor
133  *
134  * Revision 1.34 2004/10/27 21:45:13 fisyak
135  * Add debug print for tables Validities, add access to ExB correction
136  *
137  * Revision 1.33 2004/06/05 23:38:22 fisyak
138  * Add more chairs for TPC Db parameters
139  *
140  * Revision 1.32 2004/05/03 23:29:28 perev
141  * WarnOff
142  *
143  * Revision 1.31 2003/04/10 21:30:59 hardtke
144  * Allow multiple InitRun calls
145  *
146  * Revision 1.30 2003/01/12 20:38:23 jeromel
147  * fabs() not abs() for doube
148  *
149  * Revision 1.29 2002/04/02 00:16:31 hardtke
150  * New class that gets hit errors from database
151  *
152  * Revision 1.28 2002/02/12 22:50:35 hardtke
153  * separate geometrical tpc rotation from field twist
154  *
155  * Revision 1.27 2002/02/05 22:21:08 hardtke
156  * Move Init code to InitRun
157  *
158  * Revision 1.26 2002/01/03 00:01:09 hardtke
159  * Add switches for type of drift velocity data (i.e. laser vs. t0 analysis). Default to use either.
160  *
161  * Revision 1.25 2001/10/25 22:59:36 hardtke
162  * Add function tpc_localsector_to_local
163  *
164  * Revision 1.24 2001/10/24 21:36:20 hardtke
165  * Add sim flavor option
166  *
167  * Revision 1.23 2001/07/27 23:52:33 hardtke
168  * use Global (magnet) coordinates
169  *
170  * Revision 1.22 2001/06/21 16:27:52 perev
171  * two error matrix transformation methods added
172  *
173  * Revision 1.21 2001/06/19 23:07:13 hardtke
174  * Restore to old functionality using Tpc Local Coordinates
175  *
176  * Revision 1.20 2001/04/19 19:52:48 hardtke
177  * add tpc_pad_time_offset function and add ifdef for static arrays
178  *
179  * Revision 1.19 2000/11/14 22:00:06 genevb
180  * Switched several functions from float to double
181  *
182  * Revision 1.18 2000/08/09 14:54:54 hardtke
183  * Add Clear option, set trigger table pointer to 0 after each event
184  *
185  * Revision 1.17 2000/08/08 19:15:23 hardtke
186  * use correct trigger time offset in case of laser
187  *
188  * Revision 1.16 2000/07/06 21:37:34 hardtke
189  * speed up tpc_pad_to_x function
190  *
191  * Revision 1.15 2000/05/31 19:50:16 hardtke
192  * speed up tpc_time_to_z and tpc_z_to_time by factor of 5
193  *
194  * Revision 1.14 2000/04/11 16:06:26 hardtke
195  * improve speed of tpc_row_par and tpc_global_to_sector
196  *
197  * Revision 1.13 2000/02/24 18:21:51 hardtke
198  * re-define drift distance as central membrane to gating grid
199  *
200  * Revision 1.12 2000/02/23 22:21:09 hardtke
201  * add tpc_global_to_local_p
202  *
203  * Revision 1.11 2000/02/23 21:03:17 hardtke
204  * fix tpc_row_par -- causing tpt problems
205  *
206  * Revision 1.10 2000/02/23 15:09:57 hardtke
207  * move tpg_detector and tpg_pad_plane from .const to .data
208  *
209  * Revision 1.9 2000/02/22 19:40:30 hardtke
210  * fix tpc_row_par to give expected results
211  *
212  * Revision 1.8 2000/02/17 19:43:20 hardtke
213  * fixes to tpc functions
214  *
215  * Revision 1.7 2000/02/10 00:29:09 hardtke
216  * Add tpg functions to StTpcDbMaker, fix a few bugs
217  *
218  * Revision 1.6 2000/01/11 15:49:53 hardtke
219  * get Electronics table from Calibrations database, Fix error messages
220  *
221  * Revision 1.5 1999/12/16 22:00:53 hardtke
222  * add CVS tags
223  *
224  **************************************************************************/
225 
226 #include <assert.h>
227 #include "StTpcDbMaker.h"
228 #include "StDbUtilities/StCoordinates.hh"
229 #include "StDbUtilities/StTpcPadCoordinate.hh"
230 #include "StDbUtilities/StMagUtilities.h"
231 #include "StarMagField.h"
232 #include "math_constants.h"
233 #include "StDetectorDbMaker/StDetectorDbTpcRDOMasks.h"
234 #include "StDetectorDbMaker/StDetectorDbMagnet.h"
235 #include "StDetectorDbMaker/St_tpcAnodeHVavgC.h"
236 #include "StDetectorDbMaker/St_tpcChargeEventC.h"
237 #if ROOT_VERSION_CODE < 331013
238 #include "TCL.h"
239 #else
240 #include "TCernLib.h"
241 #endif
242 #include "TEnv.h"
243 ClassImp(StTpcDbMaker)
244 //_____________________________________________________________________________
245 Int_t StTpcDbMaker::InitRun(int runnumber){
246  static Bool_t Done = kFALSE;
247  if (Done) return kStOK;
248  Done = kTRUE;
249  Int_t iNewTpcAlignment = 0;
250  if (GetDateTime().GetYear() >= 2013) {
251  iNewTpcAlignment = 1;
252  }
253  Int_t iNewTpcAlignmentOld = gEnv->GetValue("NewTpcAlignment",0);
254  if (iNewTpcAlignment != iNewTpcAlignmentOld) {
255  gMessMgr->QAInfo() << "ReSet environment NewTpcAlignment (year >= 2013) from " << iNewTpcAlignmentOld << " to " << iNewTpcAlignment << endm;
256  gEnv->SetValue("NewTpcAlignment", iNewTpcAlignment);
257  }
258 
259  // Create Needed Tables:
260  if (! IAttr("Simu")) {
261  Float_t gFactor = StarMagField::Instance()->GetFactor();
262  // Set Table Flavors
263  if (gFactor<-0.8) {
264  gMessMgr->Info() << "StTpcDbMaker::Full Reverse Field Twist Parameters. If this is an embedding run, you should not use it." << endm;
265  SetFlavor("ofl+TFG+FullMagFNegative","tpcGlobalPosition");
266  }
267  else if (gFactor<-0.2) {
268  gMessMgr->Info() << "StTpcDbMaker::Half Reverse Field Twist Parameters. If this is an embedding run, you should not use it." << endm;
269  SetFlavor("ofl+TFG+HalfMagFNegative","tpcGlobalPosition");
270  }
271  else if (gFactor<0.2) {
272  gMessMgr->Info() << "StTpcDbMaker::Zero Field Twist Parameters. If this is an embedding run, you should not use it." << endm;
273  SetFlavor("ofl+TFG+ZeroMagF","tpcGlobalPosition");
274  }
275  else if (gFactor<0.8) {
276  gMessMgr->Info() << "StTpcDbMaker::Half Forward Field Twist Parameters. If this is an embedding run, you should not use it." << endm;
277  SetFlavor("ofl+TFG+HalfMagFPositive","tpcGlobalPosition");
278  }
279  else if (gFactor<1.2) {
280  gMessMgr->Info() << "StTpcDbMaker::Full Forward Field Twist Parameters. If this is an embedding run, you should not use it." << endm;
281  SetFlavor("ofl+TFG+FullMagFPositive","tpcGlobalPosition");
282  }
283  }
284  if (IAttr("useLDV")) {
285  SetFlavor("laserDV","tpcDriftVelocity");
286  gMessMgr->Info() << "StTpcDbMaker::Using drift velocity from laser analysis" << endm;
287  } else if (IAttr("useNewLDV")) {
288  SetFlavor("NewlaserDV","tpcDriftVelocity");
289  gMessMgr->Info() << "StTpcDbMaker::Using drift velocity from New laser analysis" << endm;
290  } else if (IAttr("useCDV")) {
291  SetFlavor("ofl+TFG","tpcDriftVelocity");
292  gMessMgr->Info() << "StTpcDbMaker::Using drift velocity from T0 analysis" << endm;
293  } else {
294  SetFlavor("ofl+TFG+laserDV","tpcDriftVelocity");
295  gMessMgr->Info() << "StTpcDbMaker::Using any drift velocity" << endm;
296  }
297  StTpcDb::instance()->SetDriftVelocity();
298 
299  if (IAttr("ExB")) {
300  // Backward compatibility preserved.
301  Int_t mask=1; // Al Saulys request
302  if ( IAttr("EB1") ){ // Do nothing (i.e. bit 1 at 0)
303  } else if ( IAttr("EB2") ){ // Force bit 1 at 1 regardless
304  mask = mask | 2;
305  } else {
306  if(IAttr("OldRuns")) mask = mask | 2 ; // Jim Thomas request
307  }
308  // Other options introduced in October 2001 for distortion corrections
309  // studies and year1 re-production. Those are OR additive to the mask.
310  //(void) printf("StBFChain:: Options list : %d %d %d %d %d %d %d %d\n",
311  // kPadrow13,kTwist,kClock,kMembrane,kEndcap,
312  // kIFCShift,kSpaceCharge,kSpaceChargeR2);
313  if( IAttr("OBmap") ) mask |= ( kBMap << 1);
314  if( IAttr("OPr13") ) mask |= ( kPadrow13 << 1);
315  if( IAttr("OPr40") ) mask |= ( kPadrow40 << 1);
316  if( IAttr("OTwist") ) mask |= ( kTwist << 1);
317  if( IAttr("OClock") ) mask |= ( kClock << 1);
318  if( IAttr("OCentm") ) mask |= ( kMembrane << 1);
319  if( IAttr("OECap") ) mask |= ( kEndcap << 1);
320  if( IAttr("OIFC") ) mask |= ( kIFCShift << 1);
321  if( IAttr("OSpaceZ") ) mask |= ( kSpaceCharge << 1);
322  if( IAttr("OSpaceZ2") ) mask |= ( kSpaceChargeR2 << 1);
323  if( IAttr("OSpaceFXT") ) mask |= ( kSpaceChargeFXT << 1);
324  if( IAttr("OShortR") ) mask |= ( kShortedRing << 1);
325  if( IAttr("OBMap2d") ) mask |= ( kFast2DBMap << 1);
326  if( IAttr("OGridLeak") ) mask |= ( kGridLeak << 1);
327  if( IAttr("OGridLeak3D") ) mask |= ( k3DGridLeak << 1);
328  if( IAttr("OGridLeakFull")) mask |= ( kFullGridLeak << 1);
329  if( IAttr("OGGVoltErr") ) mask |= ( kGGVoltError << 1);
330  if( IAttr("OSectorAlign") ) mask |= ( kSectorAlign << 1);
331  if( IAttr("ODistoSmear") ) mask |= ( kDistoSmearing << 1);
332  if( IAttr("OAbortGap") ) mask |= ( kAbortGap << 1);
333  LOG_QA << "Instantiate ExB The option passed will be " << Form("%d 0x%X\n",mask,mask) << endm;
334  // option handling needs some clean up, but right now we stay compatible
335  Int_t option = (mask & 0x7FFFFFFE) >> 1;
336 #ifndef __NEW_MagUtilities__
337  new StMagUtilities(gStTpcDb, GetDataBase("RunLog"), option);
338 #else
339  new StMagUtilities(gStTpcDb, option);
340 #endif
341  }
342  StTpcDb::instance()->SetTpcRotations();
343  return kStOK;
344 }
345 //_____________________________________________________________________________
347  // check that TPC is tripped
348  if (St_tpcAnodeHVavgC::instance()->tripped()) {
349  gMessMgr->Info() << "StTpcDbMaker::TPC has tripped - declaring EOF to avoid possibly bad data" << endm;
350  return kStEOF;
351  }
352  StTpcDb::instance()->SetDriftVelocity();
353 #if 0
354  if (IAttr("laserIT")) {
355  St_trgTimeOffsetC::instance()->SetLaser(kFALSE);
356  StEvent* pEvent = dynamic_cast<StEvent*> (GetInputDS("StEvent"));
357  if (pEvent) {
358  const StTriggerIdCollection* trig = pEvent->triggerIdCollection();
359  if (trig) {
360  const StTriggerId *nominal = trig->nominal();
361  if (nominal) {
362  Int_t TriggerId = 0;
363  StTpcDb::instance()->SetTriggerId(TriggerId);
364  static Int_t goodIds[2] = {9200,9201}; // Laser trigger IDs
365  for (Int_t i = 0; i < 2; i++) {
366  if (nominal->isTrigger(goodIds[i])) {TriggerId = goodIds[i]; break;}
367  }
368  if (TriggerId) {
369  St_trgTimeOffsetC::instance()->SetLaser(kTRUE);
370  StTpcDb::instance()->SetTriggerId(TriggerId);
371  }
372  }
373  }
374  if (IAttr("OAbortGap")) {
375  StTriggerData* trg = pEvent->triggerData();
376  if (trg) St_tpcChargeEventC::instance()->findChargeTimes(trg->bunchCounter());
377  }
378  }
379  if (! St_trgTimeOffsetC::instance()->IsLaser()) return kStSkip;
380  }
381 #endif
382  // SetTpcRotations();
383  return kStOK;
384 }
385 
virtual Int_t Make()
Collection of trigger ids as stored in StEvent.
Definition: Stypes.h:49
Definition: Stypes.h:43
Definition: Stypes.h:40