From 2fc8ee26399601587a45cfd466ce94eab5fec03e Mon Sep 17 00:00:00 2001 From: Martin Date: Thu, 15 Aug 2024 15:05:57 -0500 Subject: [PATCH] add trig obj --- _episodes/04-HLT_efficiency.md | 1 + _episodes/05-TriggerObj.md | 50 ++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/_episodes/04-HLT_efficiency.md b/_episodes/04-HLT_efficiency.md index a48df73..fc384a1 100644 --- a/_episodes/04-HLT_efficiency.md +++ b/_episodes/04-HLT_efficiency.md @@ -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 . diff --git a/_episodes/05-TriggerObj.md b/_episodes/05-TriggerObj.md index b5161ca..74188ba 100644 --- a/_episodes/05-TriggerObj.md +++ b/_episodes/05-TriggerObj.md @@ -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.
+> Sometimes, we want to know what is the exact object reconstructed and used in the HLT path.
+> 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