00001 /*************************************************************************** 00002 * 00003 * $Id: StTpcDbMaker.cxx,v 1.60 2011/08/23 22:14:24 genevb Exp $ 00004 * 00005 * Author: David Hardtke 00006 *************************************************************************** 00007 * 00008 * Description: 00009 *This make initializes and controls the TPC interface to the database 00010 * 00011 *************************************************************************** 00012 * 00013 * $Log: StTpcDbMaker.cxx,v $ 00014 * Revision 1.60 2011/08/23 22:14:24 genevb 00015 * Introduce sector alignment distortion corrections 00016 * 00017 * Revision 1.59 2011/01/18 14:39:43 fisyak 00018 * Clean up TpcDb interfaces and Tpc coordinate transformation 00019 * 00020 * Revision 1.58 2010/10/28 19:08:43 genevb 00021 * Introduce GG Voltage Error switch 00022 * 00023 * Revision 1.57 2010/09/01 21:11:32 fisyak 00024 * Use Mag.field flavor besides simu flag 00025 * 00026 * Revision 1.56 2010/05/27 20:46:25 genevb 00027 * Allow discontinued use of FullMagF geometry flavors, now just use ofl with appropriate timestamp 00028 * 00029 * Revision 1.55 2010/05/27 19:14:26 fisyak 00030 * Take out flavoring by 'sim' for tpcGlobalPosition,tpcSectorPosition and starClockOnl tables. remove usage tpcISTimeOffsets and tpcOSTimeOffsets tables 00031 * 00032 * Revision 1.54 2010/03/18 14:40:47 fisyak 00033 * back to 3 parameter constration of StMagUtilities 00034 * 00035 * Revision 1.53 2010/03/17 15:53:15 fisyak 00036 * Move StTpcdEdxCorrection to StdEdxY2Maker to avoid dependence of StTpcDb on StDetectorDbMaker 00037 * 00038 * Revision 1.52 2010/03/15 23:29:47 fisyak 00039 * switch from St_tpcAnodeHVC => St_tpcAnodeHVavgC 00040 * 00041 * Revision 1.51 2010/01/26 21:04:42 fisyak 00042 * Add new dE/dx calibration tables: TpcRowQ, tpcMethaneIn, tpcWaterOut, TpcZDC 00043 * 00044 * Revision 1.50 2009/12/07 23:44:58 fisyak 00045 * Drop coordinate transformation for fortran, remove TpcHitErr 00046 * 00047 * Revision 1.49 2009/11/23 16:50:27 fisyak 00048 * St_tpcAnodeHVavgC => St_tpcAnodeHVC, comment out exported for fortran coordinate transformations 00049 * 00050 * Revision 1.48 2009/11/06 13:41:31 fisyak 00051 * Revert the change done 11/03/09 00052 * 00053 * Revision 1.47 2009/11/02 17:31:41 fisyak 00054 * use directly field from StarMagField, replace St_tpcGainC and St_tpcT0C by St_tpcPadGainT0C, add remove defaults in coordinate transformations 00055 * 00056 * Revision 1.46 2009/08/11 20:38:04 genevb 00057 * slightly more detailed message 00058 * 00059 * Revision 1.45 2009/05/01 19:09:23 fisyak 00060 * StTpcDbMaker::Make is aware about TPC trips and generagte EoF when this happenss 00061 * 00062 * Revision 1.44 2008/09/10 15:46:37 fisyak 00063 * Recalculate Tpc drift velocity once per event, avoid expensive conversion to unix time 00064 * 00065 * Revision 1.43 2008/08/01 14:28:34 fisyak 00066 * Add new getT0, clean up 00067 * 00068 * Revision 1.42 2008/07/10 20:25:31 fisyak 00069 * Warn of 00070 * 00071 * Revision 1.41 2007/12/28 00:30:06 fine 00072 * Add a function to calculate the tpc coord transfoirmation in one step 00073 * 00074 * Revision 1.40 2007/08/04 00:38:04 jeromel 00075 * SL4 issue: Removal of the inline func, moved to class implementation. 00076 * Symbols may otherwise be hidden. 00077 * 00078 * Revision 1.39 2007/07/12 20:21:09 fisyak 00079 * Drift velocity depends on TPC half, use online RHIC clock 00080 * 00081 * Revision 1.38 2007/04/28 17:57:19 perev 00082 * Redundant StChain.h removed 00083 * 00084 * Revision 1.37 2007/03/21 17:27:02 fisyak 00085 * use TGeoHMatrix, change mode for switching drift velocities 00086 * 00087 * Revision 1.36 2006/02/27 19:20:53 fisyak 00088 * Set simu flag for tpcISTimeOffsets and tpcOSTimeOffsets tables 00089 * 00090 * Revision 1.35 2005/03/30 17:56:59 fisyak 00091 * Fix a bug with flavor handling, StTpcDb has to be instantiated after setting flavor 00092 * 00093 * Revision 1.34 2004/10/27 21:45:13 fisyak 00094 * Add debug print for tables Validities, add access to ExB correction 00095 * 00096 * Revision 1.33 2004/06/05 23:38:22 fisyak 00097 * Add more chairs for TPC Db parameters 00098 * 00099 * Revision 1.32 2004/05/03 23:29:28 perev 00100 * WarnOff 00101 * 00102 * Revision 1.31 2003/04/10 21:30:59 hardtke 00103 * Allow multiple InitRun calls 00104 * 00105 * Revision 1.30 2003/01/12 20:38:23 jeromel 00106 * fabs() not abs() for doube 00107 * 00108 * Revision 1.29 2002/04/02 00:16:31 hardtke 00109 * New class that gets hit errors from database 00110 * 00111 * Revision 1.28 2002/02/12 22:50:35 hardtke 00112 * separate geometrical tpc rotation from field twist 00113 * 00114 * Revision 1.27 2002/02/05 22:21:08 hardtke 00115 * Move Init code to InitRun 00116 * 00117 * Revision 1.26 2002/01/03 00:01:09 hardtke 00118 * Add switches for type of drift velocity data (i.e. laser vs. t0 analysis). Default to use either. 00119 * 00120 * Revision 1.25 2001/10/25 22:59:36 hardtke 00121 * Add function tpc_localsector_to_local 00122 * 00123 * Revision 1.24 2001/10/24 21:36:20 hardtke 00124 * Add sim flavor option 00125 * 00126 * Revision 1.23 2001/07/27 23:52:33 hardtke 00127 * use Global (magnet) coordinates 00128 * 00129 * Revision 1.22 2001/06/21 16:27:52 perev 00130 * two error matrix transformation methods added 00131 * 00132 * Revision 1.21 2001/06/19 23:07:13 hardtke 00133 * Restore to old functionality using Tpc Local Coordinates 00134 * 00135 * Revision 1.20 2001/04/19 19:52:48 hardtke 00136 * add tpc_pad_time_offset function and add ifdef for static arrays 00137 * 00138 * Revision 1.19 2000/11/14 22:00:06 genevb 00139 * Switched several functions from float to double 00140 * 00141 * Revision 1.18 2000/08/09 14:54:54 hardtke 00142 * Add Clear option, set trigger table pointer to 0 after each event 00143 * 00144 * Revision 1.17 2000/08/08 19:15:23 hardtke 00145 * use correct trigger time offset in case of laser 00146 * 00147 * Revision 1.16 2000/07/06 21:37:34 hardtke 00148 * speed up tpc_pad_to_x function 00149 * 00150 * Revision 1.15 2000/05/31 19:50:16 hardtke 00151 * speed up tpc_time_to_z and tpc_z_to_time by factor of 5 00152 * 00153 * Revision 1.14 2000/04/11 16:06:26 hardtke 00154 * improve speed of tpc_row_par and tpc_global_to_sector 00155 * 00156 * Revision 1.13 2000/02/24 18:21:51 hardtke 00157 * re-define drift distance as central membrane to gating grid 00158 * 00159 * Revision 1.12 2000/02/23 22:21:09 hardtke 00160 * add tpc_global_to_local_p 00161 * 00162 * Revision 1.11 2000/02/23 21:03:17 hardtke 00163 * fix tpc_row_par -- causing tpt problems 00164 * 00165 * Revision 1.10 2000/02/23 15:09:57 hardtke 00166 * move tpg_detector and tpg_pad_plane from .const to .data 00167 * 00168 * Revision 1.9 2000/02/22 19:40:30 hardtke 00169 * fix tpc_row_par to give expected results 00170 * 00171 * Revision 1.8 2000/02/17 19:43:20 hardtke 00172 * fixes to tpc functions 00173 * 00174 * Revision 1.7 2000/02/10 00:29:09 hardtke 00175 * Add tpg functions to StTpcDbMaker, fix a few bugs 00176 * 00177 * Revision 1.6 2000/01/11 15:49:53 hardtke 00178 * get Electronics table from Calibrations database, Fix error messages 00179 * 00180 * Revision 1.5 1999/12/16 22:00:53 hardtke 00181 * add CVS tags 00182 * 00183 **************************************************************************/ 00184 00185 #define StTpc_STATIC_ARRAYS 00186 #include <assert.h> 00187 #include "StTpcDbMaker.h" 00188 #include "StTpcDb.h" 00189 #include "StDbUtilities/StCoordinates.hh" 00190 #include "StDbUtilities/StTpcPadCoordinate.hh" 00191 #include "tables/St_tpg_pad_plane_Table.h" 00192 #include "tables/St_tpg_detector_Table.h" 00193 #include "StarMagField.h" 00194 #include "math_constants.h" 00195 #include "StDetectorDbMaker/StDetectorDbTpcRDOMasks.h" 00196 #include "StDetectorDbMaker/StDetectorDbMagnet.h" 00197 #include "StDetectorDbMaker/St_tpcAnodeHVavgC.h" 00198 #include "StDetectorDbMaker/St_tpcPadGainT0C.h" 00199 #if ROOT_VERSION_CODE < 331013 00200 #include "TCL.h" 00201 #else 00202 #include "TCernLib.h" 00203 #endif 00204 ClassImp(StTpcDbMaker) 00205 //_____________________________________________________________________________ 00206 Int_t StTpcDbMaker::InitRun(int runnumber){ 00207 // Create Needed Tables: 00208 Float_t gFactor = StarMagField::Instance()->GetFactor(); 00209 // Set Table Flavors 00210 if (gFactor<-0.8) { 00211 gMessMgr->Info() << "StTpcDbMaker::Full Reverse Field Twist Parameters. If this is an embedding run, you should not use it." << endm; 00212 SetFlavor("ofl+FullMagFNegative","tpcGlobalPosition"); 00213 } 00214 else if (gFactor<-0.2) { 00215 gMessMgr->Info() << "StTpcDbMaker::Half Reverse Field Twist Parameters. If this is an embedding run, you should not use it." << endm; 00216 SetFlavor("ofl+HalfMagFNegative","tpcGlobalPosition"); 00217 } 00218 else if (gFactor<0.2) { 00219 gMessMgr->Info() << "StTpcDbMaker::Zero Field Twist Parameters. If this is an embedding run, you should not use it." << endm; 00220 SetFlavor("ofl+ZeroMagF","tpcGlobalPosition"); 00221 } 00222 else if (gFactor<0.8) { 00223 gMessMgr->Info() << "StTpcDbMaker::Half Forward Field Twist Parameters. If this is an embedding run, you should not use it." << endm; 00224 SetFlavor("ofl+HalfMagFPositive","tpcGlobalPosition"); 00225 } 00226 else if (gFactor<1.2) { 00227 gMessMgr->Info() << "StTpcDbMaker::Full Forward Field Twist Parameters. If this is an embedding run, you should not use it." << endm; 00228 SetFlavor("ofl+FullMagFPositive","tpcGlobalPosition"); 00229 } 00230 if (IAttr("useLDV")) { 00231 SetFlavor("laserDV","tpcDriftVelocity"); 00232 gMessMgr->Info() << "StTpcDbMaker::Using drift velocity from laser analysis" << endm; 00233 } else if (IAttr("useNewLDV")) { 00234 SetFlavor("NewlaserDV","tpcDriftVelocity"); 00235 gMessMgr->Info() << "StTpcDbMaker::Using drift velocity from New laser analysis" << endm; 00236 } else if (IAttr("useCDV")) { 00237 SetFlavor("ofl","tpcDriftVelocity"); 00238 gMessMgr->Info() << "StTpcDbMaker::Using drift velocity from T0 analysis" << endm; 00239 } else { 00240 SetFlavor("ofl+laserDV","tpcDriftVelocity"); 00241 gMessMgr->Info() << "StTpcDbMaker::Using any drift velocity" << endm; 00242 } 00243 StTpcDb::instance()->SetDriftVelocity(); 00244 00245 if (IAttr("ExB")) { 00246 // Backward compatibility preserved. 00247 Int_t mask=1; // Al Saulys request 00248 if ( IAttr("EB1") ){ // Do nothing (i.e. bit 1 at 0) 00249 } else if ( IAttr("EB2") ){ // Force bit 1 at 1 regardless 00250 mask = mask | 2; 00251 } else { 00252 if(IAttr("OldRuns")) mask = mask | 2 ; // Jim Thomas request 00253 } 00254 // Other options introduced in October 2001 for distortion corrections 00255 // studies and year1 re-production. Those are OR additive to the mask. 00256 //(void) printf("StBFChain:: Options list : %d %d %d %d %d %d %d %d\n", 00257 // kPadrow13,kTwist,kClock,kMembrane,kEndcap, 00258 // kIFCShift,kSpaceCharge,kSpaceChargeR2); 00259 if( IAttr("OBmap") ) mask |= ( kBMap << 1); 00260 if( IAttr("OPr13") ) mask |= ( kPadrow13 << 1); 00261 if( IAttr("OTwist") ) mask |= ( kTwist << 1); 00262 if( IAttr("OClock") ) mask |= ( kClock << 1); 00263 if( IAttr("OCentm") ) mask |= ( kMembrane << 1); 00264 if( IAttr("OECap") ) mask |= ( kEndcap << 1); 00265 if( IAttr("OIFC") ) mask |= ( kIFCShift << 1); 00266 if( IAttr("OSpaceZ") ) mask |= ( kSpaceCharge << 1); 00267 if( IAttr("OSpaceZ2") ) mask |= ( kSpaceChargeR2<< 1); 00268 if( IAttr("OShortR") ) mask |= ( kShortedRing << 1); 00269 if( IAttr("OBMap2d") ) mask |= ( kFast2DBMap << 1); 00270 if( IAttr("OGridLeak") ) mask |= ( kGridLeak << 1); 00271 if( IAttr("OGridLeak3D")) mask |= ( k3DGridLeak << 1); 00272 if( IAttr("OGGVoltErr") ) mask |= ( kGGVoltError << 1); 00273 if( IAttr("OSectorAlign"))mask |= ( kSectorAlign << 1); 00274 LOG_QA << "Instantiate ExB The option passed will be " << Form("%d 0x%X\n",mask,mask) << endm; 00275 // option handling needs some clean up, but right now we stay compatible 00276 Int_t option = (mask & 0x7FFFFFFE) >> 1; 00277 #ifndef __NEW_MagUtilities__ 00278 StMagUtilities *magU = new StMagUtilities(gStTpcDb, GetDataBase("RunLog"), option); 00279 #else 00280 StMagUtilities *magU = new StMagUtilities(gStTpcDb, option); 00281 #endif 00282 StTpcDb::instance()->SetExB(magU); 00283 } 00284 StTpcDb::instance()->SetTpcRotations(); 00285 //Here I fill in the arrays for the row parameterization ax+by=1 00286 if (StTpcDb::instance()->GlobalPosition()) { 00287 for (int i=0;i<24;i++){ 00288 for (int j=0;j<45;j++){ 00289 int time[1] = {10}; 00290 int ipad[2] = {20,40}; 00291 StTpcPadCoordinate pad1(i+1, j+1, ipad[0], *time); 00292 StTpcPadCoordinate pad2(i+1, j+1, ipad[1], *time); 00293 StGlobalCoordinate gc1,gc2; 00294 StTpcCoordinateTransform transform(gStTpcDb); 00295 transform(pad1,gc1); 00296 transform(pad2,gc2); 00297 double x1,y1,x2,y2; 00298 double m,bb; // y = mx + bb 00299 x1 = gc1.position().x(); 00300 y1 = gc1.position().y(); 00301 x2 = gc2.position().x(); 00302 y2 = gc2.position().y(); 00303 if (fabs(x2-x1)<0.000001) { 00304 aline[i][j] = 1/x1; 00305 bline[i][j] = 0.; 00306 continue; 00307 } 00308 m = (y2 - y1)/(x2 - x1); 00309 bb = y1 - m*x1; 00310 if (bb == 0) { 00311 gMessMgr->Warning() << "StTpcDbMaker::Init() Row intersects 0,0" << endm; 00312 continue; 00313 } 00314 aline[i][j] = (float) -m/bb; 00315 bline[i][j] = (float) 1.0/bb; 00316 } 00317 } 00318 } 00319 return 0; 00320 } 00321 //_____________________________________________________________________________ 00322 Int_t StTpcDbMaker::Make(){ 00323 // check that TPC is tripped 00324 if (St_tpcAnodeHVavgC::instance()->tripped()) { 00325 gMessMgr->Info() << "StTpcDbMaker::TPC has tripped - declaring EOF to avoid possibly bad data" << endm; 00326 return kStEOF; 00327 } 00328 StTpcDb::instance()->SetDriftVelocity(); 00329 // SetTpcRotations(); 00330 return kStOK; 00331 } 00332
1.5.9