There are two sections to the code. The first section assumes that the track finder is correct and then searches for the best GEANT match, the second section of code assumes that GEANT is correct and searches for the best track finder match. When searching for tracks the routine sorts the hits according to the track number and then looks for indices such that the track number changes. The ``best'' match is found by sorting the hits within a track, and the ID that gave the most hits to this track is then considered the best match. The output is in the tables TRACKDBG (which assumes the track finder is correct and looks for GEANT matches) and GEANTDBG (which assumes the reverse).
In the event that a GEANT track has no corresponding track finder track the TRACKID is returned as zero. In the event that a TRACKID or GEANTID in the HITS table has no corresponding entry in the TRACKS table or the GEANT_TRACKS table, the TRACKID or GEANTID is returned, but the other values in the table corresponding to the TRACKID or GEANTID are set to invalid values.