Auxiliary Data

If you read the ATLAS Software chapter, you saw that part of the derivation production process is adding new properties to objects. Those properties are usually called auxiliary data. By default, most InDet/TRT information is not saved because it is a lot of information and requires a lot of disk space.

When we produce TRT D(x)AOD's, we manually add that data in the xAOD designed way: as "aux data". You can find all the variables on this TWiki page.

Every object in the xAOD framework is a daughter to the SG::AuxElement class. You can read all about the class here.

There are three main classes that we'll grab aux data from:

  • xAOD::TrackParticle: our track

  • xTRT::MSOS (typedef of xAOD::TrackStateValidation): the measurement on surface (MSOS) ("hit")

  • xTRT::DriftCircle (typedef of xAOD::TrackMeasurementValidation): the TRT drift circle

We also add a little bit of aux data to xAOD::EventInfo (just check that wiki I linked).

For this tutorial, I'm going to talk about _retrieving _aux data (not creating, because in analysis projects 99% you just need to retrieve). There are two ways we can do it. I'm going to tell you the recommended way to do it (though it is not the only way). The recommended way (especially in loops, for performance reasons) is to create a SG::AuxElement::ConstAccessor<T> class.

Let's say we have a track and we want the eProbabilityHT variable and the time over threshold of each hit, the drift circle tot variable. I'm going to take some code from the Algorithm Development part 2 chapter, and add the ConstAccessor<T>'s

  // inside the loop over tracks

  const xTRT::MSOS* msos = nullptr;
  const xTRT::DriftCircle* driftCircle = nullptr;

  // create the accessors
  SG::AuxElement::ConstAccessor<float> acc_eProbabilityHT("eProbabilityHT");
  SG::AuxElement::ConstAccessor<float> acc_tot("tot");

  float eProbHT = 0;
  // check to make sure the aux data is available
  // then retrieve with the () operator.
  if ( acc_eProbabilityHT.isAvailable(*track) ) {
    eProbHT = acc_eProbabilityHT(*track)
  }

  float tot = 0;
  // make sure track measurement container is available
  if ( xTRT::Acc::msosLink.isAvailable(*track) ) {
    float tot = 0;
    for ( const auto& trackMeasurementLink : xTRT::Acc::msosLink(*track) ) {
      if ( trackMeasurementLink.isValid() ) {
        msos = *trackMeasurementLink;
        if ( msos->detType() != 3 ) continue; // TRT hits only.
        if ( !(msos->trackMeasurementValidationLink().isValid()) ) continue;
        driftCircle = *(msos->trackMeasurementValidationLink());

        // check that tot is available and retrieve it.
        if ( acc_tot.isAvailable(*driftCircle) ) {
          tot = acc_tot(*driftCircle);
        }

      } // if track measurement is valid
    } // loop over track measurements
  } // if track available

Now, that was a handful of lines of code to accomplish that. We have some help from TRTFramework to make life easier here. When reading Algorithm Development part 2 (and above), you saw the use of xTRT::Acc::msosLink. This is a SG::AuxElement::ConstAccessor for the ElementLink to a vector of track measurements (notice the entire container of hits is aux data on the track!); well, we have a set of predefined SG::AuxElement::ConstAccessor's for you to use. We also have a one line function (get) to check if the auxdata is there and to grab it; using the TRTFramework helpers, we can make that block of code:

  // inside the loop over tracks

  float eProbHT = get(xTRT::Acc::eProbabilityHT,track);

  const xTRT::MSOS* msos = nullptr;
  const xTRT::DriftCircle* driftCircle = nullptr;

  float tot = 0;
  // make sure track measurement container is available
  if ( xTRT::Acc::msosLink.isAvailable(*track) ) {
    for ( const auto& trackMeasurementLink : xTRT::Acc::msosLink(*track) ) {
      if ( trackMeasurementLink.isValid() ) {
        msos = *trackMeasurementLink;
        if ( msos->detType() != 3 ) continue; // TRT hits only.
        if ( !(msos->trackMeasurementValidationLink().isValid()) ) continue;
        driftCircle = *(msos->trackMeasurementValidationLink());

        tot = get(xTRT::Acc::tot,driftCircle);

      } // if track measurement is valid
    } // loop over track measurements
  } // if track available

That's a bit shorter and cleaner, but shouldn't be any more difficult to read. For a complete list of available accessors supplied by TRTFramework, see this header file

Last updated