Here we describe one way to access global track data. At almost every step there are other choices--see the headers for those options.
const Event& evt = ... // Get an event from somewhere GTrackContentIdSelector sel(401); TKey<GTrackChunk> key(sel); THandle<GTrackChunk> pchk = key.find(evt);The selector is constructed from the content ID appropriate for the the type of tracks desired. A table of content ID's may be found in package gtr_find.
The global track chunk is class GTrackChunk.
The list of tracks can be accessed with get_tracks():
GTrackChunk::TrackList gtracks = pchk->get_tracks();and iterated over in the usual manner:
for ( GTrackChunk::TrackList::const_iterator itrg=gtracks.begin();
itrg!=gtracks.end(); ++itrg ) {
const GTrack& trg = *itrg;
Typically the user wants the state for a particular surface (in our example we choose the surface to be the distance of closest approach, class SurfDCA ). The class D0GTrackPropagator can be used to extract the state at this surface.
Before our track loop, we might define:
D0GTrackPropagator gprop; SurfacePtr pdca(new SurfDCA);Inside the loop we extract the state at the DCA with
const GTrackState state = gprop.propagate(trg,pdca);
assert( state.is_valid() );
assert( state.fit_status() == GTrackState::OPTIMAL );
We check for possible error in propagation and also check that the
fit for this state is optimal. In this example, we handle any errors
crudely by throwing an assertion. No doubt, you have a more elegant
treatment. The track parameters and errors should not be considered
reliable if the fit is not optimal.
The GTrack propagator described here is intended as a replacement for the old GtrTrfPropagator which did not account for material in the detector. There is a separate page which describes that propagator and options for constructing either on from different TRF++ propagators.
ETrack tre = state.track();
The meaning of the track parameters depends on the type of surface.
We verify that the surface is the DCA and extract the track vector
and error matrix:
assert( tre.get_surface()->get_type() == SurfDCA::get_static_type() );
const TrackVector& vec = tre.get_vector();
const TrackError& err = tre.get_error();
and then used the indices defined in the SurfDCA header to extract the
value and error for q/pT (charge over transverse momentum in units of
e/GeV/c):
double qoverpt = vec(SurfDCA::IQPT);
double dqoverpt = sqrt( err(SurfDCA::IQPT,SurfDCA::IQPT) );
In general one should not use TRF++ propagators to propagate these ETrack's to another surface if there is any chance of crossing any material or measurement surfaces. Such propagators are likely to ignore or improperly handle the material or measurements. Instead propagate the original GTrack to the surface and extract the state and ETrack as decribed above. material or correct the errors