// // Initialize the links between tracks and silicon hits and intersections // after the track block and svx data blocks have been made. // This block is off be default. To get it, use makeTrackLinks set t // // This block needs the track block to have been requested, and then also // SvxDataBlock // // Aaron Dominguez (LBL) 6 Nov 2002 // #include "Stntuple/obj/TStnEvent.hh" #include "Stntuple/obj/TStnDataBlock.hh" #include "Stntuple/obj/TStnTrackBlock.hh" #include "Stntuple/obj/TSvxDataBlock.hh" #include "Stntuple/obj/TStnTrackLinkBlock.hh" #include "Stntuple/mod/InitStntupleDataBlocks.hh" #include "Stntuple/mod/SiHitLookup.hh" #include "TrackingObjects/SiData/SiHit.hh" #include "TrackingObjects/SiData/SiHitSet.hh" #include "TrackingObjects/Tracks/CdfTrack.hh" #include "SiliconGeometry/SiDigiCode.hh" #include "TrackingUserHL/Utility/CorrectedHitLocations.hh" #include "STLExtensions/VectIndexedMap.hh" #include "AbsEnv/AbsEnv.hh" #include "TVector3.h" #include #include Int_t StntupleTrackLinkBlockLinks(TStnDataBlock* Block, AbsEvent* Event, int Mode) { // First get the various blocks. If not there, bail out TStnTrackBlock* tdata; tdata = (TStnTrackBlock* ) Block->GetEvent()->GetDataBlock("TrackBlock"); if (! tdata) return -1; TStnTrackLinkBlock* tlink; tlink = (TStnTrackLinkBlock* ) Block->GetEvent()->GetDataBlock("TrackLinkBlock"); if (! tlink) return -1; TSvxDataBlock* sdata; sdata = (TSvxDataBlock* ) Block->GetEvent()->GetDataBlock("SvxDataBlock"); if (! sdata) return -1; EventRecord::ConstIterator it(Event,"SiHitSet"); if (! it.is_valid()) { // No hit list. Go home return -1; } SiHitSet_ch sh(it); // Loop over Pasha's tracks and make links to SvxDataBlock and/or SiIsectBlock tlink->SiHitLinkTrk()->Init(tdata->NTracks()); for (int itrk=0; itrkNTracks(); ++itrk) { const CdfTrack *t=tdata->Track(itrk)->GetCdfTrack(); if (!t) continue; // Loop over any silicon hits on this track and make cross links if ( sh->contents().size()>0 ) { tlink->SiHitLinkTrk()->InitLinks(itrk); for (CdfTrack::SiHitIterator si=t->beginSIHits(); si!=t->endSIHits(); ++si){ // Dig out the index into the TClonesArray of TStnSiHits SiDigiCode digi=(*si)->getSiDigiCode(); SiHitSet::const_digi_iterator di=sh->contents().find(digi); if ( di != sh->contents().end()) { SiHitSet::const_iterator i = std::find((*di).second.begin(),(*di).second.end(), (*si)); if (i != (*di).second.end()) { int index = sh->index(di,i).vectorIndex(); int vecsize = (*di).second.size(); if (index>=0 && indexfId; int ihit = sdata_fid->map[digi][index]; // Index into TClonesArray. tlink->SiHitLinkTrk()->Add(itrk,ihit); // Correct the hit's global location for wafer bows & misalignments CorrectedHitLocations corrHit(*t, **si); sdata->SiHit(ihit)->fGlobal = TVector3(corrHit.getHitGlobal().x(), corrHit.getHitGlobal().y(), corrHit.getHitGlobal().z()); } } } } } // Loop over any track intersections is now done in StntupleSiIsectBlockLinks // for speed and convenience. } return 0; }