StiMaker/StiStEventFiller.cxx

00001 /*************************************************************************** 00002 * 00003 * $Id: StiStEventFiller.cxx,v 2.84 2008/08/22 13:32:52 fisyak Exp $ 00004 * 00005 * Author: Manuel Calderon de la Barca Sanchez, Mar 2002 00006 *************************************************************************** 00007 * 00008 * $Log: StiStEventFiller.cxx,v $ 00009 * Revision 2.84 2008/08/22 13:32:52 fisyak 00010 * add one more digit in trakc flag, mFlag=zxyy, where z = 1 for pile up track in TPC (otherwise 0) 00011 * 00012 * Revision 2.83 2008/04/03 20:04:05 fisyak 00013 * Straighten out DB access via chairs 00014 * 00015 * Revision 2.82 2007/10/17 15:32:35 fisyak 00016 * rename Hft => Pxl 00017 * 00018 * Revision 2.81 2007/04/16 22:47:18 perev 00019 * aux.mPt is +ve 00020 * 00021 * Revision 2.80 2007/03/21 17:51:36 fisyak 00022 * adjust for ROOT 5.14 00023 * 00024 * Revision 2.79 2006/12/19 19:46:09 perev 00025 * Filling pull tracks added 00026 * 00027 * Revision 2.78 2006/12/18 01:30:39 perev 00028 * fillPulls reorganized 00029 * 00030 * Revision 2.77 2006/08/31 03:25:58 fisyak 00031 * Make cut for EEMC pointing track based on StTrackDetectorInfo instead of StTrackFitTraits 00032 * 00033 * Revision 2.76 2006/08/29 22:18:37 fisyak 00034 * move filling of StTrackDetectorInfo into fillTrack 00035 * 00036 * Revision 2.75 2006/08/28 17:02:23 fisyak 00037 * Add +x11 short tracks pointing to EEMC, clean up StiDedxCalculator 00038 * 00039 * Revision 2.74 2006/06/16 21:28:57 perev 00040 * FillStHitErr method added and called 00041 * 00042 * Revision 2.73 2006/05/31 03:59:04 fisyak 00043 * Add Victor's dca track parameters, clean up 00044 * 00045 * Revision 2.72 2006/04/07 18:00:30 perev 00046 * Back to the latest Sti 00047 * 00048 * Revision 2.69 2006/02/14 18:56:18 perev 00049 * setGlobalDca==>setDca 00050 * 00051 * Revision 2.68 2006/01/19 22:29:57 jeromel 00052 * kMaxId -> kMaxDetectorId 00053 * 00054 * Revision 2.67 2005/12/08 00:06:27 perev 00055 * BugFix, Instead of vertex, first hit was used 00056 * 00057 * Revision 2.66 2005/08/18 22:31:47 perev 00058 * More tests 00059 * 00060 * Revision 2.65 2005/08/17 22:04:36 perev 00061 * PoinCount cleanup 00062 * 00063 * Revision 2.64 2005/08/16 21:09:06 perev 00064 * remeve 5fit cut 00065 * 00066 * Revision 2.63 2005/08/16 20:37:23 perev 00067 * remove small pt cut 00068 * 00069 * Revision 2.62 2005/08/14 01:24:40 perev 00070 * test for nhits<5 removed 00071 * 00072 * Revision 2.61 2005/08/04 04:04:19 perev 00073 * Cleanup 00074 * 00075 * Revision 2.60 2005/07/21 21:50:24 perev 00076 * First/last point of track filled from node now 00077 * 00078 * Revision 2.59 2005/07/20 17:34:08 perev 00079 * MultiVertex 00080 * 00081 * Revision 2.58 2005/05/12 18:32:20 perev 00082 * Temprary hack, save residuals 00083 * 00084 * Revision 2.57 2005/04/11 17:42:39 perev 00085 * Temporary residuals saving added 00086 * 00087 * Revision 2.56 2005/03/24 17:51:16 perev 00088 * print error code added 00089 * 00090 * Revision 2.55 2005/03/17 06:33:20 perev 00091 * TPT like errors implemented 00092 * 00093 * Revision 2.54 2005/02/25 17:43:15 perev 00094 * StTrack::setKey(...StiTrack::getId()) now 00095 * 00096 * Revision 2.53 2005/02/17 23:19:03 perev 00097 * NormalRefangle + Error reseting 00098 * 00099 * Revision 2.52 2005/02/07 18:34:16 fisyak 00100 * Add VMC dead material 00101 * 00102 * Revision 2.51 2005/01/17 03:56:56 pruneau 00103 * change track container to vector 00104 * 00105 * Revision 2.50 2005/01/17 01:32:13 perev 00106 * parameters protected 00107 * 00108 * Revision 2.49 2004/12/21 20:46:00 perev 00109 * Cleanup. All known bugs fixed 00110 * 00111 * Revision 2.48 2004/12/02 22:14:53 calderon 00112 * Only fill the fitTraits.chi2[1] data member for primaries. 00113 * It holds node->getChi2() from the innerMostHitNode, which will be the 00114 * vertex for primaries. 00115 * 00116 * Revision 2.47 2004/12/02 04:18:06 pruneau 00117 * chi2[1] now set to incremental chi2 at inner most hit or vertex 00118 * 00119 * Revision 2.46 2004/12/01 15:35:46 pruneau 00120 * removed throw and replaced with continue 00121 * 00122 * Revision 2.45 2004/11/08 15:34:16 pruneau 00123 * fix of the chi2 calculation 00124 * 00125 * Revision 2.44 2004/10/27 03:25:54 perev 00126 * Version V3V 00127 * 00128 * Revision 2.43 2004/10/26 06:45:41 perev 00129 * version V2V 00130 * 00131 * Revision 2.42 2004/10/14 02:21:34 calderon 00132 * Updated code in StTrackDetectorInfo, now only increment the reference count 00133 * for globals, not for primaries. So fillTrackDetectorInfo changed to reflect 00134 * this. 00135 * 00136 * Revision 2.41 2004/10/01 01:13:51 calderon 00137 * Added bug fix from Marco: 00138 * flag%100 -> flag/100. 00139 * 00140 * Revision 2.40 2004/08/17 20:04:28 perev 00141 * small leak fixed, delete physicalHelix,originD 00142 * 00143 * Revision 2.39 2004/08/17 04:53:05 calderon 00144 * When filling fit traits for primary tracks, set the new flag 00145 * mPrimaryVertexUsedInFit. 00146 * 00147 * Revision 2.38 2004/08/10 14:21:13 calderon 00148 * Use the firstHit from the dynamic_cast, to avoid a compiler warning 00149 * for an unused variable. 00150 * 00151 * Revision 2.37 2004/08/06 22:23:29 calderon 00152 * Modified the code to use the setNumberOfxxxPoints(unsigned char,StDetectorId) 00153 * methods of StTrack, StTrackDetectorInfo, StTrackFitTraits, and to use 00154 * the maxPointCount(unsigned int detId) method of StiKalmanTrack. 00155 * 00156 * Revision 2.36 2004/08/06 02:29:20 andrewar 00157 * Modifed call to getMaxPointCount 00158 * 00159 * Revision 2.35 2004/08/05 05:25:25 calderon 00160 * Fix the assignment of the first point for primaries. Now, 00161 * the logic for both globals and primaries is that the first 00162 * point is the first element of the stHits() vector that 00163 * can actually be casted to an StHit (the vertex will fail this test, 00164 * all other hits coming from detectors will satisfy it). 00165 * 00166 * Revision 2.34 2004/07/30 18:49:18 calderon 00167 * For running in production, Yuri's dEdx Maker will fill the Pid Traits, 00168 * so the filling of Pid Traits in the filler is no longer needed: 00169 * it actually causes confusion because the V0 finders will loop over 00170 * the PID traits vector and find the first one, so they won't find 00171 * the trait created by the dEdx Maker. It is best to just comment 00172 * out the filling of the Pid Traits here. 00173 * 00174 * Revision 2.33 2004/07/07 19:33:48 calderon 00175 * Added method fillFlags. Flags tpc, tpc+svt (globals and primaries) and flags -x02 tracks with less than 5 total fit points 00176 * 00177 * Revision 2.32 2004/04/21 21:36:24 calderon 00178 * Correction in the comments about the encoded method. 00179 * 00180 * Revision 2.31 2004/03/31 00:27:29 calderon 00181 * Modifications for setting the fit points based on the chi2<chi2Max algorithm. 00182 * -Distinguish between points and fit points, so I added a function for each. 00183 * -Points is done as it was before, just counting the stHits for a given 00184 * detector id. 00185 * -Fit points is done the same with the additional condition that each 00186 * StiKalmanTrackNode has to satisfy the chi2 criterion. 00187 * 00188 * Revision 2.30 2004/03/29 00:52:20 andrewar 00189 * Added key value to StTrack fill. Key is simply the size of the 00190 * StTrackNode container at the time the track is filled. 00191 * 00192 * Revision 2.29 2004/03/23 23:12:36 calderon 00193 * Added an "accept" function to filter unwanted tracks from Sti into StEvent. 00194 * The current method just looks for tracks with a negative length, since 00195 * these were causing problems for the vertex finder (length was nan). The 00196 * nan's have been trapped (one hopes!) in StiKalmanTrack, and for these 00197 * cases the return value is negative, so we can filter them out with a 00198 * simple length>0 condition. 00199 * 00200 * Revision 2.28 2004/03/19 19:33:23 andrewar 00201 * Restored primary filling logic. Now taking parameters at the 00202 * vertex for Primary tracks. 00203 * 00204 * Revision 2.27 2004/01/27 23:40:46 calderon 00205 * The filling of the impactParameter() for global tracks is done now 00206 * only after finding the vertex. The 00207 * StPhysicalHelix::distance(StThreeVectorD) method is used for both globals 00208 * and primaries, the only difference is where the helix is obtained: 00209 * - globals - helix from StTrack::geometry(), which was filled from the 00210 * innermost hit node, which should be a hit at the time. 00211 * - primaries - helix from innermost hit node, which should be the vertex 00212 * at the time it is called. 00213 * 00214 * Revision 2.26 2003/12/11 03:44:29 calderon 00215 * set the length right again, it had dissappeared from the code... 00216 * 00217 * Revision 2.25 2003/11/26 04:02:53 calderon 00218 * track->getChi2() returns the sum of chi2 for all sti nodes. In StEvent, 00219 * chi2(0) should be chi2/dof, so we need to divide by 00220 * dof=track->getPointCount()-5; 00221 * 00222 * Revision 2.24 2003/09/07 03:49:10 perev 00223 * gcc 3.2 + WarnOff 00224 * 00225 * Revision 2.23 2003/09/02 17:59:59 perev 00226 * gcc 3.2 updates + WarnOff 00227 * 00228 * Revision 2.22 2003/08/21 21:21:56 andrewar 00229 * Added trap for non-finite dEdx. Added logic to fillGeometry so 00230 * info is for innerMostHitNode on a detector, not vertex (note: 00231 * Primaries only) 00232 * 00233 * Revision 2.21 2003/08/05 18:26:15 andrewar 00234 * DCA track update logic modified. 00235 * 00236 * Revision 2.20 2003/07/01 20:25:28 calderon 00237 * fillGeometry() - use node->getX(), as it should have been since the 00238 * beginning 00239 * impactParameter() - always use the innermos hit node, not just for globals 00240 * removed extra variables which are no longer used. 00241 * 00242 * Revision 2.19 2003/05/15 03:50:26 andrewar 00243 * Disabled call to filldEdxInfo for the SVT. Checks need to be 00244 * applied to make sure the detector is active before calculator 00245 * is called, but for the review filling this info is unnecessary. 00246 * 00247 * Revision 2.18 2003/05/14 00:04:35 calderon 00248 * The array of 15 floats containing the covariance matrix has a different 00249 * order in Sti than in StEvent. In Sti the array is counted starting from 00250 * the first row, column go to next column until you hit the diagonal, 00251 * jump to next row starting from first column. In StEvent the array is 00252 * counted starting from the first row, column go to the next row until you 00253 * hit the end, jump to next column starting from diagonal. 00254 * The filling of the fitTraits was fixed to reflect this. 00255 * 00256 * Revision 2.17 2003/05/12 21:21:39 calderon 00257 * switch back to getting the chi2 from track->getChi2() 00258 * Covariance matrix is still obtained from node->get(), and the values 00259 * are not as expected in StEvent, so this will still need to change. 00260 * 00261 * Revision 2.16 2003/05/08 22:23:33 calderon 00262 * Adding a check for finiteness of node origin and node curvature. If any 00263 * of the numbers is not finite, the code will abort(). 00264 * 00265 * Revision 2.15 2003/04/29 18:48:52 pruneau 00266 * *** empty log message *** 00267 * 00268 * Revision 2.14 2003/04/29 15:28:10 andrewar 00269 * Removed hacks to get helicity right; switch now done at source 00270 * (StiKalmanTrackNode). 00271 * 00272 * Revision 2.13 2003/04/25 21:42:47 andrewar 00273 * corrected DCA bug and added temp fix for helicity problem. This will 00274 * have to be modified when the helicity convention in StiStKalmanTrack 00275 * is updated. 00276 * 00277 * Revision 2.12 2003/04/04 14:48:34 pruneau 00278 * *** empty log message *** 00279 * 00280 * Revision 2.11 2003/03/14 19:02:55 pruneau 00281 * various updates - DCA is a bitch 00282 * 00283 * Revision 2.10 2003/03/13 21:20:10 pruneau 00284 * bug fix in filler fixed. 00285 * 00286 * Revision 2.9 2003/03/13 18:59:44 pruneau 00287 * various updates 00288 * 00289 * Revision 2.8 2003/03/13 16:01:48 pruneau 00290 * remove various cout 00291 * 00292 * Revision 2.7 2003/03/13 15:15:52 pruneau 00293 * various 00294 * 00295 * Revision 2.6 2003/03/12 17:58:05 pruneau 00296 * fixing stuff 00297 * 00298 * Revision 2.5 2003/02/25 16:56:20 pruneau 00299 * *** empty log message *** 00300 * 00301 * Revision 2.4 2003/02/25 14:21:10 pruneau 00302 * *** empty log message *** 00303 * 00304 * Revision 2.3 2003/01/24 06:12:28 pruneau 00305 * removing centralized io 00306 * 00307 * Revision 2.2 2003/01/23 05:26:02 pruneau 00308 * primaries rec reasonable now 00309 * 00310 * Revision 2.1 2003/01/22 21:12:15 calderon 00311 * Restored encoded method, uses enums but stores the value in constructor 00312 * as a data member so bit operations are only done once. 00313 * Fixed warnings. 00314 * 00315 * Revision 2.0 2002/12/04 16:50:59 pruneau 00316 * introducing version 2.0 00317 * 00318 * Revision 1.21 2002/09/20 02:19:32 calderon 00319 * Quick hack for getting code for review: 00320 * The filler now checks the global Dca for the tracks and only fills 00321 * primaries when dca<3 cm. 00322 * Also removed some comments so that the production log files are not swamped 00323 * with debug info. 00324 * 00325 * Revision 1.20 2002/09/12 22:27:15 andrewar 00326 * Fixed signed curvature -> StHelixModel conversion bug. 00327 * 00328 * Revision 1.19 2002/09/05 05:47:36 pruneau 00329 * Adding Editable Parameters and dynamic StiOptionFrame 00330 * 00331 * Revision 1.18 2002/08/29 21:09:22 andrewar 00332 * Fixed seg violation bug. 00333 * 00334 * Revision 1.17 2002/08/22 21:46:00 pruneau 00335 * Made a fix to StiStEventFiller to remove calls to StHelix and StPhysicalHelix. 00336 * Currently there is one instance of StHelix used a calculation broker to 00337 * get helix parameters such as the distance of closest approach to the main 00338 * vertex. 00339 * 00340 * Revision 1.16 2002/08/19 19:33:00 pruneau 00341 * eliminated cout when unnecessary, made helix member of the EventFiller 00342 * 00343 * Revision 1.15 2002/08/12 21:39:56 calderon 00344 * Introduced fillPidTraits, which uses the values obtained from 00345 * Andrews brand new dEdxCalculator to create two instances of an 00346 * StTrackPidTraits object and pass it to the track being filled. 00347 * 00348 * Revision 1.14 2002/08/12 15:29:21 andrewar 00349 * Added dedx calculators 00350 * 00351 * Revision 1.13 2002/06/28 23:30:56 calderon 00352 * Updated with changes debugging for number of primary tracks added. 00353 * Merged with Claude's latest changes, but restored the tabs, othewise 00354 * cvs diff will not give useful information: everything will be different. 00355 * 00356 * Revision 1.12 2002/06/26 23:05:31 pruneau 00357 * changed macro 00358 * 00359 * Revision 1.11 2002/06/25 15:09:16 pruneau 00360 * *** empty log message *** 00361 * 00362 * Revision 1.10 2002/06/18 18:08:34 pruneau 00363 * some cout statements removed/added 00364 * 00365 * Revision 1.9 2002/06/05 20:31:15 calderon 00366 * remove some redundant statements, the call to 00367 * StTrackNode::addTrack() 00368 * already calls 00369 * track->SetNode(this), so I don't need to do it again 00370 * 00371 * Revision 1.8 2002/05/29 19:14:45 calderon 00372 * Filling of primaries, in 00373 * StiStEventFiller::fillEventPrimaries() 00374 * 00375 * Revision 1.7 2002/04/16 19:46:44 pruneau 00376 * must catch exception 00377 * 00378 * Revision 1.6 2002/04/16 13:11:30 pruneau 00379 * *** empty log message *** 00380 * 00381 * Revision 1.5 2002/04/09 16:03:13 pruneau 00382 * Included explicit extension of tracks to the main vertex. 00383 * 00384 * Revision 1.4 2002/04/03 16:35:03 calderon 00385 * Check if primary vertex is available in StiStEventFiller::impactParameter(), 00386 * if not, return DBL_MAX; 00387 * 00388 * Revision 1.3 2002/03/28 04:29:49 calderon 00389 * First test version of Filler 00390 * Currently fills only global tracks with the following characteristics 00391 * -Flag is set to 101, as most current global tracks are. This is not 00392 * strictly correct, as this flag is supposed to mean a tpc only track, so 00393 * really need to check if the track has svt hits and then set it to the 00394 * appropriate flag (501 or 601). 00395 * -Encoded method is set with bits 15 and 1 (starting from bit 0). Bit 1 00396 * means Kalman fit. 00397 * Bit 15 is an as-yet unused track-finding bit, which Thomas said ITTF 00398 * could grab. 00399 * -Impact Parameter calculation is done using StHelix and the primary vertex 00400 * from StEvent 00401 * -length is set using getTrackLength, which might still need tweaking 00402 * -possible points is currently set from getMaxPointCount which returns the 00403 * total, and it is not 00404 * what we need for StEvent, so this needs to be modified 00405 * -inner geometry (using the innermostHitNode -> Ben's transformer -> 00406 * StPhysicalHelix -> StHelixModel) 00407 * -outer geometry, needs inside-out pass to obtain good parameters at 00408 * outermostHitNode 00409 * -fit traits, still missing the probability of chi2 00410 * -topology map, filled from StuFixTopoMap once StDetectorInfo is properly set 00411 * 00412 * This version prints out lots of messages for debugging, should be more quiet 00413 * when we make progress. 00414 * 00415 **************************************************************************/ 00416 //ROOT 00417 #include "RVersion.h" 00418 #if ROOT_VERSION_CODE < 331013 00419 #include "TCL.h" 00420 #else 00421 #include "TCernLib.h" 00422 #endif 00423 //std 00424 #include "Stiostream.h" 00425 #include <algorithm> 00426 #include <stdexcept> 00427 using namespace std; 00428 00429 // SCL 00430 #include "StPhysicalHelix.hh" 00431 #include "StThreeVector.hh" 00432 #include "StThreeVectorF.hh" 00433 #include "PhysicalConstants.h" 00434 #include "SystemOfUnits.h" 00435 #include "StTrackDefinitions.h" 00436 #include "StTrackMethod.h" 00437 #include "StDedxMethod.h" 00438 00439 //StEvent 00440 #include "StPrimaryVertex.h" 00441 #include "StEventTypes.h" 00442 #include "StDetectorId.h" 00443 #include "StHelix.hh" 00444 #include "StDcaGeometry.h" 00445 #include "StHit.h" 00446 00447 00448 #include "StEventUtilities/StEventHelper.h" 00449 #include "StEventUtilities/StuFixTopoMap.cxx" 00450 //Sti 00451 #include "Sti/StiTrackContainer.h" 00452 #include "Sti/StiKalmanTrack.h" 00453 #include "Sti/StiKalmanTrackFitterParameters.h" 00455 #include "StiUtilities/StiDebug.h" 00456 #include "StiUtilities/StiPullEvent.h" 00457 00458 //StiMaker 00459 #include "StiMaker/StiStEventFiller.h" 00460 00461 #include "TMath.h" 00462 #define NICE(angle) StiKalmanTrackNode::nice((angle)) 00463 00464 //_____________________________________________________________________________ 00465 StiStEventFiller::StiStEventFiller() : mEvent(0), mTrackStore(0), mTrkNodeMap() 00466 { 00467 mUseAux = 0; 00468 mAux = 0; 00469 mGloPri = 0; 00470 mPullEvent=0; 00471 00472 originD = new StThreeVectorD(0,0,0); 00473 physicalHelix = new StPhysicalHelixD(0.,0.,0.,*originD,-1); 00474 00475 00476 //mResMaker.setLimits(-1.5,1.5,-1.5,1.5,-10,10,-10,10); 00477 //mResMaker.setDetector(kSvtId); 00478 00479 // encoded method = 16 bits = 12 finding and 4 fitting, Refer 00480 // to StTrackMethod.h and StTrackDefinitions.h in pams/global/inc/ 00481 // and StEvent/StEnumerations.h 00482 // For the IT tracks use: 00483 // Fitting: kITKalmanFitId (should be something like 7, but don't hardwire it) 00484 // Finding: tpcOther (should be 9th LSB, or shift the "1" 8 places to the left, but also don't hardwire it) 00485 // so need this bit pattern: 00486 // finding 000000010000 00487 // fitting 0111 00488 // 256 + 7 = 263; 00489 unsigned short bit = 1 << tpcOther; // shifting the "1" exactly tpcOther places to the left 00490 mStiEncoded = kITKalmanFitId + bit; // adding that to the proper fitting Id 00491 00492 } 00493 00494 //_____________________________________________________________________________ 00495 StiStEventFiller::~StiStEventFiller() 00496 { 00497 delete physicalHelix; physicalHelix=0; 00498 delete originD; originD =0; 00499 cout <<"StiStEventFiller::~StiStEventFiller()"<<endl; 00500 } 00501 00502 //Helper functor, gotta live some place else, just a temp. test of StiKalmanTrack::stHits() method 00503 //_____________________________________________________________________________ 00504 struct StreamStHit 00505 { 00506 void operator()(const StHit* h) 00507 { 00508 //cout << "DetectorId: " << (unsigned long) h->detector(); 00509 if (const StTpcHit* hit = dynamic_cast<const StTpcHit*>(h)) 00510 { 00511 cout <<hit->position() << " Sector: " << hit->sector() << " Padrow: " << hit->padrow() << endl; 00512 } 00513 else if (const StSvtHit* hit = dynamic_cast<const StSvtHit*>(h)) 00514 { 00515 cout << hit->position() << " layer: " << hit->layer() << " ladder: " << hit->ladder() 00516 << " wafer: " << hit->wafer() << " barrel: " << hit->barrel() << endl; 00517 } 00518 else 00519 { 00520 cout << hit->position() << endl; 00521 } 00522 } 00523 }; 00524 00525 //_____________________________________________________________________________ 00577 //_____________________________________________________________________________ 00578 void StiStEventFiller::fillEvent(StEvent* e, StiTrackContainer* t) 00579 { 00580 //cout << "StiStEventFiller::fillEvent() -I- Started"<<endl; 00581 mGloPri=0; 00582 if (e==0 || t==0) 00583 { 00584 cout <<"StiStEventFiller::fillEvent(). ERROR:\t" 00585 <<"Null StEvent ("<<e<<") || StiTrackContainer ("<<t<<"). Exit"<<endl; 00586 return; 00587 } 00588 mEvent = e; 00589 if (mUseAux) { mAux = new StiAux; e->Add(mAux);} 00590 mTrackStore = t; 00591 mTrkNodeMap.clear(); // need to reset for this event 00592 StSPtrVecTrackNode& trNodeVec = mEvent->trackNodes(); 00593 StSPtrVecTrackDetectorInfo& detInfoVec = mEvent->trackDetectorInfo(); 00594 int errorCount=0; 00595 00596 int fillTrackCount1=0; 00597 int fillTrackCount2=0; 00598 int fillTrackCountG=0; 00599 StErrorHelper errh; 00600 mTrackNumber=0; 00601 for (vector<StiTrack*>::iterator trackIt = mTrackStore->begin(); trackIt!=mTrackStore->end();++trackIt) 00602 { 00603 StiKalmanTrack* kTrack = static_cast<StiKalmanTrack*>(*trackIt); 00604 if (!accept(kTrack)) continue; // get rid of riff-raff 00605 mTrackNumber++; 00606 StTrackDetectorInfo* detInfo = new StTrackDetectorInfo; 00607 fillDetectorInfo(detInfo,kTrack,true); //3d argument used to increase/not increase the refCount. MCBS oct 04. 00608 // track node where the new StTrack will reside 00609 StTrackNode* trackNode = new StTrackNode; 00610 // actual filling of StTrack from StiKalmanTrack 00611 StGlobalTrack* gTrack = new StGlobalTrack; 00612 try 00613 { 00614 fillTrackCount1++; 00615 fillTrack(gTrack,kTrack,detInfo); 00616 // filling successful, set up relationships between objects 00617 detInfoVec.push_back(detInfo); 00618 //cout <<"Setting key: "<<(unsigned short)(trNodeVec.size())<<endl; 00619 gTrack->setKey((unsigned short)kTrack->getId()); 00620 trackNode->addTrack(gTrack); 00621 trNodeVec.push_back(trackNode); 00622 // reuse the utility to fill the topology map 00623 // this has to be done at the end as it relies on 00624 // having the proper track->detectorInfo() relationship 00625 // and a valid StDetectorInfo object. 00626 //cout<<"Tester: Event Track Node Entries: "<<trackNode->entries()<<endl; 00627 mTrkNodeMap.insert(map<StiKalmanTrack*,StTrackNode*>::value_type (kTrack,trNodeVec.back()) ); 00628 if (trackNode->entries(global)<1) 00629 cout << "StiStEventFiller::fillEvent() -E- Track Node has no entries!! -------------------------" << endl; 00630 int ibad = gTrack->bad(); 00631 errh.Add(ibad); 00632 if (ibad) { 00633 //VP printf("GTrack error: %s\n",errh.Say(ibad).Data()); 00634 //VP throw runtime_error("StiStEventFiller::fillEvent() StTrack::bad() non zero"); 00635 } 00636 fillTrackCount2++; 00637 fillPulls(kTrack,0); 00638 if (gTrack->numberOfPossiblePoints()<10) continue; 00639 if (gTrack->geometry()->momentum().mag()<0.1) continue; 00640 fillTrackCountG++; 00641 00642 } 00643 catch (runtime_error & rte ) 00644 { 00645 cout << "StiStEventFiller::fillEvent() -W- runtime-e filling track"<<rte.what() << endl; 00646 delete trackNode; 00647 delete detInfo; 00648 delete gTrack; 00649 } 00650 catch (...) 00651 { 00652 cout << "StiStEventFiller::fillEvent() -W- Unknown exception filling track."<<endl; 00653 delete trackNode; 00654 delete detInfo; 00655 delete gTrack; 00656 } 00657 } 00658 if (errorCount>4) 00659 cout << "There were "<<errorCount<<"runtime_error while filling StEvent"<<endl; 00660 00661 cout <<"StiStEventFiller::fillEvent() -I- Number of filled as global(1):"<< fillTrackCount1<<endl; 00662 cout <<"StiStEventFiller::fillEvent() -I- Number of filled as global(2):"<< fillTrackCount2<<endl; 00663 cout <<"StiStEventFiller::fillEvent() -I- Number of filled GOOD globals:"<< fillTrackCountG<<endl; 00664 errh.Print(); 00665 00666 return; 00667 } 00668 //_____________________________________________________________________________ 00669 void StiStEventFiller::fillEventPrimaries() 00670 { 00671 //cout <<"StiStEventFiller::fillEventPrimaries() -I- Started"<<endl; 00672 mGloPri=1; 00673 if (!mTrkNodeMap.size()) 00674 { 00675 cout <<"StiStEventFiller::fillEventPrimaries(). ERROR:\t" 00676 << "Mapping between the StTrackNodes and the StiKalmanTracks is empty. Exit." << endl; 00677 return; 00678 } 00679 //Added residual maker...aar 00680 StPrimaryVertex* vertex = 0; 00681 StSPtrVecTrackDetectorInfo& detInfoVec = mEvent->trackDetectorInfo(); 00682 cout << "StiStEventFiller::fillEventPrimaries() -I- Tracks in container:" << mTrackStore->size() << endl; 00683 int mTrackN=0,mVertN=0; 00684 int noPipe=0; 00685 int ifcOK=0; 00686 int fillTrackCount1=0; 00687 int fillTrackCount2=0; 00688 int fillTrackCountG=0; 00689 StErrorHelper errh; 00690 int nTracks = mTrackStore->size(); 00691 StiKalmanTrack *kTrack = 0; 00692 StPrimaryTrack *pTrack = 0; 00693 StGlobalTrack *gTrack = 0; 00694 StTrackNode *nTRack = 0; 00695 mTrackNumber=0; 00696 for (mTrackN=0; mTrackN<nTracks;++mTrackN) { 00697 kTrack = (StiKalmanTrack*)(*mTrackStore)[mTrackN]; 00698 if (!accept(kTrack)) continue; 00699 map<StiKalmanTrack*, StTrackNode*>::iterator itKtrack = mTrkNodeMap.find(kTrack); 00700 if (itKtrack == mTrkNodeMap.end()) continue;//Sti global was rejected 00701 mTrackNumber++; 00702 00703 nTRack = (*itKtrack).second; 00704 assert(nTRack->entries()<=10); 00705 assert(nTRack->entries(global)); 00706 00707 //double globalDca = nTRack->track(global)->impactParameter(); 00708 //Even though this is filling of primary tracks, there are certain 00709 // quantities that need to be filled for global tracks that are only known 00710 // after the vertex is found, such as dca. Here we can fill them. 00711 // 00712 gTrack = static_cast<StGlobalTrack*>(nTRack->track(global)); 00713 assert(gTrack->key()==kTrack->getId()); 00714 float minDca = 1e10; //We do not know which primary. Use the smallest one 00715 00716 pTrack = 0; 00717 for (mVertN=0; (vertex = mEvent->primaryVertex(mVertN));mVertN++) { 00718 StThreeVectorD vertexPosition = vertex->position(); 00719 double zPrim = vertexPosition.z(); 00720 // loop over StiKalmanTracks 00721 float globalDca = impactParameter(gTrack,vertexPosition); 00722 if (fabs(minDca) > fabs(globalDca)) minDca = globalDca; 00723 00724 if (!kTrack->isPrimary()) continue; 00725 StiKalmanTrackNode *lastNode = kTrack->getLastNode(); 00726 StiHit *pHit = lastNode->getHit(); 00727 if (fabs(pHit->z_g()-zPrim)>0.1) continue;//not this primary 00728 00729 fillTrackCount1++; 00730 // detector info 00731 StTrackDetectorInfo* detInfo = new StTrackDetectorInfo; 00732 fillDetectorInfo(detInfo,kTrack,false); //3d argument used to increase/not increase the refCount. MCBS oct 04. 00733 fillPulls(kTrack,1); 00734 StPrimaryTrack* pTrack = new StPrimaryTrack; 00735 pTrack->setKey( gTrack->key()); 00736 00737 fillTrack(pTrack,kTrack, detInfo); 00738 // set up relationships between objects 00739 detInfoVec.push_back(detInfo); 00740 00741 nTRack->addTrack(pTrack); // StTrackNode::addTrack() calls track->setNode(this); 00742 vertex->addDaughter(pTrack); 00743 fillTrackCount2++; 00744 int ibad = pTrack->bad(); 00745 errh.Add(ibad); 00746 if (ibad) { 00747 //VP printf("PTrack error: %s\n",errh.Say(ibad).Data()); 00748 //VP throw runtime_error("StiStEventFiller::fillEventPrimaries() StTrack::bad() non zero"); 00749 } 00750 if (pTrack->numberOfPossiblePoints()<10) break; 00751 if (pTrack->geometry()->momentum().mag()<0.1) break; 00752 fillTrackCountG++; 00753 break; 00754 } //end of verteces 00755 kTrack->setDca(minDca); 00756 gTrack->setImpactParameter(minDca); 00757 if (pTrack) pTrack->setImpactParameter(minDca); 00758 00759 } // kalman track loop 00760 mTrkNodeMap.clear(); // need to reset for the next event 00761 cout <<"StiStEventFiller::fillEventPrimaries() -I- Primaries (1):"<< fillTrackCount1<< " (2):"<< fillTrackCount2<< " no pipe node:"<<noPipe<<" with IFC:"<< ifcOK<<endl; 00762 cout <<"StiStEventFiller::fillEventPrimaries() -I- GOOD:"<< fillTrackCountG <<endl; 00763 errh.Print(); 00764 return; 00765 } 00766 //_____________________________________________________________________________ 00771 //_____________________________________________________________________________ 00772 void StiStEventFiller::fillDetectorInfo(StTrackDetectorInfo* detInfo, StiKalmanTrack* track, bool refCountIncr) 00773 { 00774 //cout << "StiStEventFiller::fillDetectorInfo() -I- Started"<<endl; 00775 int dets[kMaxDetectorId][3]; 00776 track->getAllPointCount(dets,kMaxDetectorId-1); 00777 for (int i=1;i<kMaxDetectorId;i++) { 00778 if (!dets[i][1]) continue; 00779 detInfo->setNumberOfPoints(dets[i][1],static_cast<StDetectorId>(i)); 00780 } 00781 StiKTNIterator tNode = track->rbegin(); 00782 StiKTNIterator eNode = track->rend(); 00783 StiKalmanTrackNode *lastNode=0,*fistNode=0; 00784 for (;tNode!=eNode;++tNode) 00785 { 00786 StiKalmanTrackNode *node = &(*tNode); 00787 if(!node->isValid()) continue; 00788 00789 StiHit *stiHit = node->getHit(); 00790 if (!stiHit) continue; 00791 00792 if (node->getChi2()>1000) continue; 00793 if (!node->isFitted()) continue; 00794 00795 const StiDetector *detector = node->getDetector(); 00796 assert(detector == stiHit->detector()); 00797 assert(!detector || stiHit->timesUsed()); 00798 if (!fistNode) fistNode = node; 00799 lastNode = node; 00800 StHit *hh = (StHit*)stiHit->stHit(); 00801 // Fill StHit errors for Gene 00802 FillStHitErr(hh,node); 00803 if (!detector) continue; 00804 if (!hh) continue; 00805 assert(detector->getGroupId()==hh->detector()); 00806 00807 detInfo->addHit(hh,refCountIncr); 00808 if (!refCountIncr) continue; 00809 hh->setFitFlag(1); 00810 //Kind of HACK, save residials into StiHack 00811 fillResHack(hh,stiHit,node); 00812 } 00813 assert(lastNode && fistNode && (lastNode != fistNode)); 00814 00815 StThreeVectorF posL(lastNode->x_g(),lastNode->y_g(),lastNode->z_g()); 00816 detInfo->setLastPoint (posL); 00817 StThreeVectorF posF(fistNode->x_g(),fistNode->y_g(),fistNode->z_g()); 00818 detInfo->setFirstPoint(posF); 00819 00820 00821 //cout << "StiStEventFiller::fillDetectorInfo() -I- Done"<<endl; 00822 } 00823 00824 //_____________________________________________________________________________ 00825 void StiStEventFiller::fillGeometry(StTrack* gTrack, StiKalmanTrack* track, bool outer) 00826 { 00827 //cout << "StiStEventFiller::fillGeometry() -I- Started"<<endl; 00828 assert(gTrack); 00829 assert(track) ; 00830 00831 StiKalmanTrackNode* node = track->getInnOutMostNode(outer,3); 00832 StiHit *ihit = node->getHit(); 00833 StThreeVectorF origin(node->x_g(),node->y_g(),node->z_g()); 00834 StThreeVectorF hitpos(ihit->x_g(),ihit->y_g(),ihit->z_g()); 00835 00836 double dif = (hitpos-origin).mag(); 00837 00838 if (dif>3.) { 00839 dif = node->z_g()-ihit->z_g(); 00840 double nowChi2 = node->evaluateChi2(ihit); 00841 printf("***Track(%d) DIFF TOO BIG %g chi2 = %g %g\n",track->getId(),dif,node->getChi2(),nowChi2); 00842 printf("H=%g %g %g N =%g %g %g\n",ihit->x() ,ihit->y() ,ihit->z() 00843 ,node->getX(),node->getY(),node->getZ()); 00844 const StMeasuredPoint *mp = ihit->stHit(); 00845 printf("H=%g %g %g N =%g %g %g\n",mp->position().x(),mp->position().y(),mp->position().z() 00846 ,origin.x(),origin.y(),origin.z()); 00847 00848 assert(fabs(dif)<50.); 00849 } 00850 00851 // making some checks. Seems the curvature is infinity sometimes and 00852 // the origin is sometimes filled with nan's... 00853 00854 int ibad = origin.bad(); 00855 if (ibad) { 00856 cout << "StiStEventFiller::fillGeometry() Encountered non-finite numbers!!!! Bail out completely!!! " << endl; 00857 cout << "StThreeVectorF::bad() = " << ibad << endl; 00858 cout << "Last node had:" << endl; 00859 cout << "Ref Position " << node->getRefPosition() << endl; 00860 cout << "node->getY() " << node->getY() << endl; 00861 cout << "node->getZ() " << node->getZ() << endl; 00862 cout << "Ref Angle " << node->getAlpha() << endl; 00863 cout << "origin " << origin << endl; 00864 cout << "curvature " << node->getCurvature() << endl; 00865 abort(); 00866 } 00867 StTrackGeometry* geometry =new StHelixModel(short(track->getCharge()), 00868 node->getPsi(), 00869 fabs(node->getCurvature()), 00870 node->getDipAngle(), 00871 origin, 00872 node->getGlobalMomentumF(), 00873 node->getHelicity()); 00874 00875 if (outer) 00876 gTrack->setOuterGeometry(geometry); 00877 else 00878 gTrack->setGeometry(geometry); 00879 00880 00881 return; 00882 } 00883 00884 //_____________________________________________________________________________ 00885 // void StiStEventFiller::fillTopologyMap(StTrack* gTrack, StiKalmanTrack* track){ 00886 // cout << "StiStEventFiller::fillTopologyMap()" << endl; 00887 // int map1,map2; 00888 // map1 = map2 = 0; 00889 // // change: add code to set the bits appropriately here 00890 00891 // StTrackTopologyMap topomap(map1,map2); 00892 // gTrack->setTopologyMap(topomap); 00893 // return; 00894 // } 00895 00896 //_____________________________________________________________________________ 00897 void StiStEventFiller::fillFitTraits(StTrack* gTrack, StiKalmanTrack* track){ 00898 // mass 00899 // this makes no sense right now... double massHyp = track->getMass(); // change: perhaps this mass is not set right? 00900 unsigned short geantIdPidHyp = 9999; 00901 //if (.13< massHyp<.14) 00902 geantIdPidHyp = 9; 00903 // chi square and covariance matrix, plus other stuff from the 00904 // innermost track node 00905 StiKalmanTrackNode* node = track->getInnerMostHitNode(3); 00906 float x[6],covMFloat[15]; 00907 node->getGlobalTpt(x,covMFloat); 00908 float chi2[2]; 00909 //get chi2/dof 00910 chi2[0] = track->getChi2(); 00911 chi2[1] = -999; // change: here goes an actual probability, need to calculate? 00912 // December 04: The second element of the array will now hold the incremental chi2 of adding 00913 // the vertex for primary tracks 00914 if (gTrack->type()==primary) { 00915 assert(node->getDetector()==0); 00916 chi2[1]=node->getChi2(); 00917 } 00918 00919 // setFitTraits uses assignment operator of StTrackFitTraits, which is the default one, 00920 // which does a memberwise copy. Therefore, constructing a local instance of 00921 // StTrackFitTraits is fine, as it will get properly copied. 00922 StTrackFitTraits fitTraits(geantIdPidHyp,0,chi2,covMFloat); 00923 // Now we have to use the new setters that take a detector ID to fix 00924 // a bug. There is no encoding anymore. 00925 00926 int dets[kMaxDetectorId][3]; 00927 track->getAllPointCount(dets,kMaxDetectorId-1); 00928 00929 for (int i=1;i<kMaxDetectorId;i++) { 00930 if (!dets[i][2]) continue; 00931 fitTraits.setNumberOfFitPoints((unsigned char)dets[i][2],(StDetectorId)i); 00932 } 00933 if (gTrack->type()==primary) { 00934 fitTraits.setPrimaryVertexUsedInFit(true); 00935 } 00936 gTrack->setFitTraits(fitTraits); 00937 return; 00938 } 00939 00971 00972 void StiStEventFiller::fillFlags(StTrack* gTrack) { 00973 if (gTrack->type()==global) { 00974 gTrack->setFlag(101); //change: make sure flag is ok 00975 } 00976 else if (gTrack->type()==primary) { 00977 gTrack->setFlag(301); 00978 } 00979 StTrackFitTraits& fitTrait = gTrack->fitTraits(); 00980 //int tpcFitPoints = fitTrait.numberOfFitPoints(kTpcId); 00981 int svtFitPoints = fitTrait.numberOfFitPoints(kSvtId); 00982 int ssdFitPoints = fitTrait.numberOfFitPoints(kSsdId); 00983 int pxlFitPoints = fitTrait.numberOfFitPoints(kPxlId); 00984 int istFitPoints = fitTrait.numberOfFitPoints(kIstId); 00985 // int totFitPoints = fitTrait.numberOfFitPoints(); 00989 00990 // first case is default above, tpc only = 101 and tpc+vertex = 301 00991 // next case is: 00992 // if the track has svt points, it will be an svt+tpc track 00993 // (we assume that the ittf tracks start from tpc, so we don't 00994 // use the "svt only" case.) 00995 if (svtFitPoints+ssdFitPoints+pxlFitPoints+istFitPoints>0) { 00996 if (gTrack->type()==global) { 00997 gTrack->setFlag(501); //svt+tpc 00998 } 00999 else if (gTrack->type()==primary) { 01000 gTrack->setFlag(601); //svt+tpc+primary 01001 } 01002 } 01003 const StTrackDetectorInfo *dinfo = gTrack->detectorInfo(); 01004 if (dinfo) { 01005 Int_t NoTpcFitPoints = dinfo->numberOfPoints(kTpcId); 01006 Int_t NoFtpcWestId = dinfo->numberOfPoints(kFtpcWestId); 01007 Int_t NoFtpcEastId = dinfo->numberOfPoints(kFtpcEastId); 01008 // Check that it could be TPC pile-up track, i.e. in the same half TPC (West East) 01009 // there are more than 2 hits with wrong Z -position 01010 Int_t flag = TMath::Abs(gTrack->flag()); 01011 if (NoTpcFitPoints >= 11) { 01012 const StTrackDetectorInfo *dinfo = gTrack->detectorInfo(); 01013 const StPtrVecHit& hits = dinfo->hits(kTpcId); 01014 Int_t Nhits = hits.size(); 01015 Int_t NoWrongSignZ = 0; 01016 for (Int_t i = 0; i < Nhits; i++) { 01017 const StTpcHit *hit = (StTpcHit *) hits[i]; 01018 if (hit->position().z() < -1.0 && hit->sector() <= 12 || 01019 hit->position().z() > 1.0 && hit->sector() > 12) NoWrongSignZ++; 01020 } 01021 if (NoWrongSignZ >= 2) 01022 gTrack->setFlag((flag%1000) + 1000); // +1000 01023 } 01024 if (NoTpcFitPoints < 11 && NoFtpcWestId < 5 && NoFtpcEastId < 5) { 01025 // hadrcoded number correspondant to __MIN_HITS_TPC__ 11 in StMuFilter.cxx 01026 //keep most sig. digit, set last digit to 2, and set negative sign 01027 gTrack->setFlag(-(((flag/100)*100)+2)); // -x02 01028 if (gTrack->geometry()) { 01029 const StThreeVectorF &momentum = gTrack->geometry()->momentum(); 01030 if (momentum.pseudoRapidity() > 0.5) { 01031 const StTrackDetectorInfo *dinfo = gTrack->detectorInfo(); 01032 const StPtrVecHit& hits = dinfo->hits(); 01033 Int_t Nhits = hits.size(); 01034 for (Int_t i = 0; i < Nhits; i++) { 01035 const StHit *hit = hits[i]; 01036 if (hit->position().z() > 150.0) { 01037 gTrack->setFlag((((flag/100)*100)+11)); // +x11 01038 return; 01039 } 01040 } 01041 } 01042 } 01043 } 01044 } 01045 } 01046 //_____________________________________________________________________________ 01047 void StiStEventFiller::fillTrack(StTrack* gTrack, StiKalmanTrack* track,StTrackDetectorInfo* detInfo ) 01048 { 01049 01050 //cout << "StiStEventFiller::fillTrack()" << endl; 01051 // encoded method = 16 bits = 12 fitting and 4 finding, for the moment use: 01052 // kKalmanFitId 01053 // bit 15 for finding, (needs to be changed in StEvent). 01054 // change: make sure bits are ok, are the bits set up one in each position and nothing else? 01055 // this would mean that the encoded method is wasting space! 01056 // the problem is that in principle there might be combinations of finders for each tracking detector 01057 // but the integrated tracker will use only one for all detectors maybe 01058 // so need this bit pattern: 01059 // finding 100000000000 01060 // fitting 0010 01061 // 32768 + 2 = 32770; 01062 // 01063 // above is no longer used, instead use kITKalmanfitId as fitter and tpcOther as finding method 01064 01065 gTrack->setEncodedMethod(mStiEncoded); 01066 double tlen = track->getTrackLength(); 01067 assert(tlen >0.0 && tlen<1000.); 01068 gTrack->setLength(tlen);// someone removed this, grrrr!!!! 01069 01070 // Follow the StDetectorId.h enumerations... 01071 // can't include them from here in order not to 01072 // create a package dependence... 01073 int dets[kMaxDetectorId][3]; 01074 track->getAllPointCount(dets,kMaxDetectorId-1); 01075 for (int i=1;i<kMaxDetectorId;i++) { 01076 if(!dets[i][0]) continue; 01077 gTrack->setNumberOfPossiblePoints((unsigned char)dets[i][0],(StDetectorId)i); 01078 } 01079 01080 fillGeometry(gTrack, track, false); // inner geometry 01081 fillGeometry(gTrack, track, true ); // outer geometry 01082 fillFitTraits(gTrack, track); 01083 gTrack->setDetectorInfo(detInfo); 01084 StuFixTopoMap(gTrack); 01085 fillFlags(gTrack); 01086 if (!track->isPrimary()) fillDca(gTrack,track); 01087 return; 01088 } 01089 //_____________________________________________________________________________ 01090 bool StiStEventFiller::accept(StiKalmanTrack* track) 01091 { 01092 // int nPossiblePoints = track->getMaxPointCount(0); 01093 // int nMeasuredPoints = track->getPointCount (0); 01094 int nFittedPoints = track->getFitPointCount(0); 01095 if (nFittedPoints < 5 ) return 0; 01096 #if 0 01097 if (nFittedPoints < 10 && nFittedPoints*2 < nPossiblePoints)return 0; 01098 if(track->getPt()<=0.1) return 0; 01099 #endif 01100 if(track->getTrackLength()<=0) return 0; 01101 // insert other filters for riff-raff we don't want in StEvent here. 01102 01103 01104 return 1; 01105 } 01106 //_____________________________________________________________________________ 01107 double StiStEventFiller::impactParameter(StiKalmanTrack* track 01108 ,StThreeVectorD &vertexPosition) 01109 { 01110 StiKalmanTrackNode* node; 01111 01112 node = track->getInnerMostNode(2); // ... 01113 01114 01115 originD->setX(node->x_g()); 01116 originD->setY(node->y_g()); 01117 originD->setZ(node->z_g()); 01118 01119 01120 physicalHelix->setParameters(fabs(node->getCurvature()), 01121 node->getDipAngle(), 01122 node->getPhase(), 01123 *originD, 01124 node->getHelicity()); 01125 01126 01127 //cout <<"PHelix: "<<*physicalHelix<<endl; 01128 return physicalHelix->distance(vertexPosition); 01129 } 01130 //_____________________________________________________________________________ 01131 double StiStEventFiller::impactParameter(StTrack* track, StThreeVectorD &vertex) 01132 { 01133 StPhysicalHelixD helix = track->geometry()->helix(); 01134 01135 //cout <<"PHelix: "<<helix<<endl; 01136 return helix.distance(vertex); 01137 } 01138 //_____________________________________________________________________________ 01139 void StiStEventFiller::fillResHack(StHit *hh,const StiHit *stiHit, const StiKalmanTrackNode *node) 01140 { 01141 01142 if (!mAux) return; 01143 StiAux_t aux; 01144 // local frame 01145 aux.xnl[0] = node->getX(); 01146 aux.xnl[1] = node->getY(); 01147 aux.xnl[2] = node->getZ(); 01148 01149 aux.xhl[0] = stiHit->x(); 01150 aux.xhl[1] = stiHit->y(); 01151 aux.xhl[2] = stiHit->z(); 01152 01153 aux.ca = node->getEta(); 01154 aux.rho = node->getCurvature(); 01155 aux.nYY = node->getCyy(); 01156 aux.nZZ = node->getCzz(); 01157 aux.hYY = node->getEyy(); 01158 aux.hZZ = node->getEzz(); 01159 01160 aux.unl[0] = node->getX(); 01161 aux.unl[1] = node->unTouched().mPar[0]; 01162 aux.unl[2] = node->unTouched().mPar[1]; 01163 aux.uYY = sqrt(node->unTouched().mErr[0]); 01164 aux.uZZ = sqrt(node->unTouched().mErr[2]); 01165 01166 01167 // global frame 01168 aux.xng[0] = node->x_g(); 01169 aux.xng[1] = node->y_g(); 01170 aux.xng[2] = node->z_g(); 01171 01172 aux.xhg[0] = stiHit->x_g(); 01173 aux.xhg[1] = stiHit->y_g(); 01174 aux.xhg[2] = stiHit->z_g(); 01175 aux.psi = node->getPsi(); 01176 aux.dip = node->getDipAngle(); 01177 // invariant 01178 double chi2 = node->getChi2();if (chi2>1000) chi2=1000; 01179 aux.chi2 = chi2; 01180 int id = mAux->AddIt(&aux); 01181 assert(id); 01182 hh->setId(id); 01183 assert(hh->id()); 01184 //mAux->PrintIt(id); 01185 01186 01187 } 01188 //_____________________________________________________________________________ 01189 void StiStEventFiller::fillDca(StTrack* stTrack, StiKalmanTrack* track) 01190 { 01191 StGlobalTrack *gTrack = dynamic_cast<StGlobalTrack*>(stTrack); 01192 assert(gTrack); 01193 01194 StiKalmanTrackNode *tNode = track->getInnerMostNode(); 01195 if (!tNode->isDca()) return; 01196 const StiNodePars &pars = tNode->fitPars(); 01197 const StiNodeErrs &errs = tNode->fitErrs(); 01198 float alfa = tNode->getAlpha(); 01199 float setp[7],sete[15]; 01200 TCL::ucopy(&pars._y,setp,7); 01201 setp[2]+= alfa; 01202 for (int i=1,li=1,jj=0;i< kNPars;li+=++i) { 01203 for (int j=1;j<=i;j++) {sete[jj++]=errs.A[li+j];}} 01204 StDcaGeometry *dca = new StDcaGeometry; 01205 gTrack->setDcaGeometry(dca); 01206 dca->set(setp,sete); 01207 01208 } 01209 //_____________________________________________________________________________ 01210 void StiStEventFiller::FillStHitErr(StHit *hh,const StiKalmanTrackNode *node) 01211 { 01212 double stiErr[6],stErr[6]; 01213 memcpy(stiErr,node->hitErrs(),sizeof(stiErr)); 01214 double alfa = node->getAlpha(); 01215 double c = cos(alfa); 01216 double s = sin(alfa); 01217 double T[3][3]={{c,-s, 0} 01218 ,{s, c, 0} 01219 ,{0, 0, 1}}; 01220 01221 TCL::trasat(T[0],stiErr,stErr,3,3); 01222 StThreeVectorF f3(sqrt(stErr[0]),sqrt(stErr[2]),sqrt(stErr[5])); 01223 hh->setPositionError(f3); 01224 } 01225 //_____________________________________________________________________________ 01226 void StiStEventFiller::fillPulls(StiKalmanTrack* track, int gloPri) 01227 { 01228 //cout << "StiStEventFiller::fillDetectorInfo() -I- Started"<<endl; 01229 if (!mPullEvent) return; 01230 int dets[kMaxDetectorId][3]; 01231 track->getAllPointCount(dets,kMaxDetectorId-1); 01232 StiPullTrk aux; 01233 aux.mTrackNumber=mTrackNumber; 01234 aux.nAllHits = dets[0][2]; 01235 aux.nTpcHits = dets[kTpcId][2]; 01236 aux.nSvtHits = dets[kSvtId][2]; 01237 aux.nSsdHits = dets[kSsdId][2]; 01238 aux.nPxlHits = dets[kPxlId][2]; 01239 aux.nIstHits = dets[kIstId][2]; 01240 aux.mL = (unsigned char)track->getTrackLength(); 01241 aux.mChi2 = track->getChi2(); 01242 aux.mCurv = track->getCurvature(); 01243 aux.mPt = track->getPt(); 01244 aux.mPsi = track->getPhi(); 01245 aux.mDip = atan(track->getTanL()); 01246 StThreeVectorD v3 = track->getPoint(); 01247 aux.mRxy = v3.perp(); 01248 aux.mPhi = v3.phi(); 01249 aux.mZ = v3.z(); 01250 mPullEvent->Add(aux,gloPri); 01251 01252 01253 StiKTNIterator tNode = track->rbegin(); 01254 StiKTNIterator eNode = track->rend(); 01255 for (;tNode!=eNode;++tNode) 01256 { 01257 StiKalmanTrackNode *node = &(*tNode); 01258 if(!node->isValid()) continue; 01259 01260 StiHit *stiHit = node->getHit(); 01261 if (!stiHit) continue; 01262 01263 if (node->getChi2()>1000) continue; 01264 if (!node->isFitted()) continue; 01265 01266 const StiDetector *detector = node->getDetector(); 01267 assert(detector == stiHit->detector()); 01268 assert(!detector || stiHit->timesUsed()); 01269 StHit *hh = (StHit*)stiHit->stHit(); 01270 fillPulls(hh,stiHit,node,track,dets,gloPri); 01271 if (gloPri) continue; 01272 fillPulls(hh,stiHit,node,track,dets,2); 01273 } 01274 } 01275 //_____________________________________________________________________________ 01276 void StiStEventFiller::fillPulls(StHit *stHit,const StiHit *stiHit 01277 ,const StiKalmanTrackNode *node 01278 ,const StiKalmanTrack *track 01279 ,int dets[1][3],int gloPriRnd) 01280 { 01281 double x,y,z,r,xp,yp,zp,rp; 01282 float untErrs[3]; 01283 01284 const StiNodeInf *inf = 0; 01285 if (gloPriRnd==2) { 01286 inf = node->getInfo(); 01287 if (!inf) return; 01288 } 01289 const StiNodeErrs &mFE = (inf)? inf->mPE : node->fitErrs(); 01290 const StiNodePars &mFP = (inf)? inf->mPP : node->fitPars(); 01291 StiHitErrs mHrr; 01292 memcpy(mHrr.A, (inf)? inf->mHrr.A : node->hitErrs(),sizeof(StiHitErrs)); 01293 01294 StiPullHit aux; 01295 // local frame 01296 // local HIT 01297 aux.nHitCand = node->getHitCand(); 01298 aux.iHitCand = node->getIHitCand(); 01299 if (!aux.nHitCand) aux.nHitCand=1; 01300 aux.lXHit = stiHit->x(); 01301 aux.lYHit = stiHit->y(); 01302 aux.lZHit = stiHit->z(); 01303 aux.lYHitErr = sqrt(mHrr.hYY); 01304 aux.lZHitErr = sqrt(mHrr.hZZ); 01305 aux.lHitEmx[0] = mHrr.hYY; 01306 aux.lHitEmx[1] = mHrr.hZY; 01307 aux.lHitEmx[2] = mHrr.hZZ; 01308 01309 // local FIT 01310 aux.lXFit = mFP._x; 01311 aux.lYFit = mFP._y; 01312 aux.lZFit = mFP._z; 01313 aux.lYFitErr = sqrt(mFE._cYY); 01314 aux.lZFitErr = sqrt(mFE._cZZ); 01315 aux.lFitEmx[0] = mFE._cYY; 01316 aux.lFitEmx[1] = mFE._cZY; 01317 aux.lFitEmx[2] = mFE._cZZ; 01318 // assert(fabs(aux.lYFit-aux.lYHit)>1e-10 || fabs(aux.lXHit)<4); 01319 01320 // local Pull 01321 xp = aux.lXHit; 01322 yp = (inf)? mFP._y: (double)node->unTouched().mPar[0]; 01323 zp = (inf)? mFP._z: (double)node->unTouched().mPar[1]; 01324 aux.lYPul = aux.lYHit-yp; 01325 aux.lZPul = aux.lZHit-zp; 01326 if (fabs(aux.lYPul)>10) StiDebug::Break(-1); 01327 if (fabs(aux.lZPul)>10) StiDebug::Break(-1); 01328 if (!inf) {TCL::ucopy(node->unTouched().mErr,untErrs,3);} 01329 else {TCL::ucopy(aux.lFitEmx ,untErrs,3);} 01330 assert(untErrs[0]>0); 01331 assert(untErrs[2]>0); 01332 TCL::vadd(untErrs,aux.lHitEmx,aux.lPulEmx,3); 01333 aux.lYPulErr = sqrt(aux.lPulEmx[0]); 01334 aux.lZPulErr = sqrt(aux.lPulEmx[2]); 01335 01336 aux.lPsi = mFP._eta; 01337 aux.lDip = atan(mFP._tanl); 01338 01339 // global frame 01340 double alfa = node->getAlpha(); 01341 float F[2][2]; 01342 01343 // global Hit 01344 x = stiHit->x(); y = stiHit->y(); z = stiHit->z(); 01345 r = sqrt(x*x+y*y); 01346 01347 aux.gRHit = r; 01348 aux.gPHit = atan2(stiHit->y_g(),stiHit->x_g()); 01349 aux.gZHit = stiHit->z_g(); 01350 memset(F[0],0,sizeof(F)); 01351 F[0][0]= x/(r*r); 01352 F[1][1]= 1; 01353 TCL::trasat(F[0],aux.lHitEmx,aux.gHitEmx,2,2); 01354 aux.gPHitErr = sqrt(aux.gHitEmx[0]); 01355 aux.gZHitErr = sqrt(aux.gHitEmx[2]); 01356 01357 01358 // global Fit 01359 x = mFP._x; y = mFP._y;z = mFP._z; 01360 r = sqrt(x*x+y*y); 01361 aux.gRFit = r; 01362 aux.gPFit = NICE(atan2(y,x)+alfa); 01363 aux.gZFit = z; 01364 01365 memset(F[0],0,sizeof(F)); 01366 F[0][0]= x/(r*r); 01367 F[1][1]= 1; 01368 TCL::trasat(F[0],aux.lFitEmx,aux.gFitEmx,2,2); 01369 aux.gPFitErr = sqrt(aux.gFitEmx[0]); 01370 aux.gZFitErr = sqrt(aux.gFitEmx[2]); 01371 01372 // global Pull 01373 rp = sqrt(xp*xp+yp*yp); 01374 aux.gPPul = ((aux.gPHit-alfa)-atan2(yp,xp))*rp; 01375 aux.gZPul = aux.lZHit-zp; 01376 memset(F[0],0,sizeof(F)); 01377 F[0][0]= xp/(rp*rp); 01378 F[1][1]= 1; 01379 TCL::trasat(F[0],untErrs,aux.gPulEmx,2,2); 01380 TCL::vadd(aux.gHitEmx,aux.gPulEmx,aux.gPulEmx,3); 01381 // Now account that Phi ==> R*Phi 01382 aux.gPulEmx[0]*= rp*rp; 01383 aux.gPulEmx[1]*= rp; 01384 aux.gPPulErr = sqrt(aux.gPulEmx[0]); 01385 aux.gZPulErr = sqrt(aux.gPulEmx[2]); 01386 01387 aux.gPsi = node->getPsi(); 01388 aux.gDip = node->getDipAngle(); 01389 01390 // invariant 01391 aux.mCurv = mFP._curv; 01392 aux.mPt = fabs(1./mFP._ptin); 01393 aux.mChi2 = node->getChi2(); 01394 aux.mNormalRefAngle = alfa; 01395 aux.mHardwarePosition=0; 01396 aux.mDetector=0; 01397 aux.mTrackNumber=mTrackNumber; 01398 aux.nAllHits = dets[0][2]; 01399 aux.nTpcHits = dets[kTpcId][2]; 01400 aux.nSvtHits = dets[kSvtId][2]; 01401 aux.nSsdHits = dets[kSsdId][2]; 01402 aux.nPxlHits = dets[kPxlId][2]; 01403 aux.nIstHits = dets[kIstId][2]; 01404 const StiDetector *stiDet = stiHit->detector(); 01405 if (stiDet) { 01406 aux.mHardwarePosition=stHit->hardwarePosition(); 01407 aux.mDetector=stHit->detector(); 01408 const StiPlacement *place = stiDet->getPlacement(); 01409 aux.mNormalRadius = place->getNormalRadius(); 01410 aux.mNormalYOffset = place->getNormalYoffset(); 01411 aux.mZCenter = 0; 01412 } 01413 mPullEvent->Add(aux,gloPriRnd); 01414 01415 }

Generated on Sun Mar 15 04:54:49 2009 for StRoot by doxygen 1.3.7