Skip to content

Commit

Permalink
add trig obj
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin committed Aug 15, 2024
1 parent 0153f2b commit 2fc8ee2
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
1 change: 1 addition & 0 deletions _episodes/04-HLT_efficiency.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ We will first run this exercise on MiniAOD format, then run it again on NanoAOD.
> scram b -j 4
> cd $CMSSW_BASE/src/ShortExerciseTrigger2023/ShortExerciseTrigger/test
> ~~~
> {: .language-bash}
> Copy the skimmed NanoAOD file to your working directory as follows:
> ~~~
> xrdcp root://cmseos.fnal.gov//store/user/cmsdas/2023/short_exercises/Trigger/New_NanoAOD_M1000.root .
Expand Down
50 changes: 50 additions & 0 deletions _episodes/05-TriggerObj.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,56 @@ objectives:
---

> ## MiniAOD
> In the [efficiency measurement Ex.][lesson-04-HLT_efficiency], we performed a simple efficiency measurement using the `TriggerResults` product in a MiniAOD file and a NanoAOD file.<br>
> Sometimes, we want to know what is the exact object reconstructed and used in the HLT path.<br>
> This is what `TriggerObjectStandAloneCollection` contains - the actual physics objects reconstructed at the HLT.
>
> Have a look at the code in `plugins/SingleMuTrigAnalyzerMiniAOD.cc`, especially the analyze function starting from line 95, as well as the configuration file `ana_SingleMuMiniAOD.py`.
>
> > ## Additional info
> > The configuration file shows that also this time we are using as input a skimmed MiniAOD file called `skim_dimu20_SingleMuon_2016G_ReReco_180k.root`. In case you are wondering again, this skim has been produced with the configuration `skim_dimu20.py`, requires two offline muons with pt above 20 GeV.
> {: .objectives}
>
> This time we don't have a signal trigger and a separate reference trigger. Instead, we focus only on one single-muon trigger, namely HLT_IsoMu24:
> ~~~
> process.singleMuTrigAnalyzerMiniAOD.triggerName = cms.untracked.string("HLT_IsoMu24_v2")
> ~~~
> {: .language-python}
> The `SingleMuTrigAnalyzerMiniAOD.cc` analyzer is longer and more complicated than the one in [efficiency measurement Ex.][lesson-04-HLT_efficiency], and we will discuss it not only in this exercise, but also in two others that follow. So don't worry if some parts look somewhat mysterious first.
>
> Similarly to [efficiency measurement Ex.][lesson-04-HLT_efficiency], in line 129 the name of the HLT path (`triggerName_`) is used to retrieve the corresponding index (`triggerIndex`):
> ~~~
> const unsigned int triggerIndex(hltConfig_.triggerIndex(triggerName_));
> ~~~
> {: .language-cpp}
> which is then used (in line 148) to access the HLT decision to accept or reject the event:
> ~~~
> bool accept = triggerResultsHandle_->accept(triggerIndex);
> ~~~
> {: .language-cpp}
> You can find some new, more interesting tricks on lines 180-190.
> There we create an empty vector `trigMuons`, loop over all trigger objects (that is, physics objects reconstructed at HLT), select the objects that HLT classified as muons that would pass our single-muon trigger, and add the four-vectors of these trigger-level muon objects to the trigMuons vector:
> ~~~
> std::vector trigMuons;
> if (verbose_) cout << "found trigger muons:" << endl;
> const edm::TriggerNames &names = iEvent.triggerNames(*triggerResultsHandle_);
> for (pat::TriggerObjectStandAlone obj : *triggerOSA_) {
> obj.unpackPathNames(names);
> if ( !obj.id(83) ) continue; // muon type id
> if ( !obj.hasPathName( triggerName_, true, true ) ) continue; // checks if object is associated to last filter (true) and L3 filter (true)
> trigMuons.push_back(LorentzVector(obj.p4()));
> if (verbose_) cout << " - pt: " << obj.pt() << ", eta: " << obj.eta() << ", phi: " << obj.phi() << endl;
> } // loop on trigger objects
> ~~~
> {: .language-cpp}
>
> Run the configuration file as follows:
> ~~~
> cd $CMSSW_BASE/src/ShortExerciseTrigger2023/ShortExerciseTrigger/test
> cmsRun ana_SingleMuMiniAOD.py
> ~~~
> {: .language-bash}
> The code will output a file called `histos_SingleMuTrigAnalyzer.root`, which we will inspect in the next exercise.
{: .solution}
> ## NanoAOD
Expand Down

0 comments on commit 2fc8ee2

Please sign in to comment.