This Twiki describes how to do a basic trigger analysis in CMSSW. This is a first draft and may contain mistakes.

It is designed for a user who just wants to know a) if their favourite trigger fired and b) what objects passed their favourite trigger. For a more detailed description of the HLT software, please see SWGuideHighLevelTrigger. For a more sophisticated approach using the PAT, please see SWGuidePATTrigger.

Introduction

Trigger information is contained in two objects in CMSSW which are both present in AOD

TriggerResults:
stores whether the trigger was run and whether it accepted the event or not

TriggerEvent:
stores the four-momentum of the objects passing filters of a trigger. Only important filter outputs are saved, typically the last filter of each part of the trigger. It is important to note that just because objects pass the last filter, it doesnt mean the trigger you are interested in fired. For example, if only one object passed the filter, a di-object trigger wouldnt accept the event. Secondly triggers often share modules, it could be that this trigger is prescaled and not run on this event but another trigger with additional ID ran the filter.

Accessing if a trigger accepted an event or not

This is how to figure out if a given trigger fired or not for a given event.

Header files necessary:

#include "DataFormats/Common/interface/TriggerResults.h"
#include "FWCore/Common/interface/TriggerNames.h"

code snippet:

edm::Handle<edm::TriggerResults> trigResults; //our trigger result object
edm::InputTag trigResultsTag("TriggerResults","","HLT"); //make sure have correct process on MC
//data process=HLT, MC depends, Spring11 is REDIGI311X
iEvent.getByLabel(trigResultsTag,trigResults);
const edm::TriggerNames& trigNames = iEvent.triggerNames(*trigResults);   

std::string pathName="HLT_PFHT350_PFMET120_NoiseCleaned_v1";

bool passTrig=trigResults->accept(trigNames.triggerIndex(pathName));  

Getting Four-Momentum of Objects Passing a Filter

The following code snippet tells you how to access the trigger objects (which contain the p4) of the objects passing a given filter. Note the filter must have had saveTag=True in its configuration which is only the case for the most important filters. The L1 filter is also saved so this can be used to perform L1 studies. Note that L1 eta/phi is courser than RECO so looser matching needs to be done.

Currently (41X) saveTag is an untracked parameter however in 42X this will be tracked meaning it can be checked from HLTConfigProvider.

Warning: for electron triggers which have tracker ID or tracker isolation cuts, the p4 is vertex corrected while the Et filter calculates w.r.t 0,0,0.

Header files necessary:

#include "DataFormats/HLTReco/interface/TriggerObject.h"
#include "DataFormats/HLTReco/interface/TriggerEvent.h"

code snippet:

edm::InputTag trigEventTag("hltTriggerSummaryAOD","","HLT"); //make sure have correct process on MC
//data process=HLT, MC depends, Spring11 is REDIGI311X
edm::Handle<trigger::TriggerEvent> trigEvent; 
iEvent.getByLabel(trigEventTag,trigEvent);

std::string filterName("hltSingleJet190Regional"); 

//it is important to specify the right HLT process for the filter, not doing this is a common bug
trigger::size_type filterIndex = trigEvent->filterIndex(edm::InputTag(filterName,"",trigEventTag.process())); 
if(filterIndex<trigEvent->sizeFilters()){ 
    const trigger::Keys& trigKeys = trigEvent->filterKeys(filterIndex); 
    const trigger::TriggerObjectCollection & trigObjColl(trigEvent->getObjects());
    //now loop of the trigger objects passing filter
    for(trigger::Keys::const_iterator keyIt=trigKeys.begin();keyIt!=trigKeys.end();++keyIt){ 
      const trigger::TriggerObject& obj = trigObjColl[*keyIt];
      //do what you want with the trigger objects, you have
      //eta,phi,pt,mass,p,px,py,pz,et,energy accessors
    }
    
}//end filter size check

Matching between Paths and Filters

A filter may (and many infact do) belong to multiple paths. To determine what modules belong to a path the class HLTConfigProvider contains methods suchs as:

const std::vector<std::string>& HLTConfigProvider::moduleLabels(const std::string& trigger)const;
const std::vector<std::string>& HLTConfigProvider::saveTagsModules(const std::string& trigger)const;

The first method will give a list of the all the modules of a Path and the second will give only those modules which are saved in the TriggerEvent. However the second function will require 42X and data /MC produced in 42X. A good rule of thumb is that the last module is saved (which is the second to last module due to the presence of HLTBool at the end). Instructions on how to setup the HLTConfigProvider can be found here.

Emulating a new trigger with higher thresholds/object numbers

Note this only works for a trigger which is a threshold change or object number change ie emulating Jet210 from a Jet190 sample. It does not work if the reconstruction at the HLT changed or additional ID was applied

Example: Lets emulate TriJet300 starting from Jet190

//as above example
std::string filterName("hltSingleJet190Regional"); //whatever your filter name is

bool passTriJet300 =false;
int nrJet300=0;

//it is important to specify the right HLT process for the filter, not doing this is a common bug
trigger::size_type filterIndex = trigEvent->filterIndex(edm::InputTag(filterName,"",trigEventTag.process())); 
if(filterIndex<trigEvent->sizeFilters()){ 
    const trigger::Keys& trigKeys = trigEvent->filterKeys(filterIndex); 
    const trigger::TriggerObjectCollection & trigObjColl(trigEvent->getObjects());
    //now loop of the trigger objects passing filter
    for(trigger::Keys::const_iterator keyIt=trigKeys.begin();keyIt!=trigKeys.end();++keyIt){ 
      const trigger::TriggerObject& obj = trigObjColl[*keyIt];
      if(obj.pt()>300) nrJet300++;
    }
    
}//end filter size check
 
if(nrJet300>=3) passTriJet300 = true;

-- SamHarper - 03-May-2011

Edit | Attach | Watch | Print version | History: r6 < r5 < r4 < r3 < r2 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r6 - 2015-06-16 - SamBein
 
    • 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