Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Phase-2 L1 Trigger NanoAOD #47178

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1720,6 +1720,26 @@ def condition(self, fragment, stepList, key, hasHarvest):
offset = 0.78
)

# use HLTTiming75e33 template as it skips the steps after DIGI
upgradeWFs['L1CompleteWithNano'] = deepcopy(upgradeWFs['HLTTiming75e33'])
upgradeWFs['L1CompleteWithNano'].suffix = '_L1CompleteWithNano'
upgradeWFs['L1CompleteWithNano'].offset = 0.781
upgradeWFs['L1CompleteWithNano'].step2 = {
'-s': 'DIGI:pdigi_valid,L1,L1TrackTrigger,L1P2GT,DIGI2RAW,HLT:@relvalRun4,NANO:@Phase2L1DPG',
'--datatier':'GEN-SIM-DIGI-RAW,NANOAODSIM',
'--eventcontent':'FEVTDEBUGHLT,NANOAODSIM'
}

upgradeWFs['L1CompleteOnlyNano'] = deepcopy(upgradeWFs['L1CompleteWithNano'])
upgradeWFs['L1CompleteOnlyNano'].suffix = '_L1CompleteOnlyNano'
upgradeWFs['L1CompleteOnlyNano'].offset = 0.782
upgradeWFs['L1CompleteOnlyNano'].step2 = {
# '-s': 'NANO:@Phase2L1DPG',
'-s': 'DIGI:pdigi_valid,L1,L1TrackTrigger,L1P2GT,DIGI2RAW,HLT:@relvalRun4,NANO:@Phase2L1DPG',
'--datatier':'NANOAODSIM',
'--eventcontent':'NANOAODSIM'
}

class UpgradeWorkflow_Neutron(UpgradeWorkflow):
def setup_(self, step, stepName, stepDict, k, properties):
if 'GenSim' in step:
Expand Down
14 changes: 14 additions & 0 deletions DPGAnalysis/Phase2L1TNanoAOD/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<use name="FWCore/Utilities"/>
<use name="FWCore/Common"/>
<use name="DataFormats/Common"/>
<use name="DataFormats/StdDictionaries"/>
<use name="DataFormats/Candidate"/>
<use name="DataFormats/PatCandidates"/>
<use name="CommonTools/Utils"/>
<use name="CommonTools/UtilAlgos"/>
<use name="CommonTools/CandAlgos"/>
<use name="DataFormats/NanoAOD"/>
<use name="boost"/>
<export>
<lib name="1"/>
</export>
73 changes: 73 additions & 0 deletions DPGAnalysis/Phase2L1TNanoAOD/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Phase2-L1Nano
NanoAOD ntupler for Phase-2 L1 Objects

Initially an independent package here: https://github.com/cms-l1-dpg/Phase2-L1Nano/

## Setup

For more information on the latest L1T Phase 2 software developments in CMSSW see: https://twiki.cern.ch/twiki/bin/view/CMSPublic/SWGuideL1TPhase2Instructions#Development

Corresponding menu twiki section: https://twiki.cern.ch/twiki/bin/viewauth/CMS/PhaseIIL1TriggerMenuTools#Phase_2_L1_Trigger_objects_based


## Usage

### Via cmsDriver

One can append the L1Nano output to the `cmsDriver` command via the `NANO:@Phase2L1DPG` autoNANO handle, e.g.:
```bash
cmsDriver.py -s L1,L1TrackTrigger,L1P2GT,NANO:@Phase2L1DPG
```

Check `PhysicsTools/NanoAOD/python/autoNANO.py` for the way this command is defined.

`cmsDriver` command for 14x files:
```bash
cmsDriver.py -s L1,L1TrackTrigger,L1P2GT,NANO:@Phase2L1DPG \
--conditions auto:phase2_realistic_T33 \
--geometry ExtendedRun4D110 \
--era Phase2C17I13M9 \
--eventcontent NANOAOD \
--datatier GEN-SIM-DIGI-RAW-MINIAOD \
--customise SLHCUpgradeSimulations/Configuration/aging.customise_aging_1000,Configuration/DataProcessing/Utils.addMonitoring,L1Trigger/Configuration/customisePhase2TTOn110.customisePhase2TTOn110 \
--filein /store/mc/Phase2Spring24DIGIRECOMiniAOD/TT_TuneCP5_14TeV-powheg-pythia8/GEN-SIM-DIGI-RAW-MINIAOD/PU200_AllTP_140X_mcRun4_realistic_v4-v1/2560000/11d1f6f0-5f03-421e-90c7-b5815197fc85.root \
--fileout file:output_Phase2_L1T.root \
--python_filename rerunL1_cfg.py \
--inputCommands="keep *, drop l1tPFJets_*_*_*, drop l1tTrackerMuons_l1tTkMuonsGmt*_*_HLT" \
--mc \
-n 10 --nThreads 4 --no_exec
```


## Output

The output file is a nanoAOD file with the output branches in the `Events` tree.

An overview of the corresponding content is shown here: https://alobanov.web.cern.ch/L1T/Phase2/L1Nano/l1menu_nano_V38_1400pre3V9_doc_report.html

Size report: https://alobanov.web.cern.ch/L1T/Phase2/L1Nano/l1menu_nano_V38_1400pre3V9_size_report.html

Example:

```python
'run',
'luminosityBlock',
'event',
'L1tkPhoton_saId',
'L1tkPhoton_hwEta',
'L1tkPhoton_hwIso',
'L1tkPhoton_hwPhi',
```

This can be easily handled with [`uproot/awkward`](https://gitlab.cern.ch/cms-podas23/dpg/trigger-exercise/-/blob/solutions/1_Intro_NanoAwk_Analysis_Solution.ipynb) like this:

```python
f = uproot.open("l1nano.root")
events = f["Events"].arrays()
```

### P2GT emulator decisions
The GT emulator decisions are stored like this now:
```
L1_pSingleTkMuon22_final # seed name and final for post prescale value
```
24 changes: 24 additions & 0 deletions DPGAnalysis/Phase2L1TNanoAOD/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<use name="CondFormats/DataRecord"/>
<use name="CondFormats/L1TObjects"/>
<use name="CondFormats/RunInfo"/>
<use name="DataFormats/Candidate"/>
<use name="DataFormats/L1TGlobal"/>
<use name="DataFormats/L1Trigger"/>
<use name="DataFormats/L1TCorrelator"/>
<use name="DataFormats/L1TMuonPhase2"/>
<use name="DataFormats/L1TParticleFlow"/>
<use name="DataFormats/NanoAOD"/>
<use name="DataFormats/PatCandidates"/>
<use name="DataFormats/ProtonReco"/>
<use name="FWCore/Framework"/>
<use name="FWCore/ParameterSet"/>
<use name="FWCore/ServiceRegistry"/>
<use name="FWCore/Utilities"/>
<use name="IOPool/Provenance"/>
<use name="PhysicsTools/PatAlgos"/>
<use name="CommonTools/Utils"/>
<use name="CommonTools/UtilAlgos"/>
<use name="CommonTools/CandAlgos"/>
<library file="*.cc" name="DPGAnalysisPhase2L1TNanoAOD_plugins">
<flags EDM_PLUGIN="1"/>
</library>
55 changes: 55 additions & 0 deletions DPGAnalysis/Phase2L1TNanoAOD/plugins/L1TableProducer.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#include "PhysicsTools/NanoAOD/interface/SimpleFlatTableProducer.h"

#include "DataFormats/L1Trigger/interface/VertexWord.h"
typedef SimpleFlatTableProducer<l1t::VertexWord> SimpleL1VtxWordCandidateFlatTableProducer;

#include "DataFormats/L1Trigger/interface/P2GTAlgoBlock.h"
typedef SimpleFlatTableProducer<l1t::P2GTAlgoBlock> P2GTAlgoBlockFlatTableProducer;

#include "DataFormats/L1Trigger/interface/P2GTCandidate.h"
typedef SimpleFlatTableProducer<l1t::P2GTCandidate> SimpleP2GTCandidateFlatTableProducer;

#include "DataFormats/L1Trigger/interface/TkJetWord.h"
typedef SimpleFlatTableProducer<l1t::TkJetWord> SimpleL1TkJetWordCandidateFlatTableProducer;

#include "DataFormats/L1Trigger/interface/TkTripletWord.h"
typedef SimpleFlatTableProducer<l1t::TkTripletWord> SimpleTkTripletWordCandidateFlatTableProducer;

#include "DataFormats/L1Trigger/interface/L1Candidate.h"
typedef SimpleFlatTableProducer<l1t::L1Candidate> SimpleTriggerL1CandidateFlatTableProducer;

#include "DataFormats/L1TCorrelator/interface/TkEm.h"
typedef SimpleFlatTableProducer<l1t::TkEm> SimpleTriggerL1TkEmFlatTableProducer;

#include "DataFormats/L1TCorrelator/interface/TkElectron.h"
typedef SimpleFlatTableProducer<l1t::TkElectron> SimpleTriggerL1TkElectronFlatTableProducer;

#include "DataFormats/L1TMuonPhase2/interface/SAMuon.h"
typedef SimpleFlatTableProducer<l1t::SAMuon> SimpleTriggerL1SAMuonFlatTableProducer;

#include "DataFormats/L1TMuonPhase2/interface/TrackerMuon.h"
typedef SimpleFlatTableProducer<l1t::TrackerMuon> SimpleTriggerL1TrackerMuonFlatTableProducer;

#include "DataFormats/L1TCalorimeterPhase2/interface/Phase2L1CaloJet.h"
typedef SimpleFlatTableProducer<l1tp2::Phase2L1CaloJet> SimpleTriggerL1CaloJetFlatTableProducer;

#include "DataFormats/L1TParticleFlow/interface/PFTau.h"
typedef SimpleFlatTableProducer<l1t::PFTau> SimpleTriggerL1PFTauFlatTableProducer;

#include "DataFormats/L1TParticleFlow/interface/HPSPFTau.h"
typedef SimpleFlatTableProducer<l1t::HPSPFTau> SimpleTriggerL1HPSPFTauFlatTableProducer;

#include "FWCore/Framework/interface/MakerMacros.h"
DEFINE_FWK_MODULE(SimpleL1VtxWordCandidateFlatTableProducer);
DEFINE_FWK_MODULE(P2GTAlgoBlockFlatTableProducer);
DEFINE_FWK_MODULE(SimpleP2GTCandidateFlatTableProducer);
DEFINE_FWK_MODULE(SimpleL1TkJetWordCandidateFlatTableProducer);
DEFINE_FWK_MODULE(SimpleTkTripletWordCandidateFlatTableProducer);
DEFINE_FWK_MODULE(SimpleTriggerL1CandidateFlatTableProducer);
DEFINE_FWK_MODULE(SimpleTriggerL1TkEmFlatTableProducer);
DEFINE_FWK_MODULE(SimpleTriggerL1TkElectronFlatTableProducer);
DEFINE_FWK_MODULE(SimpleTriggerL1SAMuonFlatTableProducer);
DEFINE_FWK_MODULE(SimpleTriggerL1TrackerMuonFlatTableProducer);
DEFINE_FWK_MODULE(SimpleTriggerL1CaloJetFlatTableProducer);
DEFINE_FWK_MODULE(SimpleTriggerL1PFTauFlatTableProducer);
DEFINE_FWK_MODULE(SimpleTriggerL1HPSPFTauFlatTableProducer);
Loading