Tracker reco-to-sim association

Complete: 4

Goals of this page

This page is intended to familiarize the CMSSW user with the tools available in order to associate a reconstructed Track (in the Tracker) with the corresponding MC true simulated particle. This information is essential for the evaluation of efficiency and fake rates of tracking algorithms but it is also essential for higher level Physics Analysis. It is only possible with FEVT data, since the RECO does not contain TrackingParticles.

In particular, you will learn:

  • How RecHits are associated to the corresponding SimHits in the Tracker (Pixel+Strip detectors)
  • How RecoTracks are associated to the corresponding MC truth object (TrackingParticle)
  • Where to find the code
  • Examples on how to run the code and obtain the association information in your own Analyzer

MC Truth association of muon tracks is described in another twiki page, although part of the tools (tracker related) are common.

Introduction

Associating RecHits

During analysis or MC data Validation it might become necessary to associate a reconstructed RecHit object in the Tracker (Strip or Pixel detector) to its corresponding true SimHit in order to compare their properties (for instance their positions). Since in the EDM the RecHit object cannot contain any dependence on the simulation information this information needs to be saved in a different object specifically designed for this purpose, the SiStrip(Pixel)DigiSimLink.

The SiStrip(Pixel)DigiSimLink is filled after the digitazion stage (SimTracker/SiStrip(Pixel)Digitizer package). For each strip(pixel), and for each PSimHit that deposited some amount of charge in it, we save: the index into the PSimHit collection; a bit [high|low]ToF that in combination with the detId.subdet() identifies the PSimHit collection; the ID of the associated SimTrack; the EncodedEventId that the particle belongs to; and the charge deposited by the PSimHit as a fraction of the charge deposited by all PSimHits in crossing that particular pixel or strip. The SiStrip(Pixel)DigiSimLink object is part of the FEVT output. It is important to remember that in order to perform this association the RECO event output does not contain all the necessary information since all the digitization level information is dropped.

The hit association code is contained in the SimTracker/TrackerHitAssociation package. The code has been developed to have a seamless interface for the user who requires strip or pixel information. The procedure works as follows: for each RecHit the information of the digis that are contained in it is queried through the corresponding Cluster object. There are two different type of methods of the HitAssociator that are suitable for different purposes:

  • TrackerHitAssociator::associateHit(const TrackingRecHit & thit) this method takes as an input a generic TrackingRecHit and returns a vector containing all the PSimHits that correspond to the same strips(pixels) contained in the RecHit. The list is not ordered. The user, depending on the analysis scope needs to decide how to choose the best PSimHit from the list.
  • TrackerHitAssociation::associateHitId(const TrackingRecHit & thit) this method takes as an input a generic TrackingRecHit and returns a vector of SimTrack ID's paired with their encoded event information (this is necessary for the case of events with pile-up). The list is not ordered. The user, depending on the analysis scope needs to decide how to choose the best ID from the list.

The following parameters can be set via configuration file:

  • associateStrip = cms.bool Flag to turn off if no Strip information is present
  • associatePixel = cms.bool Flag to turn off if no Pixel information is present
  • Comment out the appropriate strings to remove sub-detectors from hit association:
    ROUList = cms.vstring("TrackerHitsTIBLowTof","TrackerHitsTIBHighTof", 
               "TrackerHitsTIDLowTof","TrackerHitsTIDHighTof",
               "TrackerHitsTOBLowTof","TrackerHitsTOBHighTof",
               "TrackerHitsTECLowTof","TrackerHitsTECHighTof",
               "TrackerHitsPixelBarrelLowTof","TrackerHitsPixelBarrelHighTof",
               "TrackerHitsPixelEndcapLowTof","TrackerHitsPixelEndcapHighTof")
  • associateRecoTracks = cms.bool This switch set to true allows to run over events already produced that do not contain the transient MixingModule information. This can be done when the full PSimHit information is not needed and only the hit Id is requested as in the TrackAssociation usage case (see below). If the switch is set to false it means that the code needs to be run at the same time as the simulation job.

Track Association

In order to evaluate the performances of tracking algorithms in simulated data it is necessary to be able to define if a reconstructed track is associated to a simulated track or not (that is the track is a "fake track"). There are several methods that allow to accomplish this task, they can be divided in methods that compare the parameter of real and simulated tracks or that compare the provenance of the hits associated to the track itself. In order to be able to make a better comparison with the simulation information a new object has been developed called the TrackingParticle, described here.

The Track Associators implement two methods:

  • associateRecoToSim: associates reconstructed tracks to TrackingParticles.
  • associateSimToReco: associates TrackingParticles to reconstructed tracks.
These methods are defined in the the base class of the track associators, TrackAssociatorBase.


Two versions of each method is provided:

  • The first taks as input an edm::Handle<edm::View<reco::Track> > and an edm::Handle. View allows to use the Track Associator with any collection of objects inheriting from the Track class (i.e. Track itself, GsfTracks). The collection of tracks can be directly taken from the event as follows:
  Handle<View<Track> > trackCollectionH;
  event.getByLabel(tracksTag,trackCollectionH);
  edm::Handle<TrackingParticleCollection>  TPCollectionH ;
  event.getByLabel(tpTag,TPCollectionH);
  const View<Track>  tC = *(trackCollectionH.product()); 
  ESHandle<TrackAssociatorBase> myAssociator;
  iSetup.get<TrackAssociatorRecord>().get("TrackAssociatorByChi2", myAssociator);
  reco::RecoToSimCollection p = myAssociator->associateRecoToSim(trackCollectionH,TPCollectionH,&event );
  • The second takes as input an edm::RefToBaseVector<reco::Track>. Starting from any collection of tracks stored in the event, the user can select a different set of tracks to be associated:
  edm::Handle<edm::View<reco::Track> > tCH;
  event.getByLabel(tracksTag,tCH);
  edm::Handle<TrackingParticleCollection>  TPCollectionH ;
  event.getByLabel(tpTag,TPCollectionH);
  edm::RefToBaseVector<reco::Track> tc(tCH);
  for (unsigned int j=0; j<tCH->size();j++)
       if ( ... ) tc.push_back(edm::RefToBase<reco::Track>(tCH,j));
  }
  ESHandle<TrackAssociatorBase> myAssociator;
  iSetup.get<TrackAssociatorRecord>().get("TrackAssociatorByChi2", myAssociator);
  reco::RecoToSimCollection p = myAssociator->associateRecoToSim(tc,TPCollectionH,&event );

N.B. You can alternatively create the RecoToSimCollection and SimToRecoCollection simply by running the EDProducer !SimTracker.TrackAssociation.trackingParticleRecoTrackAsssociation_cfi in your _cfg.py file. You then just need to read it in to your analysis program with:

    Handle<reco::RecoToSimCollection > rectosimCollection;
    iEvent.getByLabel("trackingParticleRecoTrackAssociation", rectosimCollection);

The RecoToSimCollection is a OneToManyWithQualityGeneric AssociationMap, defined in: DataFormats/RecoCandidate/interface/TrackAssociation.h. This association map, for every Track (TrackingParticle), stores the vector of associated TrackingParticles (Tracks) and the quality of the association. The vector is ordered from the element with the best quality to the element with the worst.

Once the association is performed, the map can be read as follows:

   for(View<Track>::size_type i=0; i<trackCollection->size(); ++i){
   RefToBase<Track> track(trackCollection, i);
   std::vector<std::pair<TrackingParticleRef, double> > tp;
   if(recSimColl.find(track) != recSimColl.end()){
     tp = recSimColl[track];
     if (tp.size()!=0) {
              TrackingParticleRef tpr = tp.begin()->first;
              double associationQuality = tp.begin()->second;
              ...
          }
        }
      }
A more complete example can be found in testTrackAssociator.cc.

The TrackAssociatorBase allows the association of TrajectorySeeds and TrackCandidates: it defines the corresponding association maps and the associateSimToReco (RecoToSim) methods. These methods are implemented dummy in the TrackAssociatorBase, but they are virtual, so the concrete Track Associators can implement their own Seed or TrackCandidate association. At the moment, the TrackAssociatorByHits implements the Seed association Seed Association By Hits.

Track Associator By Hits

The TrackAssociatorByHits associates tracks and TrackingParticles on the basis of the number of hits they share. A TrackingRecHit is shared with a TrackingParticle if TrackerHitAssociation::associateHitId method returns at least one of the SimTrack IDs belonging to the TrackingParticle.

Many options are configurable via parameter set. Default settings are in SimTracker/TrackAssociation/python/TrackAssociatorByHits_cfi.py.

  • AbsoluteNumberOfHits: false (default) means that the association quality is the fraction of hits shared, true means that the association quality is the absolute number of shared hits.
  • SimToRecoDenominator: by default, for the SimToReco association the minimum fraction is defined as (shared hits)/(TrackingParticle hits) (SimToRecoDenominator = "sim"). If SimToRecoDenominator = "reco" the fraction is defined as (shared hits)/(reco track hits).
  • UseGrouped: if true (default), the TrackingParticle hits are computed counting all the simulated hits in the tracker layer: this option has to be used if the track has been reconstructed using the GroupedTrajectoryBuilder. If it is false, only one hit per layer is computed (to be used for TrajectoryBuilder).
  • UseSplitting: if false the hits in strip matched layers count one for the number of TrackingParticle hits. If true (default since CMSSW20X), both hits (mono and stereo) contribute: this option has to be set to true when the matched hits are split before the Final Fit.
  • UsePixels: if true the pixel hits are counted for the number of TrackingParticle hits. If false they are not: set it to true only for pixel-less tracking.
  • ThreeHitTracksAreSpecial: if true (default) the tracks with a number of hits equal to three are associated only if they have all the hits shared.

Up to CMSSW_2_0_6:

  • MinHitCut: the threshold value for the association. If AbsoluteNumberOfHits = false, MinHitCut is the minimum fraction of shared hits (default value 0.5). For RecoToSim association the fraction is defined as (shared hits)/(reco track hits); for SimToReco association the fraction is defined as (shared hits)/(TrackingParticle hits). If AbsoluteNumberOfHits =true, MinHitCut is the minimum number of hits shared by the track and the TrackingParticle.

Since CMSSW_2_0_7:

  • The parameter set does not change, but an additional hard-coded request of purity>0.75 (where purity = #shared/#recoHits) is added. This implies that for SimToReco association a track is associated if quality > MinHitCut AND purity > 0.75 while for RecoToSim association, since quality and purity have the same definition, the tracks are associated if purity > 0.75 AND purity > MinHitCut. This means that if MinHitCut < 0.75 it has no effect.

Since CMSSW_2_1_0_pre6:

  • MinHitCut: this parameter is deprecated and has been replaced by the following three parameters.
  • Quality_SimToReco: Quality cut for SimToReco association. If AbsoluteNumberOfHits = false, the quality is defined as (shared hits)/(TrackingParticle hits) (default value 0.5) and a TP is associated if quality > Quality_SimToReco AND purity > Purity_SimToReco. If AbsoluteNumberOfHits = true the quality is defined as the number of shared hits, the purity cut has no effect and a TP is associated if quality > Quality_SimToReco.
  • Purity_SimToReco: Purity cut for SimToReco association. The purity is still defined as (shared hits)/(TrackingParticle hits). The default value is 0.75.
  • Cut_RecoToSim: Cut for RecoToSim association (default value 0.75). A reco::Track is associated if quality > Cut_RecoToSim.

Seed Association By Hits

The TrackAssociatorByHits has also the methods to associate seeds, taking as input an edm::Handle<edm::View > and returning a reco::RecoToSimCollectionSeed (associateRecoToSim method) or a reco::SimToRecoCollectionSeed (associateSimToReco method). The seed association collection maps are defined in TrackAssociatorBase.h. The association algorithm is the same as in the track association: the only differences are the following:
  • The input collection.
  • Also the SimToReco association fraction is always defined as (shared hits)/(reco track hits).
  • No request is made on the purity.

Note that, as the seeds have two or three hits, the default settings (AbsoluteNumberOfHits = false, MinHitCut = 0.5, ThreeHitTracksAreSpecial = true) allow the association only if 100% of the seed hits are shared with the same TrackingParticle.

Track Associator By Chi2

The TrackAssociatorByChi2 associates tracks and TrackingParticles on the basis of the chi2 (per degree of freedom) computed between the track parameters of the reconstructed track and those of the TrackingParticle. If the chi2 value is below the cut value they are associated. The chi2 is stored in the association map as -chi2 because the association map is ordered according to std::greater: in this way the first element in the map is still the one with the best quality, i.e. the lowest chi2.

Default settings are in SimTracker/TrackAssociation/data/TrackAssociatorByChi2.cfi.

  • chi2cut: value of the applied cut (default=25).
  • onlyDiagonal: false by default. Turn it to true to use only the diagonal terms of the track parameters covariance matrix.
  • beamSpot: name of the module that produced the BeamSpot (default: offlineBeamSpot).

The BeamSpot is needed by the TrackAssociatorByChi2 because the TrackingParticle contains the information about the position and the momentum at the point where the particle is created, while the reconstructed track parameter are defined at the point of closest approach to the beam line. The TrajectoryStateClosestToBeamLineBuilder class is responsible for the propagation of the TrackingParticle state from the production point to the point of closest approach to the beam line (note that the TrajectoryStateClosestToBeamLineBuilder is used also in TrackProducer).

Track Associator By Position

A third track associator is available in CMSSW, the TrackAssociatorByPosition, which is mainly used to associate muons. More on muon MC Truth association is found in this twiki page.

Use of Track Selectors with Track Associators

When studying tracks, one often wishes to select a subset of all tracks/TrackingParticles (e.g. satisfying quality criteria). This can be done by copying the selected subset to a new collection, by including in _cfg.py!:

import CMS.PhysicsTools.RecoAlgos.trackingParticleSelector_cfi
process.mySimTrackEffi = CMS.PhysicsTools.RecoAlgos.trackingParticleSelector_cfi.trackingParticleSelector.clone()
import CMS.PhysicsTools.RecoAlgos.recoTrackSelector_cfi
process.myRecoTrackSel = CMS.PhysicsTools.RecoAlgos.recoTrackSelector_cfi.recoTrackSelector.clone()

However, there is no trivial way of relating the tracks in the copied collection to those in the original one. So if one had produced an association map between tracks and TrackingParticles in the original collection, this can't easily be used on the copied collection. It is therefore usually better to select the desired tracks/!TrackingParticles by creating RefVectors containing references back to the selected tracks in the original collections. This is done as follows.

import CommonTools.RecoAlgos.trackingParticleRefSelector_cfi
process.mySimTrackEffi = CommonTools.RecoAlgos.trackingParticleRefSelector_cfi.trackingParticleRefSelector.clone()

import CommonTools.RecoAlgos.recoTrackRefSelector_cfi
process.myRecoTrackSel = CommonTools.RecoAlgos.recoTrackRefSelector_cfi.recoTrackRefSelector.clone()

(N.B. These files only exist from CMSSW 3.4 onwards, although they can be checked out and used with earlier versions). The original association maps can be used transparently on these collections.

Recreating TrackingParticles

From CMSSW_7_X TrackingParticles are not saved in the persistent collections. They can be reconstituted with lines in the configuration file like the following:

process.load("SimGeneral.MixingModule.mixNoPU_cfi")
process.load("SimGeneral.MixingModule.trackingTruthProducerSelection_cfi")
process.trackingParticles.simHitCollections = cms.PSet( )
process.mix.playback = cms.untracked.bool(True)
process.mix.digitizers = cms.PSet(
     mergedtruth = cms.PSet(process.trackingParticles)
)
for a in process.aliases: delattr(process, a)

and then add process.mix to the path.

Review status

Reviewer/Editor and Date (copy from screen) Comments
PatriziaAzzi - 04 Feb 2007 author
JennyWilliams - 19 Dec 2007 moved to SWGuide
GiuseppeCerati - 24 Jan 2008 Added TrackAssociatorByHits and TrackAssociatorByChi2
VictorBazterra - 13 Feb 2008 Adding TrackHistory documentation.
VictorBazterra - 03 Mar 2008 Adding TrackHistory manual.
GiuseppeCerati - 26 Mar 2008 Updated TrackAssociation
VictorBazterra - 16 Jul 2008 Update of TrackHistory
GiuseppeCerati - 04 May 2009 Updates for docs review
VictorBazterra - 2009-08-27 Moving TrackHistory documentation to the manual.
| Main.Tomalin - 2009-10-2009 | Described !SimTracker.TrackAssociation.trackingParticleRecoTrackAsssociation_cfi and use of Track Selectors.

Responsible: PatriziaAzzi
Last reviewed by: PatriziaAzzi - 07 Jan 2008

Edit | Attach | Watch | Print version | History: r42 < r41 < r40 < r39 < r38 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r42 - 2015-09-28 - WilliamFord
 
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    CMSPublic All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback